Notify players when there is a new player in first place
This commit is contained in:
parent
12e7dee374
commit
16bea6d0f9
|
|
@ -147,4 +147,16 @@ public class Messages extends AbstractConfig {
|
||||||
WINNER_FORMAT = config.getString(prefix, "winner-format", WINNER_FORMAT);
|
WINNER_FORMAT = config.getString(prefix, "winner-format", WINNER_FORMAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class OTHER_MESSAGES {
|
||||||
|
private static final String prefix = "other-messages.";
|
||||||
|
|
||||||
|
public static String NEW_LEADER = "<green><gold><player></gold> just caught a new longest fish! They caught a <rarity> <fish> <gold><length> cm</gold></green>";
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private static void load() {
|
||||||
|
NEW_LEADER = config.getString(prefix, "new-leader", NEW_LEADER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
package com.alttd.fishingevent.scoreboard;
|
package com.alttd.fishingevent.scoreboard;
|
||||||
|
|
||||||
|
import com.alttd.fishingevent.config.Messages;
|
||||||
import com.alttd.fishingevent.fish.Fish;
|
import com.alttd.fishingevent.fish.Fish;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scoreboard.*;
|
import org.bukkit.scoreboard.*;
|
||||||
|
|
@ -16,6 +19,7 @@ public class ScoreboardManager {
|
||||||
private Objective objective;
|
private Objective objective;
|
||||||
private final String scoreName = "Fish Leaderboard";
|
private final String scoreName = "Fish Leaderboard";
|
||||||
private double tenthLength = 0;
|
private double tenthLength = 0;
|
||||||
|
private double firstLength = 0;
|
||||||
private final HashMap<UUID, PlayerScore> playerScores = new HashMap<>(); //TODO save and load this along with the points data
|
private final HashMap<UUID, PlayerScore> playerScores = new HashMap<>(); //TODO save and load this along with the points data
|
||||||
|
|
||||||
private ScoreboardManager() {
|
private ScoreboardManager() {
|
||||||
|
|
@ -46,10 +50,22 @@ public class ScoreboardManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerScores.put(uuid, new PlayerScore(player, fishLength, fish));
|
playerScore = new PlayerScore(player, fishLength, fish);
|
||||||
|
playerScores.put(uuid, playerScore);
|
||||||
if (fishLength <= tenthLength)
|
if (fishLength <= tenthLength)
|
||||||
return;
|
return;
|
||||||
updateScoreBoard();
|
updateScoreBoard();
|
||||||
|
|
||||||
|
if (!(fishLength > firstLength)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
firstLength = fishLength;
|
||||||
|
player.getServer().sendMessage(MiniMessage.miniMessage().deserialize(Messages.OTHER_MESSAGES.NEW_LEADER, TagResolver.resolver(
|
||||||
|
Placeholder.component("player", playerScore.player().displayName()),
|
||||||
|
Placeholder.component("rarity", playerScore.fish().getRarity().displayName()),
|
||||||
|
Placeholder.component("fish", playerScore.fish().fishName()),
|
||||||
|
Placeholder.parsed("length", String.format("%.2f", playerScore.biggestFish()))
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateScoreBoard() {
|
private void updateScoreBoard() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user