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",
|
||||
Placeholder.component("player", playerScore.player().displayName()),
|
||||
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())));
|
||||
if (playerScore.player().getUniqueId().equals(uuid))
|
||||
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",
|
||||
Placeholder.component("player", playerScore.player().displayName()),
|
||||
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())));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,10 +68,12 @@ public class Config extends AbstractConfig {
|
|||
config.logger.severe("No rarities found");
|
||||
return;
|
||||
}
|
||||
MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||
for (String key : configurationSection.getKeys(false)) {
|
||||
String rarityPrefix = prefix + key + ".";
|
||||
Rarity rarity = new Rarity(
|
||||
config.getString(rarityPrefix, "internal-name", "rarity-example"),
|
||||
miniMessage.deserialize(config.getString(rarityPrefix, "display-name", "Rarity Example")),
|
||||
config.getString(rarityPrefix, "display-name", "Rarity Example"),
|
||||
getFishTypes(rarityPrefix),
|
||||
config.getInt(rarityPrefix, "chance", 1),
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public abstract class Fish {
|
|||
TagResolver resolver = TagResolver.resolver(
|
||||
Placeholder.component("player", player.name()),
|
||||
Placeholder.parsed("length", String.format("%.2f", length)),
|
||||
Placeholder.unparsed("rarity", getRarity().displayName())
|
||||
Placeholder.component("rarity", getRarity().displayName())
|
||||
);
|
||||
|
||||
itemMeta.lore(fishLore(resolver));
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public class CatchFish implements Listener {
|
|||
item.setOwner(player.getUniqueId());
|
||||
logger.debug("[%] caught a [%] with length [%] and rarity [%] for [%] points",
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
package com.alttd.fishingevent.objects;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
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 ->
|
||||
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("rarity", MiniMessage.miniMessage().deserialize(playerScore.fish().getRarity().displayName())),
|
||||
Placeholder.component("rarity", playerScore.fish().getRarity().displayName()),
|
||||
Placeholder.component("fish", playerScore.fish().fishName()),
|
||||
Placeholder.parsed("length", String.format("%.2f", playerScore.biggestFish()))
|
||||
)))));
|
||||
|
|
|
|||
|
|
@ -36,8 +36,15 @@ public class FishConfigHelper {
|
|||
|
||||
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
|
||||
|
||||
PlayerProfile playerProfile = Bukkit.getOfflinePlayer(UUID.fromString(fishItemSection.getString("uuid", UUID.randomUUID().toString()))).getPlayerProfile();
|
||||
String uuidString = fishItemSection.getString("uuid");
|
||||
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();
|
||||
try {
|
||||
playerTextures.setSkin(new URL("http://textures.minecraft.net/texture/" + fishItemSection.getString("url-texture")));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user