API
How to use
To use and implement the ConditionalEvents API, create a plugin and import ConditionalEvents.jar as an external jar or use maven and set the following on your pom.xml file:
Remember to also set depend
or softdepend
in your plugin.yml file!
Methods
You can access all API static methods using the ConditionalEventsAPI class.
Events
The plugin has one event:
Creating your own Actions
The API allows you to create custom and unique ConditionalEvents actions, that you can add to your events.
First, start by creating a class associated with your new action. This class must extends from the ConditionalEventsAction class. For example, I want to create a CE action to change the weather of a certain world.
Next, create a constructor that calls the super constructor with a certain name. This name corresponds to the name of the action, the one you use in your event (for example, cancel_event
, message
, console_command
, playsound
, and so on). In my case the name of the action will be change_weather.
Now, override the execute
method from the super class, which provides a Player object and a String object.
Player player: The player involved in the event. If there is no player, this variable will be null.
String actionLine: Everything that comes after the name of the action. Example:
You can now create your own logic and do whatever you want with the parameters stored in the actionLine String.
Finally, you must register this new action and make ConditionalEvents know about it. For that, when enabling your plugin, use the ConditionalEventsAPI.registerApiActions() method. The first parameter is the object of your plugin class, and the second parameter is a new object of your action class.
If you are creating multiple action types, you can concatenate more objects.
Last updated