Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom effect can't modify converted expressions via raw expression #122

Open
Maple-YZ opened this issue Sep 3, 2024 · 2 comments
Open

Comments

@Maple-YZ
Copy link

Maple-YZ commented Sep 3, 2024

Describe the bug
when change value of a ConvertedExpression instance on custom effect, the trigger stops and generates an error like this:

[18:12:26 ERROR]: #!#! 
[18:12:26 ERROR]: #!#! [Skript] Severe Error:
[18:12:26 ERROR]: #!#! 
[18:12:26 ERROR]: #!#! Something went horribly wrong with Skript.
[18:12:26 ERROR]: #!#! This issue is NOT your fault! You probably can't fix it yourself, either.
[18:12:26 ERROR]: #!#! It looks like you are using some plugin(s) that alter how Skript works (addons).
[18:12:26 ERROR]: #!#! Here is full list of them:
[18:12:26 ERROR]: #!#! skript-placeholders v1.7.0 (https://github.com/APickledWalrus/skript-placeholders) skript-reflect v2.5.1 (https://github.com/SkriptLang/skript-reflect) skript-gui v1.3 (https://github.com/APickledWalrus/skript-gui) SKeb v0.1.2 SkJson v4.0.1 SkBee v3.6.1 (https://github.com/ShaneBeee/SkBee) skUtilities v0.9.2 (https://tim740.github.io/) 
[18:12:26 ERROR]: #!#! We could not identify which of those are specially related, so this might also be Skript issue.
[18:12:26 ERROR]: #!#! You should try disabling those plugins one by one, trying to find which one causes it.
[18:12:26 ERROR]: #!#! If the error doesn't disappear even after disabling all listed plugins, it is probably Skript issue.
[18:12:26 ERROR]: #!#! In that case, you will be given instruction on how should you report it.
[18:12:26 ERROR]: #!#! On the other hand, if the error disappears when disabling some plugin, report it to author of that plugin.
[18:12:26 ERROR]: #!#! Only if the author tells you to do so, report it to Skript's issue tracker.
[18:12:26 ERROR]: #!#! 
[18:12:26 ERROR]: #!#! Stack trace:
[18:12:26 ERROR]: #!#! java.lang.UnsupportedOperationException
[18:12:26 ERROR]: #!#!     at Skript-2.9.2.jar//ch.njol.skript.lang.util.SimpleExpression.change(SimpleExpression.java:259)
[18:12:26 ERROR]: #!#!     at Skript-2.9.2.jar//ch.njol.skript.lang.util.ConvertedExpression.change(ConvertedExpression.java:181)
[18:12:26 ERROR]: #!#!     at skript-reflect-2.5.1.jar//com.btk5h.skriptmirror.skript.custom.ExprRawExpression.change(ExprRawExpression.java:60)
[18:12:26 ERROR]: #!#!     at Skript-2.9.2.jar//ch.njol.skript.effects.EffChange.execute(EffChange.java:292)
[18:12:26 ERROR]: #!#!     at Skript-2.9.2.jar//ch.njol.skript.lang.Effect.run(Effect.java:49)
[18:12:26 ERROR]: #!#!     at Skript-2.9.2.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:61)
[18:12:26 ERROR]: #!#!     at Skript-2.9.2.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:88)
[18:12:26 ERROR]: #!#!     at Skript-2.9.2.jar//ch.njol.skript.lang.Trigger.execute(Trigger.java:52)
[18:12:26 ERROR]: #!#!     at skript-reflect-2.5.1.jar//org.skriptlang.reflect.syntax.effect.elements.CustomEffect.invokeEffect(CustomEffect.java:62)
[18:12:26 ERROR]: #!#!     at skript-reflect-2.5.1.jar//org.skriptlang.reflect.syntax.effect.elements.CustomEffect.walk(CustomEffect.java:37)
[18:12:26 ERROR]: #!#!     at Skript-2.9.2.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:88)
[18:12:26 ERROR]: #!#!     at Skript-2.9.2.jar//ch.njol.skript.lang.Trigger.execute(Trigger.java:52)
[18:12:26 ERROR]: #!#!     at Skript-2.9.2.jar//ch.njol.skript.command.ScriptCommand.execute2(ScriptCommand.java:345)
[18:12:26 ERROR]: #!#!     at Skript-2.9.2.jar//ch.njol.skript.command.ScriptCommand.lambda$execute$0(ScriptCommand.java:304)
[18:12:26 ERROR]: #!#!     at Skript-2.9.2.jar//ch.njol.skript.command.ScriptCommand.execute(ScriptCommand.java:315)
[18:12:26 ERROR]: #!#!     at Skript-2.9.2.jar//ch.njol.skript.command.ScriptCommand.onCommand(ScriptCommand.java:250)
[18:12:26 ERROR]: #!#!     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[18:12:26 ERROR]: #!#!     at io.papermc.paper.command.brigadier.bukkit.BukkitCommandNode$BukkitBrigCommand.run(BukkitCommandNode.java:91)
[18:12:26 ERROR]: #!#!     at com.mojang.brigadier.context.ContextChain.runExecutable(ContextChain.java:73)
[18:12:26 ERROR]: #!#!     at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:30)
[18:12:26 ERROR]: #!#!     at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:13)
[18:12:26 ERROR]: #!#!     at net.minecraft.commands.execution.UnboundEntryAction.lambda$bind$0(UnboundEntryAction.java:8)
[18:12:26 ERROR]: #!#!     at net.minecraft.commands.execution.CommandQueueEntry.execute(CommandQueueEntry.java:5)
[18:12:26 ERROR]: #!#!     at net.minecraft.commands.execution.ExecutionContext.runCommandQueue(ExecutionContext.java:103)
[18:12:26 ERROR]: #!#!     at net.minecraft.commands.Commands.executeCommandInContext(Commands.java:451)
[18:12:26 ERROR]: #!#!     at net.minecraft.commands.Commands.performCommand(Commands.java:358)
[18:12:26 ERROR]: #!#!     at net.minecraft.commands.Commands.performCommand(Commands.java:345)
[18:12:26 ERROR]: #!#!     at net.minecraft.commands.Commands.performCommand(Commands.java:340)
[18:12:26 ERROR]: #!#!     at net.minecraft.server.network.ServerGamePacketListenerImpl.performUnsignedChatCommand(ServerGamePacketListenerImpl.java:2297)
[18:12:26 ERROR]: #!#!     at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$15(ServerGamePacketListenerImpl.java:2271)
[18:12:26 ERROR]: #!#!     at net.minecraft.server.TickTask.run(TickTask.java:18)
[18:12:26 ERROR]: #!#!     at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:151)
[18:12:26 ERROR]: #!#!     at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24)
[18:12:26 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1574)
[18:12:26 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:201)
[18:12:26 ERROR]: #!#!     at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:125)
[18:12:26 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1551)
[18:12:26 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1544)
[18:12:26 ERROR]: #!#!     at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:135)
[18:12:26 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.managedBlock(MinecraftServer.java:1503)
[18:12:26 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1510)
[18:12:26 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1355)
[18:12:26 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:334)
[18:12:26 ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:1583)
[18:12:26 ERROR]: #!#! 
[18:12:26 ERROR]: #!#! Version Information:
[18:12:26 ERROR]: #!#!   Skript: 2.9.2
[18:12:26 ERROR]: #!#!     Flavor: skriptlang-github
[18:12:26 ERROR]: #!#!     Date: 14:35:57.106583600
[18:12:26 ERROR]: #!#!   Bukkit: 1.21.1-R0.1-SNAPSHOT
[18:12:26 ERROR]: #!#!   Minecraft: 1.21.1
[18:12:26 ERROR]: #!#!   Java: 21 (OpenJDK 64-Bit Server VM 21+35-2513)
[18:12:26 ERROR]: #!#!   OS: Linux amd64 5.15.0-119-generic
[18:12:26 ERROR]: #!#! 
[18:12:26 ERROR]: #!#! Server platform: Paper
[18:12:26 ERROR]: #!#! 
[18:12:26 ERROR]: #!#! Current node: null
[18:12:26 ERROR]: #!#! Current item: set raw expression 1 to {_i} (as java.lang.Object)
[18:12:26 ERROR]: #!#! Current trigger: effect bind %itemstack% to %offlineplayer% (simple event) (utils/bind-lib.sk, line -1)
[18:12:26 ERROR]: #!#! 
[18:12:26 ERROR]: #!#! Thread: Server thread
[18:12:26 ERROR]: #!#! 
[18:12:26 ERROR]: #!#! Language: simplifiedchinese
[18:12:26 ERROR]: #!#! Link parse mode: DISABLED
[18:12:26 ERROR]: #!#! 
[18:12:26 ERROR]: #!#! End of Error.
[18:12:26 ERROR]: #!#!

To reproduce
use the script below to reproduce:

effect bind %item% to %offline player%:
    trigger:
        set {_i} to expr-1
        set name of {_i} to name of expr-2
        set the raw expr-1 to {_i}

command /bindtest <offline player>:
    trigger:
        bind tool of player to arg-1

Expected behavior
Modify the ConvertedExpression normally, like in the origin skript effects.

Screenshots
image

QQ_1725344154583

for details of the error message, please see Describe the bug part

Server information

  • skript-reflect: v2.5.1
  • Skript: 2.9.2
  • Bukkit: purpur-1.21.1-2299
  • Minecraft: 1.21.1
  • Java: 21 (OpenJDK 64-Bit Server VM 21+35-2513)
  • OS: Linux amd64 5.15.0-119-generic

Additional context
If we change a variable instead of a converted expression, the custom effect works well:
image

@Fusezion
Copy link

Fusezion commented Sep 3, 2024

not unheard of I'd probably wait for a member of the org to respond as it was responded with in under 10 seconds of making this issue

@Maple-YZ
Copy link
Author

Maple-YZ commented Sep 3, 2024

Temporarily fixed this issue

QQ_1725388449346

By adding a piece of codes:

+import:
+    ch.njol.skript.classes.Changer
+    ch.njol.skript.lang.util.ConvertedExpression


effect bind %item% to %offline player%:
    trigger:
        set {_i} to expr-1
        set string tag "bind" of custom nbt of {_i} to name of expr-2 # from SkBee addon
+        if (the raw expr-1) is an instance of ConvertedExpression:
+            (the raw expr-1).acceptChange(Changer.ChangeMode.SET)
        set the raw expr-1 to {_i}


command /bindtest <offline player>:
    permission: jing.op
    trigger:
        bind tool of player to arg-1

The thing is, a converted expression won't use acceptChange method on custom effect section, which won't initialize the returnTypeInfo field, thus the expression can't be changed by using change method.

I know very little of how the script system works, so I don't know how to fix this in a better way and only made this simple fix.

Needs someone knowing the system well to eventually fix this.

Maple-YZ added a commit to Maple-YZ/skript-reflect that referenced this issue Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@Maple-YZ @Fusezion and others