mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-24 17:11:30 +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) {
|
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;
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user