PHP: public function onCommand(CommandSender $player, Command $cmd, $label, array $args): bool{ switch($cmd->getName()){ case "setrank": if(!$player->hasPermission("arank.cmd.add")) { $player->sendMessage("§cYou have not permissions to use this command!"); break; } if($player->isOp()) { if(!empty($args[0])) { if(!empty($args[1])) { $rank = ""; if($args[0]=="jay") { $rank = "§dJAY"; } else if($args[0]=="god") { $rank = "§eGOD"; } else if($args[0]=="member") { $rank = "§aMEMBER"; } else { $rank = "§b[" . $args[0] . "§b]"; } $config = new Config($this->getDataFolder() . "/rank.yml", Config::YAML); $config->set($args[1],$rank); $config->save(); $player->sendMessage($args[1] . " The resulting range: " . $rank); } else { $player->sendMessage("Theres no rank registered"); } } else { $player->sendMessage("List of the rank:" . $rank); } } } return true; } when i type /setrank jay cant set it up to my rank and always said when i type /setrank jay "said : Theres no rank registered" all rank i try and always said theres no rank register!? and please help me to make like this /setrank <playername> <rank> and can add more rank /addrank <samplerank> save config please thankss!!
I’d often use the console in plugins... PHP: $this->getServer()->dispatchCommand(new ConsoleCommandSender(), 'setgroup '.$player.” “.$rank); For this u need PurePerms and PureChat
if (!empty($args[1])) { checks if the second argument is set, so /setrank jay is obviously not going to work. Not that any of our posts solve the OP's problem, but: No, don't do that. Because player names can have spaces, a player can "hack" your server by having the name "whatever Admin". You should always use the API directly if available: PHP: $purePerms = $this->getServer()->getPluginManager()->getPlugin("PurePerms");$group = $purePerms->getGroup("groupname");$purePerms->setGroup($player, $group);
thanks for that can i ask you about form?? how to make form like when i click the first button and wheni open the form again the button name is change?