Sashie / skript-yaml

The proper way to do yaml in skript
MIT License
32 stars 22 forks source link

[Bug] Can't remove value from yaml list #35

Closed qsef1256 closed 1 year ago

qsef1256 commented 3 years ago

Description: Can't remove value from yaml list.

Code:

options:
    file: "plugins/Skript/scripts/test.yml"

command /yaml [<text>] [<text>]:
    trigger:
        load yaml {@file} as {@file}
        set {_data} to "a"
        if arg 1 is "add":
            add {_data} to yaml list "user" from {@file}
        if arg 1 is "remove":
            remove {_data} from yaml list "user" from {@file}

Expected Result: The value should be removed from the list.

Console Error:

[00:14:22] [Server thread/ERROR]: #!#!
[00:14:22] [Server thread/ERROR]: #!#! [Skript] Severe Error:
[00:14:22] [Server thread/ERROR]: #!#!
[00:14:22] [Server thread/ERROR]: #!#! Something went horribly wrong with Skript.
[00:14:22] [Server thread/ERROR]: #!#! This issue is NOT your fault! You probably can't fix it yourself, either.
[00:14:22] [Server thread/ERROR]: #!#! It looks like you are using some plugin(s) that alter how Skript works (addons).
[00:14:22] [Server thread/ERROR]: #!#! Here is full list of them:
[00:14:22] [Server thread/ERROR]: #!#! skript-yaml v1.4
[00:14:22] [Server thread/ERROR]: #!#! We could not identify which of those are specially related, so this might also be Skript issue.
[00:14:22] [Server thread/ERROR]: #!#! You should try disabling those plugins one by one, trying to find which one causes it.
[00:14:22] [Server thread/ERROR]: #!#! If the error doesn't disappear even after disabling all listed plugins, it is probably Skript issue.
[00:14:22] [Server thread/ERROR]: #!#! In that case, you will be given instruction on how should you report it.
[00:14:22] [Server thread/ERROR]: #!#! On the other hand, if the error disappears when disabling some plugin, report it to author of that plugin.
[00:14:22] [Server thread/ERROR]: #!#! Only if the author tells you to do so, report it to Skript's issue tracker.
[00:14:22] [Server thread/ERROR]: #!#!
[00:14:22] [Server thread/ERROR]: #!#! Stack trace:
[00:14:22] [Server thread/ERROR]: #!#! java.lang.NullPointerException: Cannot invoke "java.util.List.remove(Object)" because "objects" is null
[00:14:22] [Server thread/ERROR]: #!#!     at me.sashie.skriptyaml.skript.ExprYaml.change(ExprYaml.java:261)
[00:14:22] [Server thread/ERROR]: #!#!     at ch.njol.skript.effects.EffChange.execute(EffChange.java:282)
[00:14:22] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.Effect.run(Effect.java:51)
[00:14:22] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:60)
[00:14:22] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:88)
[00:14:22] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.Trigger.execute(Trigger.java:56)
[00:14:22] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.ScriptCommand.execute2(ScriptCommand.java:289)
[00:14:22] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.ScriptCommand.execute(ScriptCommand.java:250)
[00:14:22] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.Commands.handleCommand(Commands.java:258)
[00:14:22] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.Commands$1.onPlayerCommand(Commands.java:175)
[00:14:22] [Server thread/ERROR]: #!#!     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[00:14:22] [Server thread/ERROR]: #!#!     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
[00:14:22] [Server thread/ERROR]: #!#!     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[00:14:22] [Server thread/ERROR]: #!#!     at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[00:14:22] [Server thread/ERROR]: #!#!     at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306)
[00:14:22] [Server thread/ERROR]: #!#!     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
[00:14:22] [Server thread/ERROR]: #!#!     at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589)
[00:14:22] [Server thread/ERROR]: #!#!     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.server.network.PlayerConnection.handleCommand(PlayerConnection.java:1923)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1770)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1751)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:46)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:1)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:30)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.server.TickTask.run(SourceFile:18)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandler.executeTask(SourceFile:151)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandler.executeNext(SourceFile:125)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.bf(MinecraftServer.java:1148)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.executeNext(MinecraftServer.java:1141)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandler.awaitTasks(SourceFile:134)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.sleepForTick(MinecraftServer.java:1125)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1054)
[00:14:22] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305)
[00:14:22] [Server thread/ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:831)
[00:14:22] [Server thread/ERROR]: #!#!
[00:14:22] [Server thread/ERROR]: #!#! Version Information:
[00:14:22] [Server thread/ERROR]: #!#!   Skript: 2.6-beta3 (latest)
[00:14:22] [Server thread/ERROR]: #!#!     Flavor: skriptlang-github
[00:14:22] [Server thread/ERROR]: #!#!     Date: 14:09:29.995077500
[00:14:22] [Server thread/ERROR]: #!#!   Bukkit: 1.17.1-R0.1-SNAPSHOT
[00:14:22] [Server thread/ERROR]: #!#!   Minecraft: 1.17.1
[00:14:22] [Server thread/ERROR]: #!#!   Java: 16.0.1 (Java HotSpot(TM) 64-Bit Server VM 16.0.1+9-24)
[00:14:22] [Server thread/ERROR]: #!#!   OS: Windows 10 amd64 10.0
[00:14:22] [Server thread/ERROR]: #!#!
[00:14:22] [Server thread/ERROR]: #!#! Server platform: Spigot
[00:14:22] [Server thread/ERROR]: #!#!
[00:14:22] [Server thread/ERROR]: #!#! Current node: null
[00:14:22] [Server thread/ERROR]: #!#! Current item: remove {_data}(as java.lang.Object) from yaml list "user" from "plugins/Skript/scripts/test.yml"
[00:14:22] [Server thread/ERROR]: #!#! Current trigger: command /yaml (simple event) (test.sk, line 5)
[00:14:22] [Server thread/ERROR]: #!#!
[00:14:22] [Server thread/ERROR]: #!#! Thread: Server thread
[00:14:22] [Server thread/ERROR]: #!#!
[00:14:22] [Server thread/ERROR]: #!#! Language: english
[00:14:22] [Server thread/ERROR]: #!#! Link parse mode: DISABLED
[00:14:22] [Server thread/ERROR]: #!#!
[00:14:22] [Server thread/ERROR]: #!#! End of Error.
[00:14:22] [Server thread/ERROR]: #!#!

