SkriptLang / skript-reflect

Powerful reflection utilities for Skript.
MIT License
56 stars 19 forks source link

Having more than one custom syntax with the same pattern causes an exception #86

Open Pikachu920 opened 4 months ago

Pikachu920 commented 4 months ago

Describe the bug Having more than one custom syntax with the same pattern causes an exception upon reloading. This exception only occurs during unload, so you will need to reload the test script to reproduce. The duplicate custom syntax can be in the same script or in other scripts.

[19:17:45 ERROR]: #!#!
[19:17:45 ERROR]: #!#! [Skript] Severe Error:
[19:17:45 ERROR]: #!#! Exception occurred in Skript's main command
[19:17:45 ERROR]: #!#! Used command: /sk reload test
[19:17:45 ERROR]: #!#!
[19:17:45 ERROR]: #!#! Something went horribly wrong with Skript.
[19:17:45 ERROR]: #!#! This issue is NOT your fault! You probably can't fix it yourself, either.
[19:17:45 ERROR]: #!#! It looks like you are using some plugin(s) that alter how Skript works (addons).
[19:17:45 ERROR]: #!#! Here is full list of them:
[19:17:45 ERROR]: #!#! skript-reflect v2.4 (https://github.com/SkriptLang/skript-reflect)
[19:17:45 ERROR]: #!#! We could not identify which of those are specially related, so this might also be Skript issue.
[19:17:45 ERROR]: #!#! You should try disabling those plugins one by one, trying to find which one causes it.
[19:17:45 ERROR]: #!#! If the error doesn't disappear even after disabling all listed plugins, it is probably Skript issue.
[19:17:45 ERROR]: #!#! In that case, you will be given instruction on how should you report it.
[19:17:45 ERROR]: #!#! On the other hand, if the error disappears when disabling some plugin, report it to author of that plugin.
[19:17:45 ERROR]: #!#! Only if the author tells you to do so, report it to Skript's issue tracker.
[19:17:45 ERROR]: #!#!
[19:17:45 ERROR]: #!#! Stack trace:
[19:17:45 ERROR]: #!#! java.lang.NullPointerException: Cannot invoke "java.util.Map.remove(Object)" because "syntaxes" is null
[19:17:45 ERROR]: #!#!     at skript-reflect (5).jar//org.skriptlang.reflect.syntax.CustomSyntaxStructure.lambda$unload$1(CustomSyntaxStructure.java:158)
[19:17:45 ERROR]: #!#!     at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
[19:17:45 ERROR]: #!#!     at skript-reflect (5).jar//org.skriptlang.reflect.syntax.CustomSyntaxStructure.unload(CustomSyntaxStructure.java:153)
[19:17:45 ERROR]: #!#!     at Skript (12).jar//ch.njol.skript.ScriptLoader.unloadScripts(ScriptLoader.java:830)
[19:17:45 ERROR]: #!#!     at Skript (12).jar//ch.njol.skript.ScriptLoader.unloadScript(ScriptLoader.java:864)
[19:17:45 ERROR]: #!#!     at Skript (12).jar//ch.njol.skript.SkriptCommand.onCommand(SkriptCommand.java:189)
[19:17:45 ERROR]: #!#!     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[19:17:45 ERROR]: #!#!     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155)
[19:17:45 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_20_R2.CraftServer.dispatchCommand(CraftServer.java:991)
[19:17:45 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_20_R2.CraftServer.dispatchServerCommand(CraftServer.java:976)
[19:17:45 ERROR]: #!#!     at net.minecraft.server.dedicated.DedicatedServer.bf(DedicatedServer.java:500)
[19:17:45 ERROR]: #!#!     at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:447)
[19:17:45 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1379)
[19:17:45 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1156)
[19:17:45 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315)
[19:17:45 ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:833)
[19:17:45 ERROR]: #!#!
[19:17:45 ERROR]: #!#! Version Information:
[19:17:45 ERROR]: #!#!   Skript: 2.8.0 (latest)
[19:17:45 ERROR]: #!#!     Flavor: skriptlang-github
[19:17:45 ERROR]: #!#!     Date: 18:20:11.223179900
[19:17:45 ERROR]: #!#!   Bukkit: 1.20.2-R0.1-SNAPSHOT
[19:17:45 ERROR]: #!#!   Minecraft: 1.20.2
[19:17:45 ERROR]: #!#!   Java: 17.0.2 (Java HotSpot(TM) 64-Bit Server VM 17.0.2+8-LTS-86)
[19:17:45 ERROR]: #!#!   OS: Windows 10 amd64 10.0
[19:17:45 ERROR]: #!#!
[19:17:45 ERROR]: #!#! Server platform: Paper
[19:17:45 ERROR]: #!#!
[19:17:45 ERROR]: #!#! Current node: null
[19:17:45 ERROR]: #!#! Current item: null
[19:17:45 ERROR]: #!#!
[19:17:45 ERROR]: #!#! Thread: Server thread
[19:17:45 ERROR]: #!#!
[19:17:45 ERROR]: #!#! Language: english
[19:17:45 ERROR]: #!#! Link parse mode: DISABLED
[19:17:45 ERROR]: #!#!
[19:17:45 ERROR]: #!#! End of Error.
[19:17:45 ERROR]: #!#!

To reproduce

  1. Add this script to your server
    
    effect test:
    trigger:
    stop

effect test: trigger: stop


2. Start server (note script loads fine)
3. Reload the script
4. Exception!

**Expected behavior**
A parse time error