Skript icon indicating copy to clipboard operation
Skript copied to clipboard

Change EventValues class to be using Converter instead of Getter

Open TheLimeGlass opened this issue 3 years ago • 0 comments

Suggestion

Getter doesn't allow for Java lambdas, and most Skript classes use Converter directly.

This will allow for

EventValues.registerEventValue(PlayerEggThrowEvent.class, Egg.class, event -> event.getEgg(), EventValues.TIME_NOW);

Tested this and it works fine with Getter support for older implementations and Getter extends Converter.

Note that the generics are swapped between the Getter and Converter classes, still no issue as Getter handles this for the Converter implementation.

While whoever is inside the EventValues class, ensure that EVERY CALLING OF EventValueInfo fields are using the getter instead of the raw field direct access. Skript has getters in this class, but never actually uses them... Skript needs to stop doing this for security handling.

Why?

Simplifies the code, easier to read, faster to code, added support for those that want to use Java 8 lambdas.

TheLimeGlass avatar Aug 04 '22 05:08 TheLimeGlass