Search in sources :

Example 81 with MinigamePlayer

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);
            }
        });
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) Minigame(au.com.mineauz.minigames.minigame.Minigame) EventHandler(org.bukkit.event.EventHandler)

Example 82 with MinigamePlayer

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);
                }
            }
        });
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 83 with MinigamePlayer

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);
}
Also used : Player(org.bukkit.entity.Player) MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) EventHandler(org.bukkit.event.EventHandler)

Example 84 with MinigamePlayer

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);
}
Also used : Player(org.bukkit.entity.Player) MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) EventHandler(org.bukkit.event.EventHandler)

Example 85 with MinigamePlayer

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));
    }
}
Also used : Player(org.bukkit.entity.Player) MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) Trigger(au.com.mineauz.minigamesregions.triggers.Trigger) EventHandler(org.bukkit.event.EventHandler)

Aggregations

MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)134 EventHandler (org.bukkit.event.EventHandler)46 Minigame (au.com.mineauz.minigames.minigame.Minigame)40 ArrayList (java.util.ArrayList)25 Team (au.com.mineauz.minigames.minigame.Team)24 OfflineMinigamePlayer (au.com.mineauz.minigames.objects.OfflineMinigamePlayer)15 Player (org.bukkit.entity.Player)15 Location (org.bukkit.Location)11 ItemStack (org.bukkit.inventory.ItemStack)8 MinigameTool (au.com.mineauz.minigames.tool.MinigameTool)7 Menu (au.com.mineauz.minigames.menu.Menu)5 TeamColor (au.com.mineauz.minigames.minigame.TeamColor)5 List (java.util.List)5 PotionEffect (org.bukkit.potion.PotionEffect)5 ResourcePack (au.com.mineauz.minigames.objects.ResourcePack)4 Material (org.bukkit.Material)4 Sign (org.bukkit.block.Sign)4 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)3 MenuItem (au.com.mineauz.minigames.menu.MenuItem)2 MenuItemBoolean (au.com.mineauz.minigames.menu.MenuItemBoolean)2