From 308fc5c8a0db6b84ff68f64c78326924a962b8bf Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Fri, 18 Mar 2016 13:56:05 +0100 Subject: [PATCH] limit the number of entities in initEntity --- src/lib/plugins/spawn.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/plugins/spawn.js b/src/lib/plugins/spawn.js index aa44eb9..cf09621 100644 --- a/src/lib/plugins/spawn.js +++ b/src/lib/plugins/spawn.js @@ -13,6 +13,8 @@ const Vec3 = require("vec3").Vec3; module.exports.server=function(serv,options) { serv.initEntity = (type, entityType, world, position) => { + if(Object.keys(serv.entities).length>options["max-entities"]) + throw new Error("Too many mobs !"); serv.entityMaxId++; const entity = new Entity(serv.entityMaxId);