.dev

Developers2 min read

Events

Ready, consent, staff, keybind, UI and client events on every platform.

Every platform delivers the same moments. On Bukkit you also get dedicated events for keybinds, UI, the inspector and staff actions; elsewhere those arrive through TehoListener.

What fires when

MomentTehoListenerBukkit event
The handshake finished and sends will workonReadyTehoPlayerReadyEvent
The player leftonLeave
The player accepted or declined staff tools or a data requestonConsentTehoConsentEvent
A staff tool was switched on or offonStaffToolTehoStaffToolEvent
A generic client event, such as a hologram clickonEventTehoClientEvent
A server keybind was pressed or releasedonKeyTehoKeyEvent
A server screen was clicked, changed, submitted or closedonUiTehoUiEvent
A moderator looked at something with the inspectoronInspectTehoInspectEvent
A moderator picked an action on the wheel or a cardonStaffActionTehoStaffActionEvent (cancellable)
A hologram marked clickable was clickedonHologramClickTehoClientEvent with kind hologram.click
A cutscene finished or was skippedonCutsceneEnded
A resource pack prefetch finishedonPackStatus
Your private grant was checkedonPrivileges

Platform event classes

Java
@EventHandler
public void onReady(TehoPlayerReadyEvent event) {
    Player player = event.getPlayer();
    TehoPlayer teho = event.getTehoPlayer();
}

@EventHandler
public void onTool(TehoStaffToolEvent event) {
    if (event.getTool() == StaffTool.FREECAM && event.isActive()) {
        vanish(event.getPlayer());
    }
}

TehoConsentEvent tells you how a player answered a prompt. getScope() says what was asked, getItems() lists what the answer covers, such as tool ids or info fields, and isGranted() says whether they agreed.

Java
@EventHandler
public void onConsent(TehoConsentEvent event) {
    if (!event.isGranted()) {
        getLogger().info(event.getPlayer().getName() + " declined " + event.getScope() + " " + event.getItems());
    }
}

Cancelling staff actions

TehoStaffActionEvent fires on Bukkit before any action from the wheel or an inspector card runs, whether it is built in or a configured command. Cancel it to stop that behaviour and handle the action yourself.

Java
@EventHandler
public void onAction(TehoStaffActionEvent event) {
    if (event.getAction().equals("freeze") && event.getTarget().kind() == Target.Kind.PLAYER) {
        Player suspect = Bukkit.getPlayer(event.getTarget().id());
        if (suspect != null && suspect.hasPermission("skyline.freeze.exempt")) {
            event.setCancelled(true);
            event.getPlayer().sendMessage("That player cannot be frozen.");
        }
    }
}

Through a proxy

When a proxy plugin owns the session, client replies such as consent, staff tool state and client events are relayed to the current backend, so these events fire on both the proxy and the backend. See Networks & proxies.