SkriptLang / skript-reflect

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

Wrong method? #61

Closed UsainSrht closed 1 year ago

UsainSrht commented 1 year ago

Describe the bug #args() method returns single TranslatableComponent instead of List<Component>

To reproduce

import:
    org.bukkit.event.player.PlayerAdvancementDoneEvent

    net.kyori.adventure.text.format.NamedTextColor

    net.kyori.adventure.text.serializer.gson.GsonComponentSerializer

    net.kyori.adventure.text.TranslatableComponent

    java.lang.Class

on PlayerAdvancementDoneEvent:
    set {_message} to event.message()
    set {_args} to {_message}.args()
    send "args %{_args}%" to (ops and console)

Expected behavior #args() method to return List

Screenshots image

Server information

Additional context I've tried with [TranslatableComponent]args() too

TPGamesNL commented 1 year ago

Issue is caused by these methods: image Since the second is a varargs method, {_var}.args() is also a valid call for that method.

Fixed in https://github.com/TPGamesNL/skript-reflect/commit/8f6bb82950906489a5e382efef04f82690ea757e by prioritizing non-varargs methods.

If anyone has this situation (two methods with same signature apart from varargs) and wants to use the varargs one instead, use either argument specification (e.g. {-msg}.args[ComponentLike[]]()) or specify a zero-length array in the method (e.g. {-msg}.args(new ComponentLike[0]))