use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.
the class RegionEvents method itemPickupEvent.
@EventHandler(ignoreCancelled = true)
private void itemPickupEvent(PlayerPickupItemEvent event) {
final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame()) {
final Trigger trig = Triggers.getTrigger("ITEM_PICKUP");
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (!ply.isInMinigame()) {
return;
}
for (Node node : getRegionModule(ply.getMinigame()).getNodes()) {
node.execute(trig, ply);
}
for (Region region : getRegionModule(ply.getMinigame()).getRegions()) {
if (region.hasPlayer(ply)) {
region.execute(trig, ply);
}
}
}
});
}
}
use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.
the class RegionEvents method playerJoin.
@EventHandler(ignoreCancelled = true)
private void playerJoin(JoinMinigameEvent event) {
final MinigamePlayer ply = event.getMinigamePlayer();
if (ply == null)
return;
final Minigame mg = event.getMinigame();
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
executeRegionChanges(mg, ply);
for (Node node : RegionModule.getMinigameModule(mg).getNodes()) {
node.execute(Triggers.getTrigger("GAME_JOIN"), ply);
}
for (Region region : RegionModule.getMinigameModule(mg).getRegions()) {
if (region.hasPlayer(ply))
region.execute(Triggers.getTrigger("GAME_JOIN"), ply);
}
}
});
if (event.getMinigame().getPlayers().size() == 0) {
for (Region region : RegionModule.getMinigameModule(event.getMinigame()).getRegions()) {
for (RegionExecutor ex : region.getExecutors()) {
if (ex.getTrigger().getName().equalsIgnoreCase("TICK")) {
region.startTickTask();
break;
}
}
}
}
}
use of org.bukkit.event.EventHandler in project Denizen-For-Bukkit by DenizenScript.
the class NPCTags method navBegin.
// <--[event]
// @Events
// npc begins navigation
//
// @Warning This event may fire very rapidly.
//
// @Triggers when an NPC begins navigating.
//
// @Context
// None
//
// -->
// <--[action]
// @Actions
// begin navigation
//
// @Triggers when the NPC has received a 'walk' command,
// or is about to follow a path.
//
// @Context
// None
//
// -->
@EventHandler
public void navBegin(NavigationBeginEvent event) {
dNPC npc = DenizenAPI.getDenizenNPC(event.getNPC());
// Do world script event 'On NPC Completes Navigation'
if (NPCNavigationSmartEvent.IsActive()) {
OldEventManager.doEvents(Arrays.asList("npc begins navigation"), new BukkitScriptEntryData(null, npc), null);
}
if (!event.getNPC().hasTrait(AssignmentTrait.class)) {
return;
}
npc.action("begin navigation", null);
if (event.getNPC().getNavigator().getTargetType() == TargetType.ENTITY) {
LivingEntity entity = (LivingEntity) event.getNPC().getNavigator().getEntityTarget().getTarget();
// and that entity is not dead, trigger "on attack" command
if (event.getNPC().getNavigator().getEntityTarget().isAggressive() && !entity.isDead()) {
dPlayer player = null;
// Check if the entity attacked by this NPC is a player
if (entity instanceof Player) {
player = dPlayer.mirrorBukkitPlayer((Player) entity);
}
// <--[action]
// @Actions
// attack
// attack on <entity>
//
// @Triggers when the NPC is about to attack an enemy.
//
// @Context
// None
//
// -->
npc.action("attack", player);
npc.action("attack on " + entity.getType().toString(), player);
}
previousLocations.put(event.getNPC().getId(), npc.getLocation());
}
}
use of org.bukkit.event.EventHandler in project Denizen-For-Bukkit by DenizenScript.
the class NPCTags method navComplete.
// <--[event]
// @Events
// npc completes navigation
//
// @Warning This event may fire very rapidly.
//
// @Triggers when an NPC finishes navigating.
//
// @Context
// None
//
// -->
// <--[action]
// @Actions
// complete navigation
//
// @Triggers when the NPC has finished a 'walk' command,
// or has reached a path point.
//
// @Context
// None
//
// -->
@EventHandler
public void navComplete(NavigationCompleteEvent event) {
dNPC npc = DenizenAPI.getDenizenNPC(event.getNPC());
// Do world script event 'On NPC Completes Navigation'
if (NPCNavigationSmartEvent.IsActive()) {
OldEventManager.doEvents(Arrays.asList("npc completes navigation"), new BukkitScriptEntryData(null, npc), null);
}
// Do the assignment script action
if (!event.getNPC().hasTrait(AssignmentTrait.class)) {
return;
}
npc.action("complete navigation", null);
}
use of org.bukkit.event.EventHandler in project Denizen-For-Bukkit by DenizenScript.
the class BlockBurnsScriptEvent method onBlockBurns.
@EventHandler
public void onBlockBurns(BlockBurnEvent event) {
location = new dLocation(event.getBlock().getLocation());
material = dMaterial.getMaterialFrom(event.getBlock().getType(), event.getBlock().getData());
cancelled = event.isCancelled();
this.event = event;
fire();
event.setCancelled(cancelled);
}
Aggregations