Sashie / skript-yaml

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

Can't use yml with only Comments #38

Open qsef1256 opened 3 years ago

qsef1256 commented 3 years ago

Description:

  1. If there is a yaml file with only comments, skript-yaml removes comments.
  2. If there is a space next to the comment mark #, skript-yaml throws the error below.

It's not a duplicate of #29.

Code:

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

command /comment [<text>]:
    trigger:
        load yaml {@file} as {@file}
        set yaml value "data" from {@file} to "test"
        save yaml {@file}

test.yml

# the comment

Console Error:

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

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

It also happens in skript-yaml v1.4.1.

Sashie commented 2 years ago

hmmmm i'll have to work out a better system for comments, perhaps a good chance to add subnode comments as well :D