Some fixes.

This commit is contained in:
kotyara 2022-07-26 18:11:27 +05:00
parent b60f0877e1
commit 51e77bf77e
8 changed files with 22 additions and 17 deletions

View file

@ -126,6 +126,10 @@ class BanAPI{
case "sudo":
$target = strtolower(array_shift($params));
$player = $this->server->api->player->get($target);
if(!isset($params[0])){
$output .= "Usage: /sudo <player>\n";
break;
}
if(!($player instanceof Player)){
$output .= "Player not connected.\n";
break;
@ -134,11 +138,11 @@ class BanAPI{
$output .= "Command ran as " . $player->username . ".\n";
break;
case "op":
$user = strtolower($params[0]);
if($user == null){
if(!isset($params[0])){
$output .= "Usage: /op <player>\n";
break;
}
$user = strtolower($params[0]);
$player = $this->server->api->player->get($user);
if(!($player instanceof Player)){
$this->ops->set($user);
@ -152,6 +156,10 @@ class BanAPI{
$this->server->api->chat->sendTo(false, "You are now op.", $player->iusername);
break;
case "deop":
if(!isset($params[0])){
$output .= "Usage: /deop <player>\n";
break;
}
$user = strtolower($params[0]);
$player = $this->server->api->player->get($user);
if(!($player instanceof Player)){

View file

@ -191,7 +191,7 @@ class ConsoleAPI{
"spectator" => VIEW,
"v" => VIEW,
];
if(!isset($gms[strtolower($params[0])])){
if(!isset($params[0]) or !isset($gms[strtolower($params[0])])){
$output .= "Usage: /$cmd <mode>\n";
break;
}
@ -205,9 +205,6 @@ class ConsoleAPI{
$info = $this->server->debugInfo();
$output .= "TPS: " . $info["tps"] . ", Memory usage: " . $info["memory_usage"] . " (Peak " . $info["memory_peak_usage"] . ")\n";
break;
case "update-done":
$this->server->api->setProperty("last-update", time());
break;
case "stop":
$this->loop->stop = true;
$output .= "Stopping the server\n";

View file

@ -93,7 +93,7 @@ class EntityAPI{
"z" => $spawnZ,
"Health" => $this->hp[$type],
]);
$this->spawnToAll($entityit, $level);
$this->spawnToAll($entityit, $spawnLevel);
$output .= $this->mobName[$type] . " spawned in " . $spawnX . ", " . $spawnY . ", " . $spawnZ . ".";
break;
}elseif(is_numeric($args[1])){//summon <mob> [amount]
@ -104,7 +104,7 @@ class EntityAPI{
}
$isBaby = 0;
if(strtolower($args[2]) == 'baby'){//summon <mob> [amount] [baby]
if(isset($args[2]) and strtolower($args[2]) == 'baby'){//summon <mob> [amount] [baby]
if($type > 13){
$output .= "This mob cant be baby!";
break;
@ -125,7 +125,7 @@ class EntityAPI{
"Health" => $this->hp[$type],
"IsBaby" => $isBaby,
]);
$this->spawnToAll($entityit, $level);
$this->spawnToAll($entityit, $spawnLevel);
}
if($type == 13 or $amount == 1)
@ -155,7 +155,7 @@ class EntityAPI{
"Health" => $this->hp[$type],
"isBaby" => 1,
]);
$this->spawnToAll($entityit, $level);
$this->spawnToAll($entityit, $spawnLevel);
$output .= "Baby " . $this->mobName[$type] . " spawned in " . $spawnX . ", " . $spawnY . ", " . $spawnZ . ".";
break;
}
@ -262,11 +262,11 @@ class EntityAPI{
return $entities;
}
public function heal($eid, $heal = 1, $cause){
public function heal($eid, $heal, $cause){
$this->harm($eid, -$heal, $cause);
}
public function harm($eid, $attack = 1, $cause, $force = false){
public function harm($eid, $attack, $cause, $force = false){
$e = $this->get($eid);
if($e === false or $e->dead === true){
return false;

View file

@ -147,11 +147,12 @@ class LevelAPI{
return ("Spawn set!");
break;
case "save-all":
$output .= "Saving...\n";
$save = $this->server->saveEnabled;
$this->server->saveEnabled = true;
$this->saveAll();
$this->server->saveEnabled = $save;
$this->server->api->chat->broadcast("[NostalgiaCore] All files are saved.");
$output .= "Saved the world";
break;
case "save-on":
$this->server->saveEnabled = true;

View file

@ -65,7 +65,7 @@ class TimeAPI{
$output .= "Added $addTime ticks" . $world . "\n";
break;
case "set":
if(substr($args[1], 0, 2) === "w:"){
if(isset($args[1]) and substr($args[1], 0, 2) === "w:"){
$levelName = preg_replace("/w:/", "", $args[1]);
$level = $this->server->api->level->get($levelName);
if($level instanceof Level){
@ -83,6 +83,7 @@ class TimeAPI{
;
else{
$output .= "Wrong time!";
break;
}
$this->set($setTime, $level);
$output .= "Set the time to " . $setTime . $world . "\n";

View file

@ -2332,7 +2332,6 @@ class Player{
}else{
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $s->count + $item->count), false);
}
console($item->getID());
switch($item->getID()){
case WORKBENCH:
AchievementAPI::grantAchievement($this, "buildWorkBench");

View file

@ -58,7 +58,7 @@ class EntityRegistry{
//self::$entityList[$className::TYPE] = $className;
self::$entityList->addEntity(new PropertyEntity($className::CLASS_TYPE, $className::TYPE, $className));
//self::$shortNames[$className] = $class->getShortName(); what is this even supposed to do?
console("Registered a ".$className);
console("[INFO] Registered a ".$className);
return true;
}

View file

@ -19,7 +19,6 @@ class PlayerActionPacket extends RakNetDataPacket{
$this->z = $this->getInt();
$this->face = $this->getInt();
$this->eid = $this->getInt();
console($this->getInt());
}
public function encode(){