From 69819b880e86ce1025f0860228f8eeb99e8ea529 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sun, 25 Oct 2015 23:58:30 +0100 Subject: [PATCH] proper /changeworld overworld|nether command implemented --- doc/api.md | 4 ---- src/lib/playerPlugins/commands.js | 10 ++++++++++ src/lib/playerPlugins/world.js | 11 +---------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/doc/api.md b/doc/api.md index 73df217..5b9a23b 100644 --- a/doc/api.md +++ b/doc/api.md @@ -363,10 +363,6 @@ The world object which the player is in (use serv.overworld, serv.netherworld, s - gamemode: Gamemode of the world (Default is player gamemode) - difficulty: Difficulty of world. Default is 0 (easiest) - dimension: Dimension of world. 0 is Overworld, -1 is Nether, 1 is End (Default is 0) -- position: Position player spawns, default is their default spawn point -- yaw: Yaw in which they spawn, default is 0 -- pitch: Pitch in which they spawn, default is 0 - #### player.spawnAPlayer(spawnedPlayer) diff --git a/src/lib/playerPlugins/commands.js b/src/lib/playerPlugins/commands.js index d17c073..b51db6c 100644 --- a/src/lib/playerPlugins/commands.js +++ b/src/lib/playerPlugins/commands.js @@ -263,6 +263,16 @@ function inject(serv, player) { } }); + base.add({ + base: 'changeworld', + info: 'to change world', + usage: '/changeworld overworld|nether', + action(world) { + if(world=="nether") player.changeWorld(serv.netherworld, {dimension: -1}); + if(world=="overworld") player.changeWorld(serv.overworld, {dimension: 0}); + } + }); + serv.commands = base; player.handleCommand = function(str) { diff --git a/src/lib/playerPlugins/world.js b/src/lib/playerPlugins/world.js index 03e178f..5c5c23f 100644 --- a/src/lib/playerPlugins/world.js +++ b/src/lib/playerPlugins/world.js @@ -92,7 +92,7 @@ function inject(serv, player) { } async function changeWorld(world, opt) { - + if(player.world == world) return Promise.resolve(); opt = opt || {}; player.world = world; player.loadedChunks={}; @@ -121,13 +121,4 @@ function inject(serv, player) { player.sendRestMap = sendRestMap; player.sendSpawnPosition = sendSpawnPosition; player.spawnAPlayer = spawnAPlayer; - - player.on('chat', function(message) { - if (message == 'world') { - player.changeWorld(serv.netherworld, { - position: new vec3(0, 60, 0), - dimension: -1 - }); - } - }); } \ No newline at end of file