mirror of
https://github.com/SimplexDevelopment/FeelingLucky.git
synced 2025-07-04 19:16:41 +00:00
more qol
This commit is contained in:
@ -5,16 +5,15 @@ import io.github.simplex.luck.player.PlayerHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public final class FeelingLucky extends JavaPlugin {
|
||||
private static final List<PlayerConfig> configList = new ArrayList<>();
|
||||
private static final Map<UUID, PlayerConfig> configMap = new HashMap<>();
|
||||
public PlayerHandler handler;
|
||||
|
||||
public static List<PlayerConfig> getConfigList() {
|
||||
return configList;
|
||||
public static Map<UUID, PlayerConfig> getConfigMap() {
|
||||
return configMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -24,21 +23,25 @@ public final class FeelingLucky extends JavaPlugin {
|
||||
Bukkit.getLogger().info("Initialization complete! Attempting to register the handler...");
|
||||
this.getServer().getPluginManager().registerEvents(handler, this);
|
||||
Bukkit.getLogger().info("Registration complete! Attempting to load all player configuration files...");
|
||||
if (getDataFolder().listFiles() != null) {
|
||||
Arrays.stream(getDataFolder().listFiles()).forEach(file -> {
|
||||
configList.add(PlayerConfig.loadFrom(file));
|
||||
|
||||
File[] files = getDataFolder().listFiles();
|
||||
if (files != null) {
|
||||
Arrays.stream(files).forEach(file -> {
|
||||
UUID uuid = UUID.fromString(file.getName().split("\\.")[0]);
|
||||
configMap.put(uuid, PlayerConfig.loadFrom(file));
|
||||
});
|
||||
configList.forEach(PlayerConfig::load);
|
||||
configMap.forEach((u, pc) -> pc.load());
|
||||
getLogger().info("Successfully loaded all configurations!");
|
||||
} else {
|
||||
getLogger().info("There are no player configurations to load.");
|
||||
}
|
||||
|
||||
Bukkit.getLogger().info("Successfully initialized!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Bukkit.getLogger().info("Saving all player configurations...");
|
||||
configList.forEach(PlayerConfig::save);
|
||||
configMap.forEach((u, pc) -> pc.save());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user