Hello Forums, this Thing has been baffling me for ages. So I tried to do everything from deleting SaveConfig() to implementing SimpleConfig and it realy doesnt work. First of the details, I am not using addDefault(), I'm editing the config.yml Directly and when using SimpleConfig, It's nuts considering I use alot of complicating methods like this one before implementing SimpleConfig. Code (Java): public ConfigurationSection getConfigSection(String name, ConfigurationSection section){ if(section.isConfigurationSection(name)){ return section.getConfigurationSection(name); }else{ return section.createSection(name); } } (Note: This Method is used if there is a section or not because sometimes when using createSection and reloading the server, the data in the config.yml would be reset to it's default values, you can solve and tell the solution of this if you have the time). Thanks for Helping and please make this quick cause I'm answering my School Modules.
This topic has been discussed here a million times. There are only two ways to save a config with comments: A) Custom saving to the file B) Custom saving to the file EDIT: We have created our own YAML file manager for this case, but it will be useless in the case of YamlConfiguration. https://github.com/TheDevTec/TheAPI...c/theapi/utils/datakeeper/SectionBuilder.java
Well I have tried many things such as Code (Java): if (!getDataFolder().exists()) getDataFolder().mkdir(); File file = new File(getDataFolder(), "config.yml"); if (!file.exists()) { try (InputStream in = getClass().getResourceAsStream("config.yml")) { Files.copy(in, file.toPath()); } catch (IOException e) { e.printStackTrace(); } } saveDefaultConfig(); and Code (Text): saveDefaultConfig(); //The config needs to exist before using the updater File configFile = new File(getDataFolder(), "config.yml"); try { ConfigUpdater.update(plugin, "config.yml", configFile, Arrays.asList(...)); } catch (IOException e) { e.printStackTrace(); } reloadConfig(); and all of them still doesn't work! Is Bukkit ever gonna fix this? I have tried like a million times in one day and everything would STILL NOT WORK! Please Help Me!
If you read the post that @mrfloris sent, you would find that comment support has been added in 1.18. If you need to save comments for older versions, then you will need a custom solution. Why? Because, IIRC, @md_5 stated somewhere that the changes won't be backported to older versions, which IMO is dumb, but hey I don't make the rules.
Yeah but when I try Code (Java): getConfig().setComments("gui_items", Arrays.asList("Yes Test")) It throws a java.lang.NoSuchMethodError. Here is the Stacktrace Code (Text): java.lang.NoSuchMethodError: 'void org.bukkit.configuration.file.FileConfiguration.setComments(java.lang.String, java.util.List)' at mc.fenderas.arrowroyale.ArrowRoyale.onEnable(ArrowRoyale.java:58) ~[arrowroyale-1.0-SNAPSHOT.jar:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:564) ~[paper-1.18.1.jar:git-Paper-101] at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:478) ~[paper-1.18.1.jar:git-Paper-101] at org.bukkit.craftbukkit.v1_18_R1.CraftServer.reload(CraftServer.java:1036) ~[paper-1.18.1.jar:git-Paper-101] at org.bukkit.Bukkit.reload(Bukkit.java:857) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:54) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.craftbukkit.v1_18_R1.CraftServer.dispatchCommand(CraftServer.java:897) ~[paper-1.18.1.jar:git-Paper-101] at org.bukkit.craftbukkit.v1_18_R1.CraftServer.dispatchServerCommand(CraftServer.java:860) ~[paper-1.18.1.jar:git-Paper-101] at net.minecraft.server.dedicated.DedicatedServer.handleConsoleInputs(DedicatedServer.java:507) ~[paper-1.18.1.jar:git-Paper-101] at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:481) ~[paper-1.18.1.jar:git-Paper-101] at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1470) ~[paper-1.18.1.jar:git-Paper-101] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1264) ~[paper-1.18.1.jar:git-Paper-101] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-101] at java.lang.Thread.run(Thread.java:833) ~[?:?]
The thread had 1.18-1.18.1 in the title, but maybe the support was only added in 1.18.1. I’d recommend trying that version since your are getting a NoSuchMethodError.
But I'm in that version. 1.18.1 Code (Text): <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.18.1-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency>
It's a risk, and I don't want to unless that's the only way then I'll do it. I purposely made this plugin for paper and spigot so I don't know what to do
Updated your server software, paper build 101 does not have the comment support merged yet. It was added in build 120.
Oh my gosh thanks DerFrZocker, I just updated to build 170 and it saved it, turns out my server was an old test server in build 101 and the comment update build was 134 (33 builds later). Thanks so much. I guess updating the server was the solution.