mirror of
https://github.com/SimplexDevelopment/FeelingLucky.git
synced 2025-07-05 19:46:41 +00:00
Alpha 1.0 RC02 PATCH 01
Fixed an issue where initializing a new PlayerConfig would attempt to read a non existent value from the Luck Container list.
This commit is contained in:
@ -31,24 +31,28 @@ public record PlayerHandler(FeelingLucky plugin) implements Listener {
|
||||
return markedPlayers.contains(player);
|
||||
}
|
||||
|
||||
public static void updatePlayer(Player player, Luck luck) {
|
||||
playerLuckMap.replace(player, luck);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void initializePlayer(PlayerLoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerConfig config = FeelingLucky.getConfigMap().get(player.getUniqueId());
|
||||
PlayerConfig playerConfig = FeelingLucky.getConfigMap().get(player.getUniqueId());
|
||||
|
||||
if (config == null) {
|
||||
config = new PlayerConfig(plugin, player);
|
||||
FeelingLucky.getConfigMap().put(player.getUniqueId(), config);
|
||||
if (playerConfig == null) {
|
||||
playerConfig = new PlayerConfig(plugin, player);
|
||||
FeelingLucky.getConfigMap().put(player.getUniqueId(), playerConfig);
|
||||
}
|
||||
|
||||
String username = config.getString("username");
|
||||
double luck = config.getDouble("luck");
|
||||
double multiplier = config.getDouble("multiplier");
|
||||
String username = playerConfig.getConfig().getString("username");
|
||||
double luck = playerConfig.getConfig().getDouble("luck");
|
||||
double multiplier = playerConfig.getConfig().getDouble("multiplier");
|
||||
|
||||
if (!player.getName().equalsIgnoreCase(username)) {
|
||||
config.set("username", player.getName());
|
||||
config.save();
|
||||
config.load();
|
||||
playerConfig.getConfig().set("username", player.getName());
|
||||
playerConfig.save();
|
||||
playerConfig.load();
|
||||
}
|
||||
|
||||
Luck container = new Luck(player, multiplier);
|
||||
@ -56,8 +60,4 @@ public record PlayerHandler(FeelingLucky plugin) implements Listener {
|
||||
|
||||
playerLuckMap.put(player, container);
|
||||
}
|
||||
|
||||
public static void updatePlayer(Player player, Luck luck) {
|
||||
playerLuckMap.replace(player, luck);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user