![Function API](https://media.forgecdn.net/avatars/thumbnails/225/971/256/256/637042619739144499.png)
Create a more geneic ˋeventˋ class
Frontrider opened this issue · 7 comments
Is your feature request related to a problem? Please describe.
As the engine supports event handlers other than commands (java included, javascript WIP) we should use something more generic than the ˋCommandSourceˋ.
Describe the solution you'd like
A new ˋEventˋ class that can better accomodate new script engines.
Requested fields:
- position(vector3)
- block (optional)
- sourceEntity(optional)
- Target for sending feedback
- members: an array containin additional entities that are involved, for example the other animal during breeding, or the true source of damage.
Additionally:
It should also have an ˋexecuteˋ style command to switch into these members. The command context should not change, unless an ˋasˋ subcommand was called.
Describe alternatives you've considered
The current solution is to use the built-in ˋServerCommandSourceˋ class, as this is what commands use.
We'd definitely need some way to either convert to a ServerCommandSource or wrap a ServerCommandSource in our EventSource.
I'd probably mix into the ServerCommandSource
to contain the required fields, the convert our Event
to it. I'd like to remove minecraft classes from the core of the system.
This is the current way of creating command sources:
https://github.com/CottonMC/FunctionAPI/blob/master/src/main/java/io/github/cottonmc/functionapi/ServerCommandSourceFactory.java
Cotton Scripting has its own command-source-creating methods.
I wanted to avoid parsing strings in the middle of my code. And I already have all the members at hand. No need to search for them again.
Would be great if it got integrated into this class:
https://github.com/CottonMC/FunctionAPI/blob/master/src/main/java/io/github/cottonmc/functionapi/events/runners/script/api/ScriptApiObject.java