diff --git a/src/pocketmine/Gamemode.php b/src/pocketmine/GameMode.php similarity index 97% rename from src/pocketmine/Gamemode.php rename to src/pocketmine/GameMode.php index 1eb494ed2..43271d568 100644 --- a/src/pocketmine/Gamemode.php +++ b/src/pocketmine/GameMode.php @@ -23,12 +23,12 @@ declare(strict_types=1); namespace pocketmine; -final class Gamemode{ +final class GameMode{ public const SURVIVAL = 0; public const CREATIVE = 1; public const ADVENTURE = 2; public const SPECTATOR = 3; - public const VIEW = Gamemode::SPECTATOR; + public const VIEW = GameMode::SPECTATOR; private function __construct(){ //NOOP diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index fa45259e2..37604a413 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1302,8 +1302,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ */ public static function getClientFriendlyGamemode(int $gamemode) : int{ $gamemode &= 0x03; - if($gamemode === Gamemode::SPECTATOR){ - return Gamemode::CREATIVE; + if($gamemode === GameMode::SPECTATOR){ + return GameMode::CREATIVE; } return $gamemode; @@ -1348,10 +1348,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->resetFallDistance(); - if(!$client){ //Gamemode changed by server, do not send for client changes + if(!$client){ //GameMode changed by server, do not send for client changes $this->sendGamemode(); }else{ - Command::broadcastCommandMessage($this, new TranslationContainer("commands.gamemode.success.self", [Gamemode::toTranslation($gm)])); + Command::broadcastCommandMessage($this, new TranslationContainer("commands.gamemode.success.self", [GameMode::toTranslation($gm)])); } $this->sendSettings(); @@ -1400,7 +1400,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ */ public function isSurvival(bool $literal = false) : bool{ if($literal){ - return $this->gamemode === Gamemode::SURVIVAL; + return $this->gamemode === GameMode::SURVIVAL; }else{ return ($this->gamemode & 0x01) === 0; } @@ -1416,7 +1416,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ */ public function isCreative(bool $literal = false) : bool{ if($literal){ - return $this->gamemode === Gamemode::CREATIVE; + return $this->gamemode === GameMode::CREATIVE; }else{ return ($this->gamemode & 0x01) === 1; } @@ -1432,7 +1432,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ */ public function isAdventure(bool $literal = false) : bool{ if($literal){ - return $this->gamemode === Gamemode::ADVENTURE; + return $this->gamemode === GameMode::ADVENTURE; }else{ return ($this->gamemode & 0x02) > 0; } @@ -1442,7 +1442,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * @return bool */ public function isSpectator() : bool{ - return $this->gamemode === Gamemode::SPECTATOR; + return $this->gamemode === GameMode::SPECTATOR; } public function isFireProof() : bool{ @@ -1887,7 +1887,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->firstPlayed = $nbt->getLong("firstPlayed", $now = (int) (microtime(true) * 1000)); $this->lastPlayed = $nbt->getLong("lastPlayed", $now); - $this->gamemode = $nbt->getInt("playerGameType", Gamemode::SURVIVAL) & 0x03; + $this->gamemode = $nbt->getInt("playerGameType", GameMode::SURVIVAL) & 0x03; if($this->server->getForceGamemode()){ $this->gamemode = $this->server->getGamemode(); } diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index b750e112f..059d243bd 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -2167,7 +2167,7 @@ class Server{ $this->dispatchSignals = true; } - $this->logger->info($this->getLanguage()->translateString("pocketmine.server.defaultGameMode", [Gamemode::toTranslation($this->getGamemode())])); + $this->logger->info($this->getLanguage()->translateString("pocketmine.server.defaultGameMode", [GameMode::toTranslation($this->getGamemode())])); $this->logger->info($this->getLanguage()->translateString("pocketmine.server.startFinished", [round(microtime(true) - \pocketmine\START_TIME, 3)])); diff --git a/src/pocketmine/command/defaults/DefaultGamemodeCommand.php b/src/pocketmine/command/defaults/DefaultGamemodeCommand.php index d5bdc0f09..c8bede912 100644 --- a/src/pocketmine/command/defaults/DefaultGamemodeCommand.php +++ b/src/pocketmine/command/defaults/DefaultGamemodeCommand.php @@ -25,7 +25,7 @@ namespace pocketmine\command\defaults; use pocketmine\command\CommandSender; use pocketmine\command\utils\InvalidCommandSyntaxException; -use pocketmine\Gamemode; +use pocketmine\GameMode; use pocketmine\lang\TranslationContainer; use function count; @@ -49,11 +49,11 @@ class DefaultGamemodeCommand extends VanillaCommand{ throw new InvalidCommandSyntaxException(); } - $gameMode = Gamemode::fromString($args[0]); + $gameMode = GameMode::fromString($args[0]); if($gameMode !== -1){ $sender->getServer()->setConfigInt("gamemode", $gameMode); - $sender->sendMessage(new TranslationContainer("commands.defaultgamemode.success", [Gamemode::toTranslation($gameMode)])); + $sender->sendMessage(new TranslationContainer("commands.defaultgamemode.success", [GameMode::toTranslation($gameMode)])); }else{ $sender->sendMessage("Unknown game mode"); } diff --git a/src/pocketmine/command/defaults/GamemodeCommand.php b/src/pocketmine/command/defaults/GamemodeCommand.php index 9199e74e6..3439caa8a 100644 --- a/src/pocketmine/command/defaults/GamemodeCommand.php +++ b/src/pocketmine/command/defaults/GamemodeCommand.php @@ -26,7 +26,7 @@ namespace pocketmine\command\defaults; use pocketmine\command\Command; use pocketmine\command\CommandSender; use pocketmine\command\utils\InvalidCommandSyntaxException; -use pocketmine\Gamemode; +use pocketmine\GameMode; use pocketmine\lang\TranslationContainer; use pocketmine\Player; use pocketmine\utils\TextFormat; @@ -52,7 +52,7 @@ class GamemodeCommand extends VanillaCommand{ throw new InvalidCommandSyntaxException(); } - $gameMode = Gamemode::fromString($args[0]); + $gameMode = GameMode::fromString($args[0]); if($gameMode === -1){ $sender->sendMessage("Unknown game mode"); @@ -77,10 +77,10 @@ class GamemodeCommand extends VanillaCommand{ $sender->sendMessage("Game mode change for " . $target->getName() . " failed!"); }else{ if($target === $sender){ - Command::broadcastCommandMessage($sender, new TranslationContainer("commands.gamemode.success.self", [Gamemode::toTranslation($gameMode)])); + Command::broadcastCommandMessage($sender, new TranslationContainer("commands.gamemode.success.self", [GameMode::toTranslation($gameMode)])); }else{ - $target->sendMessage(new TranslationContainer("gameMode.changed", [Gamemode::toTranslation($gameMode)])); - Command::broadcastCommandMessage($sender, new TranslationContainer("commands.gamemode.success.other", [Gamemode::toTranslation($gameMode), $target->getName()])); + $target->sendMessage(new TranslationContainer("gameMode.changed", [GameMode::toTranslation($gameMode)])); + Command::broadcastCommandMessage($sender, new TranslationContainer("commands.gamemode.success.other", [GameMode::toTranslation($gameMode), $target->getName()])); } } diff --git a/src/pocketmine/network/mcpe/RakLibInterface.php b/src/pocketmine/network/mcpe/RakLibInterface.php index 3a3529602..cfa083303 100644 --- a/src/pocketmine/network/mcpe/RakLibInterface.php +++ b/src/pocketmine/network/mcpe/RakLibInterface.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace pocketmine\network\mcpe; -use pocketmine\Gamemode; +use pocketmine\GameMode; use pocketmine\network\AdvancedNetworkInterface; use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\network\Network; @@ -197,7 +197,7 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{ $info->getMaxPlayerCount(), $this->rakLib->getServerId(), $this->server->getName(), - Gamemode::toString($this->server->getGamemode()) + GameMode::toString($this->server->getGamemode()) ]) . ";" ); }