Fix rarity for everything that needs it as a component
This commit is contained in:
parent
c5cca1c5aa
commit
9059a1f3d5
|
|
@ -25,7 +25,7 @@ public class Leaderboard extends SubCommand {
|
||||||
component = component.append(Component.newline()).append(MiniMessage.miniMessage().deserialize("<player>'s biggest fish was the <rarity> <fish> at <length> cm",
|
component = component.append(Component.newline()).append(MiniMessage.miniMessage().deserialize("<player>'s biggest fish was the <rarity> <fish> at <length> cm",
|
||||||
Placeholder.component("player", playerScore.player().displayName()),
|
Placeholder.component("player", playerScore.player().displayName()),
|
||||||
Placeholder.parsed("length", String.format("%.2f", playerScore.biggestFish())),
|
Placeholder.parsed("length", String.format("%.2f", playerScore.biggestFish())),
|
||||||
Placeholder.unparsed("rarity", playerScore.fish().getRarity().displayName()),
|
Placeholder.component("rarity", playerScore.fish().getRarity().displayName()),
|
||||||
Placeholder.component("fish", playerScore.fish().fishName())));
|
Placeholder.component("fish", playerScore.fish().fishName())));
|
||||||
if (playerScore.player().getUniqueId().equals(uuid))
|
if (playerScore.player().getUniqueId().equals(uuid))
|
||||||
displayPlayerScore = false;
|
displayPlayerScore = false;
|
||||||
|
|
@ -36,7 +36,7 @@ public class Leaderboard extends SubCommand {
|
||||||
component = component.append(Component.newline()).append(MiniMessage.miniMessage().deserialize("Your biggest fish was the <rarity> <fish> at <length> cm",
|
component = component.append(Component.newline()).append(MiniMessage.miniMessage().deserialize("Your biggest fish was the <rarity> <fish> at <length> cm",
|
||||||
Placeholder.component("player", playerScore.player().displayName()),
|
Placeholder.component("player", playerScore.player().displayName()),
|
||||||
Placeholder.parsed("length", String.format("%.2f", playerScore.biggestFish())),
|
Placeholder.parsed("length", String.format("%.2f", playerScore.biggestFish())),
|
||||||
Placeholder.unparsed("rarity", playerScore.fish().getRarity().displayName()),
|
Placeholder.component("rarity", playerScore.fish().getRarity().displayName()),
|
||||||
Placeholder.component("fish", playerScore.fish().fishName())));
|
Placeholder.component("fish", playerScore.fish().fishName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,12 @@ public class Config extends AbstractConfig {
|
||||||
config.logger.severe("No rarities found");
|
config.logger.severe("No rarities found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||||
for (String key : configurationSection.getKeys(false)) {
|
for (String key : configurationSection.getKeys(false)) {
|
||||||
String rarityPrefix = prefix + key + ".";
|
String rarityPrefix = prefix + key + ".";
|
||||||
Rarity rarity = new Rarity(
|
Rarity rarity = new Rarity(
|
||||||
config.getString(rarityPrefix, "internal-name", "rarity-example"),
|
config.getString(rarityPrefix, "internal-name", "rarity-example"),
|
||||||
|
miniMessage.deserialize(config.getString(rarityPrefix, "display-name", "Rarity Example")),
|
||||||
config.getString(rarityPrefix, "display-name", "Rarity Example"),
|
config.getString(rarityPrefix, "display-name", "Rarity Example"),
|
||||||
getFishTypes(rarityPrefix),
|
getFishTypes(rarityPrefix),
|
||||||
config.getInt(rarityPrefix, "chance", 1),
|
config.getInt(rarityPrefix, "chance", 1),
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ public abstract class Fish {
|
||||||
TagResolver resolver = TagResolver.resolver(
|
TagResolver resolver = TagResolver.resolver(
|
||||||
Placeholder.component("player", player.name()),
|
Placeholder.component("player", player.name()),
|
||||||
Placeholder.parsed("length", String.format("%.2f", length)),
|
Placeholder.parsed("length", String.format("%.2f", length)),
|
||||||
Placeholder.unparsed("rarity", getRarity().displayName())
|
Placeholder.component("rarity", getRarity().displayName())
|
||||||
);
|
);
|
||||||
|
|
||||||
itemMeta.lore(fishLore(resolver));
|
itemMeta.lore(fishLore(resolver));
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ public class CatchFish implements Listener {
|
||||||
item.setOwner(player.getUniqueId());
|
item.setOwner(player.getUniqueId());
|
||||||
logger.debug("[%] caught a [%] with length [%] and rarity [%] for [%] points",
|
logger.debug("[%] caught a [%] with length [%] and rarity [%] for [%] points",
|
||||||
player.getName(), fish.normalFishName(), String.format("%.2f", length),
|
player.getName(), fish.normalFishName(), String.format("%.2f", length),
|
||||||
fish.getRarity().displayName(), String.valueOf(pointsValue));
|
fish.getRarity().displayNameString(), String.valueOf(pointsValue));
|
||||||
ScoreboardManager.getInstance().updateScoreboard(player, length, fish);
|
ScoreboardManager.getInstance().updateScoreboard(player, length, fish);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
package com.alttd.fishingevent.objects;
|
package com.alttd.fishingevent.objects;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public record Rarity(String internalName, String displayName, Set<FishType> fishTypes, int chance, double multiplier, int rarityValue) {
|
public record Rarity(String internalName, Component displayName, String displayNameString, Set<FishType> fishTypes, int chance, double multiplier, int rarityValue) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ public class EventManager {
|
||||||
ScoreboardManager.getInstance().getTop10().stream().limit(3).forEachOrdered(playerScore ->
|
ScoreboardManager.getInstance().getTop10().stream().limit(3).forEachOrdered(playerScore ->
|
||||||
message.set(message.get().append(Component.newline()).append(MiniMessage.miniMessage().deserialize(Messages.TIMER.WINNER_FORMAT, TagResolver.resolver(
|
message.set(message.get().append(Component.newline()).append(MiniMessage.miniMessage().deserialize(Messages.TIMER.WINNER_FORMAT, TagResolver.resolver(
|
||||||
Placeholder.component("player", playerScore.player().displayName()),
|
Placeholder.component("player", playerScore.player().displayName()),
|
||||||
Placeholder.component("rarity", MiniMessage.miniMessage().deserialize(playerScore.fish().getRarity().displayName())),
|
Placeholder.component("rarity", playerScore.fish().getRarity().displayName()),
|
||||||
Placeholder.component("fish", playerScore.fish().fishName()),
|
Placeholder.component("fish", playerScore.fish().fishName()),
|
||||||
Placeholder.parsed("length", String.format("%.2f", playerScore.biggestFish()))
|
Placeholder.parsed("length", String.format("%.2f", playerScore.biggestFish()))
|
||||||
)))));
|
)))));
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,15 @@ public class FishConfigHelper {
|
||||||
|
|
||||||
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
||||||
SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
|
SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
|
||||||
|
String uuidString = fishItemSection.getString("uuid");
|
||||||
PlayerProfile playerProfile = Bukkit.getOfflinePlayer(UUID.fromString(fishItemSection.getString("uuid", UUID.randomUUID().toString()))).getPlayerProfile();
|
UUID uuid;
|
||||||
|
if (uuidString == null) {
|
||||||
|
uuid = UUID.randomUUID();
|
||||||
|
fishItemSection.set("uuid", uuid.toString());
|
||||||
|
} else {
|
||||||
|
uuid = UUID.fromString(uuidString);
|
||||||
|
}
|
||||||
|
PlayerProfile playerProfile = Bukkit.getOfflinePlayer(uuid).getPlayerProfile();
|
||||||
PlayerTextures playerTextures = playerProfile.getTextures();
|
PlayerTextures playerTextures = playerProfile.getTextures();
|
||||||
try {
|
try {
|
||||||
playerTextures.setSkin(new URL("http://textures.minecraft.net/texture/" + fishItemSection.getString("url-texture")));
|
playerTextures.setSkin(new URL("http://textures.minecraft.net/texture/" + fishItemSection.getString("url-texture")));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user