49 if(count($args) === 0){
53 $gameMode = GameMode::fromString($args[0]);
54 if($gameMode ===
null){
55 $sender->sendMessage(KnownTranslationFactory::pocketmine_command_gamemode_unknown($args[0]));
59 $target = $this->fetchPermittedPlayerTarget($sender, $args[1] ??
null, DefaultPermissionNames::COMMAND_GAMEMODE_SELF, DefaultPermissionNames::COMMAND_GAMEMODE_OTHER);
64 if($target->getGamemode() === $gameMode){
65 $sender->sendMessage(KnownTranslationFactory::pocketmine_command_gamemode_failure($target->getName()));
69 $target->setGamemode($gameMode);
70 if($gameMode !== $target->getGamemode()){
71 $sender->sendMessage(KnownTranslationFactory::pocketmine_command_gamemode_failure($target->getName()));
73 if($target === $sender){
74 Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_gamemode_success_self($gameMode->getTranslatableName()));
76 $target->sendMessage(KnownTranslationFactory::gameMode_changed($gameMode->getTranslatableName()));
77 Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_gamemode_success_other($gameMode->getTranslatableName(), $target->getName()));