use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class RegionEvents method playerSpawn.
@EventHandler
private void playerSpawn(PlayerRespawnEvent event) {
final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame()) {
final Minigame mg = ply.getMinigame();
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
if (!ply.isInMinigame()) {
return;
}
executeRegionChanges(mg, ply);
for (Node node : RegionModule.getMinigameModule(ply.getMinigame()).getNodes()) {
node.execute(Triggers.getTrigger("RESPAWN"), ply);
}
for (Region region : RegionModule.getMinigameModule(ply.getMinigame()).getRegions()) {
if (region.hasPlayer(ply))
region.execute(Triggers.getTrigger("RESPAWN"), ply);
}
});
}
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class RegionEvents method blockPlace.
@EventHandler(ignoreCancelled = true)
private void blockPlace(BlockPlaceEvent event) {
final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame()) {
final Location loc2 = event.getBlock().getLocation();
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
if (!ply.isInMinigame()) {
return;
}
for (Node node : RegionModule.getMinigameModule(ply.getMinigame()).getNodes()) {
if (node.getLocation().getWorld() == loc2.getWorld()) {
Location loc1 = node.getLocation();
if (loc1.getBlockX() == loc2.getBlockX() && loc1.getBlockY() == loc2.getBlockY() && loc1.getBlockZ() == loc2.getBlockZ()) {
node.execute(Triggers.getTrigger("BLOCK_PLACE"), ply);
}
}
}
for (Region region : RegionModule.getMinigameModule(ply.getMinigame()).getRegions()) {
if (region.locationInRegion(loc2)) {
region.execute(Triggers.getTrigger("BLOCK_PLACE"), ply);
}
}
});
}
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class RegionEvents method playerDamage.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
private void playerDamage(EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player)) {
return;
}
final MinigamePlayer player = pdata.getMinigamePlayer((Player) event.getEntity());
if (player == null || !player.isInMinigame()) {
return;
}
executeTrigger(Triggers.getTrigger("PLAYER_DAMAGE"), player);
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class RegionEvents method playerFoodChange.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
private void playerFoodChange(FoodLevelChangeEvent event) {
if (!(event.getEntity() instanceof Player)) {
return;
}
final MinigamePlayer player = pdata.getMinigamePlayer((Player) event.getEntity());
if (player == null || !player.isInMinigame()) {
return;
}
executeTrigger(Triggers.getTrigger("FOOD_CHANGE"), player);
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class RegionEvents method itemPickupEvent.
@EventHandler(ignoreCancelled = true)
private void itemPickupEvent(EntityPickupItemEvent event) {
if (!(event.getEntity() instanceof Player))
return;
final MinigamePlayer ply = pdata.getMinigamePlayer(((Player) event.getEntity()));
if (ply.isInMinigame()) {
final Trigger trig = Triggers.getTrigger("ITEM_PICKUP");
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, executeScriptObjects(ply, trig));
}
}
Aggregations