SkriptLang / skript-reflect

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

Reflect breakdown on expressions #98

Closed Vulcano771 closed 2 months ago

Vulcano771 commented 3 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

ShaneBeee commented 2 months ago

I ran your exact code, and had no issues.

I even did a cleanup

on load:
    set {_commands::*} to ...AllCommands.getCommandMap().getCommands()
    set {_remain} to size of {_commands::*}
    loop {_commands::*}:
        set {_i} to loop iteration
        if loop-value is an instance of PluginCommand:
            set {_plugin} to loop-value.getPlugin().getName()
            send "&b%{_i}%/%{_remain}%: %loop-value.getLabel()% &7[&a%{_plugin}%&7]"
        else:
            send "&e%{_i}%/%{_remain}%: %loop-value.getLabel()%"

and this was the outcome:

Screenshot 2024-03-11 at 2 36 08 PM

Needless to say, I personally could not replicate the issue you're having.

Bingonymous commented 2 months ago

Maybe its bcs some of the command idk

AyhamAl-Ali commented 2 months ago

Probably due to a command/plugin you have registering something wrong.