Skip to content
goflishMC edited this page Jul 1, 2025 · 1 revision

πŸ“£ Events – Hook into Genesis Behavior

Genesis provides several custom Bukkit events you can listen to for integrating your plugin with shop behavior.

These events fire at key moments like opening shops, selecting items, and completing purchases.


🧩 How to Listen to Genesis Events

Genesis events are standard Bukkit events. Just register a listener as you would for any other plugin:

@EventHandler
public void onShopOpen(GenesisShopOpenEvent event) {
    Player player = event.getPlayer();
    player.sendMessage("You opened: " + event.getShop().getShopName());
}

Make sure to register your listener class in onEnable():

getServer().getPluginManager().registerEvents(new YourListenerClass(), this);

πŸ—‚οΈ Available Events

πŸͺ GenesisShopOpenEvent

Fired when a player opens a shop GUI.

public class GenesisShopOpenEvent extends PlayerEvent {
    public Shop getShop();
    public boolean isCancelled();
    public void setCancelled(boolean);
}

Example:

@EventHandler
public void onShopOpen(GenesisShopOpenEvent event) {
    if (!event.getPlayer().hasPermission("myplugin.shop.open")) {
        event.setCancelled(true);
    }
}

πŸ›’ GenesisItemSelectEvent

Fired when a player clicks a shop item (before any conditions or costs are checked).

public class GenesisItemSelectEvent extends PlayerEvent {
    public ShopItem getShopItem();
    public Shop getShop();
    public boolean isCancelled();
    public void setCancelled(boolean);
}

Use this to block interactions with specific items or apply custom behavior.


βœ… GenesisItemPurchaseEvent

Fired after the item is successfully purchased (i.e., conditions met, prices paid, rewards given).

public class GenesisItemPurchaseEvent extends PlayerEvent {
    public ShopItem getShopItem();
    public Shop getShop();
}

You can’t cancel this event β€” it has already happened β€” but you can use it for logging or triggering external logic (e.g., statistics, external database tracking).


🧠 Notes

  • All events extend PlayerEvent, so event.getPlayer() is always available.
  • Genesis does not currently fire an event for item hover or menu close.
  • Custom RewardTypes and PriceTypes must implement their own logic; these events will not fire for internal shop mechanics like animated slots.

πŸ”Œ Advanced Use

Want to modify an item dynamically right before it's displayed?
You can override or manipulate its MenuItem on GenesisItemSelectEvent:

@EventHandler
public void onSelect(GenesisItemSelectEvent event) {
    ShopItem item = event.getShopItem();
    if (item.getShopItemName().equalsIgnoreCase("DailyReward")) {
        item.getMenuItemBuilder().setName("&eLimited Time!");
    }
}

πŸ“ž Need Custom Events?

If you want to request additional events (e.g. shop close, price evaluation), contact the plugin maintainer.


Last updated: June 2025

Clone this wiki locally