Search in sources :

Example 46 with EventHandler

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

the class RecorderData method cartkMoveItem.

@EventHandler(ignoreCancelled = true)
private void cartkMoveItem(InventoryMoveItemEvent event) {
    if (!hasRegenArea() || !minigame.hasPlayers())
        return;
    Location loc = null;
    if (event.getInitiator().getHolder() instanceof HopperMinecart) {
        loc = ((HopperMinecart) event.getInitiator().getHolder()).getLocation().clone();
        if (blockInRegenArea(loc))
            addEntity((Entity) event.getInitiator().getHolder(), null, false);
    }
    loc = null;
    if (event.getDestination().getHolder() instanceof HopperMinecart) {
        loc = ((HopperMinecart) event.getDestination().getHolder()).getLocation().clone();
        if (blockInRegenArea(loc))
            addEntity((Entity) event.getInitiator().getHolder(), null, false);
    }
}
Also used : Entity(org.bukkit.entity.Entity) HopperMinecart(org.bukkit.entity.minecart.HopperMinecart) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 47 with EventHandler

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

the class BasicRecorder method bucketFill.

@EventHandler(ignoreCancelled = true)
private void bucketFill(PlayerBucketFillEvent event) {
    MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply == null)
        return;
    if (ply.isInMinigame()) {
        Minigame mgm = ply.getMinigame();
        RecorderData d = mgm.getBlockRecorder();
        if (((d.getWhitelistMode() && d.getWBBlocks().contains(event.getBlockClicked().getType())) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(event.getBlockClicked().getType()))) && mgm.canBlockBreak()) {
            d.addBlock(event.getBlockClicked(), pdata.getMinigamePlayer(event.getPlayer()));
        } else {
            event.setCancelled(true);
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) Minigame(au.com.mineauz.minigames.minigame.Minigame) EventHandler(org.bukkit.event.EventHandler)

Example 48 with EventHandler

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

the class BasicRecorder method takeItem.

@EventHandler(ignoreCancelled = true)
private void takeItem(PlayerInteractEvent event) {
    MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply == null)
        return;
    if (ply.isInMinigame() && event.getAction() == Action.RIGHT_CLICK_BLOCK && !ply.getMinigame().isSpectator(ply)) {
        Minigame mgm = ply.getMinigame();
        RecorderData d = mgm.getBlockRecorder();
        if (event.getClickedBlock().getState() instanceof InventoryHolder) {
            d.addBlock(event.getClickedBlock().getLocation().getBlock(), ply);
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) Minigame(au.com.mineauz.minigames.minigame.Minigame) InventoryHolder(org.bukkit.inventory.InventoryHolder) EventHandler(org.bukkit.event.EventHandler)

Example 49 with EventHandler

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

the class BasicRecorder method bucketEmpty.

@EventHandler(ignoreCancelled = true)
private void bucketEmpty(PlayerBucketEmptyEvent event) {
    MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply == null)
        return;
    if (ply.isInMinigame()) {
        Minigame mgm = ply.getMinigame();
        RecorderData d = mgm.getBlockRecorder();
        if (((d.getWhitelistMode() && d.getWBBlocks().contains(event.getBlockClicked().getType())) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(event.getBlockClicked().getType()))) && mgm.canBlockPlace()) {
            Location loc = new Location(event.getBlockClicked().getWorld(), event.getBlockFace().getModX() + event.getBlockClicked().getX(), event.getBlockFace().getModY() + event.getBlockClicked().getY(), event.getBlockFace().getModZ() + event.getBlockClicked().getZ());
            d.addBlock(loc.getBlock(), pdata.getMinigamePlayer(event.getPlayer()));
        } else {
            event.setCancelled(true);
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) Minigame(au.com.mineauz.minigames.minigame.Minigame) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 50 with EventHandler

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

the class Events method playerSpawn.

@EventHandler(priority = EventPriority.HIGHEST)
private void playerSpawn(PlayerRespawnEvent event) {
    final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply == null)
        return;
    if (ply.isInMinigame()) {
        final WeatherTimeModule mod = WeatherTimeModule.getMinigameModule(ply.getMinigame());
        if (mod.isUsingCustomWeather()) {
            Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

                @Override
                public void run() {
                    ply.getPlayer().setPlayerWeather(mod.getCustomWeather());
                }
            });
        }
        if (ply.getMinigame().getState() == MinigameState.ENDED) {
            plugin.pdata.quitMinigame(ply, true);
        }
    }
    if (ply.isRequiredQuit()) {
        Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

            @Override
            public void run() {
                ply.restorePlayerData();
            }
        });
        event.setRespawnLocation(ply.getQuitPos());
        ply.setRequiredQuit(false);
        ply.setQuitPos(null);
    }
}
Also used : WeatherTimeModule(au.com.mineauz.minigames.minigame.modules.WeatherTimeModule) 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