Separate ID handling from GameMode

the aliases of 0,1,2,3 remain for user-interface level compatibility.
This commit is contained in:
Dylan K. Taylor
2021-06-27 20:32:35 +01:00
parent 5cdf0b169f
commit 902ea515f7
7 changed files with 83 additions and 31 deletions

View File

@ -25,6 +25,7 @@ namespace pocketmine\command\defaults;
use pocketmine\command\CommandSender;
use pocketmine\command\utils\InvalidCommandSyntaxException;
use pocketmine\data\java\GameModeIdMap;
use pocketmine\lang\TranslationContainer;
use pocketmine\permission\DefaultPermissionNames;
use pocketmine\player\GameMode;
@ -57,7 +58,7 @@ class DefaultGamemodeCommand extends VanillaCommand{
return true;
}
$sender->getServer()->getConfigGroup()->setConfigInt("gamemode", $gameMode->getMagicNumber());
$sender->getServer()->getConfigGroup()->setConfigInt("gamemode", GameModeIdMap::getInstance()->toId($gameMode));
$sender->sendMessage(new TranslationContainer("commands.defaultgamemode.success", [$gameMode->getTranslationKey()]));
return true;
}