mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-09 01:48:24 +01:00
Refactor to improve code quality
This commit is contained in:
parent
1215a43766
commit
83eaa50b49
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user