diff --git a/app.js b/app.js index 1bfee67..815f26c 100644 --- a/app.js +++ b/app.js @@ -6,7 +6,8 @@ var options = { motd: settings.motd, 'max-players': settings.maxPlayers, port: settings.port, - 'online-mode': settings.onlineMode + 'online-mode': settings.onlineMode, + gameMode:settings.gameMode }; mcServer.createMCServer(options); diff --git a/config/settings.json b/config/settings.json index 862f6ab..5c3425b 100644 --- a/config/settings.json +++ b/config/settings.json @@ -3,5 +3,6 @@ "port": 25565, "maxPlayers": 10, "onlineMode": true, - "logging": false + "logging": false, + "gameMode":1 } diff --git a/doc/api.md b/doc/api.md index 94c8898..583ff6f 100644 --- a/doc/api.md +++ b/doc/api.md @@ -52,7 +52,6 @@ - [player.login()](#playerlogin) - [player.others()](#playerothers) - [player.chat(message)](#playerchatmessage) - - [player.setSpawnPoint()](#playersetspawnpoint) - [Low level properties](#low-level-properties) - [player._client](#player_client) - [Low level methods](#low-level-methods) @@ -243,10 +242,6 @@ return the other players than `player` sends `message` to the player -#### player.setSpawnPoint() - -set the spawn point of a player - ### Low level properties #### player._client diff --git a/lib/playerPlugins/login.js b/lib/playerPlugins/login.js index b0020a8..f406655 100644 --- a/lib/playerPlugins/login.js +++ b/lib/playerPlugins/login.js @@ -32,7 +32,7 @@ function inject(serv,player) player._client.write('login', { entityId: player.entity.id, levelType: 'default', - gameMode: 0, + gameMode: player.gameMode, dimension: 0, difficulty: 0, reducedDebugInfo: false, @@ -82,7 +82,7 @@ function inject(serv,player) { player._client.write('game_state_change', { reason: 3, - gameMode: 0 + gameMode: player.gameMode }); } @@ -94,7 +94,7 @@ function inject(serv,player) UUID: transformUuid(player._client.uuid), name: player.username, properties: [], - gamemode: 0, + gamemode: player.gameMode, ping: 1, hasDisplayName: true, displayName: player.username @@ -109,7 +109,7 @@ function inject(serv,player) UUID: transformUuid(otherPlayer._client.uuid), name: otherPlayer.username, properties: [], - gamemode: 0, + gamemode: otherPlayer.gameMode, ping: 1, hasDisplayName: true, displayName: otherPlayer.username @@ -165,7 +165,6 @@ function inject(serv,player) addPlayer(); sendLogin(); sendMap(); - player.setSpawnPoint(); sendSpawn(); sendInitialPosition(); diff --git a/lib/playerPlugins/settings.js b/lib/playerPlugins/settings.js new file mode 100644 index 0000000..7547de8 --- /dev/null +++ b/lib/playerPlugins/settings.js @@ -0,0 +1,11 @@ +module.exports=inject; + +function randomInt (low, high) { + return Math.floor(Math.random() * (high - low) + low); +} + +function inject(serv,player) +{ + player.gameMode=serv.gameMode; + player.spawnPoint=serv.spawnPoints[randomInt(0,serv.spawnPoints.length)]; +} \ No newline at end of file diff --git a/lib/playerPlugins/spawn.js b/lib/playerPlugins/spawn.js deleted file mode 100644 index 4c03439..0000000 --- a/lib/playerPlugins/spawn.js +++ /dev/null @@ -1,13 +0,0 @@ -var vec3 = require("vec3"); - -module.exports=inject; - -function inject(serv,player) -{ - function setSpawnPoint() - { - player.spawnPoint=new vec3(6,51,6); - } - - player.setSpawnPoint=setSpawnPoint; -} \ No newline at end of file diff --git a/lib/serverPlugins/settings.js b/lib/serverPlugins/settings.js new file mode 100644 index 0000000..98a3879 --- /dev/null +++ b/lib/serverPlugins/settings.js @@ -0,0 +1,9 @@ +var vec3=require("vec3"); + +module.exports=inject; + +function inject(serv,settings) +{ + serv.gameMode=settings.gameMode; + serv.spawnPoints=[new vec3(6,51,6),new vec3(3,51,6),new vec3(8,51,6)]; +} \ No newline at end of file