Events

zHomes triggers a few events. You can find a list with all the events on this page.

You can see more detailed documentation about each holder and manager in the JavaDocs.

SendTeleportRequestEvent

Called when a player send a teleport request

AcceptTeleportRequestEvent

Called when a player accept a teleport request

DenyTeleportRequestEvent

Called when a player deny a teleport request

CancelTeleportRequestEvent

Called when a player cancel a teleport request

ExecuteMainCommandEvent

Called when /ztpa (Main command) is executed by a player

Example

Example of a class listening to the AcceptTeleportRequestEvent canceling it the sender of the teleport request is "yLeoft2" and who accept is "yLeoft"

https://github.com/yL3oft/zTPA/blob/master/src/main/java/com/zTPA/api/examples/ExampleEvent.java
package com.zTPA.api.examples;

import com.zTPA.api.event.player.AcceptTeleportRequestEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

public class ExampleEvent implements Listener {

    @EventHandler
    public void onAcceptTeleportRequestEvent(AcceptTeleportRequestEvent event) {
        Player player = event.getPlayer();
        Player target = event.getTarget();
        // Checks if the player and target are specific players
        if(player.getName().equals("yLeoft") && target.getName().equals("yLeoft2")) {
            event.setCancelled(true);
        }
    }

}

Last updated

Was this helpful?