Leaderboard clickable heads to teleport

This commit is contained in:
Esophose 2019-03-23 03:16:40 -06:00
parent abddc11159
commit 8b3fa5db8a
3 changed files with 58 additions and 8 deletions

View File

@ -145,8 +145,10 @@ public class LevellingManager {
Map<String, Integer> materials = new HashMap<>(); Map<String, Integer> materials = new HashMap<>();
for (LevellingData data : levellingData.keySet()) { for (LevellingData data : levellingData.keySet()) {
int amount = levellingData.get(data); int amount = levellingData.get(data);
if (data.getMaterials() != null) {
materials.put(data.getMaterials().name(), amount); materials.put(data.getMaterials().name(), amount);
} }
}
if (materials.size() == 0) { if (materials.size() == 0) {
if (player != null) { if (player != null) {

View File

@ -166,6 +166,50 @@ public class Leaderboard {
} }
} }
int clickedSlot = event.getSlot();
int leaderboardPosition = -1;
if (clickedSlot == 13) {
leaderboardPosition = 0;
} else if (clickedSlot == 21) {
leaderboardPosition = 1;
} else if (clickedSlot == 22) {
leaderboardPosition = 2;
} else if (clickedSlot == 23) {
leaderboardPosition = 3;
} else if (clickedSlot == 29) {
leaderboardPosition = 4;
} else if (clickedSlot == 31) {
leaderboardPosition = 5;
} else if (clickedSlot == 33) {
leaderboardPosition = 6;
} else if (clickedSlot == 37) {
leaderboardPosition = 7;
} else if (clickedSlot == 40) {
leaderboardPosition = 8;
} else if (clickedSlot == 43) {
leaderboardPosition = 9;
}
if (leaderboardPosition != -1) {
List<me.goodandevil.skyblock.leaderboard.Leaderboard> leaderboardIslands = skyblock
.getLeaderboardManager().getLeaderboard(
me.goodandevil.skyblock.leaderboard.Leaderboard.Type.valueOf(viewer.getType().name()));
if (leaderboardIslands.size() > leaderboardPosition) {
me.goodandevil.skyblock.leaderboard.Leaderboard leaderboard = leaderboardIslands.get(leaderboardPosition);
me.goodandevil.skyblock.visit.Visit visit = leaderboard.getVisit();
OfflinePlayer offlinePlayer = new OfflinePlayer(visit.getOwnerUUID());
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> Bukkit.dispatchCommand(player, "island teleport " + offlinePlayer.getName()));
}
event.setWillClose(false);
event.setWillDestroy(false);
return;
}
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F); soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
event.setWillClose(false); event.setWillClose(false);

View File

@ -194,7 +194,7 @@ public class Levelling {
IslandLevel level = island.getLevel(); IslandLevel level = island.getLevel();
Map<String, Integer> testIslandMaterials = level.getMaterials(); Map<String, Integer> testIslandMaterials = level.getMaterials();
Map<String, Integer> islandMaterials = level.getMaterials(); Map<String, Integer> islandMaterials = new HashMap<>();
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "levelling.yml")); Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "levelling.yml"));
Config settingsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); Config settingsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
@ -204,7 +204,8 @@ public class Levelling {
for (String materialName : testIslandMaterials.keySet()) { for (String materialName : testIslandMaterials.keySet()) {
if (mainConfig.getFileConfiguration().getString("Materials." + materialName + ".Points") == null) if (mainConfig.getFileConfiguration().getString("Materials." + materialName + ".Points") == null)
continue; continue;
if (mainConfig.getFileConfiguration().getInt("Materials." + materialName + ".Points") <= 0) if (!settingsConfig.getFileConfiguration().getBoolean("Island.Levelling.IncludeEmptyPointsInList") &&
mainConfig.getFileConfiguration().getInt("Materials." + materialName + ".Points") <= 0)
continue; continue;
Materials materials = Materials.fromString(materialName); Materials materials = Materials.fromString(materialName);
@ -281,17 +282,20 @@ public class Levelling {
int pointsEarned = materialAmount * pointsMultiplier; int pointsEarned = materialAmount * pointsMultiplier;
ItemStack is = materials.parseItem(); ItemStack is = materials.parseItem();
is.setAmount(materialAmount); is.setAmount(Math.min(materialAmount, 64));
is.setType(MaterialUtil.correctMaterial(is.getType())); is.setType(MaterialUtil.correctMaterial(is.getType()));
System.out.println(MaterialUtil.correctMaterial(is.getType()).name() + " | " + material);
List<String> lore = configLoad.getStringList("Menu.Levelling.Item.Material.Lore"); List<String> lore = configLoad.getStringList("Menu.Levelling.Item.Material.Lore");
lore.replaceAll(x -> x.replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount))); lore.replaceAll(x -> x.replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned))
.replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount))
.replace("%material",
WordUtils.capitalize(material.toLowerCase().replace("_", " ")
.replace("item", "").replace("block", ""))));
nInv.addItem(nInv.createItem(is, configLoad nInv.addItem(nInv.createItem(is, configLoad
.getString("Menu.Levelling.Item.Material.Displayname") .getString("Menu.Levelling.Item.Material.Displayname")
.replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned)) .replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned))
.replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount))
.replace("%material", .replace("%material",
WordUtils.capitalize(material.toLowerCase().replace("_", " ") WordUtils.capitalize(material.toLowerCase().replace("_", " ")
.replace("item", "").replace("block", ""))), .replace("item", "").replace("block", ""))),