more canonical codestyle

This commit is contained in:
Sunch 2025-04-28 19:49:29 +08:00
parent 27554d29bd
commit 2b90f6499e
30 changed files with 1388 additions and 1689 deletions

View file

@ -184,7 +184,7 @@ class AchievementAPI{
if(count($achs) <= 0){
return "Player {$params[0]} unlocked 0 achievements";
}
$output = "Unlocked Achievements(" . count($achs) . "/" . count(self::$achievements) . "): ";
$output = "Unlocked Achievements(".count($achs)."/".count(self::$achievements)."): ";
foreach($achs as $achievement => $unlocked){
if($unlocked && isset(self::$achievements[$achievement])){
$info = self::$achievements[$achievement];

View file

@ -235,7 +235,7 @@ class BlockAPI{
break;
}
$itemheld = $issuer->getSlot($issuer->slot);
$output = self::getItem($itemheld->getID(), $itemheld->getMetadata()) . "";
$output = self::getItem($itemheld->getID(), $itemheld->getMetadata())."";
break;
case "setblock":
if(!($issuer instanceof Player)){
@ -289,7 +289,7 @@ class BlockAPI{
break;
}else{
$level->setBlock($pos, $block, true, false, true);
$output .= "Placed $block in " . implode(", ", $coords) . ", w:" . $level->getName();
$output .= "Placed $block in ".implode(", ", $coords).", w:".$level->getName();
}
break;
case "give":
@ -311,7 +311,7 @@ class BlockAPI{
}
$player->addItem($item->getID(), $item->getMetadata(), $item->count);
$output .= "Giving " . $item->count . " of " . $item->getName() . " (" . $item->getID() . ":" . $item->getMetadata() . ") to " . $player->username;
$output .= "Giving ".$item->count." of ".$item->getName()." (".$item->getID().":".$item->getMetadata().") to ".$player->username;
break;
}else{
$item = self::fromString($args[0] ?? "");
@ -334,7 +334,7 @@ class BlockAPI{
}
$issuer->addItem($item->getID(), $item->getMetadata(), $item->count);
$output .= "Giving " . $item->count . " of " . $item->getName() . " (" . $item->getID() . ":" . $item->getMetadata() . ") to " . $issuer->username;
$output .= "Giving ".$item->count." of ".$item->getName()." (".$item->getID().":".$item->getMetadata().") to ".$issuer->username;
break;
}
}

View file

@ -272,19 +272,19 @@ class ConsoleAPI{
}
public static function debug($msg){
console("[DEBUG] " . $msg, true, true, 2);
console("[DEBUG] ".$msg, true, true, 2);
}
public static function info($msg){
console("[INFO] " . $msg);
console("[INFO] ".$msg);
}
public static function notice($msg){
console("[NOTICE] " . $msg);
console("[NOTICE] ".$msg);
}
public static function warn($msg){
console("[WARNING] " . $msg);
console("[WARNING] ".$msg);
}
public static function error($msg){
console("[ERROR] " . $msg);
console("[ERROR] ".$msg);
}
}

View file

@ -36,7 +36,7 @@ class EntityAPI{
$output = "";
switch($cmd){
case "entcnt":
return "Total amount of entities: " . count($this->entities);
return "Total amount of entities: ". count($this->entities);
case "summon":
case "spawnmob":
if(!($issuer instanceof Player)){
@ -81,7 +81,7 @@ class EntityAPI{
$this->summon($pos, ENTITY_MOB, $type, ["IsBaby" => $isBaby]);
}
return "$amount " . ($isBaby ? "Baby " : "") . "$mobName(s) spawned in $x, $y, $z.";
return "$amount ".($isBaby ? "Baby " : "")."$mobName(s) spawned in $x, $y, $z.";
}
elseif(strtolower($args[1]) == "baby"){//summon <mob> [baby]
$this->summon($pos, ENTITY_MOB, $type, ["IsBaby" => 1]);

View file

@ -139,8 +139,8 @@ class PluginAPI extends stdClass{
if($ext2 === "phar"){
++$pharCnt;
$pluginInfo = []; //TODO: A PluginInfo class?
$filePath = $this->pluginsPath() . $file;
$p = new Phar($this->pluginsPath() . $file, 0);
$filePath = $this->pluginsPath().$file;
$p = new Phar($this->pluginsPath().$file, 0);
foreach (new RecursiveIteratorIterator($p) as $file) {
$name = $file->getFileName();
$content = file_get_contents($file->getPathName());
@ -149,7 +149,7 @@ class PluginAPI extends stdClass{
break;
}
}
console("[INFO] Loading PHAR plugin \"" . FORMAT_GREEN . $pluginInfo["name"] . FORMAT_RESET . "\" " . FORMAT_AQUA . $pluginInfo["version"] . FORMAT_RESET . " by " . FORMAT_AQUA . $pluginInfo["author"] . FORMAT_RESET);
console("[INFO] Loading PHAR plugin \"".FORMAT_GREEN.$pluginInfo["name"].FORMAT_RESET."\" ".FORMAT_AQUA.$pluginInfo["version"].FORMAT_RESET." by ".FORMAT_AQUA.$pluginInfo["author"].FORMAT_RESET);
$aver = CURRENT_API_VERSION;
if(!in_array((string) CURRENT_API_VERSION, $pluginInfo["api"])){
@ -159,13 +159,13 @@ class PluginAPI extends stdClass{
}
$phr = "phar://$filePath/";
include($phr . "/src/" . $pluginInfo["classLoader"]);
include($phr."/src/".$pluginInfo["classLoader"]);
$class = $pluginInfo["CLClass"];
$loader = new $class();
$loader->loadAll($phr);
$pluginName = PharUtils::getNameSpaceClass($pluginInfo["mainFile"]);
include($phr . "/src/" . $pluginInfo["mainFile"]);
include($phr."/src/".$pluginInfo["mainFile"]);
$plugin = new $pluginName($this->server->api, false);
if(!($plugin instanceof Plugin)){
console("[ERROR] Plugin \"" . $pluginInfo["name"] . "\" doesn't use the Plugin Interface");