diff --git a/TODO.md b/TODO.md index e420ae1..dafc050 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,6 @@ # Migration TODOs for Paper Modernization -- [ ] Switch all player score storage to use UUID instead of Player as the key +- [x] Switch all player score storage to use UUID instead of Player as the key - [ ] Update logger usage to use getLogger() from JavaPlugin - [ ] Remove or modernize any old/deprecated event registration (use @EventHandler and registerEvents) - [ ] Review and update player lookup logic to use getPlayerExact or handle case sensitivity diff --git a/src/main/java/com/majinnaibu/minecraft/plugins/scorekeeper/ScoreKeeperPlugin.java b/src/main/java/com/majinnaibu/minecraft/plugins/scorekeeper/ScoreKeeperPlugin.java index a33138c..b787d71 100644 --- a/src/main/java/com/majinnaibu/minecraft/plugins/scorekeeper/ScoreKeeperPlugin.java +++ b/src/main/java/com/majinnaibu/minecraft/plugins/scorekeeper/ScoreKeeperPlugin.java @@ -2,6 +2,7 @@ package com.majinnaibu.minecraft.plugins.scorekeeper; import java.util.HashMap; import java.util.logging.Logger; +import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.plugin.PluginDescriptionFile; @@ -14,7 +15,7 @@ import com.majinnaibu.minecraft.plugins.scorekeeper.commands.ScoreResetCommand; import com.majinnaibu.minecraft.plugins.scorekeeper.commands.ScoreSubtractCommand; public class ScoreKeeperPlugin extends JavaPlugin { - private final HashMap _playerScores = new HashMap(); + private final HashMap _playerScores = new HashMap(); public final Logger log = Logger.getLogger("Minecraft"); @@ -41,21 +42,24 @@ public class ScoreKeeperPlugin extends JavaPlugin { } public int getPlayerScore(Player player) { - if(!_playerScores.containsKey(player)){ - _playerScores.put(player, 0); + UUID uuid = player.getUniqueId(); + if(!_playerScores.containsKey(uuid)){ + _playerScores.put(uuid, 0); } - return _playerScores.get(player); + return _playerScores.get(uuid); } public void addScore(Player player, int amount) { + UUID uuid = player.getUniqueId(); int score = getPlayerScore(player); - _playerScores.put(player, score + amount); + _playerScores.put(uuid, score + amount); } public void subtractScore(Player player, int amount) { + UUID uuid = player.getUniqueId(); int score = getPlayerScore(player); - _playerScores.put(player, score - amount); + _playerScores.put(uuid, score - amount); } public void resetPlayerScore(Player targetPlayer) {