mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-18 05:51:12 +00:00
have a options["max-entities"], fix #222
This commit is contained in:
parent
6f36e7c450
commit
fed2208809
2 changed files with 6 additions and 5 deletions
|
|
@ -22,5 +22,6 @@
|
|||
"header":"Flying squid",
|
||||
"footer":"Test server"
|
||||
},
|
||||
"everybody-op":true
|
||||
"everybody-op":true,
|
||||
"max-entities":100
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,14 +73,14 @@ module.exports.server=function(serv,options) {
|
|||
};
|
||||
|
||||
|
||||
module.exports.player=function(player,serv){
|
||||
module.exports.player=function(player,serv,options){
|
||||
player.commands.add({
|
||||
base: 'summon',
|
||||
info: 'Summon an entity',
|
||||
usage: '/summon <entity_name>',
|
||||
op: true,
|
||||
action(name) {
|
||||
if(Object.keys(serv.entities).length>100)
|
||||
if(Object.keys(serv.entities).length>options["max-entities"])
|
||||
throw new UserError("Too many mobs !");
|
||||
const entity=entitiesByName[name];
|
||||
if(!entity) {
|
||||
|
|
@ -108,7 +108,7 @@ module.exports.player=function(player,serv){
|
|||
return {number:args[0],name:args[1]};
|
||||
},
|
||||
action({number,name}) {
|
||||
if(Object.keys(serv.entities).length>100-number)
|
||||
if(Object.keys(serv.entities).length>options["max-entities"]-number)
|
||||
throw new UserError("Too many mobs !");
|
||||
const entity=entitiesByName[name];
|
||||
if(!entity) {
|
||||
|
|
@ -143,7 +143,7 @@ module.exports.player=function(player,serv){
|
|||
.filter(entity => !!entity);
|
||||
},
|
||||
action(entityTypes) {
|
||||
if(Object.keys(serv.entities).length>100-entityTypes.length)
|
||||
if(Object.keys(serv.entities).length>options["max-entities"]-entityTypes.length)
|
||||
throw new UserError("Too many mobs !");
|
||||
entityTypes.map(entity => {
|
||||
if(entity.type=="mob") serv.spawnMob(entity.id, player.world, player.position.scaled(1/32), {
|
||||
|
|
|
|||
Loading…
Reference in a new issue