mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-25 05:59:44 +00:00
Despawn command into core
This commit is contained in:
parent
f484c90f7b
commit
133f398a42
1 changed files with 37 additions and 21 deletions
|
|
@ -82,6 +82,7 @@ class EntityAPI{
|
|||
$this->server->schedule(25, array($this, "updateEntities"), array(), true);
|
||||
$this->server->api->console->register("summon", "<mob>", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("spawnmob", "<mob>", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("despawn", "", array($this, "CommandHandler"));
|
||||
}
|
||||
|
||||
public function commandHandler($cmd, $args, $issuer, $alias){
|
||||
|
|
@ -186,7 +187,22 @@ class EntityAPI{
|
|||
$output .= "Baby ".$this->mobName[$type]." spawned in ".$spawnX.", ".$spawnY.", ".$spawnZ.".";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'despawn':
|
||||
$cnt = 0;
|
||||
$l = $this->server->query("SELECT EID FROM entities WHERE class = ".ENTITY_MOB.";");
|
||||
if ($l !== false and $l !== true){
|
||||
while(($e = $l->fetchArray(SQLITE3_ASSOC)) !== false){
|
||||
$e = $this->get($e["EID"]);
|
||||
if ($e instanceof Entity){
|
||||
$this->remove($e->eid);
|
||||
$cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$output .= $cnt." mobs has been despawned!";
|
||||
break;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue