Search in sources :

Example 61 with EventHandler

use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.

the class LivesMechanic method minigameStart.

@EventHandler
private void minigameStart(StartMinigameEvent event) {
    if (event.getMinigame().getMechanicName().equals(getMechanic())) {
        final List<MinigamePlayer> players = event.getPlayers();
        final Minigame minigame = event.getMinigame();
        for (MinigamePlayer player : players) {
            player.setScore(minigame.getLives());
            minigame.setScore(player, minigame.getLives());
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) Minigame(au.com.mineauz.minigames.minigame.Minigame) EventHandler(org.bukkit.event.EventHandler)

Example 62 with EventHandler

use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.

the class RegionEvents method playerMove.

@EventHandler(ignoreCancelled = true)
private void playerMove(PlayerMoveEvent event) {
    MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply == null)
        return;
    if (ply.isInMinigame()) {
        Minigame mg = ply.getMinigame();
        executeRegionChanges(mg, ply);
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) Minigame(au.com.mineauz.minigames.minigame.Minigame) EventHandler(org.bukkit.event.EventHandler)

Example 63 with EventHandler

use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.

the class RegionEvents method itemPickupEvent.

@EventHandler(ignoreCancelled = true)
private void itemPickupEvent(PlayerDropItemEvent event) {
    final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply == null)
        return;
    if (ply.isInMinigame()) {
        final Trigger trig = Triggers.getTrigger("ITEM_DROP");
        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);
                    }
                }
            }
        });
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) Trigger(au.com.mineauz.minigamesregions.triggers.Trigger) EventHandler(org.bukkit.event.EventHandler)

Example 64 with EventHandler

use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.

the class RegionEvents method playerQuit.

@EventHandler(ignoreCancelled = true)
private void playerQuit(QuitMinigameEvent event) {
    MinigamePlayer ply = event.getMinigamePlayer();
    if (ply == null)
        return;
    Minigame mg = ply.getMinigame();
    for (Region r : RegionModule.getMinigameModule(mg).getRegions()) {
        if (r.hasPlayer(ply))
            r.removePlayer(ply);
    }
    for (Node node : RegionModule.getMinigameModule(event.getMinigame()).getNodes()) {
        node.execute(Triggers.getTrigger("GAME_QUIT"), event.getMinigamePlayer());
        if (event.getMinigame().getPlayers().size() > 1) {
            for (NodeExecutor exec : node.getExecutors()) exec.removeTrigger(event.getMinigamePlayer());
        } else {
            for (NodeExecutor exec : node.getExecutors()) exec.clearTriggers();
            node.setEnabled(true);
        }
    }
    for (Region region : RegionModule.getMinigameModule(event.getMinigame()).getRegions()) {
        if (region.playerInRegion(ply))
            region.execute(Triggers.getTrigger("GAME_QUIT"), event.getMinigamePlayer());
        if (event.getMinigame().getPlayers().size() > 1) {
            for (RegionExecutor exec : region.getExecutors()) exec.removeTrigger(event.getMinigamePlayer());
        } else {
            for (RegionExecutor exec : region.getExecutors()) {
                exec.clearTriggers();
            }
            region.removeTickTask();
            region.setEnabled(true);
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) RegionExecutor(au.com.mineauz.minigamesregions.executors.RegionExecutor) Minigame(au.com.mineauz.minigames.minigame.Minigame) NodeExecutor(au.com.mineauz.minigamesregions.executors.NodeExecutor) EventHandler(org.bukkit.event.EventHandler)

Example 65 with EventHandler

use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.

the class RegionEvents method playerXpChange.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
private void playerXpChange(PlayerExpChangeEvent event) {
    final MinigamePlayer player = pdata.getMinigamePlayer(event.getPlayer());
    if (player == null || !player.isInMinigame()) {
        return;
    }
    executeTrigger(Triggers.getTrigger("XP_CHANGE"), player);
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) EventHandler(org.bukkit.event.EventHandler)

Aggregations

EventHandler (org.bukkit.event.EventHandler)532 Player (org.bukkit.entity.Player)185 Entity (org.bukkit.entity.Entity)70 net.aufdemrand.denizen.objects.dEntity (net.aufdemrand.denizen.objects.dEntity)67 net.aufdemrand.denizen.objects.dLocation (net.aufdemrand.denizen.objects.dLocation)62 Block (org.bukkit.block.Block)62 ItemStack (org.bukkit.inventory.ItemStack)55 Location (org.bukkit.Location)54 Island (com.wasteofplastic.acidisland.Island)42 Element (net.aufdemrand.denizencore.objects.Element)38 LivingEntity (org.bukkit.entity.LivingEntity)37 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)31 Minigame (au.com.mineauz.minigames.minigame.Minigame)29 net.aufdemrand.denizen.objects.dItem (net.aufdemrand.denizen.objects.dItem)29 net.aufdemrand.denizencore.objects.dList (net.aufdemrand.denizencore.objects.dList)28 Projectile (org.bukkit.entity.Projectile)26 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)23 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)22 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)18 ArrayList (java.util.ArrayList)18