SkriptLang / Skript

Skript is a Spigot plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
https://docs.skriptlang.org
GNU General Public License v3.0
1.06k stars 367 forks source link

Addon development: creating a type with "gui" in its name causes a weird error. #5879

Closed DereWah closed 1 week ago

DereWah commented 1 year ago

Skript/Server Version

Skript 2.6.4
Server version 1.20.1

Bug Description

Hello, I am working on updating my Addon Skript-AnvilGUI.

Whenever I try to rename the type codename to "anvilgui" or "virtualanvilgui", it prints an error in the console, and refers to the type as "virtualanvilguu"

Expected Behavior

It should find the class "virtualanvilgui"

Steps to Reproduce

Add the word "anvilgui" or "gui" to any classinfo in your addon.

Errors or Screenshots

: #!#! 
[15:28:54 ERROR]: #!#! [Skript] Severe Error:
[15:28:54 ERROR]: #!#! Could not load testanvil.sk
[15:28:54 ERROR]: #!#! 
[15:28:54 ERROR]: #!#! Something went horribly wrong with Skript.
[15:28:54 ERROR]: #!#! This issue is NOT your fault! You probably can't fix it yourself, either.
[15:28:54 ERROR]: #!#! It looks like you are using some plugin(s) that alter how Skript works (addons).
[15:28:54 ERROR]: #!#! Here is full list of them:
[15:28:54 ERROR]: #!#! Skript-AnvilGUI v1.2 
[15:28:54 ERROR]: #!#! We could not identify which of those are specially related, so this might also be Skript issue.
[15:28:54 ERROR]: #!#! You should try disabling those plugins one by one, trying to find which one causes it.
[15:28:54 ERROR]: #!#! If the error doesn't disappear even after disabling all listed plugins, it is probably Skript issue.
[15:28:54 ERROR]: #!#! In that case, you will be given instruction on how should you report it.
[15:28:54 ERROR]: #!#! On the other hand, if the error disappears when disabling some plugin, report it to author of that plugin.
[15:28:54 ERROR]: #!#! Only if the author tells you to do so, report it to Skript's issue tracker.
[15:28:54 ERROR]: #!#! 
[15:28:54 ERROR]: #!#! Stack trace:
[15:28:54 ERROR]: #!#! java.lang.RuntimeException: pattern compiling exception, element class: org.derewah.skriptanvilgui.effects.EffOpenAnvilGUI
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:226)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:177)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.lang.Statement.parse(Statement.java:60)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.loadItems(ScriptLoader.java:1114)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.command.Commands.loadCommand(Commands.java:500)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.loadScript(ScriptLoader.java:708)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.lambda$loadScripts$4(ScriptLoader.java:526)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.lambda$makeFuture$2(ScriptLoader.java:418)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.makeFuture(ScriptLoader.java:434)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:525)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:469)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.Skript$1.run(Skript.java:786)
[15:28:54 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftTask.run(CraftTask.java:101)
[15:28:54 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480)
[15:28:54 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1112)
[15:28:54 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318)
[15:28:54 ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:833)
[15:28:54 ERROR]: #!#! Caused by: ch.njol.skript.patterns.MalformedPatternException: caught exception while compiling pattern [pattern: open (anvilgui|anvil gui) %virtualanvilgui% to %player%]
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.patterns.PatternCompiler.compile(PatternCompiler.java:54)
[15:28:54 ERROR]: #!#!     at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.lang.SkriptParser.parse_i(SkriptParser.java:1254)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:224)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:177)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.lang.Statement.parse(Statement.java:60)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.loadItems(ScriptLoader.java:1114)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.command.Commands.loadCommand(Commands.java:500)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.loadScript(ScriptLoader.java:708)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.lambda$loadScripts$4(ScriptLoader.java:526)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.lambda$makeFuture$2(ScriptLoader.java:418)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.makeFuture(ScriptLoader.java:434)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:525)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:469)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.Skript$1.run(Skript.java:786)
[15:28:54 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftTask.run(CraftTask.java:101)
[15:28:54 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480)
[15:28:54 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1112)
[15:28:54 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318)
[15:28:54 ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:833)
[15:28:54 ERROR]: #!#! Caused by: ch.njol.skript.SkriptAPIException: No class info found for virtualanvilguus
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.registrations.Classes.getClassInfo(Classes.java:264)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.patterns.TypePatternElement.fromString(TypePatternElement.java:92)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.patterns.PatternCompiler.compile(PatternCompiler.java:138)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.patterns.PatternCompiler.compile(PatternCompiler.java:49)
[15:28:54 ERROR]: #!#!     at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.lang.SkriptParser.parse_i(SkriptParser.java:1254)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:224)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:177)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.lang.Statement.parse(Statement.java:60)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.loadItems(ScriptLoader.java:1114)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.command.Commands.loadCommand(Commands.java:500)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.loadScript(ScriptLoader.java:708)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.lambda$loadScripts$4(ScriptLoader.java:526)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.lambda$makeFuture$2(ScriptLoader.java:418)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.makeFuture(ScriptLoader.java:434)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:525)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:469)
[15:28:54 ERROR]: #!#!     at Skript-2.6.4.jar//ch.njol.skript.Skript$1.run(Skript.java:786)
[15:28:54 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftTask.run(CraftTask.java:101)
[15:28:54 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480)
[15:28:54 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1112)
[15:28:54 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318)
[15:28:54 ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:833)
[15:28:54 ERROR]: #!#! 
[15:28:54 ERROR]: #!#! Version Information:
[15:28:54 ERROR]: #!#!   Skript: 2.6.4 (latest)
[15:28:54 ERROR]: #!#!     Flavor: skriptlang-github
[15:28:54 ERROR]: #!#!     Date: 17:14:25.041218900
[15:28:54 ERROR]: #!#!   Bukkit: 1.20.1-R0.1-SNAPSHOT
[15:28:54 ERROR]: #!#!   Minecraft: 1.20.1
[15:28:54 ERROR]: #!#!   Java: 17.0.7 (Java HotSpot(TM) 64-Bit Server VM 17.0.7+8-LTS-224)
[15:28:54 ERROR]: #!#!   OS: Windows 11 amd64 10.0
[15:28:54 ERROR]: #!#! 
[15:28:54 ERROR]: #!#! Server platform: Paper
[15:28:54 ERROR]: #!#! 
[15:28:54 ERROR]: #!#! Current node: open anvil gui {_x} to player (testanvil.sk, line 4)
[15:28:54 ERROR]: #!#! Current item: null
[15:28:54 ERROR]: #!#! 
[15:28:54 ERROR]: #!#! Thread: Server thread
[15:28:54 ERROR]: #!#! 
[15:28:54 ERROR]: #!#! Language: english
[15:28:54 ERROR]: #!#! Link parse mode: DISABLED
[15:28:54 ERROR]: #!#! 
[15:28:54 ERROR]: #!#! End of Error.
[15:28:54 ERROR]: #!#! 

Other

No response

Agreement

APickledWalrus commented 1 year ago

Caused by it being interpreted as a plural, see https://github.com/SkriptLang/Skript/blob/7632dd8fb367778bf9f28b59e4f147f091d37302/src/main/java/ch/njol/skript/util/Utils.java#L261

DereWah commented 1 year ago

Ohh, yeah I see. Maybe some filtering for certain words? Or also check that the word "i" is alone and not in the end of another word.

TheLimeGlass commented 1 year ago

You're most likely not using a .lang file that defines the allowed plurals and genders. You need to tell Skript to allow virtualgui¦s @an the an can also be a or omitted entirely if you don't want a support. See the following for an example; https://github.com/SkriptLang/Skript/blob/7632dd8fb367778bf9f28b59e4f147f091d37302/src/main/resources/lang/default.lang#L1952-L2033

You also set the user allowed input using the user method in a classinfo https://docs.skriptlang.org/javadocs/ch/njol/skript/classes/ClassInfo.html#user(java.lang.String...)

AyhamAl-Ali commented 11 months ago

Any updates?

DereWah commented 11 months ago

Any updates?

Nope. I initally opened this issue because in my addon I was trying to call my TypeInfo "AnvilGui". I ended up just calling it "anvil".

The issue came back when I was trying to update compatibility for 1.20.1, as the type info name "anvil" got taken by Skript I think(?) Or anyways was no longer available.

In the end I just called it "virtualanvil".

Adding a lang file didn't solve btw

ShaneBeee commented 6 months ago

I came across a similar issue when trying to pluralize "objective" -> "objectives" in my addon, getting a similar error: Caused by: ch.njol.skript.SkriptAPIException: No class info found for objectife

I have a lang file all setup correctly, and still a no go.

TheLimeGlass commented 6 months ago

I came across a similar issue when trying to pluralize "objective" -> "objectives" in my addon, getting a similar error: Caused by: ch.njol.skript.SkriptAPIException: No class info found for objectife

I have a lang file all setup correctly, and still a no go.

Error says objectife with an F. Did you mistype objective? Send code.

APickledWalrus commented 6 months ago

Skript uses this method to get ClassInfo singular classinfo names when parsing type pattern elements. Frankly, this method is flawed and we should find ways to improve it OR just consider types in patterns plural when s is used at the end (may have its own implications!) https://github.com/SkriptLang/Skript/blob/0bfec0b709cf74bace063d315d0eb501058cac14/src/main/java/ch/njol/skript/util/Utils.java#L283