From 537b854c7518e19811bc5f57f89c661dd9b28d84 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Tue, 13 Aug 2019 10:53:07 +0200 Subject: [PATCH] Fixed some code smells Added TextVariables#NEXT --- .../bentobox/api/localization/TextVariables.java | 4 ++++ .../bentobox/bentobox/blueprints/BlueprintPaster.java | 4 +--- .../bentobox/bentobox/database/objects/Island.java | 2 +- .../bentobox/bentobox/panels/settings/SettingsTab.java | 10 +++++++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/localization/TextVariables.java b/src/main/java/world/bentobox/bentobox/api/localization/TextVariables.java index 877ab2af7..3718dc9ae 100644 --- a/src/main/java/world/bentobox/bentobox/api/localization/TextVariables.java +++ b/src/main/java/world/bentobox/bentobox/api/localization/TextVariables.java @@ -17,4 +17,8 @@ public class TextVariables { public static final String SPAWN_HERE = "[spawn_here]"; public static final String VERSION = "[version]"; public static final String START_TEXT = "[start]"; + /** + * @since 1.6.0 + */ + public static final String NEXT = "[next]"; } diff --git a/src/main/java/world/bentobox/bentobox/blueprints/BlueprintPaster.java b/src/main/java/world/bentobox/bentobox/blueprints/BlueprintPaster.java index f3fabdf64..63143c5e8 100644 --- a/src/main/java/world/bentobox/bentobox/blueprints/BlueprintPaster.java +++ b/src/main/java/world/bentobox/bentobox/blueprints/BlueprintPaster.java @@ -56,8 +56,6 @@ public class BlueprintPaster { private Location pos1; // The maximum block position (x,y,z) private Location pos2; - // Speed of pasting - private int pasteSpeed; private PasteState pasteState; private BukkitTask pastingTask; private BlueprintClipboard clipboard; @@ -113,7 +111,7 @@ public class BlueprintPaster { // Initial state & speed pasteState = PasteState.BLOCKS; - pasteSpeed = plugin.getSettings().getPasteSpeed(); + final int pasteSpeed = plugin.getSettings().getPasteSpeed(); pastingTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> { int count = 0; diff --git a/src/main/java/world/bentobox/bentobox/database/objects/Island.java b/src/main/java/world/bentobox/bentobox/database/objects/Island.java index 05bbdea0c..f5a290a42 100644 --- a/src/main/java/world/bentobox/bentobox/database/objects/Island.java +++ b/src/main/java/world/bentobox/bentobox/database/objects/Island.java @@ -1188,7 +1188,7 @@ public class Island implements DataObject { * @since 1.6.0 */ public boolean isReserved() { - return reserved == null ? false : reserved; + return reserved != null && reserved; } /** diff --git a/src/main/java/world/bentobox/bentobox/panels/settings/SettingsTab.java b/src/main/java/world/bentobox/bentobox/panels/settings/SettingsTab.java index 103a5c503..5a09094ce 100644 --- a/src/main/java/world/bentobox/bentobox/panels/settings/SettingsTab.java +++ b/src/main/java/world/bentobox/bentobox/panels/settings/SettingsTab.java @@ -14,6 +14,7 @@ import org.bukkit.event.inventory.ClickType; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.flags.Flag; import world.bentobox.bentobox.api.flags.Flag.Type; +import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.panels.Panel; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.PanelItem.ClickHandler; @@ -134,7 +135,8 @@ public class SettingsTab implements Tab, ClickHandler { icons.put(7, new PanelItemBuilder().icon(Material.GOLD_INGOT) .name(user.getTranslation(PROTECTION_PANEL + "mode.advanced.name")) .description(user.getTranslation(PROTECTION_PANEL + "mode.advanced.description"), "", - user.getTranslation(PROTECTION_PANEL + "mode.click-to-switch", "[next]", user.getTranslation(PROTECTION_PANEL + "mode.expert.name"))) + user.getTranslation(PROTECTION_PANEL + "mode.click-to-switch", + TextVariables.NEXT, user.getTranslation(PROTECTION_PANEL + "mode.expert.name"))) .clickHandler(this) .build()); break; @@ -142,7 +144,8 @@ public class SettingsTab implements Tab, ClickHandler { icons.put(7, new PanelItemBuilder().icon(Material.NETHER_BRICK) .name(user.getTranslation(PROTECTION_PANEL + "mode.expert.name")) .description(user.getTranslation(PROTECTION_PANEL + "mode.expert.description"), "", - user.getTranslation(PROTECTION_PANEL + "mode.click-to-switch", "[next]", user.getTranslation(PROTECTION_PANEL + "mode.basic.name"))) + user.getTranslation(PROTECTION_PANEL + "mode.click-to-switch", + TextVariables.NEXT, user.getTranslation(PROTECTION_PANEL + "mode.basic.name"))) .clickHandler(this) .build()); break; @@ -150,7 +153,8 @@ public class SettingsTab implements Tab, ClickHandler { icons.put(7, new PanelItemBuilder().icon(Material.IRON_INGOT) .name(user.getTranslation(PROTECTION_PANEL + "mode.basic.name")) .description(user.getTranslation(PROTECTION_PANEL + "mode.basic.description"), "", - user.getTranslation(PROTECTION_PANEL + "mode.click-to-switch", "[next]", user.getTranslation(PROTECTION_PANEL + "mode.advanced.name"))) + user.getTranslation(PROTECTION_PANEL + "mode.click-to-switch", + TextVariables.NEXT, user.getTranslation(PROTECTION_PANEL + "mode.advanced.name"))) .clickHandler(this) .build()); }