Getting Started

Class MyCustom

The MyCustom class is a custom implementation of the Trigger class in the context of a Minecraft plugin. Triggers are events or conditions that trigger specific responses in the game. In this case, MyCustom is designed to respond to a click event on a player's inventory.

public static class MyCustom extends Trigger {

    public MyCustom(Effect effect) {
        super(effect);
    }

    @EventHandler
    public void onClick(InventoryClickEvent event){
        Inventory inventory = event.getClickedInventory();
        if(inventory != null) {
            Player player = (Player) event.getWhoClicked();
            this.dispatch(player, new TriggerData()
                        .event(event));
        }
    }
}

Constructor

public MyCustom(Effect effect)
  • Description: This is the constructor of the MyCustom class. Takes an effect parameter, which is an object of the Effect class. The Effect class contains the logic that will be executed when the trigger meets the conditions and filters of this Effect only if the effect contains these characteristics.

  • Typical Use: An instance of MyCustom is created by providing a specific Effect object that defines the action that will be performed when the trigger is activated.

Dispatch

@Override
public void dispatch(Player player, TriggerData data)
  • Description: This method overrides the dispatch method of the Trigger base class. The Trigger class already has an implementation of how the effects will be executed with this trigger but it can be overridden if you want to implement your own logic.

  • Parameters:

    • player: The player to whom the trigger is applied.

    • data: Data associated with the trigger that could be used in the execution of the effect.

onClick

@EventHandler
public void onClick(InventoryClickEvent event)
  • Description: Here you can create your own logic around the @EventHandler, but you must always pass a player and a TriggerData.

Last updated