Fixes placeholders.

This commit is contained in:
tastybento 2020-04-19 15:49:16 -07:00
parent fe6ad81141
commit a5abd10678
3 changed files with 5 additions and 4 deletions

View File

@ -282,6 +282,7 @@ public class Level extends Addon {
} }
private String getVisitedIslandLevel(GameModeAddon gm, User user) { private String getVisitedIslandLevel(GameModeAddon gm, User user) {
if (!gm.inWorld(user.getLocation())) return "";
return getIslands().getIslandAt(user.getLocation()) return getIslands().getIslandAt(user.getLocation())
.map(island -> getLevelPresenter().getLevelString(getIslandLevel(gm.getOverWorld(), island.getOwner()))) .map(island -> getLevelPresenter().getLevelString(getIslandLevel(gm.getOverWorld(), island.getOwner())))
.orElse("0"); .orElse("0");

View File

@ -53,6 +53,7 @@ public class TopTen implements Listener {
World world = Bukkit.getWorld(tt.getUniqueId()); World world = Bukkit.getWorld(tt.getUniqueId());
if (world != null) { if (world != null) {
topTenList.put(world, tt); topTenList.put(world, tt);
addon.log("Loaded TopTen for " + world.getName());
} else { } else {
addon.logError("TopTen world " + tt.getUniqueId() + " is not known on server. Skipping..."); addon.logError("TopTen world " + tt.getUniqueId() + " is not known on server. Skipping...");
} }
@ -156,8 +157,7 @@ public class TopTen implements Listener {
*/ */
@NonNull @NonNull
public TopTenData getTopTenList(World world) { public TopTenData getTopTenList(World world) {
topTenList.putIfAbsent(world, new TopTenData()); return topTenList.computeIfAbsent(world, k -> new TopTenData());
return topTenList.get(world);
} }
/** /**

View File

@ -41,7 +41,7 @@ public class TopTenData implements DataObject {
*/ */
public long getTopTenLevel(int rank) { public long getTopTenLevel(int rank) {
Map<UUID, Long> tt = getTopTen(); Map<UUID, Long> tt = getTopTen();
return tt.size() < rank ? (long)tt.values().toArray()[(rank-1)] : 0; return rank <= tt.size() ? (long)tt.values().toArray()[(rank-1)] : 0;
} }
/** /**
@ -52,7 +52,7 @@ public class TopTenData implements DataObject {
@Nullable @Nullable
public UUID getTopTenUUID(int rank) { public UUID getTopTenUUID(int rank) {
Map<UUID, Long> tt = getTopTen(); Map<UUID, Long> tt = getTopTen();
return tt.size() < rank ? (UUID)tt.keySet().toArray()[(rank-1)] : null; return rank <= tt.size() ? (UUID)tt.keySet().toArray()[(rank-1)] : null;
} }
public void setTopTen(Map<UUID, Long> topTen) { public void setTopTen(Map<UUID, Long> topTen) {