Hi, when I write "reload" in the search box I can find anything interesting (forum development) So I post ! Someone can help me please ? It does NOT load/save when I : - Drag a new Mecraft.jar in "plugins" folder to replace the old one. - Drag a modified config.yml in "Mecraft" folder to replace the old one. That means the modifications of the new .jar are not here + the modifications of the new config.yml are not saved (can't use it on the server). I have to /stop However here is my log : LOG (Move your mouse to reveal the content) LOG (open) LOG (close) [03:14:46] [Server thread/INFO]: to175 issued server command: /mpl reload [03:14:46] [Server thread/INFO]: [Mecraft] Disabling Mecraft v1 [03:14:46] [Server thread/INFO]: [Mecraft] Enabling Mecraft v1 [03:14:46] [Server thread/INFO]: [Mecraft] Plugin démarré √ Code: public void onEnable() { getServer().getPluginManager().registerEvents(this, this); saveDefaultConfig(); getLogger().info("Plugin démarré √"); } //... public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(cmd.getName().equalsIgnoreCase("mecraft")){ if(sender instanceof Player){ Player player = (Player) sender; if(args.length == 1){ if (args[0].equalsIgnoreCase("reload")&&player.getName().equals("to175")) { saveConfig(); this.reloadConfig(); saveConfig(); getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().enablePlugin(this); player.sendMessage(prefixMecraft + ChatColor.GREEN + "Plugin reloaded :)"); return true; } } }
Sorry, but this is a wrong section. This should be in Plugin Development. Ontopic: Code: FileConfiguration config; File cFile; public void onEnable(){ cFile = new File(getDataFolder(), "config.yml"); config = YamlConfiguration.loadConfiguration(cfile); saveConfig(); } public void reloadConfiguration(){ config = YamlConfiguration.loadConfiguration(cfile); this.reloadConfig(); }
@To175 You can't enable your plugin after you disable it, therefor you can't restart your own plugin, and this is the wrong section.
@Experminator @xXSniperzzXx_SD ?? HomeForums>Bukkit>Plugin Development ?? I am in Plugin development ! Thanks, Why did you remove those lines ? getServer().getPluginManager().registerEvents(this, this); and saveDefaultConfig(); ? What is reloadConfiguration() ? How does it know that I do /reload ?
If I recall, go into the search bar and search something along the lines of Dropbox api world reloading, not sure how this would go with plugins, but I think people managed to get it working with world reloads
@Samthelord1 I don't understand what you say. Thanks @Experminator BUT Please, why ? Why did you remove those lines ? getServer().getPluginManager().registerEvents(this, this); and saveDefaultConfig(); ? What is reloadConfiguration() ? How does it know that I do /reload ? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
@To175 reloadconfiguration() just reloads the plugin config, getServer().reload(); reloads the server.. @To175 https://www.dropbox.com/developers/core EDIT by Moderator: merged posts, please use the edit button instead of double posting.
@Samthelord1 @xXSniperzzXx_SD @Experminator doesn't work : [16:15:34] [Server thread/INFO]: to175 issued server command: /mecraft reload nothing else in log ! Code: FileConfiguration config; File cFile; @Override public void onEnable() { getServer().getPluginManager().registerEvents(this, this); saveDefaultConfig(); cFile = new File(getDataFolder(), "config.yml"); config = YamlConfiguration.loadConfiguration(cFile); saveConfig(); getLogger().info("Plugin démarré √"); } public void reloadConfiguration(){ config = YamlConfiguration.loadConfiguration(cFile); this.reloadConfig(); } //... if (args[0].equalsIgnoreCase("reload")&&player.getName().equals("to175")) { reloadConfiguration(); player.sendMessage(prefixMecraft + ChatColor.GREEN + "Plugin reloaded :)"); return true; }
Just make a method that reinitializes all the parts of your plugin: Code:java public void reload() { //call onDisable //cancel any tasks / don't allow calls to your plugin (locking) //reset fields //call onEnable}
Thanks, I have not "onDisable" I don't know what to put in it I don't know how to do that : /cancel any tasks / don't allow calls to your plugin (locking) //reset fields