mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-05 11:10:44 +00:00
put modpe in its own command namespace (/modpe <command>), add the same /time command that minecraft has
This commit is contained in:
parent
7fd8e56d3e
commit
51148036e4
3 changed files with 23 additions and 9 deletions
|
|
@ -5,8 +5,6 @@ module.exports = inject;
|
||||||
function inject(serv, player, options) {
|
function inject(serv, player, options) {
|
||||||
function handleCommand(command) {
|
function handleCommand(command) {
|
||||||
var results;
|
var results;
|
||||||
if (options.modpe)
|
|
||||||
player.chat("§1######## VANILLA ########");
|
|
||||||
if (options.commands[command])
|
if (options.commands[command])
|
||||||
player.chat("" + options.commands[command]);
|
player.chat("" + options.commands[command]);
|
||||||
else if (results = command.match(/^gamemode ([0-3])$/)) {
|
else if (results = command.match(/^gamemode ([0-3])$/)) {
|
||||||
|
|
@ -81,6 +79,23 @@ function inject(serv, player, options) {
|
||||||
.catch(err => player.chat(results[1] + " is not banned"));
|
.catch(err => player.chat(results[1] + " is not banned"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(results = command.match(/^time (add|query|set)(?: ([0-9]+))?/)) {
|
||||||
|
var action=results[1];
|
||||||
|
var value=results[2]!==undefined ? parseInt(results[2]) : null;
|
||||||
|
if(action=="query")
|
||||||
|
player.chat("It is "+serv.time);
|
||||||
|
else if(action=="set") {
|
||||||
|
player.chat("Time was changed from "+serv.time+" to "+value);
|
||||||
|
serv.setTime(value);
|
||||||
|
}
|
||||||
|
else if(action=="add") {
|
||||||
|
player.chat("Time was changed from "+serv.time+" to "+(value + serv.time));
|
||||||
|
serv.setTime(value + serv.time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(results = command.match(/^modpe (.+)$/)) {
|
||||||
|
player.emit("modpe",results[1]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
player.chat("Invalid command.");
|
player.chat("Invalid command.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ function inject(serv, settings) {
|
||||||
|
|
||||||
serv.on('tick', function(count) {
|
serv.on('tick', function(count) {
|
||||||
if (!serv.doDaylightCycle) return;
|
if (!serv.doDaylightCycle) return;
|
||||||
if (count % 20 == 0) serv.setTime((serv.time + 20) % 24000); // Vanilla only does it every second
|
if (count % 20 == 0) {
|
||||||
|
serv.setTime((serv.time + 20) % 24000); // Vanilla only does it every second
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -183,11 +183,9 @@ function inject(serv,settings)
|
||||||
serv.world.getBlockType(new vec3(packet.location.x, packet.location.y, packet.location.z)));
|
serv.world.getBlockType(new vec3(packet.location.x, packet.location.y, packet.location.z)));
|
||||||
});
|
});
|
||||||
|
|
||||||
player._client.on('chat', function (packet) {
|
player.on('modpe', function (command) {
|
||||||
if(packet.message[0]=="/") {
|
console.log(command);
|
||||||
var command = packet.message.slice(1);
|
procCmd(command);
|
||||||
procCmd(command);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function newLevel() {
|
function newLevel() {
|
||||||
|
|
@ -216,7 +214,6 @@ function inject(serv,settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
function procCmd(command) {
|
function procCmd(command) {
|
||||||
player.chat("§2######### MODPE #########");
|
|
||||||
mods.forEach(function (element, index, array) {
|
mods.forEach(function (element, index, array) {
|
||||||
element.procCmd(command);
|
element.procCmd(command);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue