From 8b6301f90b8f14f63aa985be7bccb9f674e35eb3 Mon Sep 17 00:00:00 2001 From: WindLeaf_qwq Date: Fri, 26 Nov 2021 10:33:27 +0800 Subject: [PATCH 1/2] fix: arraylist index out of bounds --- .../com/willfp/ecoenchants/command/CommandRandomenchant.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/CommandRandomenchant.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/CommandRandomenchant.java index e8bef6d0..a13ad87c 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/CommandRandomenchant.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/CommandRandomenchant.java @@ -40,8 +40,10 @@ public class CommandRandomenchant extends Subcommand { if ((args.isEmpty() && sender instanceof Player) || !sender.hasPermission("ecoenchants.command.randomenchant.others")) { player = (Player) sender; - } else { + } else if (!args.isEmpty()) { player = Bukkit.getServer().getPlayer(args.get(0)); + } else { + player = null } if (player == null) { From 0bb4f8592a83b725c29e320b6a75e0ad902442b5 Mon Sep 17 00:00:00 2001 From: WindLeaf_qwq Date: Fri, 26 Nov 2021 11:04:57 +0800 Subject: [PATCH 2/2] bruh --- .../com/willfp/ecoenchants/command/CommandRandomenchant.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/CommandRandomenchant.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/CommandRandomenchant.java index a13ad87c..a9b45fd9 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/CommandRandomenchant.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/CommandRandomenchant.java @@ -43,7 +43,7 @@ public class CommandRandomenchant extends Subcommand { } else if (!args.isEmpty()) { player = Bukkit.getServer().getPlayer(args.get(0)); } else { - player = null + player = null; } if (player == null) {