Version: Server Version: 3243-Spigot-6c1c1b2-d3cc412 (MC: 1.17.1) Skript Version: 2.6-beta3 skript-yaml Version: v1.4

qsef1256 commented 3 years ago

I just noticed that the yaml is not saved. I added save yaml {@file} and it worked fine. It would be nice if there was a separate warning, but for now it's my fault, so I'll close the issue.

Sashie commented 3 years ago

The next release(which i should release soon) will catch this error and several others and give a bit more detail as to what went wrong that way you arent left wondering wtf.. :D

qsef1256 commented 3 years ago

Code:

options:
    file: "plugins/Skript/scripts/test.yml"

command /yaml [<text>] [<text>]:
    trigger:
        load yaml {@file} as {@file}
        arg 2 is set
        set {_data} to arg 2
        if arg 1 is "add":
            add {_data} to yaml list "user" from {@file}
        if arg 1 is "remove":
            remove {_data} from yaml list "user" from {@file}
        save yaml {@file}

Reproduce:

  1. /yaml add 1
  2. /yaml remove 1
  3. 1 not deleted from test.yml file

Version: Server Version: 3243-Spigot-6c1c1b2-d3cc412 (MC: 1.17.1) Skript Version: 2.6-beta3 skript-yaml Version: v1.4

The script I was originally trying to fix still doesn't work. While checking around for why my scripts is not working, I found a problem. When using skript-yaml with command arguments and a yaml list, skript-yaml does not remove the values from the yaml list.

When I put "a" instead of arg 2 in {_data} it worked fine. There were no console errors when running this script, but there were several internal errors when modifying the script to figure out this bug. I'm guessing it's probably the same error as the one above.

But this problem is a bit different from my script problem, and I'm still having problems. I'll post an issue when I figure out what was the problem with my script.

Sashie commented 3 years ago

if you could contact me on discord i have a more updated version id like you to try and we can go from there

Sashie#2683

wallace4BR commented 1 year ago

Skript probably tries to subtract the value and it won't remove the number