@Override public void onEnable() { this.getLogger().info(TextFormat.DARK_GREEN + "I've been enabled!"); this.getLogger().info(String.valueOf(this.getDataFolder().mkdirs())); // Register the EventListener this.getServer().getPluginManager().registerEvents(new EventListener(this), this); // PluginTask this.getServer().getScheduler().scheduleRepeatingTask(new BroadcastPluginTask(this), 200); // Save resources this.saveResource("string.txt"); // Config reading and writing Config config = new Config( new File(this.getDataFolder(), "config.yml"), Config.YAML, // Default values (not necessary) new LinkedHashMap<String, Object>() { { put("this-is-a-key", "Hello! Config!"); put("another-key", true); // you can also put other standard objects! } }); // Now try to get the value, the default value will be given if the key isn't exist! this.getLogger().info(String.valueOf(config.get("this-is-a-key", "this-is-default-value"))); // Don't forget to save it! config.save(); }
private static void initMessages() { copyLanguage(); Config lng = null; try { File f = new File(plugin.getDataFolder() + File.separator + language + ".lng"); lng = new Config(f, Config.YAML); } catch (Exception e) { LNG_LOAD_FAIL.log(); if (debugMode) e.printStackTrace(); return; } for (Message key : Message.values()) key.initMessage((String) lng.get(key.name().toLowerCase(), key.message)); }