Skip to content

Commit

Permalink
Fix page indexing for next and previous page in Edit GUI.
Browse files Browse the repository at this point in the history
Fix an issue when display name was empty and icon was not showed.
  • Loading branch information
BONNe committed Dec 3, 2020
1 parent 47f22a1 commit 0ecfc47
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ else if (this.pageIndex > (this.materialChanceList.size() / MAX_ELEMENTS))
correctPage = this.pageIndex;
}

// Update page index.
this.pageIndex = correctPage;

if (this.materialChanceList.size() > MAX_ELEMENTS)
{
// Navigation buttons if necessary
Expand Down Expand Up @@ -314,6 +317,9 @@ else if (this.pageIndex > (this.treasureChanceList.size() / MAX_ELEMENTS))
correctPage = this.pageIndex;
}

// Update page index.
this.pageIndex = correctPage;

if (this.treasureChanceList.size() > MAX_ELEMENTS)
{
// Navigation buttons if necessary
Expand Down Expand Up @@ -849,6 +855,12 @@ private PanelItem createButton(Tab button)
String name = this.user.getTranslation(reference + ".name");
List<String> description = new ArrayList<>();
description.add(this.user.getTranslationOrNothing(reference + ".description"));

if (button == Tab.TREASURES)
{
description.add(this.user.getTranslationOrNothing(reference + ".drag-and-drop"));
}

description.add("");
description.add(this.user.getTranslation(Constants.TIPS + "click-to-view"));

Expand Down Expand Up @@ -1114,6 +1126,7 @@ else if (this.activeTab == Tab.TREASURES)
name(name).
description(description).
icon(icon).
amount(count).
clickHandler(clickHandler).
glow(glow).
build();
Expand Down Expand Up @@ -1244,7 +1257,7 @@ private PanelItem createTreasureButton(Pair<ItemStack, Double> treasureChanceEnt
description.add(this.user.getTranslation(Constants.BUTTON + "treasure-icon.actual",
TextVariables.NUMBER, String.valueOf(treasureChanceEntry.getValue())));

boolean glow = this.selectedMaterial.contains(treasureChanceEntry);
boolean glow = this.selectedTreasures.contains(treasureChanceEntry);

if (glow)
{
Expand Down Expand Up @@ -1300,7 +1313,7 @@ private PanelItem createTreasureButton(Pair<ItemStack, Double> treasureChanceEnt
name(this.user.getTranslation(Constants.BUTTON + "treasure-icon.name",
Constants.BLOCK, Utils.prettifyObject(this.user, treasure))).
description(description).
icon(treasure).
icon(GuiUtils.getMaterialItem(treasure.getType())).
clickHandler(clickHandler).
glow(glow).
build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ public static String prettifyObject(User user, ItemStack itemStack)
// If item has a valid display name, return it.

ItemMeta itemMeta = itemStack.getItemMeta();
return itemMeta.getDisplayName();
return itemMeta.getDisplayName().isEmpty() ?
Utils.prettifyObject(user, itemStack.getType()) :
itemMeta.getDisplayName();
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ stone-generator:
&7 their chances to be dropped.
&7 Treasures are dropped
&7 on block generating.
drag-and-drop: |-
&7 Supports drag and drop
&7 items in empty spaces.
# Section for blocks and treasures icons in Generator View GUI.
block-icon:
name: "&f&l [material]"
Expand Down

0 comments on commit 0ecfc47

Please sign in to comment.