removing data from config.yml

Discussion in 'Plugin Development' started by thechrisanator, Nov 14, 2018.

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

    thechrisanator

    How can I remove data from config.yml for a certain player?

    say it looks like this:
    Show Spoiler

    toolinv:
    ab407223-1c1e-42c9-a61a-daa722d8cdcb:
    a:
    type: DIAMOND_PICKAXE
    enchants: []
    durability: 0
    amount: 1
    b:
    type: DIAMOND_SHOVEL
    enchants: []
    durability: 0
    amount: 1


    but I want it to look like this:

    Show Spoiler

    toolinv:
    ab407223-1c1e-42c9-a61a-daa722d8cdcb:
    a:
    type: DIAMOND_PICKAXE
    enchants: []
    durability: 0
    amount: 1
     
  2. Offline

    Zombie_Striker

    @thechrisanator
    config#set("path.to.stuff.to.remove" , null);

    Does not have to be the exact object. If you wanted to delete everything under b, you would just need to set that config section to null.
     
  3. Offline

    thechrisanator

    so..

    getConfig().set("toolinv." + event.getPlayer().getUniqueId() + ".", null);

    that?
    because that just makes this error:

    Show Spoiler

    Code:
    org.bukkit.event.EventException: null
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at net.minecraft.server.v1_12_R1.PlayerList.disconnect(PlayerList.java:405) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1106) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at net.minecraft.server.v1_12_R1.NetworkManager.handleDisconnection(NetworkManager.java:321) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at net.minecraft.server.v1_12_R1.ServerConnection.c(ServerConnection.java:174) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:845) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot.jar:git-Spigot-e8ded36-acbc348]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_191]
    Caused by: java.lang.IllegalArgumentException: Cannot set to an empty path
            at org.apache.commons.lang.Validate.notEmpty(Validate.java:321) ~[spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.configuration.MemorySection.set(MemorySection.java:168) ~[spigot.jar:git-Spigot-e8ded36-acbc348]
            at org.bukkit.configuration.MemorySection.set(MemorySection.java:202) ~[spigot.jar:git-Spigot-e8ded36-acbc348]
            at me.Darkolythe.Multitool.main.onPlayerLeave(main.java:58) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_191]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_191]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_191]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-e8ded36-acbc348]
            ... 12 more
     
  4. Offline

    timtower Administrator Administrator Moderator

Thread Status:
Not open for further replies.

Share This Page