From bdf4ca84e0a422775068ad3ef6264dfc64176db9 Mon Sep 17 00:00:00 2001 From: Video Date: Tue, 4 May 2021 06:31:55 -0600 Subject: [PATCH] Why overcomplicating things is a horrifically bad idea (#55) The longer I look into this plugin's code, the angrier I will become. This fixes 2 bugs in the /potion command: - Fixes non-admins being able to clear other players - Fixes NPE caused when trying to add potion effects to players who are not on the server as a non-admin. Both of these issues are caused by overcomplicating seemingly simple solutions, hence the name of this commit. Co-authored-by: Ryan Co-authored-by: Nathan Curran <30569566+Focusvity@users.noreply.github.com> --- .../totalfreedom/totalfreedommod/command/Command_potion.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java index f130d51a..0f30f24d 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java @@ -65,7 +65,7 @@ public class Command_potion extends FreedomCommand Player target = playerSender; if (args.length == 2) { - if (!plugin.al.isAdmin(sender) && !target.equals(getPlayer(sender.getName()))) + if (!plugin.al.isAdmin(sender) && !args[1].equalsIgnoreCase(sender.getName())) { msg(ChatColor.RED + "Only admins can clear potion effects from other players."); return true; @@ -104,7 +104,7 @@ public class Command_potion extends FreedomCommand if (args.length == 5) { - if (!plugin.al.isAdmin(sender) && !getPlayer(args[4]).equals(getPlayer(sender.getName()))) + if (!plugin.al.isAdmin(sender) && !args[4].equalsIgnoreCase(sender.getName())) { msg("Only admins can apply potion effects to other players.", ChatColor.RED); return true;