diff --git a/src/VectorNetworkProject/TheMix/TheMix.php b/src/VectorNetworkProject/TheMix/TheMix.php index 9d8c192..617d2ab 100644 --- a/src/VectorNetworkProject/TheMix/TheMix.php +++ b/src/VectorNetworkProject/TheMix/TheMix.php @@ -8,7 +8,6 @@ namespace VectorNetworkProject\TheMix; - use pocketmine\plugin\PluginBase; use pocketmine\utils\TextFormat; use VectorNetworkProject\TheMix\command\PingCommand; @@ -25,14 +24,14 @@ class TheMix extends PluginBase public function onLoad() { self::$instance = $this; - $this->getLogger()->notice("Loading System..."); + $this->getLogger()->notice('Loading System...'); } public function onEnable() { $this->registerCommands(); $this->registerEvents(); - $this->getLogger()->notice(TextFormat::AQUA . ' + $this->getLogger()->notice(TextFormat::AQUA.' ███ ▄█ █▄ ▄████████ ▄▄▄▄███▄▄▄▄ ▄█ ▀████ ▐████▀ @@ -50,13 +49,13 @@ public function onEnable() public function onDisable() { - $this->getLogger()->notice("Unload System..."); + $this->getLogger()->notice('Unload System...'); } /** * @return TheMix */ - public static function getInstance(): TheMix + public static function getInstance(): self { return self::$instance; } @@ -65,7 +64,7 @@ private function registerCommands(): void { $commands = [ new PingCommand($this), - new TpsCommand($this) + new TpsCommand($this), ]; $this->getServer()->getCommandMap()->registerAll($this->getName(), $commands); } diff --git a/src/VectorNetworkProject/TheMix/command/PingCommand.php b/src/VectorNetworkProject/TheMix/command/PingCommand.php index 092e826..d389b7f 100644 --- a/src/VectorNetworkProject/TheMix/command/PingCommand.php +++ b/src/VectorNetworkProject/TheMix/command/PingCommand.php @@ -8,7 +8,6 @@ namespace VectorNetworkProject\TheMix\command; - use pocketmine\command\CommandSender; use pocketmine\command\PluginCommand; use pocketmine\Player; @@ -27,10 +26,12 @@ public function __construct(Plugin $owner) public function execute(CommandSender $sender, string $commandLabel, array $args): bool { if (!$sender instanceof Player) { - $sender->sendMessage(TextFormat::RED . "このコマンドはプレイヤーのみ実行可能です。"); + $sender->sendMessage(TextFormat::RED.'このコマンドはプレイヤーのみ実行可能です。'); + return true; } - $sender->sendMessage(TextFormat::RED . $sender->getPing() . TextFormat::YELLOW . "ms"); + $sender->sendMessage(TextFormat::RED.$sender->getPing().TextFormat::YELLOW.'ms'); + return true; } } diff --git a/src/VectorNetworkProject/TheMix/command/TpsCommand.php b/src/VectorNetworkProject/TheMix/command/TpsCommand.php index a64557b..eb5eb18 100644 --- a/src/VectorNetworkProject/TheMix/command/TpsCommand.php +++ b/src/VectorNetworkProject/TheMix/command/TpsCommand.php @@ -8,7 +8,6 @@ namespace VectorNetworkProject\TheMix\command; - use pocketmine\command\CommandSender; use pocketmine\command\PluginCommand; use pocketmine\plugin\Plugin; @@ -26,7 +25,8 @@ public function __construct(Plugin $owner) public function execute(CommandSender $sender, string $commandLabel, array $args): bool { - $sender->sendMessage(TextFormat::GREEN . 'TPS: ' . Server::getInstance()->getTicksPerSecond() . '/20'); + $sender->sendMessage(TextFormat::GREEN.'TPS: '.Server::getInstance()->getTicksPerSecond().'/20'); + return true; } } diff --git a/src/VectorNetworkProject/TheMix/event/ThePlayerJoinEvent.php b/src/VectorNetworkProject/TheMix/event/ThePlayerJoinEvent.php index 04fcc9d..7ebaed2 100644 --- a/src/VectorNetworkProject/TheMix/event/ThePlayerJoinEvent.php +++ b/src/VectorNetworkProject/TheMix/event/ThePlayerJoinEvent.php @@ -8,12 +8,12 @@ namespace VectorNetworkProject\TheMix\event; - +use Miste\scoreboardspe\API\Scoreboard; +use Miste\scoreboardspe\API\ScoreboardAction; +use Miste\scoreboardspe\API\ScoreboardDisplaySlot; +use Miste\scoreboardspe\API\ScoreboardSort; use pocketmine\event\Listener; use pocketmine\event\player\PlayerJoinEvent; -use Miste\scoreboardspe\API\{ - Scoreboard, ScoreboardDisplaySlot, ScoreboardSort, ScoreboardAction -}; use VectorNetworkProject\TheMix\task\UpdateScoreboardTask; use VectorNetworkProject\TheMix\TheMix; @@ -22,7 +22,7 @@ class ThePlayerJoinEvent implements Listener public function event(PlayerJoinEvent $event) { $player = $event->getPlayer(); - $scoreboard = new Scoreboard(TheMix::getInstance()->getServer()->getPluginManager()->getPlugin("ScoreboardsPE")->getPlugin(), "§l§7=== §6THE §aM§cI§eX §7===", ScoreboardAction::CREATE); + $scoreboard = new Scoreboard(TheMix::getInstance()->getServer()->getPluginManager()->getPlugin('ScoreboardsPE')->getPlugin(), '§l§7=== §6THE §aM§cI§eX §7===', ScoreboardAction::CREATE); $scoreboard->create(ScoreboardDisplaySlot::SIDEBAR, ScoreboardSort::DESCENDING); $scoreboard->addDisplay($player); TheMix::getInstance()->getScheduler()->scheduleRepeatingTask(new UpdateScoreboardTask($scoreboard, $player), 20); diff --git a/src/VectorNetworkProject/TheMix/event/ThePlayerLoginEvent.php b/src/VectorNetworkProject/TheMix/event/ThePlayerLoginEvent.php index 55e29ee..30841db 100644 --- a/src/VectorNetworkProject/TheMix/event/ThePlayerLoginEvent.php +++ b/src/VectorNetworkProject/TheMix/event/ThePlayerLoginEvent.php @@ -8,7 +8,6 @@ namespace VectorNetworkProject\TheMix\event; - use pocketmine\event\Listener; use pocketmine\event\player\PlayerLoginEvent; use VectorNetworkProject\TheMix\provider\DataFile; diff --git a/src/VectorNetworkProject/TheMix/event/ThePlayerQuitEvent.php b/src/VectorNetworkProject/TheMix/event/ThePlayerQuitEvent.php index 4502052..7b7f66b 100644 --- a/src/VectorNetworkProject/TheMix/event/ThePlayerQuitEvent.php +++ b/src/VectorNetworkProject/TheMix/event/ThePlayerQuitEvent.php @@ -8,7 +8,6 @@ namespace VectorNetworkProject\TheMix\event; - use pocketmine\event\Listener; use pocketmine\event\player\PlayerQuitEvent; diff --git a/src/VectorNetworkProject/TheMix/lib/database/Provider.php b/src/VectorNetworkProject/TheMix/lib/database/Provider.php index 28f8b77..17ea61b 100644 --- a/src/VectorNetworkProject/TheMix/lib/database/Provider.php +++ b/src/VectorNetworkProject/TheMix/lib/database/Provider.php @@ -8,13 +8,12 @@ namespace VectorNetworkProject\TheMix\lib\database; - use VectorNetworkProject\TheMix\TheMix; abstract class Provider { protected static function getPath(string $folder, string $type): string { - return TheMix::getInstance()->getDataFolder() . '/' . $folder . '/' . $type . '/'; + return TheMix::getInstance()->getDataFolder().'/'.$folder.'/'.$type.'/'; } } diff --git a/src/VectorNetworkProject/TheMix/lib/sound/LevelSounds.php b/src/VectorNetworkProject/TheMix/lib/sound/LevelSounds.php index 3e6639a..2f94d31 100644 --- a/src/VectorNetworkProject/TheMix/lib/sound/LevelSounds.php +++ b/src/VectorNetworkProject/TheMix/lib/sound/LevelSounds.php @@ -8,7 +8,6 @@ namespace VectorNetworkProject\TheMix\lib\sound; - use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; use pocketmine\Player; @@ -16,6 +15,7 @@ class LevelSounds { /** * @param Player $player + * * @return void */ public static function LevelUp(Player $player): void @@ -29,6 +29,7 @@ public static function LevelUp(Player $player): void /** * @param Player $player + * * @return void */ public static function Anvil(Player $player): void @@ -41,6 +42,7 @@ public static function Anvil(Player $player): void /** * @param Player $player + * * @return void */ public static function Travle(Player $player): void @@ -53,6 +55,7 @@ public static function Travle(Player $player): void /** * @param Player $player + * * @return void */ public static function EndPortalSpawn(Player $player): void @@ -65,6 +68,7 @@ public static function EndPortalSpawn(Player $player): void /** * @param Player $player + * * @return void */ public static function Portal(Player $player): void @@ -77,6 +81,7 @@ public static function Portal(Player $player): void /** * @param Player $player + * * @return void */ public static function Thunder(Player $player): void @@ -89,6 +94,7 @@ public static function Thunder(Player $player): void /** * @param Player $player + * * @return void */ public static function Remedy(Player $player): void @@ -101,6 +107,7 @@ public static function Remedy(Player $player): void /** * @param Player $player + * * @return void */ public static function Launch(Player $player): void @@ -113,6 +120,7 @@ public static function Launch(Player $player): void /** * @param Player $player + * * @return void */ public static function Blast(Player $player): void @@ -125,6 +133,7 @@ public static function Blast(Player $player): void /** * @param Player $player + * * @return void */ public static function LargeBlast(Player $player): void @@ -137,6 +146,7 @@ public static function LargeBlast(Player $player): void /** * @param Player $player + * * @return void */ public static function Twinklt(Player $player): void diff --git a/src/VectorNetworkProject/TheMix/provider/DataFile.php b/src/VectorNetworkProject/TheMix/provider/DataFile.php index 2a12e9e..699dbd1 100644 --- a/src/VectorNetworkProject/TheMix/provider/DataFile.php +++ b/src/VectorNetworkProject/TheMix/provider/DataFile.php @@ -8,7 +8,6 @@ namespace VectorNetworkProject\TheMix\provider; - interface DataFile { public const PLAYER_LEVEL = 'Level'; diff --git a/src/VectorNetworkProject/TheMix/provider/JSON.php b/src/VectorNetworkProject/TheMix/provider/JSON.php index 557bb62..2d14909 100644 --- a/src/VectorNetworkProject/TheMix/provider/JSON.php +++ b/src/VectorNetworkProject/TheMix/provider/JSON.php @@ -8,7 +8,6 @@ namespace VectorNetworkProject\TheMix\provider; - use pocketmine\utils\Config; use pocketmine\utils\MainLogger; use VectorNetworkProject\TheMix\lib\database\Provider; @@ -23,30 +22,34 @@ class JSON extends Provider /** * JSON constructor. + * * @param string $xuid * @param string $file */ public function __construct(string $xuid, string $file) { - $this->path = self::getPath('datas', 'json') . $xuid . '/'; - $this->file = $file . '.json'; + $this->path = self::getPath('datas', 'json').$xuid.'/'; + $this->file = $file.'.json'; } public function init(array $data = []): void { - if (!$this->hasTable()) $this->createTable($data); + if (!$this->hasTable()) { + $this->createTable($data); + } } /** * @param array $table + * * @return void */ public function createTable(array $table = []): void { @mkdir($this->path, 0755, true); - $config = new Config($this->path . $this->file, Config::JSON, $table); + $config = new Config($this->path.$this->file, Config::JSON, $table); $config->save(); - MainLogger::getLogger()->debug("[PROVIDER] Create ".$this->file); + MainLogger::getLogger()->debug('[PROVIDER] Create '.$this->file); } /** @@ -54,7 +57,7 @@ public function createTable(array $table = []): void */ public function hasTable(): bool { - return file_exists($this->path . $this->file) + return file_exists($this->path.$this->file) ? true : false; } @@ -64,27 +67,29 @@ public function hasTable(): bool */ public function deleteTable(): void { - unlink($this->path . $this->file); + unlink($this->path.$this->file); } /** - * @param string $key + * @param string $key * @param bool|mixed $data */ public function set(string $key, $data): void { - $config = new Config($this->path . $this->file, Config::JSON); + $config = new Config($this->path.$this->file, Config::JSON); $config->set($key, $data); $config->save(); } /** * @param string $key + * * @return bool|mixed */ public function get(string $key) { - $config = new Config($this->path . $this->file, Config::JSON); + $config = new Config($this->path.$this->file, Config::JSON); + return $config->get($key); } @@ -93,7 +98,8 @@ public function get(string $key) */ public function getAll(): array { - $config = new Config($this->path . $this->file, Config::JSON); + $config = new Config($this->path.$this->file, Config::JSON); + return $config->getAll(); } @@ -102,17 +108,20 @@ public function getAll(): array */ public function getKeys(): array { - $config = new Config($this->path . $this->file, Config::JSON); + $config = new Config($this->path.$this->file, Config::JSON); + return $config->getAll(true); } /** * @param string $key + * * @return bool */ public function exists(string $key): bool { - $config = new Config($this->path . $this->file, Config::JSON); + $config = new Config($this->path.$this->file, Config::JSON); + return $config->exists($key) ? true : false; @@ -120,11 +129,12 @@ public function exists(string $key): bool /** * @param string $key + * * @return void */ public function remove(string $key): void { - $config = new Config($this->path . $this->file, Config::JSON); + $config = new Config($this->path.$this->file, Config::JSON); $config->remove($key); } } diff --git a/src/VectorNetworkProject/TheMix/provider/YAML.php b/src/VectorNetworkProject/TheMix/provider/YAML.php index 78cc20b..9ca2f17 100644 --- a/src/VectorNetworkProject/TheMix/provider/YAML.php +++ b/src/VectorNetworkProject/TheMix/provider/YAML.php @@ -8,7 +8,6 @@ namespace VectorNetworkProject\TheMix\provider; - use pocketmine\utils\Config; use VectorNetworkProject\TheMix\lib\database\Provider; @@ -22,22 +21,24 @@ class YAML extends Provider /** * JSON constructor. + * * @param string $file */ public function __construct(string $file = 'config') { $this->path = self::getPath('configs', 'yaml'); - $this->file = $file . '.yml'; + $this->file = $file.'.yml'; } /** * @param array $table + * * @return void */ public function createTable(array $table = []): void { @mkdir($this->path); - $config = new Config($this->path . $this->file, Config::YAML, $table); + $config = new Config($this->path.$this->file, Config::YAML, $table); $config->save(); } @@ -46,7 +47,7 @@ public function createTable(array $table = []): void */ public function hasTable(): bool { - return file_exists($this->path . $this->file) + return file_exists($this->path.$this->file) ? true : false; } @@ -56,29 +57,31 @@ public function hasTable(): bool */ public function deleteTable(): bool { - return unlink($this->path . $this->file) + return unlink($this->path.$this->file) ? true : false; } /** - * @param string $key + * @param string $key * @param bool|mixed $data */ public function set(string $key, $data): void { - $config = new Config($this->path . $this->file, Config::YAML); + $config = new Config($this->path.$this->file, Config::YAML); $config->set($key, $data); $config->save(); } /** * @param string $key + * * @return mixed */ public function get(string $key) { - $config = new Config($this->path . $this->file, Config::YAML); + $config = new Config($this->path.$this->file, Config::YAML); + return $config->get($key); } @@ -87,7 +90,8 @@ public function get(string $key) */ public function getAll(): array { - $config = new Config($this->path . $this->file, Config::YAML); + $config = new Config($this->path.$this->file, Config::YAML); + return $config->getAll(); } @@ -96,17 +100,20 @@ public function getAll(): array */ public function getKeys(): array { - $config = new Config($this->path . $this->file, Config::YAML); + $config = new Config($this->path.$this->file, Config::YAML); + return $config->getAll(true); } /** * @param string $key + * * @return bool */ public function exists(string $key): bool { - $config = new Config($this->path . $this->file, Config::YAML); + $config = new Config($this->path.$this->file, Config::YAML); + return $config->exists($key) ? true : false; @@ -114,11 +121,12 @@ public function exists(string $key): bool /** * @param string $key + * * @return void */ public function remove(string $key): void { - $config = new Config($this->path . $this->file, Config::YAML); + $config = new Config($this->path.$this->file, Config::YAML); $config->remove($key); } } diff --git a/src/VectorNetworkProject/TheMix/task/UpdateScoreboardTask.php b/src/VectorNetworkProject/TheMix/task/UpdateScoreboardTask.php index 43dcc9d..d4959ee 100644 --- a/src/VectorNetworkProject/TheMix/task/UpdateScoreboardTask.php +++ b/src/VectorNetworkProject/TheMix/task/UpdateScoreboardTask.php @@ -8,12 +8,9 @@ namespace VectorNetworkProject\TheMix\task; - +use Miste\scoreboardspe\API\Scoreboard; use pocketmine\Player; use pocketmine\scheduler\Task; -use Miste\scoreboardspe\API\{ - Scoreboard, ScoreboardDisplaySlot, ScoreboardSort, ScoreboardAction -}; use pocketmine\Server; class UpdateScoreboardTask extends Task @@ -31,10 +28,12 @@ public function __construct(Scoreboard $scoreboard, Player $player) public function onRun(int $currentTick) { - if (!$this->player->isOnline()) $this->getHandler()->cancel(); + if (!$this->player->isOnline()) { + $this->getHandler()->cancel(); + } $scoreboard = $this->scoreboard; - $scoreboard->setLine($this->player, 0, '§7' . date("Y/m/d H:i:s")); - $scoreboard->setLine($this->player, 2, "§7Players: " . count(Server::getInstance()->getOnlinePlayers()) . "/" . Server::getInstance()->getMaxPlayers()); - $scoreboard->setLine($this->player, 4, "§ewww.vector-network.tk "); + $scoreboard->setLine($this->player, 0, '§7'.date('Y/m/d H:i:s')); + $scoreboard->setLine($this->player, 2, '§7Players: '.count(Server::getInstance()->getOnlinePlayers()).'/'.Server::getInstance()->getMaxPlayers()); + $scoreboard->setLine($this->player, 4, '§ewww.vector-network.tk '); } }