Skip to content

Custom Events

PXAV edited this page Jan 28, 2021 · 2 revisions

Table of all Kelp Custom Events

Kelp contains a bunch of custom events by default.

Name Description Cancelable? Type
KelpInventoryCloseEvent Triggered when the KelpInventory of any KelpPlayer is closed. Either by the plugin or a manual exit. no PlayerEvent
KelpInventoryOpenEvent Triggered when a KelpInventory is opened to any KelpPlayer for any reason. no PlayerEvent
KelpInventoryUpdateEvent Triggered when a widget in the KelpInventory of any player is updated. This does not include inventory title updates no PlayerEvent
KelpPlayerLoginEvent This event should be used if you want to work with the KelpPlayer object of a player who has just logged in to the server. It is called on login but after the player has been added to the KelpPlayerRepository. So calls to KelpPlayer are safe using this event, but they are not with Bukkit's normal PlayerLoginEvent no PlayerEvent
KelpPlayerUpdateSettingsEvent This event is called when the player sends client-side settings updates to the server such as renderDistance, language, chatColorEnabled and chatVisibility no PlayerEvent
KelpSidebarRenderEvent Triggered when a sidebar is rendered to a player, which means it is only called once during a sidebar's lifetime as render means it is displayed for the first time. no KelpPlayerEvent
KelpSidebarUpdateEvent Called when any sidebar is updated for a player - no matter if a lazy or normal update has been performed. Title updates are not included. no KelpPlayerEvent
KelpSidebarRemoveEvent Called when a sidebar is removed/hidden from a player and any schedulers related to it are interrupted. no KelpPlayerEvent

Listening to Kelp custom events

Kelp custom events are written in Bukkit's default event library so they can be handled just as normal bukkit events, which is described in this wiki entry.

@EventHandler
public void onPlayerSettingsChange(KelpPlayerUpdateSettingsEvent event) {
  if (!event.hasViewDistanceChanged()) {
    return;
  }
  
  event.getKelpPlayer().sendMessage("...");
}
Clone this wiki locally