From 5444f75c211afa3957138743b7cf4db55dd76957 Mon Sep 17 00:00:00 2001 From: Alexander B Date: Tue, 5 Jan 2021 19:20:31 +0100 Subject: [PATCH] Load additional config --- eu/railduction/ruakij/spawnerDrops/Main.java | 46 +++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/eu/railduction/ruakij/spawnerDrops/Main.java b/eu/railduction/ruakij/spawnerDrops/Main.java index 472557f..36abb68 100644 --- a/eu/railduction/ruakij/spawnerDrops/Main.java +++ b/eu/railduction/ruakij/spawnerDrops/Main.java @@ -1,7 +1,51 @@ package eu.railduction.ruakij.spawnerDrops; -public class Main extends JavaPlugin{ +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; +import java.io.File; +public class Main extends JavaPlugin { + public static FileConfiguration config; + public static FileConfiguration data; + + public void onEnable() { + + PluginManager PluginManager = Bukkit.getPluginManager(); + + loadConfigs(); + + getLogger().info("Plugin activated"); + } + + public void onDisable() { + + getLogger().info("Plugin deactivated"); + } + + public void loadConfigs() { + this.saveDefaultConfig(); + config = this.getConfig(); + + try{ + File dataFile = new File("data.yml"); + dataFile.createNewFile(); + data = YamlConfiguration.loadConfiguration( + dataFile + ); + }catch (Exception ex){ + getLogger().severe("Could not load/create data.yml!"); + ex.printStackTrace(); + Bukkit.getPluginManager().disablePlugin(this); + } + } + + public static String serialiseLocation(Location loc){ + return loc.getWorld().getName()+";"+loc.getBlockX()+";"+loc.getBlockY()+";"+loc.getBlockZ(); + } }