Just need someone to check if I am approaching this correctly please... Code:java package dev.flareline.ipcheck; import java.io.File;import java.util.ArrayList; import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.EventPriority;import org.bukkit.event.Listener;import org.bukkit.event.player.PlayerJoinEvent;import org.bukkit.plugin.java.JavaPlugin; public class IPCMain extends JavaPlugin implements Listener { public static ArrayList<String> OnlinePlayers = new ArrayList<String>(); @Override public void onEnable() { getServer().getPluginManager().registerEvents(new IPCMain(), this); // Start Configuration File ConfigFile = new File("/config.yml"); if (!ConfigFile.exists()) { this.saveDefaultConfig(); getLogger().info("Default Config Saved."); } else { getLogger().info("Config File Exists."); } // End Configuration } @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerJoin(PlayerJoinEvent event, Player player) { this.getConfig().set("playerlogs." + player.getName(), null); String address = (String) this.getConfig().get("playerlogs." + player.getName()); this.saveConfig(); if(!(player.getAddress().equals(address))){ player.kickPlayer("Player has already Logged-in from another address!"); } else { this.getConfig().set("playerlogs." + player.getName(), player.getAddress()); this.saveConfig(); } } @Override public void onDisable() { } }
Code: File ConfigFile = new File("/config.yml"); if (!ConfigFile.exists()) { this.saveDefaultConfig(); getLogger().info("Default Config Saved."); } else { getLogger().info("Config File Exists."); } All this is not needed! The java "saveDefaultConfig()" will check if it exists and if it dosn't it will create it.
FlareLine To use the getConfig() method in your onEnable(), do Code:java this.getConfig().options().copyDefaults(true); Then you can save the config with this.saveConfig(); And you can do this.getConfig() in eclipse, and press " . " to see all the possible ways to access the data.