Search in sources :

Example 36 with Minigame

use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.

the class BasicRecorder method vehicleDestroy.

@EventHandler(ignoreCancelled = true)
private void vehicleDestroy(VehicleDestroyEvent event) {
    if (event.getAttacker() != null) {
        if (event.getAttacker() instanceof Player) {
            Player ply = (Player) event.getAttacker();
            Minigame mg = pdata.getMinigamePlayer(ply).getMinigame();
            if (pdata.getMinigamePlayer(ply).isInMinigame()) {
                if (!mg.getBlockRecorder().hasEntity(event.getVehicle())) {
                    mg.getBlockRecorder().addEntity(event.getVehicle(), pdata.getMinigamePlayer(ply), false);
                }
            }
        }
    }
}
Also used : Player(org.bukkit.entity.Player) MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) Minigame(au.com.mineauz.minigames.minigame.Minigame) EventHandler(org.bukkit.event.EventHandler)

Example 37 with Minigame

use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.

the class BasicRecorder method blockPlace.

@EventHandler(priority = EventPriority.HIGH)
private void blockPlace(BlockPlaceEvent event) {
    MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply == null)
        return;
    if (ply.isInMinigame() && !event.isCancelled()) {
        if (!ply.getMinigame().hasStarted() || ply.isLatejoining()) {
            event.setCancelled(true);
            return;
        }
        Minigame mgm = ply.getMinigame();
        RecorderData d = mgm.getBlockRecorder();
        if (((d.getWhitelistMode() && d.getWBBlocks().contains(event.getBlock().getType())) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(event.getBlock().getType()))) && mgm.canBlockPlace()) {
            d.addBlock(event.getBlockReplacedState(), ply);
        } 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 38 with Minigame

use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.

the class BasicRecorder method igniteblock.

@EventHandler(ignoreCancelled = true)
public void igniteblock(BlockIgniteEvent event) {
    MinigamePlayer ply = null;
    if (event.getPlayer() != null)
        ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply == null)
        return;
    if (ply.isInMinigame() && (event.getCause() == IgniteCause.FIREBALL || event.getCause() == IgniteCause.FLINT_AND_STEEL)) {
        Minigame mgm = ply.getMinigame();
        RecorderData d = mgm.getBlockRecorder();
        if (((d.getWhitelistMode() && d.getWBBlocks().contains(Material.FIRE)) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(Material.FIRE))) && mgm.canBlockPlace()) {
            d.addBlock(event.getBlock(), 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 39 with Minigame

use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.

the class BasicRecorder method blockBreak.

@EventHandler(priority = EventPriority.HIGH)
private void blockBreak(BlockBreakEvent event) {
    MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply == null)
        return;
    if (ply.isInMinigame()) {
        if (!ply.getMinigame().hasStarted() || ply.isLatejoining()) {
            event.setCancelled(true);
            return;
        }
        Minigame mgm = ply.getMinigame();
        RecorderData d = mgm.getBlockRecorder();
        if (((d.getWhitelistMode() && d.getWBBlocks().contains(event.getBlock().getType())) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(event.getBlock().getType()))) && mgm.canBlockBreak()) {
            if (event.getBlock().getState() instanceof Sign) {
                Sign sign = (Sign) event.getBlock().getState();
                if (sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE + "[Minigame]")) {
                    event.setCancelled(true);
                } else {
                    d.addBlock(event.getBlock(), ply);
                    if (!mgm.canBlocksdrop()) {
                        event.setCancelled(true);
                        event.getBlock().setType(Material.AIR);
                    }
                }
            } else {
                Location above = event.getBlock().getLocation().clone();
                above.setY(above.getY() + 1);
                d.addBlock(event.getBlock(), ply);
                if (!mgm.canBlocksdrop()) {
                    event.setCancelled(true);
                    event.getBlock().setType(Material.AIR);
                }
            }
        } else {
            event.setCancelled(true);
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) Sign(org.bukkit.block.Sign) Minigame(au.com.mineauz.minigames.minigame.Minigame) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 40 with Minigame

use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.

the class BasicRecorder method paintingPlace.

@EventHandler(ignoreCancelled = true)
private void paintingPlace(HangingPlaceEvent event) {
    MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply.isInMinigame()) {
        Minigame mgm = ply.getMinigame();
        RecorderData d = mgm.getBlockRecorder();
        if (((d.getWhitelistMode() && d.getWBBlocks().contains(Material.PAINTING)) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(Material.PAINTING))) || ((d.getWhitelistMode() && d.getWBBlocks().contains(Material.ITEM_FRAME)) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(Material.ITEM_FRAME)))) {
            d.addEntity(event.getEntity(), ply, true);
        } else {
            event.setCancelled(true);
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) Minigame(au.com.mineauz.minigames.minigame.Minigame) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Minigame (au.com.mineauz.minigames.minigame.Minigame)64 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)33 EventHandler (org.bukkit.event.EventHandler)29 ArrayList (java.util.ArrayList)19 Player (org.bukkit.entity.Player)16 Team (au.com.mineauz.minigames.minigame.Team)15 List (java.util.List)7 Location (org.bukkit.Location)7 TreasureHuntModule (au.com.mineauz.minigames.minigame.modules.TreasureHuntModule)4 Sign (org.bukkit.block.Sign)4 TeamColor (au.com.mineauz.minigames.minigame.TeamColor)3 Block (org.bukkit.block.Block)3 ItemStack (org.bukkit.inventory.ItemStack)3 PotionEffect (org.bukkit.potion.PotionEffect)3 CTFFlag (au.com.mineauz.minigames.CTFFlag)2 MinigameData (au.com.mineauz.minigames.MinigameData)2 MultiplayerTimer (au.com.mineauz.minigames.MultiplayerTimer)2 ICommand (au.com.mineauz.minigames.commands.ICommand)2 TakeFlagEvent (au.com.mineauz.minigames.events.TakeFlagEvent)2 ScoreboardDisplay (au.com.mineauz.minigames.minigame.ScoreboardDisplay)2