mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 13:09:44 +00:00
/despawn update
This commit is contained in:
parent
f6256160fa
commit
b47369414e
1 changed files with 24 additions and 8 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class EntityAPI{
|
class EntityAPI{
|
||||||
|
|
||||||
public $entities;
|
public $entities;
|
||||||
private $server;
|
private $server;
|
||||||
private $eCnt = 1;
|
private $eCnt = 1;
|
||||||
|
|
@ -37,8 +36,8 @@ class EntityAPI{
|
||||||
];
|
];
|
||||||
$output = "";
|
$output = "";
|
||||||
switch($cmd){
|
switch($cmd){
|
||||||
case 'summon':
|
case "summon":
|
||||||
case 'spawnmob':
|
case "spawnmob":
|
||||||
if(!($issuer instanceof Player)){
|
if(!($issuer instanceof Player)){
|
||||||
$output .= "Please run this command in-game.";
|
$output .= "Please run this command in-game.";
|
||||||
break;
|
break;
|
||||||
|
|
@ -90,18 +89,35 @@ class EntityAPI{
|
||||||
$output .= "$amount ".($isBaby === 1 ? "Baby" : "")." $mobName".(($type !== 13 || $amount > 1) ? "s" : "")." spawned in $x, $y, $z.";
|
$output .= "$amount ".($isBaby === 1 ? "Baby" : "")." $mobName".(($type !== 13 || $amount > 1) ? "s" : "")." spawned in $x, $y, $z.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
elseif(strtolower($args[1]) == 'baby'){//summon <mob> [baby]
|
elseif(strtolower($args[1]) == "baby"){//summon <mob> [baby]
|
||||||
$this->summon($pos, ENTITY_MOB, $type, ["IsBaby" => 1]);
|
$this->summon($pos, ENTITY_MOB, $type, ["IsBaby" => 1]);
|
||||||
$output .= "Baby $mobName spawned in $x, $y, $z.";
|
$output .= "Baby $mobName spawned in $x, $y, $z.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'despawn':
|
case "despawn":
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
if($args[0] === "items"){
|
if(!isset($args[0])){
|
||||||
$l = $this->server->query("SELECT EID FROM entities WHERE class = ".ENTITY_ITEM.";");
|
$output .= "/despawn <all or (mobs,objects,items,fallings)>";
|
||||||
|
break;
|
||||||
}else{
|
}else{
|
||||||
$l = $this->server->query("SELECT EID FROM entities WHERE class = ".ENTITY_MOB.";");
|
if($args[0] === "all"){
|
||||||
|
$l = $this->server->query("SELECT EID FROM entities WHERE class = 2 and 3 and 4 and 5;");
|
||||||
|
}else{
|
||||||
|
$array = explode(",", strtolower($args[0]));
|
||||||
|
if(count($array) > 4){
|
||||||
|
$output .= "Many arguments!";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//terrible code
|
||||||
|
$list = "";
|
||||||
|
$temp = ["mobs" => "2", "objects" => "3", "items" => "4", "fallings" => "5"];
|
||||||
|
foreach($array as $value){
|
||||||
|
$list .= $temp[$value]." and ";
|
||||||
|
}
|
||||||
|
$despawning = substr($list, 0, -5);
|
||||||
|
$l = $this->server->query("SELECT EID FROM entities WHERE class = ".$despawning.";");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if($l !== false and $l !== true){
|
if($l !== false and $l !== true){
|
||||||
while(($e = $l->fetchArray(SQLITE3_ASSOC)) !== false){
|
while(($e = $l->fetchArray(SQLITE3_ASSOC)) !== false){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue