From 330034ea8e05023b80174579957b880dda6a7486 Mon Sep 17 00:00:00 2001 From: BONNe Date: Mon, 20 May 2019 08:28:35 +0300 Subject: [PATCH] Add SIGN_MATERIAL constant in ChallengesAddon which value depends on Minecraft version. This will allow to drop down 1.14 branch. --- .../world/bentobox/challenges/ChallengesAddon.java | 8 ++++++++ .../world/bentobox/challenges/panel/CommonGUI.java | 4 ++-- .../challenges/panel/admin/EditSettingsGUI.java | 2 +- .../challenges/panel/user/ChallengesGUI.java | 12 ++++++------ .../challenges/panel/util/SelectBlocksGUI.java | 5 +++-- .../challenges/panel/util/SelectChallengeGUI.java | 5 +++-- .../challenges/panel/util/SelectEntityGUI.java | 5 +++-- 7 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/ChallengesAddon.java b/src/main/java/world/bentobox/challenges/ChallengesAddon.java index e3b7a71..0735838 100644 --- a/src/main/java/world/bentobox/challenges/ChallengesAddon.java +++ b/src/main/java/world/bentobox/challenges/ChallengesAddon.java @@ -88,6 +88,14 @@ public class ChallengesAddon extends Addon { new Flag.Builder("CHALLENGES_ISLAND_PROTECTION", Material.COMMAND_BLOCK).defaultRank(RanksManager.VISITOR_RANK).build(); + /** + * This ir ugly way how to fix comparability issues between 1.13 and 1.14 versions. + * @deprecated Should be removed as soon as 1.13 support are dropped down. + */ + @Deprecated + public static final Material SIGN_MATERIAL = Bukkit.getBukkitVersion().startsWith("1.13") ? Material.getMaterial("SIGN") : Material.getMaterial("OAK_SIGN"); + + // --------------------------------------------------------------------- // Section: Methods // --------------------------------------------------------------------- diff --git a/src/main/java/world/bentobox/challenges/panel/CommonGUI.java b/src/main/java/world/bentobox/challenges/panel/CommonGUI.java index 219a2be..31ccae9 100644 --- a/src/main/java/world/bentobox/challenges/panel/CommonGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/CommonGUI.java @@ -216,7 +216,7 @@ public abstract class CommonGUI { name = this.user.getTranslation("challenges.gui.buttons.next"); description = Collections.emptyList(); - icon = new ItemStack(Material.SIGN); + icon = new ItemStack(ChallengesAddon.SIGN_MATERIAL); clickHandler = (panel, user, clickType, slot) -> { this.pageIndex++; this.build(); @@ -229,7 +229,7 @@ public abstract class CommonGUI { name = this.user.getTranslation("challenges.gui.buttons.previous"); description = Collections.emptyList(); - icon = new ItemStack(Material.SIGN); + icon = new ItemStack(ChallengesAddon.SIGN_MATERIAL); clickHandler = (panel, user, clickType, slot) -> { this.pageIndex--; this.build(); diff --git a/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java index 42864e5..e4c46a7 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java @@ -466,7 +466,7 @@ public class EditSettingsGUI extends CommonGUI this.user.getTranslation("challenges.gui.descriptions.enabled") : this.user.getTranslation("challenges.gui.descriptions.disabled"))); name = this.user.getTranslation("challenges.gui.buttons.admin.title-enable"); - icon = new ItemStack(Material.SIGN); + icon = new ItemStack(ChallengesAddon.SIGN_MATERIAL); clickHandler = (panel, user1, clickType, i) -> { this.settings.setShowCompletionTitle(!this.settings.isShowCompletionTitle()); diff --git a/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java b/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java index 29d52ff..c9cbff9 100644 --- a/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java @@ -162,7 +162,7 @@ public class ChallengesGUI extends CommonGUI if (this.freeChallengeIndex > 0) { panelBuilder.item(index++, new PanelItemBuilder(). - icon(Material.SIGN). + icon(ChallengesAddon.SIGN_MATERIAL). name(this.user.getTranslation("challenges.gui.buttons.previous")). clickHandler((panel, user1, clickType, slot) -> { this.freeChallengeIndex--; @@ -186,7 +186,7 @@ public class ChallengesGUI extends CommonGUI else if (currentIndex < freeChallengesCount) { panelBuilder.item(index, new PanelItemBuilder(). - icon(Material.SIGN). + icon(ChallengesAddon.SIGN_MATERIAL). name(this.user.getTranslation("challenges.gui.buttons.next")). clickHandler((panel, user1, clickType, slot) -> { this.freeChallengeIndex++; @@ -232,7 +232,7 @@ public class ChallengesGUI extends CommonGUI if (this.pageIndex > 0) { panelBuilder.item(index++, new PanelItemBuilder(). - icon(Material.SIGN). + icon(ChallengesAddon.SIGN_MATERIAL). name(this.user.getTranslation("challenges.gui.buttons.previous")). clickHandler((panel, user1, clickType, slot) -> { this.pageIndex--; @@ -256,7 +256,7 @@ public class ChallengesGUI extends CommonGUI else if (currentIndex < challengesCount) { panelBuilder.item(index, new PanelItemBuilder(). - icon(Material.SIGN). + icon(ChallengesAddon.SIGN_MATERIAL). name(this.user.getTranslation("challenges.gui.buttons.next")). clickHandler((panel, user1, clickType, slot) -> { this.pageIndex++; @@ -293,7 +293,7 @@ public class ChallengesGUI extends CommonGUI if (this.levelIndex > 0) { panelBuilder.item(index++, new PanelItemBuilder(). - icon(Material.SIGN). + icon(ChallengesAddon.SIGN_MATERIAL). name(this.user.getTranslation("challenges.gui.buttons.previous")). clickHandler((panel, user1, clickType, slot) -> { this.levelIndex--; @@ -317,7 +317,7 @@ public class ChallengesGUI extends CommonGUI else if (currentIndex < levelCounts) { panelBuilder.item(index, new PanelItemBuilder(). - icon(Material.SIGN). + icon(ChallengesAddon.SIGN_MATERIAL). name(this.user.getTranslation("challenges.gui.buttons.next")). clickHandler((panel, user1, clickType, slot) -> { this.levelIndex++; diff --git a/src/main/java/world/bentobox/challenges/panel/util/SelectBlocksGUI.java b/src/main/java/world/bentobox/challenges/panel/util/SelectBlocksGUI.java index 52a79f2..7bcc51c 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/SelectBlocksGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/SelectBlocksGUI.java @@ -11,6 +11,7 @@ import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; import world.bentobox.bentobox.api.user.User; +import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.utils.GuiUtils; @@ -138,7 +139,7 @@ public class SelectBlocksGUI panelBuilder.item(18, new PanelItemBuilder(). - icon(Material.SIGN). + icon(ChallengesAddon.SIGN_MATERIAL). name(this.user.getTranslation("challenges.gui.buttons.previous")). clickHandler((panel, user1, clickType, slot) -> { this.build(correctPage - 1); @@ -147,7 +148,7 @@ public class SelectBlocksGUI panelBuilder.item(26, new PanelItemBuilder(). - icon(Material.SIGN). + icon(ChallengesAddon.SIGN_MATERIAL). name(this.user.getTranslation("challenges.gui.buttons.next")). clickHandler((panel, user1, clickType, slot) -> { this.build(correctPage + 1); diff --git a/src/main/java/world/bentobox/challenges/panel/util/SelectChallengeGUI.java b/src/main/java/world/bentobox/challenges/panel/util/SelectChallengeGUI.java index b348663..3988544 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/SelectChallengeGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/SelectChallengeGUI.java @@ -11,6 +11,7 @@ import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; import world.bentobox.bentobox.api.user.User; +import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.database.object.Challenge; import world.bentobox.challenges.utils.GuiUtils; @@ -75,7 +76,7 @@ public class SelectChallengeGUI panelBuilder.item(18, new PanelItemBuilder(). - icon(Material.SIGN). + icon(ChallengesAddon.SIGN_MATERIAL). name(this.user.getTranslation("challenges.gui.buttons.previous")). clickHandler((panel, user1, clickType, slot) -> { this.build(correctPage - 1); @@ -84,7 +85,7 @@ public class SelectChallengeGUI panelBuilder.item(26, new PanelItemBuilder(). - icon(Material.SIGN). + icon(ChallengesAddon.SIGN_MATERIAL). name(this.user.getTranslation("challenges.gui.buttons.next")). clickHandler((panel, user1, clickType, slot) -> { this.build(correctPage + 1); diff --git a/src/main/java/world/bentobox/challenges/panel/util/SelectEntityGUI.java b/src/main/java/world/bentobox/challenges/panel/util/SelectEntityGUI.java index 4cf2a72..27ef404 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/SelectEntityGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/SelectEntityGUI.java @@ -12,6 +12,7 @@ import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; import world.bentobox.bentobox.api.user.User; +import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.utils.GuiUtils; @@ -114,7 +115,7 @@ public class SelectEntityGUI panelBuilder.item(18, new PanelItemBuilder(). - icon(Material.SIGN). + icon(ChallengesAddon.SIGN_MATERIAL). name(this.user.getTranslation("challenges.gui.buttons.previous")). clickHandler((panel, user1, clickType, slot) -> { this.build(correctPage - 1); @@ -123,7 +124,7 @@ public class SelectEntityGUI panelBuilder.item(26, new PanelItemBuilder(). - icon(Material.SIGN). + icon(ChallengesAddon.SIGN_MATERIAL). name(this.user.getTranslation("challenges.gui.buttons.next")). clickHandler((panel, user1, clickType, slot) -> { this.build(correctPage + 1);