From 4ad7fd874fdd9c70ffa69ffcd19baf086b1e937f Mon Sep 17 00:00:00 2001 From: speedxx <43330808+speedxx@users.noreply.github.com> Date: Fri, 24 Jul 2020 23:24:14 -0400 Subject: [PATCH] separate unblocking commands from bcmd --- .../command/Command_blockcmd.java | 18 +++++--- .../command/Command_unblockcmd.java | 44 +++++++++++++++++++ 2 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java index 50328c99..32a42f8f 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java @@ -73,12 +73,16 @@ public class Command_blockcmd extends FreedomCommand } FPlayer playerdata = plugin.pl.getPlayer(player); - - playerdata.setCommandsBlocked(!playerdata.allCommandsBlocked()); - - FUtil.adminAction(sender.getName(), (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + player.getName(), true); - msg((playerdata.allCommandsBlocked() ? "B" : "Unb") + "locked all commands."); - + if (!playerdata.allCommandsBlocked()) + { + playerdata.setCommandsBlocked(true); + FUtil.adminAction(sender.getName(), "Blocking all commands for " + player.getName(), true); + msg("Blocked commands for " + player.getName() + "."); + } + else + { + msg("That players commands are already blocked.", ChatColor.RED); + } return true; } -} +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java new file mode 100644 index 00000000..86566985 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java @@ -0,0 +1,44 @@ +package me.totalfreedom.totalfreedommod.command; + +import me.totalfreedom.totalfreedommod.player.FPlayer; +import me.totalfreedom.totalfreedommod.rank.Rank; +import me.totalfreedom.totalfreedommod.util.FUtil; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) +@CommandParameters(description = "Unblocks commands for a player.", usage = "/ ", aliases = "unblockcommand,unblockcommands,ubcmds,unblockcmds,ubc") +public class Command_unblockcmd extends FreedomCommand +{ + + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (args.length == 0) + { + return false; + } + + Player player = getPlayer(args[0]); + if (player == null) + { + sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + return true; + } + + FPlayer fPlayer = plugin.pl.getPlayer(player); + if (fPlayer.allCommandsBlocked()) + { + fPlayer.setCommandsBlocked(false); + FUtil.adminAction(sender.getName(), "Unblocking all commands for " + player.getName(), true); + msg("Unblocked commands for " + player.getName() + "."); + } + else + { + msg("That players commands aren't blocked.", ChatColor.RED); + } + return true; + } +} \ No newline at end of file