Events
zHomes triggers a few events. You can find a list with all the events on this page.
PreExecuteSethomeCommandEvent
Called when /sethome command is executed by a player
PreExecuteDelhomeCommandEvent
Called when /delhome command is executed by a player\
PreExecuteHomeCommandEvent
Called when /home command is executed by a player
ExecuteSethomeCommandEvent
Called when /sethome (Home) command is executed by a player
ExecuteDelhomeCommandEvent
Called when /delhome (Home) command is executed by a player
ExecuteHomesCommandEvent
Called when /homes command is executed by a player
ExecuteMainCommandEvent
Called when /zhomes command is executed by a playe
TeleportToHomeEvent
Called when a player is teleported to a home
Example
Example of a class listening to the PreExecuteSethomeCommandEvent and ExecuteSethomeCommandEvent and canceling it if the player's name is yLeoft (Or if the home's name is test)
On ExecuteSethomeCommandEvent it also sets the home to test if it's not the test home
package com.zhomes.api.examples;
import com.zhomes.api.event.player.ExecuteSethomeCommandEvent;
import com.zhomes.api.event.player.PreExecuteSethomeCommandEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class ExampleEvent implements Listener {
@EventHandler
public void onPreExecuteSethomeCommandEvent(PreExecuteSethomeCommandEvent event) {
Player player = event.getPlayer();
if(player.getName().equals("yLeoft")) event.setCancelled(true);
}
@EventHandler
public void onExecuteSethomeCommandEvent(ExecuteSethomeCommandEvent event) {
Player player = event.getPlayer();
String home = event.getHome();
if(player.getName().equals("yLeoft")) event.setCancelled(true);
if(home.equals("test")) event.setCancelled(true);
else event.setHome("test");
}
}
Last updated
Was this helpful?