Skip to content

Commit

Permalink
Fixed permission command
Browse files Browse the repository at this point in the history
  • Loading branch information
Der-Zauberer committed Jul 2, 2021
1 parent 7200b15 commit da92af4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
1 change: 0 additions & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ commands:
permission:
description: Set the permissions of a player
usage: /<command> [<player>] [<group>]
permission: serversystem.command.permission
vanish:
description: Allow the player to vanish
usage: /<command> [<player>]
Expand Down
30 changes: 17 additions & 13 deletions src/serversystem/commands/PermissionCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,28 @@ public class PermissionCommand implements CommandExecutor, TabCompleter{

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(args.length == 2) {
if(Bukkit.getPlayer(args[0]) != null && Bukkit.getOnlinePlayers().contains(Bukkit.getPlayer(args[0]))) {
if(Config.getSection("Groups", false) != null && Config.getSection("Groups", false).contains(args[1])) {
Player player = Bukkit.getPlayer(args[0]);
PermissionHandler.removeConfigPermissions(player);
Config.setPlayerGroup(player, args[1]);
PermissionHandler.addConfigPermissions(player);
PermissionHandler.reloadPlayerPermissions(player);
TeamHandler.addRoleToPlayer(player);
ChatHandler.sendServerMessage(sender, "Moved the player " + args[0] + " in group " + args[1] + "!");
if(!(sender instanceof Player) || sender.hasPermission("serversystem.command.permission")) {
if(args.length == 2) {
if(Bukkit.getPlayer(args[0]) != null && Bukkit.getOnlinePlayers().contains(Bukkit.getPlayer(args[0]))) {
if(Config.getSection("Groups", false) != null && Config.getSection("Groups", false).contains(args[1])) {
Player player = Bukkit.getPlayer(args[0]);
PermissionHandler.removeConfigPermissions(player);
Config.setPlayerGroup(player, args[1]);
PermissionHandler.addConfigPermissions(player);
PermissionHandler.reloadPlayerPermissions(player);
TeamHandler.addRoleToPlayer(player);
ChatHandler.sendServerMessage(sender, "Moved the player " + args[0] + " in group " + args[1] + "!");
} else {
ChatHandler.sendServerErrorMessage(sender, "The group does not exist!");
}
} else {
ChatHandler.sendServerErrorMessage(sender, "The group does not exist!");
ChatHandler.sendServerErrorMessage(sender, ErrorMessage.PLAYERNOTONLINE);
}
} else {
ChatHandler.sendServerErrorMessage(sender, ErrorMessage.PLAYERNOTONLINE);
ChatHandler.sendServerErrorMessage(sender, ErrorMessage.NOTENOUGHTARGUMENTS);
}
} else {
ChatHandler.sendServerErrorMessage(sender, ErrorMessage.NOTENOUGHTARGUMENTS);
ChatHandler.sendServerErrorMessage(sender, ErrorMessage.NOPERMISSION);
}
return true;
}
Expand Down

0 comments on commit da92af4

Please sign in to comment.