Hi! I'm having a slight problem with configs at the moment and wondered if anyone can give me any help: Here is my main class: Code: package me.timbragg12.ResortcraftCore; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import clearlag.ClearLag; import clearlag.ClearLagCmd; import scoreboard.JoinQuit; public class Main extends JavaPlugin implements Listener { private static Plugin plugin; public void onEnable() { this.saveDefaultConfig(); repeatClearLag(); plugin = this; PluginManager pm = Bukkit.getPluginManager(); pm.registerEvents(new JoinQuit(), this); getCommand("clearlag").setExecutor(new ClearLagCmd()); } public static Plugin getPlugin() { return plugin; } public void repeatClearLag() { Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { public void run() { ClearLag.removeAllEntities(); Bukkit.broadcastMessage("§7[§cResortcraft§7] §cAll lag has been cleared from the server!"); } }, 6000, 12000); } public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(cmd.getName().equalsIgnoreCase("resortcraft") || cmd.getName().equalsIgnoreCase("rc")) { if(args[0].equalsIgnoreCase("reload")) { saveConfig(); reloadConfig(); sender.sendMessage("§6Successfully reloaded the config.yml!"); return true; } } return false; } } And then one of my other classes (which I'm trying to use a string form the config in.): Code: package scoreboard; import me.timbragg12.ResortcraftCore.Main; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Score; import org.bukkit.scoreboard.Scoreboard; public class PlayerScoreBoard { public static Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); public static Objective ob = board.registerNewObjective("PlayerScoreBoard", "dummy"); public static void updateScoreboard() { for(Player p : Bukkit.getOnlinePlayers()) { if(p.getScoreboard() != null && p.getScoreboard().equals(board)) { ob.setDisplaySlot(DisplaySlot.SIDEBAR); ob.setDisplayName("§6§lResortcraft!"); //Unique Guests //My Money //Online - Interacting with bungee! Score forums = ob.getScore(Bukkit.getOfflinePlayer("§aForums:")); forums.setScore(-5); Score forumslink = ob.getScore(Bukkit.getOfflinePlayer("§bforums.resortcraft.net")); forumslink.setScore(-6); Score twitter = ob.getScore(Bukkit.getOfflinePlayer("§aTwitter:")); twitter.setScore(-3); Score name = ob.getScore(Bukkit.getOfflinePlayer("§b@ResortcraftMC")); name.setScore(-4); Score website = ob.getScore(Bukkit.getOfflinePlayer("§aWebsite:")); website.setScore(-1); Score address = ob.getScore(Bukkit.getOfflinePlayer("§bwww.resortcraft.net")); address.setScore(-2); Score online = ob.getScore(Bukkit.getOfflinePlayer("§aOnline ->")); online.setScore(Bukkit.getOnlinePlayers().length); Score unique = ob.getScore(Bukkit.getOfflinePlayer("§aUnique Guests ->")); unique.setScore(Bukkit.getOfflinePlayers().length + Bukkit.getOfflinePlayers().length + 1000); Score server = ob.getScore(Bukkit.getOfflinePlayer("§aServer:")); server.setScore(100); Score servername = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.AQUA + Main.getPlugin().getConfig().getString("server"))); servername.setScore(99); } else { p.setScoreboard(board); } } } } The problem is for some reason it isn't displaying what I have put in the config file... It's displaying: "hub" which used to be in the config file and then after reloading it, installing it and uninstalling it and deleting the config.yml file to try and fix it (generating a new config.yml file with the defaults but it still makes no difference.), it still displays "hub" and not what I have in the config file. Thanks for any help, Tim
@timbragg12 Nowhere is the config file's data being stored, making me think that it does not think that the file you are editing is the config file. Make the file in the plugin, then come back here.
@timbragg12, I was right. You are misunderstanding how this works. EDIT: The forum finds youtube links now? AWESOME.
So, change SaveDefaultConfig(); to getConfig().options.copyDefaults(true) and saveConfig();? EDIT: Because that didn't work.
@timbragg12, you need to be saving the value within the plugin itself, and not reset it every time. Here is the config section of my plugin. Yes, this is INCREDIBLY complicated vs what you need, but it gives a great example of the behavior. Code: ///////////////////////////////////////////////////////////////////////////////////////////////////// //File structures ///////////////////////////////////////////////////////////////////////////////////////////////////// // controls setup of config file public void setUpConfig() { super.reloadConfig();// makes sure that the current version of the file // is loaded // these 2 values are set to comply with the Curse rules, or i'd have // them always on (sorry) getConfig().addDefault("UpdaterOn", true); getConfig().addDefault("AutomaticallyUpdate", false); getConfig().addDefault("CurrencyPlural", "void"); // other values getConfig().addDefault("PluginPrefix", "CommandsForSale"); getConfig().addDefault("GUIEnabled", true); // adds the MainCommands section of config getConfig().addDefault("MainCommands", new ArrayList<String>()); // if a value with the same name as the default exists, it will not be // touched, otherwise the default will be added getConfig().options().copyDefaults(true); saveConfig(); if (!getConfig().contains("CommandOptions")) { log.severe("[CommandsForSale] It seems that either your configuration has been corrupted or is empty.\n" + "[CommandsForSale] The plugin will not operate without any commands. Make sure you are " + "regularly saving a copy of the configuration in case of corruption."); } ArrayList<String> inLower = new ArrayList<>(); // changes commands to lower case for (String toChange : getConfig().getStringList("MainCommands")) { inLower.add(toChange.toLowerCase()); } getConfig().set("MainCommands", inLower); saveConfig(); // controls and generates the command options section for (String commandName : getConfig().getStringList("MainCommands")) { getConfig().addDefault("CommandOptions." + commandName + ".price", 0); getConfig().addDefault("CommandOptions." + commandName + ".permission", "void"); } // save again getConfig().options().copyDefaults(true); saveConfig(); // controls aliases section for (String cmd : getConfig().getStringList("MainCommands")) { getConfig().addDefault("Aliases." + cmd, new ArrayList<String>()); } // save again getConfig().options().copyDefaults(true); saveConfig(); // generates all commands to prevent searching through the entire config // on each run of a command ArrayList<String> allCmds = new ArrayList<>(); for (String cmd : getConfig().getStringList("MainCommands")) { allCmds.add(cmd); for (String aliase : getConfig().getStringList("Aliases." + cmd)) { allCmds.add(aliase); } } getConfig().set("AllCommands", allCmds); saveConfig(); resources = new Resources(this); } I apologize for the late response, you didn't tag me.