Add SIGN_MATERIAL constant in ChallengesAddon which value depends on Minecraft version.

This will allow to drop down 1.14 branch.
This commit is contained in:
BONNe 2019-05-20 08:28:35 +03:00
parent 7e04f592ad
commit 330034ea8e
7 changed files with 26 additions and 15 deletions

View File

@ -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
// ---------------------------------------------------------------------

View File

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

View File

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

View File

@ -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++;

View File

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

View File

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

View File

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