mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-20 06:51:42 +00:00
Adding op 'n stuff
This commit is contained in:
parent
127ef3c777
commit
f17f54fe92
14 changed files with 32 additions and 8 deletions
|
|
@ -6,15 +6,15 @@
|
|||
"logging": true,
|
||||
"gameMode": 1,
|
||||
"generation": {
|
||||
"name":"diamond_square",
|
||||
"name": "diamond_square",
|
||||
"options":{
|
||||
"worldHeight":80
|
||||
"worldHeight": 80
|
||||
}
|
||||
},
|
||||
"kickTimeout":10000,
|
||||
"kickTimeout": 10000,
|
||||
"plugins": {
|
||||
|
||||
},
|
||||
"modpe": false,
|
||||
"view-distance":10
|
||||
"view-distance": 10
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,11 @@ class Command {
|
|||
return res;
|
||||
}
|
||||
|
||||
async use(command) {
|
||||
async use(command, op=true) {
|
||||
var res = this.find(command);
|
||||
|
||||
if(res) {
|
||||
if (res[0].params.op && !op) return 'You do not have permission to use this command';
|
||||
var parse = res[0].params.parse;
|
||||
if(parse) {
|
||||
if(typeof parse == 'function') {
|
||||
|
|
@ -74,6 +75,10 @@ class Command {
|
|||
var first = !(this.parent && this.parent.parent);
|
||||
return this.params.merged || (!end && first) ? '' : ' ';
|
||||
}
|
||||
|
||||
setOp(op) {
|
||||
this.params.op = op;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports=Command;
|
||||
|
|
@ -32,6 +32,7 @@ module.exports.player=function(player,serv)
|
|||
base: 'setblock',
|
||||
info: 'to put a block',
|
||||
usage: '/setblock <x> <y> <z> <id> <data>',
|
||||
op: true,
|
||||
parse(str) {
|
||||
var results = str.match(/^(~|~?-?[0-9]*) (~|~?-?[0-9]*) (~|~?-?[0-9]*) ([0-9]{1,3}) ([0-9]{1,3})/);
|
||||
if(!results) return false;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module.exports.player=function(player) {
|
|||
if(used.indexOf(hash[key]) > -1) continue;
|
||||
used.push(hash[key]);
|
||||
|
||||
if(hash[key].params.info) {
|
||||
if(hash[key].params.info && (player.op || !hash[key].params.op)) {
|
||||
var str = hash[key].params.usage + ' ' + hash[key].params.info;
|
||||
if(hash[key].params.aliases && hash[key].params.aliases.length) {
|
||||
str += ' (aliases: ' + hash[key].params.aliases.join(', ') + ')';
|
||||
|
|
@ -76,7 +76,7 @@ module.exports.player=function(player) {
|
|||
|
||||
player.handleCommand = async (str) => {
|
||||
try {
|
||||
var res = await player.commands.use(str);
|
||||
var res = await player.commands.use(str, player.op);
|
||||
if (res) player.chat('' + res);
|
||||
}
|
||||
catch(err) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ module.exports.player=function(player,serv){
|
|||
base: 'night',
|
||||
info: 'to change a time to night',
|
||||
usage: '/night',
|
||||
op: true,
|
||||
action() {
|
||||
return player.handleCommand('time set night');
|
||||
}
|
||||
|
|
@ -38,6 +39,7 @@ module.exports.player=function(player,serv){
|
|||
base: 'time',
|
||||
info: 'to change a time',
|
||||
usage: '/time <add|query|set> <value>',
|
||||
op: true,
|
||||
parse(str) {
|
||||
var data = str.match(/^(add|query|set)(?: ([0-9]+|day|night))?/);
|
||||
if(!data) return false;
|
||||
|
|
@ -68,6 +70,7 @@ module.exports.player=function(player,serv){
|
|||
base: 'day',
|
||||
info: 'to change a time to day',
|
||||
usage: '/day',
|
||||
op: true,
|
||||
action() {
|
||||
return player.handleCommand('time set day');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ module.exports.player=function(player,serv)
|
|||
player.health = 20;
|
||||
player.food = 20;
|
||||
player.crouching = false; // Needs added in prismarine-entity later
|
||||
player.op = true; // REMOVE THIS WHEN OUT OF TESTING
|
||||
player.username=player._client.username;
|
||||
serv.players.push(player);
|
||||
serv.uuidToPlayer[player._client.uuid] = player;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ module.exports.player=function(player,serv)
|
|||
base: 'kick',
|
||||
info: 'to kick a player',
|
||||
usage: '/kick <player> [reason]',
|
||||
op: true,
|
||||
parse(str) {
|
||||
if(!str.match(/([a-zA-Z0-9_]+)(?: (.*))?/))
|
||||
return false;
|
||||
|
|
@ -95,6 +96,7 @@ module.exports.player=function(player,serv)
|
|||
base: 'ban',
|
||||
info: 'to ban a player',
|
||||
usage: '/ban <player> [reason]',
|
||||
op: true,
|
||||
parse(str) {
|
||||
if(!str.match(/([a-zA-Z0-9_]+)(?: (.*))?/))
|
||||
return false;
|
||||
|
|
@ -125,6 +127,7 @@ module.exports.player=function(player,serv)
|
|||
base: 'pardon',
|
||||
info: 'to pardon a player',
|
||||
usage: '/pardon <player>',
|
||||
op: true,
|
||||
parse(str) {
|
||||
if(!str.match(/([a-zA-Z0-9_]+)/))
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ module.exports.player=function(player,serv){
|
|||
base: 'particle',
|
||||
info: 'emit a particle at a position',
|
||||
usage: '/particle <id> [amount] [<sizeX> <sizeY> <sizeZ>]',
|
||||
op: true,
|
||||
parse(str) {
|
||||
var results=str.match(/(\d+)(?: (\d+))?(?: (\d+))?(?: (\d+))?(?: (\d+))?(?: (\d+))?/);
|
||||
if(!results) return false;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ module.exports.player=function(player){
|
|||
aliases: ['gm'],
|
||||
info: 'to change game mode',
|
||||
usage: '/gamemode <0-3>',
|
||||
op: true,
|
||||
parse(str) {
|
||||
var results;
|
||||
if(!(results = str.match(/^([0-3])$/)))
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ module.exports.player=function(player,serv)
|
|||
base: 'killall',
|
||||
info: 'Kill everything',
|
||||
usage: '/killall',
|
||||
op: true,
|
||||
action() {
|
||||
Object.keys(serv.entities).forEach(key => serv.entities[key].takeDamage({damage:20}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ module.exports.player=function(player,serv) {
|
|||
base: 'playsound',
|
||||
info: 'to play sound for yourself',
|
||||
usage: '/playsound <sound_name> [volume] [pitch]',
|
||||
op: true,
|
||||
parse(str) {
|
||||
var results=str.match(/([^ ]+)(?: ([^ ]+))?(?: ([^ ]+))?/);
|
||||
if(!results) return false;
|
||||
|
|
@ -87,6 +88,7 @@ module.exports.player=function(player,serv) {
|
|||
base: 'playsoundforall',
|
||||
info: 'to play sound for everyone',
|
||||
usage: '/playsoundforall <sound_name> [volume] [pitch]',
|
||||
op: true,
|
||||
parse(str) {
|
||||
var results=str.match(/([^ ]+)(?: ([^ ]+))?(?: ([^ ]+))?/);
|
||||
if(!results) return false;
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ module.exports.player=function(player,serv){
|
|||
base: 'spawn',
|
||||
info: 'Spawn a mob',
|
||||
usage: '/spawn <entity_id>',
|
||||
op: true,
|
||||
parse(str) {
|
||||
var results=str.match(/(\d+)/);
|
||||
if (!results) return false;
|
||||
|
|
@ -90,6 +91,7 @@ module.exports.player=function(player,serv){
|
|||
base: 'spawnObject',
|
||||
info: 'Spawn an object',
|
||||
usage: '/spawnObject <entity_id>',
|
||||
op: true,
|
||||
parse(str) {
|
||||
var results=str.match(/(\d+)/);
|
||||
if (!results) return false;
|
||||
|
|
@ -108,6 +110,7 @@ module.exports.player=function(player,serv){
|
|||
base: 'summon',
|
||||
info: 'Summon an entity',
|
||||
usage: '/summon <entity_name>',
|
||||
op: true,
|
||||
action(name) {
|
||||
var entity=entitiesByName[name];
|
||||
if(!entity) {
|
||||
|
|
@ -124,6 +127,7 @@ module.exports.player=function(player,serv){
|
|||
base: 'attach',
|
||||
info: 'attach an entity on an other entity',
|
||||
usage: '/attach <carrierId> <attachedId>',
|
||||
op: true,
|
||||
parse(str) {
|
||||
var pars=str.split(' ');
|
||||
if(pars.length!=2)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ module.exports.player = (player, serv) => {
|
|||
|
||||
var getPos = (num, dir='x', p=player) => {
|
||||
if (num[0] == '~') return p.position[dir] + parseInt(num.slice(1, num.length) || 0)*32;
|
||||
else return parseInt(num);
|
||||
else return parseInt(num)*32;
|
||||
}
|
||||
|
||||
player.commands.add({
|
||||
|
|
@ -12,6 +12,7 @@ module.exports.player = (player, serv) => {
|
|||
aliases: ['tp'],
|
||||
info: 'to teleport a player',
|
||||
usage: '/teleport [target player] <destination player or x> [y] [z]',
|
||||
op: true,
|
||||
parse(str) {
|
||||
return str.match(/^(((\w* )?~?-?\d* ~?-?\d* ~?-?\d*)|(\w* \w*))$/) ? str.split(' ') : false;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ module.exports.player=function(player,serv,settings) {
|
|||
base: 'changeworld',
|
||||
info: 'to change world',
|
||||
usage: '/changeworld overworld|nether',
|
||||
op: true,
|
||||
action(world) {
|
||||
if(world=="nether") player.changeWorld(serv.netherworld, {dimension: -1});
|
||||
if(world=="overworld") player.changeWorld(serv.overworld, {dimension: 0});
|
||||
|
|
|
|||
Loading…
Reference in a new issue