Skip to content

Commit

Permalink
Add SIGN_MATERIAL constant in ChallengesAddon which value depends on …
Browse files Browse the repository at this point in the history
…Minecraft version.

This will allow to drop down 1.14 branch.
  • Loading branch information
BONNe committed May 20, 2019
1 parent 7e04f59 commit 330034e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 15 deletions.
8 changes: 8 additions & 0 deletions src/main/java/world/bentobox/challenges/ChallengesAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ---------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/world/bentobox/challenges/panel/CommonGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ protected PanelItem getButton(CommonButtons button)
{
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();
Expand All @@ -229,7 +229,7 @@ protected PanelItem getButton(CommonButtons button)
{
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ private PanelItem getSettingsButton(Button button)
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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void addFreeChallenges(PanelBuilder panelBuilder, int firstItemIndex)
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--;
Expand All @@ -186,7 +186,7 @@ private void addFreeChallenges(PanelBuilder panelBuilder, int firstItemIndex)
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++;
Expand Down Expand Up @@ -232,7 +232,7 @@ private void addChallenges(PanelBuilder panelBuilder, int firstItemIndex)
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--;
Expand All @@ -256,7 +256,7 @@ private void addChallenges(PanelBuilder panelBuilder, int firstItemIndex)
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++;
Expand Down Expand Up @@ -293,7 +293,7 @@ private void addChallengeLevels(PanelBuilder panelBuilder, int firstItemIndex)
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--;
Expand All @@ -317,7 +317,7 @@ private void addChallengeLevels(PanelBuilder panelBuilder, int firstItemIndex)
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++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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;


Expand Down Expand Up @@ -138,7 +139,7 @@ else if (pageIndex > (this.elements.size() / MAX_ELEMENTS))

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);
Expand All @@ -147,7 +148,7 @@ else if (pageIndex > (this.elements.size() / MAX_ELEMENTS))

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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;

Expand Down Expand Up @@ -75,7 +76,7 @@ else if (pageIndex > (this.challengesList.size() / MAX_ELEMENTS))

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);
Expand All @@ -84,7 +85,7 @@ else if (pageIndex > (this.challengesList.size() / MAX_ELEMENTS))

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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;


Expand Down Expand Up @@ -114,7 +115,7 @@ else if (pageIndex > (this.entities.size() / MAX_ELEMENTS))

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);
Expand All @@ -123,7 +124,7 @@ else if (pageIndex > (this.entities.size() / MAX_ELEMENTS))

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);
Expand Down

0 comments on commit 330034e

Please sign in to comment.