Event API
Last updated
Last updated
PlayerSkillUseEvent (Cancellable)
GameStartEvent
GameEndEvent
PlayerAchievementEvent
PlayerHitEvent (Cancellable)
DamageBlockEvent
PlayerFlagCaptureEvent (Cancellable)
Event usage example
@EventHandler
public void onFlagCapture(PlayerFlagCaptureEvent event) {
if(event.getPlayer().getMana() <= 50) {
event.setCancelled(true);
event.getPlayer().getP().sendMessage(ChatColor.RED + "You need at least 50 mana to capture the flag!");
}
}
@EventHandler
public void onSkillUse(PlayerSkillUseEvent event) {
GamePlayer player = event.getPlayer();
if(player.getP().isSneaking())
player.setMana(player.getMana()+5);
}
@EventHandler
public void onGameStart(GameStartEvent event) {
event.getGame().sendTitle("The", "start");
}
@EventHandler
public void onGameEnd(GameEndEvent event) {
event.getWinner().getPlayers().forEach(player -> player.sendMessage("You won!"));
}
@EventHandler
public void onAchievement(PlayerAchievementEvent event) {
if(event.getType() == AchievementType.WINS) {
event.getPlayer().sendMessage("Wins!");
}
}
@EventHandler
public void onPlayerDamage(PlayerHitEvent event) {
GamePlayer damager = event.getDamager();
GamePlayer target = event.getPlayer();
if(target.getName().equalsIgnoreCase("Floodeer")) {
event.setCancelled(true);
}else{
if(!target.getP().isSneaking())
event.setDamage(event.getDamage() + 2);
damager.getP().sendMessage("Hit " + target.getName() + " with " + event.getDamage() + " of damage.");
}
}
@EventHandler
public void onDamageBlock(DamageBlockEvent event) {
GamePlayer damager = event.getDamager();
GamePlayer blocker = event.getPlayer();
if(blocker.getP().isSneaking()) {
event.setDamage(event.getDamage()/2);
}
blocker.getP().sendMessage("Blocked " + event.getDamage() + " from " + damager.getName());
}