Alpha 1.1.0

This commit is contained in:
Paldiu 2022-04-10 17:35:33 -05:00
parent d08b240ff9
commit 474abcdb0d
4 changed files with 15 additions and 8 deletions

View File

@ -1,9 +1,11 @@
package io.github.simplex.luck;
import io.github.simplex.luck.listener.PlayerListener;
import io.github.simplex.luck.player.Luck;
import io.github.simplex.luck.player.PlayerConfig;
import io.github.simplex.luck.player.PlayerHandler;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
@ -11,14 +13,18 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
public final class FeelingLucky extends JavaPlugin {
private static final Map<UUID, PlayerConfig> configMap = new HashMap<>();
private final Map<UUID, PlayerConfig> configMap = new HashMap<>();
private final Map<OfflinePlayer, Luck> offlinePlayerLuckMap = new HashMap<>();
public LuckCMD cmd;
public PlayerHandler handler;
public PlayerListener playerListener;
public static Map<UUID, PlayerConfig> getConfigMap() {
public static FeelingLucky plugin = getPlugin(FeelingLucky.class);
public Map<UUID, PlayerConfig> getConfigMap() {
return configMap;
}

View File

@ -40,7 +40,7 @@ public class LuckCMD extends Command implements TabCompleter {
}
Luck luck = plugin.handler.getLuckContainer(player);
PlayerConfig config = FeelingLucky.getConfigMap().get(player.getUniqueId());
PlayerConfig config = plugin.getConfigMap().get(player.getUniqueId());
switch (args[0]) {
case "set" -> {
@ -95,7 +95,7 @@ public class LuckCMD extends Command implements TabCompleter {
}
Luck luck = plugin.handler.getLuckContainer(player);
PlayerConfig config = FeelingLucky.getConfigMap().get(player.getUniqueId());
PlayerConfig config = plugin.getConfigMap().get(player.getUniqueId());
luck.reset();
plugin.handler.updatePlayer(player, luck);
config.setLuck(luck.getValue());

View File

@ -1,7 +1,6 @@
package io.github.simplex.luck.player;
import io.github.simplex.api.LuckContainer;
import io.github.simplex.luck.FeelingLucky;
import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
@ -12,6 +11,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.SplittableRandom;
import static io.github.simplex.luck.FeelingLucky.plugin;
@SuppressWarnings("all")
public class Luck implements LuckContainer {
private final Player player;
@ -125,7 +126,7 @@ public class Luck implements LuckContainer {
public void setValue(double value) {
player.getAttribute(Attribute.GENERIC_LUCK).setBaseValue(value);
FeelingLucky.getConfigMap().get(associatedPlayer().getUniqueId()).setLuck(value);
plugin.getConfigMap().get(associatedPlayer().getUniqueId()).setLuck(value);
Bukkit.getPluginManager().callEvent(event);
}

View File

@ -30,11 +30,11 @@ public class PlayerHandler implements Listener {
@EventHandler
public void initializePlayer(PlayerLoginEvent event) {
Player player = event.getPlayer();
PlayerConfig playerConfig = FeelingLucky.getConfigMap().get(player.getUniqueId());
PlayerConfig playerConfig = plugin.getConfigMap().get(player.getUniqueId());
if (playerConfig == null) {
playerConfig = new PlayerConfig(plugin, player);
FeelingLucky.getConfigMap().put(player.getUniqueId(), playerConfig);
plugin.getConfigMap().put(player.getUniqueId(), playerConfig);
}
String username = playerConfig.getConfig().getString("username");