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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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