Error when accessing .yml file on startup.

Discussion in 'Plugin Development' started by feff890, May 1, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    feff890

    I have an issue where when I start my server I get an error where my custom .yml file can't load- the strange thing is it only occurs on startup and if I type /reload then there are no problems whatsoever.

    Here's the error log:
    Code:
    [18:09:34 ERROR]: Could not call method 'public static org.bukkit.Location org.bukkit.Location.deserialize(java.util.Map)' of class org.bukkit.Location for deserialization
    java.lang.IllegalArgumentException: unknown world
            at org.bukkit.Location.deserialize(Location.java:612) ~[spigot.jar:git-Spigot-e8ded36-acbc348]
            at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
            at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
            at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
            at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
            at org.bukkit.configuration.serialization.ConfigurationSerialization.deserializeViaMethod(ConfigurationSerialization.java:79) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.configuration.serialization.ConfigurationSerialization.deserialize(ConfigurationSerialization.java:119) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.configuration.serialization.ConfigurationSerialization.deserializeObject(ConfigurationSerialization.java:197) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.configuration.file.YamlConstructor$ConstructCustomObject.construct(YamlConstructor.java:35) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:207) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:196) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructSequenceStep2(BaseConstructor.java:373) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructSequence(BaseConstructor.java:357) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlSeq.construct(SafeConstructor.java:498) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:207) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:196) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping2ndStep(BaseConstructor.java:462) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.SafeConstructor.constructMapping2ndStep(SafeConstructor.java:183) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping(BaseConstructor.java:443) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.construct(SafeConstructor.java:519) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.configuration.file.YamlConstructor$ConstructCustomObject.construct(YamlConstructor.java:26) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:207) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:196) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping2ndStep(BaseConstructor.java:462) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.SafeConstructor.constructMapping2ndStep(SafeConstructor.java:183) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping(BaseConstructor.java:443) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.construct(SafeConstructor.java:519) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.configuration.file.YamlConstructor$ConstructCustomObject.construct(YamlConstructor.java:26) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:207) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:196) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:161) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:147) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:524) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.yaml.snakeyaml.Yaml.load(Yaml.java:437) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:53) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:162) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:130) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(YamlConfiguration.java:178) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at com.fred890.survivalgames.SurvivalGames.setupMaps(SurvivalGames.java:173) [SurvivalGames.jar:?]
            at com.fred890.survivalgames.SurvivalGames.setupConfig(SurvivalGames.java:144) [SurvivalGames.jar:?]
            at com.fred890.survivalgames.SurvivalGames.onEnable(SurvivalGames.java:72) [SurvivalGames.jar:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at net.minecraft.server.v1_12_R1.MinecraftServer.t(MinecraftServer.java:422) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at net.minecraft.server.v1_12_R1.MinecraftServer.l(MinecraftServer.java:383) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at net.minecraft.server.v1_12_R1.MinecraftServer.a(MinecraftServer.java:338) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:272) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at java.lang.Thread.run(Thread.java:834) [?:?]
    
    And here's the actual code:

    Code:
    public void setupMaps(Plugin p) {
            if(!p.getDataFolder().exists()) {
                try {
                    p.getDataFolder().createNewFile();
                }
                catch(IOException e) {
                    Bukkit.getServer().getLogger().severe("Couldn't create maps folder.");
                }
            }
    
            mfile = new File(p.getDataFolder(), "maps.yml");
    
            if(!mfile.exists()) {
                try {
                    mfile.createNewFile();
                }
                catch(IOException e) {
                    Bukkit.getServer().getLogger().severe("Could not create maps.yml");
                }
            }
            maps = YamlConfiguration.loadConfiguration(mfile); // <- Here is line 173 for reference.)
        }
     
    Last edited by a moderator: May 1, 2019
  2. Offline

    timtower Administrator Administrator Moderator

    @feff890 Could you post the content of the config?
     
  3. Offline

    feff890

    Code:
    active: true
    name: sg
    sg:
      world: HungerGames
      spawns:
      - ==: org.bukkit.Location
        world: HungerGames
        x: 122.54043055826487
        y: 72.0
        z: 242.45580973938493
        pitch: -0.5700412
        yaw: -89.902176
      - ==: org.bukkit.Location
        world: HungerGames
        x: 140.4357711098236
        y: 72.0
        z: 224.537693805801
        pitch: -0.40309548
        yaw: 0.41734225
      - ==: org.bukkit.Location
        world: HungerGames
        x: 158.46253634255268
        y: 72.0
        z: 242.5673753483988
        pitch: -0.9039347
        yaw: 90.736946
      - ==: org.bukkit.Location
        world: HungerGames
        x: 140.44522855416628
        y: 72.0
        z: 260.41490096703427
        pitch: -1.4882718
        yaw: 180.13828
    region:
      min:
        ==: org.bukkit.Location
        world: HungerGames
        x: -127.0
        y: 114.0
        z: -17.0
        pitch: 0.0
        yaw: 0.0
      max:
        ==: org.bukkit.Location
        world: HungerGames
        x: 411.0
        y: 119.0
        z: 512.0
        pitch: 0.0
        yaw: 0.0
    
     
  4. Offline

    timtower Administrator Administrator Moderator

    @feff890 I think that you need to serialize the locations yourself, don't think that you can get Location lists.
     
  5. Offline

    feff890

    Ill try that and see if it fixes the error, but then why would it work on /reload ?
     
  6. Offline

    timtower Administrator Administrator Moderator

    Did you check the file after the reload?
     
Thread Status:
Not open for further replies.

Share This Page