From 83eaa50b49bdfeaa8c81c03818b53e7ebea4e719 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 31 Mar 2024 18:16:45 -0700 Subject: [PATCH] Refactor to improve code quality --- .../api/commands/island/IslandCreateCommand.java | 10 ++++------ .../bentobox/panels/BlueprintManagementPanel.java | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/IslandCreateCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/IslandCreateCommand.java index 1d4bbaf84..aebd0cb32 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/IslandCreateCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/IslandCreateCommand.java @@ -114,12 +114,10 @@ public class IslandCreateCommand extends CompositeCommand { private boolean checkMaxUses(User user, String name) { if (getPlugin().getBlueprintsManager().getBlueprintBundles(getAddon()).containsKey(name)) { int maxTimes = getPlugin().getBlueprintsManager().getBlueprintBundles(getAddon()).get(name).getTimes(); - if (maxTimes > 0) { - // Check how many times this player has used this bundle - if (getBundleUses(user, name) >= maxTimes) { - user.sendMessage("commands.island.create.max-uses"); - return true; - } + // Check how many times this player has used this bundle + if (maxTimes > 0 && getBundleUses(user, name) >= maxTimes) { + user.sendMessage("commands.island.create.max-uses"); + return true; } } return false; diff --git a/src/main/java/world/bentobox/bentobox/panels/BlueprintManagementPanel.java b/src/main/java/world/bentobox/bentobox/panels/BlueprintManagementPanel.java index 05b505fd8..6abf5a6e1 100644 --- a/src/main/java/world/bentobox/bentobox/panels/BlueprintManagementPanel.java +++ b/src/main/java/world/bentobox/bentobox/panels/BlueprintManagementPanel.java @@ -199,7 +199,7 @@ public class BlueprintManagementPanel { } if (plugin.getSettings().getIslandNumber() > 1) { // Number of times allowed - pb.item(42, getTimesIcon(addon, bb)); + pb.item(42, getTimesIcon(bb)); } // Preferred slot pb.item(40, getSlotIcon(addon, bb)); @@ -213,7 +213,7 @@ public class BlueprintManagementPanel { } - private PanelItem getTimesIcon(GameModeAddon addon2, BlueprintBundle bb) { + private PanelItem getTimesIcon(BlueprintBundle bb) { return new PanelItemBuilder().icon(Material.CLOCK).name(t("times")) .description(bb.getTimes() == 0 ? t("unlimited-times") : t("maximum-times", TextVariables.NUMBER, String.valueOf(bb.getTimes()))) @@ -227,7 +227,7 @@ public class BlueprintManagementPanel { } // Save plugin.getBlueprintsManager().saveBlueprintBundle(addon, bb); - panel.getInventory().setItem(42, getTimesIcon(addon, bb).getItem()); + panel.getInventory().setItem(42, getTimesIcon(bb).getItem()); return true; }).build(); }