SkriptLang / skript-reflect

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

Reflect breakdown on expressions #104

Open Vulcano771 opened 7 months ago

Vulcano771 commented 7 months ago
import:
    ch.njol.skript.command.Commands as AllCommands
    org.bukkit.command.PluginCommand

on load:
    set {_commands::*} to ...AllCommands.getCommandMap().getCommands()

    delete {_all::*}

    set {_remain} to size of {_commands::*}
    loop {_commands::*}:
        send "&c1 - %{_remain}%: %loop-value%" to "MyName" parsed as offlineplayer
        set {_name} to loop-value.getLabel()
        send "&c2 - %{_remain}%: %loop-value%" to "MyName" parsed as offlineplayer
        if "%{_name}%" does not contain ":":
            send "&c3 - %{_remain}%: %loop-value%" to "MyName" parsed as offlineplayer
            if loop-value is an instance of PluginCommand:
                send "&c4 - %{_remain}%: %loop-value%" to "MyName" parsed as offlineplayer
                set {_plugin} to loop-value.getPlugin()
                send "&c5 - %{_remain}%: %loop-value% &a%{_plugin}%" to "MyName" parsed as offlineplayer

        #       set {_plugin} to try {_plugin}.getName()

                send "&c6 - %{_remain}%: %loop-value%" to "MyName" parsed as offlineplayer

When removing the comment (-> set {_plugin} to try {_plugin}.getName()) it stops saying 6 - ... removing the try ... doesnt help either

https://github.com/SkriptLang/skript-reflect/issues/98

I now tested that again and got a new "error":

[16:15:21 ERROR]: Could not pass event PlayerCommandSendEvent to Skript v2.8.4
java.lang.NoClassDefFoundError: me/ryanhamshire/GriefPrevention/GriefPrevention
        at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:?]
        at java.lang.Class.privateGetDeclaredMethods(Class.java:3502) ~[?:?]
        at java.lang.Class.privateGetPublicMethods(Class.java:3527) ~[?:?]
        at java.lang.Class.getMethods(Class.java:2112) ~[?:?]
        at com.btk5h.skriptmirror.util.JavaUtil.methods(JavaUtil.java:80) ~[sk-skript-reflect.jar:?]
        at com.btk5h.skriptmirror.skript.reflect.ExprJavaCall.createCallSite(ExprJavaCall.java:406) ~[sk-skript-reflect.jar:?]
        at java.util.HashMap.computeIfAbsent(HashMap.java:1228) ~[?:?]
        at com.btk5h.skriptmirror.skript.reflect.ExprJavaCall.getCallSite(ExprJavaCall.java:366) ~[sk-skript-reflect.jar:?]
        at com.btk5h.skriptmirror.skript.reflect.ExprJavaCall.findCompatibleMethod(ExprJavaCall.java:566) ~[sk-skript-reflect.jar:?]
        at com.btk5h.skriptmirror.skript.reflect.ExprJavaCall.invoke(ExprJavaCall.java:469) ~[sk-skript-reflect.jar:?]
        at com.btk5h.skriptmirror.skript.reflect.ExprJavaCall.getSingle(ExprJavaCall.java:228) ~[sk-skript-reflect.jar:?]
        at com.btk5h.skriptmirror.skript.reflect.ExprJavaCall.getArray(ExprJavaCall.java:233) ~[sk-skript-reflect.jar:?]
        at ch.njol.skript.lang.VariableString.getMessageComponents(VariableString.java:453) ~[sk-Skript.jar:?]
        at ch.njol.skript.effects.EffBroadcast.execute(EffBroadcast.java:92) ~[sk-Skript.jar:?]
        at ch.njol.skript.lang.Effect.run(Effect.java:49) ~[sk-Skript.jar:?]
        at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:61) ~[sk-Skript.jar:?]
        at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:88) ~[sk-Skript.jar:?]
        at ch.njol.skript.lang.Trigger.execute(Trigger.java:52) ~[sk-Skript.jar:?]
        at ch.njol.skript.SkriptEventHandler.lambda$check$3(SkriptEventHandler.java:155) ~[sk-Skript.jar:?]
        at ch.njol.skript.SkriptEventHandler.lambda$check$4(SkriptEventHandler.java:166) ~[sk-Skript.jar:?]
        at ch.njol.skript.util.Task.callSync(Task.java:164) ~[sk-Skript.jar:?]
        at ch.njol.skript.util.Task.callSync(Task.java:148) ~[sk-Skript.jar:?]
        at ch.njol.skript.SkriptEventHandler.check(SkriptEventHandler.java:164) ~[sk-Skript.jar:?]
        at ch.njol.skript.SkriptEventHandler.access$000(SkriptEventHandler.java:53) ~[sk-Skript.jar:?]
        at ch.njol.skript.SkriptEventHandler$PriorityListener.lambda$new$0(SkriptEventHandler.java:66) ~[sk-Skript.jar:?]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:77) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:git-Paper-478]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-1.20.4.jar:git-Paper-478]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[paper-1.20.4.jar:git-Paper-478]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:615) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.commands.Commands.runSync(Commands.java:510) ~[?:?]
        at net.minecraft.commands.Commands.lambda$sendAsync$7(Commands.java:502) ~[?:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.20.4.jar:git-Paper-478]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1465) ~[paper-1.20.4.jar:git-Paper-478]
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:194) ~[paper-1.20.4.jar:git-Paper-478]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1442) ~[paper-1.20.4.jar:git-Paper-478]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1365) ~[paper-1.20.4.jar:git-Paper-478]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1516) ~[paper-1.20.4.jar:git-Paper-478]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1226) ~[paper-1.20.4.jar:git-Paper-478]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[paper-1.20.4.jar:git-Paper-478]
        at java.lang.Thread.run(Thread.java:1623) ~[?:?]
Caused by: java.lang.ClassNotFoundException: me.ryanhamshire.GriefPrevention.GriefPrevention
        at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:197) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:164) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
        ... 45 more
Vulcano771 commented 7 months ago

I dont even use that Plugin image

sovdeeth commented 7 months ago

Replicated, attached jar files of plugins needed to replicate. Seems to be due to the main plugin class of ShopChests having methods returning classes from softdepends, so when reflect tries to loop over all the methods, it can't resolve the missing softdepends and errors out.

code:

command /l:
    trigger:
        set {_cmd} to Bukkit.getCommandMap().getCommand("shop")
        broadcast "%try {_cmd}.getPlugin().getName()%"

plugins.zip