I have this language.yml that was working fine. Until I restarted the server. I changed it, in any way possible but still have no solution. Any help? Code (Text): public static FileConfiguration getLanguageConfig() { File folder = new File(Core.getInstance().getDataFolder(), "language.yml"); FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(folder); return fileConfiguration; } The config is there, but it doesn't find it and gives me errors.
I saw you capitalized the first letter in the thread title, is the config name 'Language.yml' or 'language.yml'?
Just try this for me: Code (Text): public static FileConfiguration getLanguageConfig() { File folder = new File("/plugins/YOUR PLUGIN FOLDER/language.yml"); FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(folder); return fileConfiguration; } If that works then there is a problem with getting the data folder. If it doesn't work, then there is another problem.
Getting a new null pointer but don't see the problem: Code (Text): [00:06:29 ERROR]: null org.bukkit.command.CommandException: Unhandled exception executing command 'msmounts' in plugin Mounts v1.0 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.bukkit.craftbukkit.v1_8_R2.CraftServer.dispatchCommand(CraftServer.java:646) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PlayerConnection.handleCommand(PlayerConnection.java:1133) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PlayerConnection.a(PlayerConnection.java:968) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-dbe012b-61ef214] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) [?:1.6.0_65] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [?:1.6.0_65] at java.util.concurrent.FutureTask.run(FutureTask.java:138) [?:1.6.0_65] at net.minecraft.server.v1_8_R2.SystemUtils.a(SourceFile:60) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.MinecraftServer.A(MinecraftServer.java:710) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:368) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:651) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:554) [spigot.jar:git-Spigot-dbe012b-61ef214] at java.lang.Thread.run(Thread.java:695) [?:1.6.0_65] Caused by: java.lang.NullPointerException at me.mounts.core.Inventories.createChestGUI(Inventories.java:97) ~[?:?] at me.mounts.core.Commands.onCommand(Commands.java:30) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-dbe012b-61ef214] ... 16 more >
This null pointer is in Inventories.java on line 97. Post the method createChestGUI() from the Inventories class.
Was about to, but I must have edited out by accident, here it is. Inventory inventory = Bukkit.createInventory(p, 9, Configs.getLanguageConfig().getString("current-mounts-chest-name").replace("&", "§")); I really think it's the config.
Is this string in the path "current-mounts-chest-name" null? Debug using PHP: System.out.println(Configs.getLanguageConfig().getString("current-mounts-chest-name"));
Okay so it's definitely returning null. Here is how I have it set up. First of all the error. Code (Text): [00:44:42 ERROR]: null org.bukkit.command.CommandException: Unhandled exception executing command 'msmounts' in plugin Mounts v1.0 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.bukkit.craftbukkit.v1_8_R2.CraftServer.dispatchCommand(CraftServer.java:646) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PlayerConnection.handleCommand(PlayerConnection.java:1133) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PlayerConnection.a(PlayerConnection.java:968) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-dbe012b-61ef214] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) [?:1.6.0_65] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [?:1.6.0_65] at java.util.concurrent.FutureTask.run(FutureTask.java:138) [?:1.6.0_65] at net.minecraft.server.v1_8_R2.SystemUtils.a(SourceFile:60) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.MinecraftServer.A(MinecraftServer.java:710) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:368) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:651) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:554) [spigot.jar:git-Spigot-dbe012b-61ef214] at java.lang.Thread.run(Thread.java:695) [?:1.6.0_65] Caused by: java.lang.NullPointerException at me.mounts.core.Commands.onCommand(Commands.java:34) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-dbe012b-61ef214] ... 16 more > Then here is how I retrieve it. Code (Text): public static FileConfiguration getLanguageConfig() { File folder = new File("plugin/Mounts/language.yml"); FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(folder); return fileConfiguration; }
Okay, I'm now back to my old error. Code (Text): [12:50:56 ERROR]: Cannot load plugins/Mounts/language.yml org.bukkit.configuration.InvalidConfigurationException: while scanning an anchor in 'string', line 7, column 17: mounts-item: "&e&lMounts" ^ expected alphabetic or numeric character, but found &(38) in 'string', line 7, column 19: mounts-item: "&e&lMounts" ^ at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:57) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:226) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:169) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(YamlConfiguration.java:180) [spigot.jar:git-Spigot-dbe012b-61ef214] at me.mounts.configs.Configs.getLanguageConfig(Configs.java:84) [Mounts.jar:?] at me.mounts.core.Commands.onCommand(Commands.java:34) [Mounts.jar:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) [spigot.jar:git-Spigot-dbe012b-61ef214] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-dbe012b-61ef214] at org.bukkit.craftbukkit.v1_8_R2.CraftServer.dispatchCommand(CraftServer.java:646) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PlayerConnection.handleCommand(PlayerConnection.java:1133) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PlayerConnection.a(PlayerConnection.java:968) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-dbe012b-61ef214] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) [?:1.6.0_65] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [?:1.6.0_65] at java.util.concurrent.FutureTask.run(FutureTask.java:138) [?:1.6.0_65] at net.minecraft.server.v1_8_R2.SystemUtils.a(SourceFile:60) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.MinecraftServer.A(MinecraftServer.java:710) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:368) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:651) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:554) [spigot.jar:git-Spigot-dbe012b-61ef214] at java.lang.Thread.run(Thread.java:695) [?:1.6.0_65] Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning an anchor in 'string', line 7, column 17: mounts-item: "&e&lMounts" ^ expected alphabetic or numeric character, but found &(38) in 'string', line 7, column 19: mounts-item: "&e&lMounts" ^ at org.yaml.snakeyaml.scanner.ScannerImpl.scanAnchor(ScannerImpl.java:1446) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.yaml.snakeyaml.scanner.ScannerImpl.fetchAnchor(ScannerImpl.java:939) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:370) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:226) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:558) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:143) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:226) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:155) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:105) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:120) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:481) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.yaml.snakeyaml.Yaml.load(Yaml.java:400) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:55) ~[spigot.jar:git-Spigot-dbe012b-61ef214] ... 22 more [12:50:56 ERROR]: null org.bukkit.command.CommandException: Unhandled exception executing command 'msmounts' in plugin Mounts v1.0 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at org.bukkit.craftbukkit.v1_8_R2.CraftServer.dispatchCommand(CraftServer.java:646) ~[spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PlayerConnection.handleCommand(PlayerConnection.java:1133) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PlayerConnection.a(PlayerConnection.java:968) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-dbe012b-61ef214] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) [?:1.6.0_65] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [?:1.6.0_65] at java.util.concurrent.FutureTask.run(FutureTask.java:138) [?:1.6.0_65] at net.minecraft.server.v1_8_R2.SystemUtils.a(SourceFile:60) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.MinecraftServer.A(MinecraftServer.java:710) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:368) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:651) [spigot.jar:git-Spigot-dbe012b-61ef214] at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:554) [spigot.jar:git-Spigot-dbe012b-61ef214] at java.lang.Thread.run(Thread.java:695) [?:1.6.0_65] Caused by: java.lang.NullPointerException at me.mounts.core.Commands.onCommand(Commands.java:34) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-dbe012b-61ef214] ... 16 more > For some weird reason it doesn't recognize the "&" even though I replace it all to "§" Config: Code (Text): gui-chest-name: "&e&lMOUNTS" current-mounts-chest-name: "&e&lMOUNTS" rental-mounts-chest-name: "&e&lRENTAL MOUNTS" advertisement-chest-name: "&e&lADVERTISEMENTS & SALES gui: mounts-item: "&e&lMounts" rent-mount-item: "&e&lRent-A-Mount" advertisement: "&4&lAdvertisements and Sales" exit: "&4&lExit" So it obviously finds it, but doesn't change the alternate code. Here is where I tested it: Code (Text): p.sendMessage(Configs.getLanguageConfig().getString("current-mounts-chest-name").replace("&", "§") + "Not there or there");
Did a bit of research and the & character isn't the problem. There is probably multiple spaces somewhere in your file which is messing with the parser. Also, use ChatColor.translateAlternateColorCodes('&', String) instead of String#replace().
I double checked every single line and there is no extra space. Here just incase: Code (Text): gui-chest-name: "&e&lMOUNTS" current-mounts-chest-name: "&e&lMOUNTS" rental-mounts-chest-name: "&e&lRENTAL MOUNTS" advertisement-chest-name: "&e&lADVERTISEMENTS & SALES gui: mounts-item: "&e&lMounts" rent-mount-item: "&e&lRent-A-Mount" advertisement: "&4&lAdvertisements and Sales" exit: "&4&lExit" mounts: chicken: Chicken cow: Cow pig: Pig sheep: Sheep zombie: Zombie creeper: Creeper spider: Spider skeleton: Skeleton enderman: Enderman
It probably did work. Again the plugin worked perfectly until I reloaded the server. Which must have meant, I accidentally changed the the language.yml. Oh well not a problem.