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 <Wild1145@users.noreply.github.com>
Co-authored-by: Nathan Curran <30569566+Focusvity@users.noreply.github.com>
This commit is contained in:
Video 2021-05-04 06:31:55 -06:00 committed by Ryan
parent 879a524bb4
commit 6fb9507a4c

View File

@ -65,7 +65,7 @@ public class Command_potion extends FreedomCommand
Player target = playerSender; Player target = playerSender;
if (args.length == 2) 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."); msg(ChatColor.RED + "Only admins can clear potion effects from other players.");
return true; return true;
@ -104,7 +104,7 @@ public class Command_potion extends FreedomCommand
if (args.length == 5) 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); msg("Only admins can apply potion effects to other players.", ChatColor.RED);
return true; return true;