Refactor to improve code quality

This commit is contained in:
tastybento 2024-03-31 18:16:45 -07:00
parent 1215a43766
commit 83eaa50b49
2 changed files with 7 additions and 9 deletions

View File

@ -114,12 +114,10 @@ public class IslandCreateCommand extends CompositeCommand {
private boolean checkMaxUses(User user, String name) { private boolean checkMaxUses(User user, String name) {
if (getPlugin().getBlueprintsManager().getBlueprintBundles(getAddon()).containsKey(name)) { if (getPlugin().getBlueprintsManager().getBlueprintBundles(getAddon()).containsKey(name)) {
int maxTimes = getPlugin().getBlueprintsManager().getBlueprintBundles(getAddon()).get(name).getTimes(); int maxTimes = getPlugin().getBlueprintsManager().getBlueprintBundles(getAddon()).get(name).getTimes();
if (maxTimes > 0) { // Check how many times this player has used this bundle
// Check how many times this player has used this bundle if (maxTimes > 0 && getBundleUses(user, name) >= maxTimes) {
if (getBundleUses(user, name) >= maxTimes) { user.sendMessage("commands.island.create.max-uses");
user.sendMessage("commands.island.create.max-uses"); return true;
return true;
}
} }
} }
return false; return false;

View File

@ -199,7 +199,7 @@ public class BlueprintManagementPanel {
} }
if (plugin.getSettings().getIslandNumber() > 1) { if (plugin.getSettings().getIslandNumber() > 1) {
// Number of times allowed // Number of times allowed
pb.item(42, getTimesIcon(addon, bb)); pb.item(42, getTimesIcon(bb));
} }
// Preferred slot // Preferred slot
pb.item(40, getSlotIcon(addon, bb)); 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")) return new PanelItemBuilder().icon(Material.CLOCK).name(t("times"))
.description(bb.getTimes() == 0 ? t("unlimited-times") .description(bb.getTimes() == 0 ? t("unlimited-times")
: t("maximum-times", TextVariables.NUMBER, String.valueOf(bb.getTimes()))) : t("maximum-times", TextVariables.NUMBER, String.valueOf(bb.getTimes())))
@ -227,7 +227,7 @@ public class BlueprintManagementPanel {
} }
// Save // Save
plugin.getBlueprintsManager().saveBlueprintBundle(addon, bb); plugin.getBlueprintsManager().saveBlueprintBundle(addon, bb);
panel.getInventory().setItem(42, getTimesIcon(addon, bb).getItem()); panel.getInventory().setItem(42, getTimesIcon(bb).getItem());
return true; return true;
}).build(); }).build();
} }