Buy enchantment + Misc Update
This commit is contained in:
parent
53dbcb6800
commit
a24db4dbcd
41 changed files with 488 additions and 122 deletions
|
|
@ -8,6 +8,7 @@ import org.gsdistance.grimmsServer.GrimmsServer;
|
|||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -19,24 +20,26 @@ public class PlayerStatLeaderBoard {
|
|||
"tPoint", Double.class,
|
||||
"block_break_count", Long.class,
|
||||
"money", Double.class,
|
||||
"level", Integer.class
|
||||
"level", Integer.class,
|
||||
"sent_messages", Long.class
|
||||
);
|
||||
public Map<String, LeaderboardEntry> leaderboard;
|
||||
|
||||
public PlayerStatLeaderBoard() {
|
||||
this.leaderboard = Map.of(
|
||||
"total_kill_count", new LeaderboardEntry("None", 0),
|
||||
"death_count", new LeaderboardEntry("None", 0),
|
||||
"join_count", new LeaderboardEntry("None", 0),
|
||||
"tPoint", new LeaderboardEntry("None", 0),
|
||||
"block_break_count", new LeaderboardEntry("None", 0),
|
||||
"money", new LeaderboardEntry("None", 0),
|
||||
"level", new LeaderboardEntry("None", 0)
|
||||
);
|
||||
leaderboard = new HashMap<>();
|
||||
for (String stat : Stats.keySet()) {
|
||||
leaderboard.put(stat, new LeaderboardEntry("None", 0));
|
||||
}
|
||||
}
|
||||
|
||||
public static PlayerStatLeaderBoard getPlayerStatLeaderBoard() {
|
||||
return new Gson().fromJson((String) ServerStats.getServerStats().getStat("leaderboard"), PlayerStatLeaderBoard.class);
|
||||
PlayerStatLeaderBoard playerStatLeaderBoard = new Gson().fromJson((String) ServerStats.getServerStats().getStat("leaderboard"), PlayerStatLeaderBoard.class);
|
||||
for (String stat : Stats.keySet()) {
|
||||
if (!playerStatLeaderBoard.leaderboard.containsKey(stat)) {
|
||||
playerStatLeaderBoard.leaderboard.put(stat, new LeaderboardEntry("None", 0));
|
||||
}
|
||||
}
|
||||
return playerStatLeaderBoard;
|
||||
}
|
||||
|
||||
public void savePlayerStatLeaderBoard() {
|
||||
|
|
@ -51,7 +54,7 @@ public class PlayerStatLeaderBoard {
|
|||
Number playerStatValue = (Number) playerStats.getStat(stat);
|
||||
Number leaderboardStatValue = leaderboard.get(stat).getStatValue();
|
||||
if (playerStatValue != null && playerStatValue.doubleValue() > leaderboardStatValue.doubleValue()) {
|
||||
if(!player.getName().equalsIgnoreCase(leaderboard.get(stat).getPlayerName())){
|
||||
if (!player.getName().equalsIgnoreCase(leaderboard.get(stat).getPlayerName())) {
|
||||
overtakes.add(stat);
|
||||
}
|
||||
leaderboard.put(stat, new LeaderboardEntry(player.getName(), playerStatValue.intValue()));
|
||||
|
|
@ -59,9 +62,9 @@ public class PlayerStatLeaderBoard {
|
|||
pass = true;
|
||||
}
|
||||
}
|
||||
if(pass){
|
||||
for (String stat : overtakes){
|
||||
GrimmsServer.instance.getServer().broadcastMessage("The leader of stat " + stat + " is now " + player.getDisplayName());
|
||||
if (pass) {
|
||||
for (String stat : overtakes) {
|
||||
GrimmsServer.instance.getServer().broadcastMessage("The leader of stat " + PlayerStats.StatNames.get(stat) + " is now " + player.getDisplayName());
|
||||
}
|
||||
PlayerTitleManager.gotOnLeaderboard(player);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue