59 if(count($args) === 1){
60 switch(strtolower($args[0])){
62 if($this->testPermission($sender, DefaultPermissionNames::COMMAND_WHITELIST_RELOAD)){
63 $server = $sender->getServer();
64 $server->getWhitelisted()->reload();
65 if($server->hasWhitelist()){
66 $this->kickNonWhitelistedPlayers($server);
68 Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_whitelist_reloaded());
73 if($this->testPermission($sender, DefaultPermissionNames::COMMAND_WHITELIST_ENABLE)){
74 $server = $sender->getServer();
75 $server->getConfigGroup()->setConfigBool(ServerProperties::WHITELIST,
true);
76 $this->kickNonWhitelistedPlayers($server);
77 Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_whitelist_enabled());
82 if($this->testPermission($sender, DefaultPermissionNames::COMMAND_WHITELIST_DISABLE)){
83 $sender->getServer()->getConfigGroup()->setConfigBool(ServerProperties::WHITELIST,
false);
84 Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_whitelist_disabled());
89 if($this->testPermission($sender, DefaultPermissionNames::COMMAND_WHITELIST_LIST)){
90 $entries = $sender->getServer()->getWhitelisted()->getAll(
true);
91 sort($entries, SORT_STRING);
92 $result = implode(
", ", $entries);
93 $count = (string) count($entries);
95 $sender->sendMessage(KnownTranslationFactory::commands_whitelist_list($count, $count));
96 $sender->sendMessage($result);
102 $sender->sendMessage(KnownTranslationFactory::commands_generic_usage(KnownTranslationFactory::commands_whitelist_add_usage()));
106 $sender->sendMessage(KnownTranslationFactory::commands_generic_usage(KnownTranslationFactory::commands_whitelist_remove_usage()));
109 }elseif(count($args) === 2){
110 if(!Player::isValidUserName($args[1])){
113 switch(strtolower($args[0])){
115 if($this->testPermission($sender, DefaultPermissionNames::COMMAND_WHITELIST_ADD)){
116 $sender->getServer()->addWhitelist($args[1]);
117 Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_whitelist_add_success($args[1]));
122 if($this->testPermission($sender, DefaultPermissionNames::COMMAND_WHITELIST_REMOVE)){
123 $server = $sender->getServer();
124 $server->removeWhitelist($args[1]);
125 if(!$server->isWhitelisted($args[1])){
126 $server->getPlayerExact($args[1])?->kick(KnownTranslationFactory::pocketmine_disconnect_kick(KnownTranslationFactory::pocketmine_disconnect_whitelisted()));
128 Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_whitelist_remove_success($args[1]));