Heap of bugfixes, cleanup and PHP 7 upgrades

This commit is contained in:
Dylan K. Taylor
2017-07-13 19:18:56 +01:00
parent c2a7c2c6cd
commit 2a7b736f18
49 changed files with 114 additions and 148 deletions

View File

@ -79,7 +79,7 @@ abstract class Command{
$this->name = $name;
$this->setLabel($name);
$this->setDescription($description);
$this->usageMessage = $usageMessage === null ? "/" . $name : $usageMessage;
$this->usageMessage = $usageMessage ?? ("/" . $name);
$this->setAliases($aliases);
}

View File

@ -40,7 +40,7 @@ class CommandReader extends Thread{
$this->buffer = new \Threaded;
$opts = getopt("", ["disable-readline"]);
if((extension_loaded("readline") and !isset($opts["disable-readline"]) and !$this->isPipe(STDIN))){
if(extension_loaded("readline") and !isset($opts["disable-readline"]) and !$this->isPipe(STDIN)){
$this->type = self::TYPE_READLINE;
}

View File

@ -102,7 +102,7 @@ class FormattedCommandAlias extends Command{
throw new \InvalidArgumentException("Invalid replacement token");
}
$position = intval(substr($formatString, $argStart, $index));
$position = (int) (substr($formatString, $argStart, $index));
if($position === 0){
throw new \InvalidArgumentException("Invalid replacement token");

View File

@ -52,7 +52,7 @@ class DumpMemoryCommand extends VanillaCommand{
++self::$executions;
$sender->getServer()->getMemoryManager()->dumpServerMemory(isset($args[1]) ? $args[1] : $sender->getServer()->getDataPath() . "/memoryDump_$token", 48, 80);
$sender->getServer()->getMemoryManager()->dumpServerMemory($args[1] ?? ($sender->getServer()->getDataPath() . "/memoryDump_$token"), 48, 80);
return true;
}
}

View File

@ -55,7 +55,7 @@ class KickCommand extends VanillaCommand{
if(($player = $sender->getServer()->getPlayer($name)) instanceof Player){
$player->kick($reason);
if(strlen($reason) >= 1){
if($reason !== ""){
Command::broadcastCommandMessage($sender, new TranslationContainer("commands.kick.success.reason", [$player->getName(), $reason]));
}else{
Command::broadcastCommandMessage($sender, new TranslationContainer("commands.kick.success", [$player->getName()]));

View File

@ -203,17 +203,17 @@ class ParticleCommand extends VanillaCommand{
}
if(substr($name, 0, 10) === "iconcrack_"){
if(strpos($name, "iconcrack_") === 0){
$d = explode("_", $name);
if(count($d) === 3){
return new ItemBreakParticle($pos, Item::get((int) $d[1], (int) $d[2]));
}
}elseif(substr($name, 0, 11) === "blockcrack_"){
}elseif(strpos($name, "blockcrack_") === 0){
$d = explode("_", $name);
if(count($d) === 2){
return new TerrainParticle($pos, Block::get($d[1] & 0xff, $d[1] >> 12));
}
}elseif(substr($name, 0, 10) === "blockdust_"){
}elseif(strpos($name, "blockdust_") === 0){
$d = explode("_", $name);
if(count($d) >= 4){
return new DustParticle($pos, $d[1] & 0xff, $d[2] & 0xff, $d[3] & 0xff, isset($d[4]) ? $d[4] & 0xff : 255);