diff --git a/varo/src/main/java/de/cliffbreak/varo/Varo.java b/varo/src/main/java/de/cliffbreak/varo/Varo.java index 72ec19b..b2f498a 100644 --- a/varo/src/main/java/de/cliffbreak/varo/Varo.java +++ b/varo/src/main/java/de/cliffbreak/varo/Varo.java @@ -1,25 +1,48 @@ package de.cliffbreak.varo; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; + import org.bukkit.Difficulty; import org.bukkit.World; import org.bukkit.World.Environment; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.configuration.file.YamlConfiguration; import de.cliffbreak.varo.commands.TestCommand; +import de.cliffbreak.varo.commands.VaroCommand; import de.cliffbreak.varo.listeners.ChatListener; import de.cliffbreak.varo.listeners.EntityRegainHealthListener; +import de.cliffbreak.varo.listeners.PlayerDeathListener; import de.cliffbreak.varo.listeners.PlayerJoinQuitListener; +import de.cliffbreak.varo.listeners.PlayerPreLoginListener; public class Varo extends JavaPlugin { + + public File configurationFile = new File("plugins/CliffbreakVaro", "config.yml"); + public FileConfiguration config = YamlConfiguration.loadConfiguration(this.configurationFile); + @Override public void onEnable() { getLogger().info("CliffbreakVaro is starting..."); - getServer().getPluginManager().registerEvents(new ChatListener(), this); - getServer().getPluginManager().registerEvents(new PlayerJoinQuitListener(), this); - getServer().getPluginManager().registerEvents(new EntityRegainHealthListener(), this); + // this.config.addDefault("Varo.Start", "TODO: StartDate"); + this.config.addDefault("Varo.Bans", new ArrayList()); + this.config.options().copyDefaults(true); + this.saveConfiguration(); + // this.config.getStringList(path) + + getServer().getPluginManager().registerEvents(new PlayerPreLoginListener(this), this); + getServer().getPluginManager().registerEvents(new PlayerJoinQuitListener(this), this); + getServer().getPluginManager().registerEvents(new ChatListener(), this); + getServer().getPluginManager().registerEvents(new EntityRegainHealthListener(), this); + getServer().getPluginManager().registerEvents(new PlayerDeathListener(this), this); + + getCommand("varo").setExecutor(new VaroCommand(this)); getCommand("test").setExecutor(new TestCommand()); for (World world : getServer().getWorlds()) { @@ -34,4 +57,13 @@ public class Varo extends JavaPlugin { public void onDisable() { getLogger().info("Stopping CliffbreakVaro!"); } + + public void saveConfiguration() { + try { + getLogger().info("Saving Config..."); + this.config.save(this.configurationFile); + } catch (IOException e) { + e.printStackTrace(); + } + } }