mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-23 10:45:54 +01:00
Leaderboard clickable heads to teleport
This commit is contained in:
parent
abddc11159
commit
8b3fa5db8a
@ -145,7 +145,9 @@ 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);
|
||||||
materials.put(data.getMaterials().name(), amount);
|
if (data.getMaterials() != null) {
|
||||||
|
materials.put(data.getMaterials().name(), amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (materials.size() == 0) {
|
if (materials.size() == 0) {
|
||||||
|
@ -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);
|
||||||
|
@ -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,8 +204,9 @@ 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") &&
|
||||||
continue;
|
mainConfig.getFileConfiguration().getInt("Materials." + materialName + ".Points") <= 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
Materials materials = Materials.fromString(materialName);
|
Materials materials = Materials.fromString(materialName);
|
||||||
ItemStack is = materials.parseItem();
|
ItemStack is = materials.parseItem();
|
||||||
@ -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", ""))),
|
||||||
|
Loading…
Reference in New Issue
Block a user