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) {
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;

View File

@ -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();
}