Skip to content

Commit

Permalink
Fixed bug with missing rank text in Top Ten
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jul 13, 2020
1 parent 5e56943 commit 6160a3a
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/main/java/world/bentobox/level/LevelsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,33 @@ public void getGUI(World world, final User user) {

// Top Ten
int i = 0;
boolean inTopTen = false;
for (Entry<UUID, Long> m : topTen.entrySet()) {
panel.item(SLOTS[i], getHead(i++, m.getValue(), m.getKey(), user, world));
PanelItem h = getHead((i+1), m.getValue(), m.getKey(), user, world);
panel.item(SLOTS[i], h);
// If this is also the asking player
if (m.getKey().equals(user.getUniqueId())) {
inTopTen = true;
panel.item(49, h);
setClickHandler(h, user, world);
}
i++;
}
// Show remaining slots
for (; i < SLOTS.length; i++) {
panel.item(SLOTS[i], new PanelItemBuilder().icon(Material.GREEN_STAINED_GLASS_PANE).name(String.valueOf(i + 1)).build());
}

// Add yourself
PanelItem head = getHead(0, this.getIslandLevel(world, user.getUniqueId()), user.getUniqueId(), user, world);
// Add yourself if you were not already in the top ten
if (!inTopTen) {
PanelItem head = getHead(0, this.getIslandLevel(world, user.getUniqueId()), user.getUniqueId(), user, world);
setClickHandler(head, user, world);
panel.item(49, head);
}
panel.build();
}

private void setClickHandler(PanelItem head, User user, World world) {
head.setClickHandler((p, u, ch, s) -> {
new TabbedPanelBuilder()
.user(user)
Expand All @@ -231,8 +248,7 @@ public void getGUI(World world, final User user) {
.build().openPanel();
return true;
});
panel.item(49, head);
panel.build();

}

/**
Expand Down

0 comments on commit 6160a3a

Please sign in to comment.