QOL CHANGES

This commit is contained in:
Paldiu
2022-03-22 14:57:44 -05:00
parent 831913c668
commit 31bbf6622a
7 changed files with 180 additions and 46 deletions

View File

@ -2,28 +2,43 @@ package io.github.simplex.luck;
import io.github.simplex.luck.player.PlayerConfig;
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;
public final class FeelingLucky extends JavaPlugin {
public PlayerHandler handler;
private static final List<PlayerConfig> configList = new ArrayList<>();
@Override
public void onEnable() {
handler = new PlayerHandler(this);
configList.forEach(PlayerConfig::load);
this.getServer().getPluginManager().registerEvents(handler, this);
}
@Override
public void onDisable() {
configList.forEach(PlayerConfig::save);
}
public PlayerHandler handler;
public static List<PlayerConfig> getConfigList() {
return configList;
}
@Override
public void onEnable() {
Bukkit.getLogger().info("Initializing the PlayerHandler...");
handler = new PlayerHandler(this);
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));
});
configList.forEach(PlayerConfig::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);
}
}