mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-07 04:00:46 +00:00
some webstorm found fixes
This commit is contained in:
parent
8dc3087d65
commit
1d882c4af9
16 changed files with 32 additions and 34 deletions
|
|
@ -964,7 +964,7 @@ Sets and sends the player's new level
|
||||||
|
|
||||||
#### player.setDisplayXp(num)
|
#### player.setDisplayXp(num)
|
||||||
|
|
||||||
Sets and sends the palyer's new display amount. num should be from 0 to 1.0
|
Sets and sends the player's new display amount. num should be from 0 to 1.0
|
||||||
|
|
||||||
### Low level properties
|
### Low level properties
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ Directory architecture :
|
||||||
* src/index.js: contain the generic server implementation
|
* src/index.js: contain the generic server implementation
|
||||||
* src/lib: contain the classes and functions used in the plugins
|
* src/lib: contain the classes and functions used in the plugins
|
||||||
* plugins/: All of the default plugins made to simulate vanilla
|
* plugins/: All of the default plugins made to simulate vanilla
|
||||||
* worldGeneraions/: Contains default world generations, however plugins can use their own
|
* worldGenerations/: Contains default world generations, however plugins can use their own
|
||||||
|
|
||||||
## Structure of a plugin
|
## Structure of a plugin
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ module.exports.player=function(player,serv)
|
||||||
},
|
},
|
||||||
action(params) {
|
action(params) {
|
||||||
let res = params.slice(1, 4);
|
let res = params.slice(1, 4);
|
||||||
res = res.map((val, i) => serv.posFromString(val, player.position[['x','y','z'][i]] / 32))
|
res = res.map((val, i) => serv.posFromString(val, player.position[['x','y','z'][i]] / 32));
|
||||||
player.setBlock(new Vec3(res[0], res[1], res[2]).floored(), params[4], params[5] || 0);
|
player.setBlock(new Vec3(res[0], res[1], res[2]).floored(), params[4], params[5] || 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ module.exports.server=function(serv)
|
||||||
if (!system) player.chat(message);
|
if (!system) player.chat(message);
|
||||||
else player.system(message);
|
else player.system(message);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
serv.color = {
|
serv.color = {
|
||||||
'black': '&0',
|
'black': '&0',
|
||||||
|
|
@ -55,7 +55,7 @@ module.exports.server=function(serv)
|
||||||
let underlined = false;
|
let underlined = false;
|
||||||
let strikethrough = false;
|
let strikethrough = false;
|
||||||
let random = false;
|
let random = false;
|
||||||
const colors = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f', 'k','l','m','n','o','r','&']
|
const colors = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f', 'k','l','m','n','o','r','&'];
|
||||||
const convertColor = ['black', 'dark_blue','dark_green','dark_cyan','dark_red','dark_purple','gold',
|
const convertColor = ['black', 'dark_blue','dark_green','dark_cyan','dark_red','dark_purple','gold',
|
||||||
'gray', 'dark_gray', 'blue', 'green', 'aqua', 'red', 'light_purple', 'yellow', 'white',
|
'gray', 'dark_gray', 'blue', 'green', 'aqua', 'red', 'light_purple', 'yellow', 'white',
|
||||||
'random', 'bold', 'strikethrough', 'underlined', 'italic', 'reset', '&'];
|
'random', 'bold', 'strikethrough', 'underlined', 'italic', 'reset', '&'];
|
||||||
|
|
@ -114,7 +114,7 @@ module.exports.server=function(serv)
|
||||||
if (messageList.length > 0) return {
|
if (messageList.length > 0) return {
|
||||||
text: '',
|
text: '',
|
||||||
extra: messageList
|
extra: messageList
|
||||||
}
|
};
|
||||||
else return { text: '' }
|
else return { text: '' }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -132,7 +132,7 @@ module.exports.player=function(player,serv)
|
||||||
text: message,
|
text: message,
|
||||||
whitelist: serv.players,
|
whitelist: serv.players,
|
||||||
blacklist: []
|
blacklist: []
|
||||||
}, ({message, prefix, text, whitelist, blacklist}) => {
|
}, ({prefix, text, whitelist, blacklist}) => {
|
||||||
const obj = serv.parseClassic(prefix);
|
const obj = serv.parseClassic(prefix);
|
||||||
if (!obj.extra) obj.extra = [];
|
if (!obj.extra) obj.extra = [];
|
||||||
obj.extra.push(serv.parseClassic(text));
|
obj.extra.push(serv.parseClassic(text));
|
||||||
|
|
@ -153,7 +153,7 @@ module.exports.player=function(player,serv)
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
player.chat('');
|
player.chat('');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
player.system = message => {
|
player.system = message => {
|
||||||
if (typeof message == 'string') message = serv.parseClassic(message);
|
if (typeof message == 'string') message = serv.parseClassic(message);
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ module.exports.player=function(player, serv) {
|
||||||
|
|
||||||
module.exports.entity = function(entity, serv) {
|
module.exports.entity = function(entity, serv) {
|
||||||
entity.selectorString = (str) => serv.selectorString(str, entity.position.scaled(1/32), entity.world);
|
entity.selectorString = (str) => serv.selectorString(str, entity.position.scaled(1/32), entity.world);
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports.server = function(serv) {
|
module.exports.server = function(serv) {
|
||||||
|
|
||||||
|
|
@ -217,12 +217,12 @@ module.exports.server = function(serv) {
|
||||||
if (fail) return false;
|
if (fail) return false;
|
||||||
scores.min.forEach(m => {
|
scores.min.forEach(m => {
|
||||||
if (fail) return;
|
if (fail) return;
|
||||||
if (!notudf(s.scores[m.score])) faii = true;
|
if (!notudf(s.scores[m.score])) fail = true;
|
||||||
else if (s.scores[m] < m.val) fail = true;
|
else if (s.scores[m] < m.val) fail = true;
|
||||||
});
|
});
|
||||||
if (fail) return false;
|
return !fail;
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (type == 'near') sample.sort((a,b) => a.position.distanceTo(opt.pos) > b.position.distanceTo(opt.pos));
|
if (type == 'near') sample.sort((a,b) => a.position.distanceTo(opt.pos) > b.position.distanceTo(opt.pos));
|
||||||
|
|
@ -238,7 +238,7 @@ module.exports.server = function(serv) {
|
||||||
const player = serv.getPlayer(str);
|
const player = serv.getPlayer(str);
|
||||||
if (!player && str[0] != '@') return [];
|
if (!player && str[0] != '@') return [];
|
||||||
else if (player) return allowUser ? [player] : [];
|
else if (player) return allowUser ? [player] : [];
|
||||||
const match = str.match(/^@([a,r,p,e])(?:\[([^\]]+)\])?$/);
|
const match = str.match(/^@([arpe])(?:\[([^\]]+)\])?$/);
|
||||||
if (match == null) throw new UserError('Invalid selector format');
|
if (match == null) throw new UserError('Invalid selector format');
|
||||||
const typeConversion = {
|
const typeConversion = {
|
||||||
a: 'all',
|
a: 'all',
|
||||||
|
|
|
||||||
2
src/lib/plugins/effects.js
vendored
2
src/lib/plugins/effects.js
vendored
|
|
@ -55,7 +55,7 @@ module.exports.entity = function(entity, serv) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.player = function(player, serv) {
|
module.exports.player = function(player) {
|
||||||
player.commands.add({
|
player.commands.add({
|
||||||
base: 'effect',
|
base: 'effect',
|
||||||
info: 'Give player an effect',
|
info: 'Give player an effect',
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
module.exports.server=function(serv,options) {
|
module.exports.server=function(serv) {
|
||||||
serv.on('tick', function(delta) {
|
serv.on('tick', function(delta) {
|
||||||
Promise.all(
|
Promise.all(
|
||||||
Object.keys(serv.entities).map(async (id) => {
|
Object.keys(serv.entities).map(async (id) => {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ module.exports.player = function(player) {
|
||||||
player.sendXp();
|
player.sendXp();
|
||||||
};
|
};
|
||||||
|
|
||||||
player.setDisplayXp = (num) => {
|
player.setDisplayXp = () => {
|
||||||
player.displayXp = Math.max(0, Math.min(1, player.displayXp));
|
player.displayXp = Math.max(0, Math.min(1, player.displayXp));
|
||||||
player.sendXp();
|
player.sendXp();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,7 @@ module.exports.server = function(serv, settings) {
|
||||||
});
|
});
|
||||||
|
|
||||||
serv.on('asap', () => {
|
serv.on('asap', () => {
|
||||||
for (let p in serv.plugins) {
|
Objet.keys(serv.plugins).map(plugin -> serv.log('[PLUGINS] Loaded "' + plugin + '"'));
|
||||||
serv.log('[PLUGINS] Loaded "' + serv.plugins[p].name + '"');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
serv.externalPluginsLoaded = true;
|
serv.externalPluginsLoaded = true;
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ module.exports.player=function(player,serv)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(serv.bannedIPs[player._client.socket.remoteAddress]){
|
if(serv.bannedIPs[player._client.socket.remoteAddress]){
|
||||||
player.kick(serv.bannedIPs[player._client.socket.remoteAddress].reason)
|
player.kick(serv.bannedIPs[player._client.socket.remoteAddress].reason);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,8 @@ module.exports.player=function(player,serv)
|
||||||
serv.ban(uuid, reason);
|
serv.ban(uuid, reason);
|
||||||
};
|
};
|
||||||
player.banIP = reason => {
|
player.banIP = reason => {
|
||||||
reason = reason || "You were IP banned!"
|
reason = reason || "You were IP banned!";
|
||||||
player.kick(reason)
|
player.kick(reason);
|
||||||
serv.banIP(player._client.socket.remoteAddress)
|
serv.banIP(player._client.socket.remoteAddress)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -165,7 +165,7 @@ module.exports.player=function(player,serv)
|
||||||
op: true,
|
op: true,
|
||||||
action(IP) {
|
action(IP) {
|
||||||
const result=serv.pardonIP(IP);
|
const result=serv.pardonIP(IP);
|
||||||
player.chat(result ? IP + " was IP pardonned" : IP+" is not banned");
|
player.chat(result ? IP + " was IP pardoned" : IP+" is not banned");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -197,7 +197,7 @@ module.exports.player=function(player,serv)
|
||||||
},
|
},
|
||||||
action(username) {
|
action(username) {
|
||||||
const user = serv.getPlayer(username);
|
const user = serv.getPlayer(username);
|
||||||
if (!user) return 'That player is not on the server.'
|
if (!user) return 'That player is not on the server.';
|
||||||
user.op = true;
|
user.op = true;
|
||||||
player.chat(username + ' is opped');
|
player.chat(username + ' is opped');
|
||||||
}
|
}
|
||||||
|
|
@ -214,7 +214,7 @@ module.exports.player=function(player,serv)
|
||||||
},
|
},
|
||||||
action(username) {
|
action(username) {
|
||||||
const user = serv.getPlayer(username);
|
const user = serv.getPlayer(username);
|
||||||
if (!user) return 'That player is not on the server.'
|
if (!user) return 'That player is not on the server.';
|
||||||
user.op = false;
|
user.op = false;
|
||||||
player.chat(username + ' is deopped');
|
player.chat(username + ' is deopped');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,8 @@ module.exports.player=function(player)
|
||||||
const canFly = player.gameMode == 1 || player.gameMode == 3;
|
const canFly = player.gameMode == 1 || player.gameMode == 3;
|
||||||
const isFlying = !player.onGround && canFly;
|
const isFlying = !player.onGround && canFly;
|
||||||
const creativeMode = player.gameMode == 1;
|
const creativeMode = player.gameMode == 1;
|
||||||
const f = (+godmode*8) + (+canFly*4) + (+isFlying*2) + (+creativeMode*1);
|
const f = (+godmode*8) + (+canFly*4) + (+isFlying*2) + (+creativeMode);
|
||||||
const walkingSpeed = 0.2 * (1 + (player.effects[1] != null ? (player.effects[1].amplifier + 1) : 0) * 0.2)
|
const walkingSpeed = 0.2 * (1 + (player.effects[1] != null ? (player.effects[1].amplifier + 1) : 0) * 0.2);
|
||||||
const flyingSpeed = 0.1;
|
const flyingSpeed = 0.1;
|
||||||
/*console.log(walkingSpeed, flyingSpeed);
|
/*console.log(walkingSpeed, flyingSpeed);
|
||||||
player._client.write('abilities', { // FIIIIXXXXXXX
|
player._client.write('abilities', { // FIIIIXXXXXXX
|
||||||
|
|
@ -85,7 +85,7 @@ module.exports.player=function(player)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.entity=function(entity,serv){
|
module.exports.entity=function(entity){
|
||||||
entity.sendPosition = (position, onGround, teleport=false) => {
|
entity.sendPosition = (position, onGround, teleport=false) => {
|
||||||
if (typeof position == 'undefined') throw new Error('undef');
|
if (typeof position == 'undefined') throw new Error('undef');
|
||||||
if (entity.position.equals(position) && entity.onGround == onGround) return Promise.resolve();
|
if (entity.position.equals(position) && entity.onGround == onGround) return Promise.resolve();
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ module.exports.player=function(player,serv,settings) {
|
||||||
player.changeWorld = async (world, opt) => {
|
player.changeWorld = async (world, opt) => {
|
||||||
if(player.world == world) return Promise.resolve();
|
if(player.world == world) return Promise.resolve();
|
||||||
opt = opt || {};
|
opt = opt || {};
|
||||||
player.world = world
|
player.world = world;
|
||||||
player.loadedChunks={};
|
player.loadedChunks={};
|
||||||
if (typeof opt.gamemode != 'undefined') player.gameMode = opt.gamemode;
|
if (typeof opt.gamemode != 'undefined') player.gameMode = opt.gamemode;
|
||||||
player._client.write("respawn",{
|
player._client.write("respawn",{
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ function generation({opt='default',bottom_id=7,middle_id=1,top_id=2,middle_thick
|
||||||
else if (y < middle_thickness + 1) chunk.setBlockType(new Vec3(x, y, z), middle_id);
|
else if (y < middle_thickness + 1) chunk.setBlockType(new Vec3(x, y, z), middle_id);
|
||||||
else chunk.setBlockType(new Vec3(x, y, z), top_id);
|
else chunk.setBlockType(new Vec3(x, y, z), top_id);
|
||||||
}
|
}
|
||||||
for (y = 0; y < 256; y++) {
|
for (let y = 0; y < 256; y++) {
|
||||||
chunk.setSkyLight(new Vec3(x, y, z), 15);
|
chunk.setSkyLight(new Vec3(x, y, z), 15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ describe("Server with mineflayer connection", function() {
|
||||||
const pos=bot.entity.position.offset(0,-1,0).floored();
|
const pos=bot.entity.position.offset(0,-1,0).floored();
|
||||||
bot.dig(bot.blockAt(pos));
|
bot.dig(bot.blockAt(pos));
|
||||||
|
|
||||||
let [oldBlock,newBlock]=await once(bot2,'blockUpdate',{array:true});
|
let [,newBlock]=await once(bot2,'blockUpdate',{array:true});
|
||||||
assertPosEqual(newBlock.position,pos);
|
assertPosEqual(newBlock.position,pos);
|
||||||
assert.equal(newBlock.type,0,"block "+pos+" should have been dug");
|
assert.equal(newBlock.type,0,"block "+pos+" should have been dug");
|
||||||
});
|
});
|
||||||
|
|
@ -232,7 +232,7 @@ describe("Server with mineflayer connection", function() {
|
||||||
it("can use /setblock",async() => {
|
it("can use /setblock",async() => {
|
||||||
await once(bot,'chunkColumnLoad');
|
await once(bot,'chunkColumnLoad');
|
||||||
bot.chat('/setblock 1 2 3 95 0');
|
bot.chat('/setblock 1 2 3 95 0');
|
||||||
let [oldBlock,newBlock]=await once(bot,'blockUpdate:'+new Vec3(1,2,3),{array:true});
|
let [,newBlock]=await once(bot,'blockUpdate:'+new Vec3(1,2,3),{array:true});
|
||||||
assert.equal(newBlock.type,95);
|
assert.equal(newBlock.type,95);
|
||||||
});
|
});
|
||||||
it("can use /xp",async() => {
|
it("can use /xp",async() => {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const {detectFrame,findPotentialLines,findBorder,getAir,generateLine,generatePortal,addPortalToWorld,makeWorldWithPortal}=require("flying-squid").portal_detector;
|
const {detectFrame,findPotentialLines,findBorder,getAir,generateLine,generatePortal,makeWorldWithPortal}=require("flying-squid").portal_detector;
|
||||||
const Vec3 = require("vec3").Vec3;
|
const Vec3 = require("vec3").Vec3;
|
||||||
const assert = require('chai').assert;
|
const assert = require('chai').assert;
|
||||||
const range = require('range').range;
|
const range = require('range').range;
|
||||||
|
|
@ -219,7 +219,7 @@ describe("Doesn't detect non-portal",function() {
|
||||||
|
|
||||||
portalData.forEach(({name,bottomLeft,direction,width,height,additionalAir,additionalObsidian}) => {
|
portalData.forEach(({name,bottomLeft,direction,width,height,additionalAir,additionalObsidian}) => {
|
||||||
const portal = generatePortal(bottomLeft, direction, width, height);
|
const portal = generatePortal(bottomLeft, direction, width, height);
|
||||||
const {bottom,left,right,top,air}=portal;
|
const {bottom,left,right,top}=portal;
|
||||||
describe("Doesn't detect detect " + name, () => {
|
describe("Doesn't detect detect " + name, () => {
|
||||||
let world;
|
let world;
|
||||||
before(async function () {
|
before(async function () {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue