Search in sources :

Example 26 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPMine18 method onAttemptInteractAS.

@EventHandler
public void onAttemptInteractAS(PlayerInteractAtEntityEvent e) {
    if (e.isCancelled()) {
        return;
    }
    Entity ent = e.getRightClicked();
    Location l = ent.getLocation();
    Region r = RedProtect.get().rm.getTopRegion(l);
    Player p = e.getPlayer();
    if (r == null) {
        // global flags
        if (ent instanceof ArmorStand) {
            if (!RPConfig.getGlobalFlagBool(l.getWorld().getName() + ".build")) {
                e.setCancelled(true);
                return;
            }
        }
        return;
    }
    if (ent instanceof ArmorStand) {
        if (r != null && !r.canBuild(p)) {
            RPLang.sendMessage(p, "playerlistener.region.cantedit");
            e.setCancelled(true);
        }
    }
}
Also used : Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 27 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPMine19 method onPlayerTeleport.

@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent e) {
    if (e.isCancelled()) {
        return;
    }
    final Player p = e.getPlayer();
    Location lfrom = e.getFrom();
    Location lto = e.getTo();
    if (e.getCause().equals(PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT)) {
        final Region rfrom = RedProtect.get().rm.getTopRegion(lfrom);
        final Region rto = RedProtect.get().rm.getTopRegion(lto);
        if (rfrom != null && !rfrom.canTeleport(p)) {
            RPLang.sendMessage(p, "playerlistener.region.cantuse");
            e.setCancelled(true);
        }
        if (rto != null && !rto.canTeleport(p)) {
            RPLang.sendMessage(p, "playerlistener.region.cantuse");
            e.setCancelled(true);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 28 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPMine19 method onLingerPotion.

@EventHandler
public void onLingerPotion(LingeringPotionSplashEvent e) {
    if (!(e.getEntity().getShooter() instanceof Player)) {
        return;
    }
    Player p = (Player) e.getEntity().getShooter();
    Entity ent = e.getEntity();
    RedProtect.get().logger.debug("Is LingeringPotionSplashEvent event.");
    Region r = RedProtect.get().rm.getTopRegion(ent.getLocation());
    if (r != null && !r.allowEffects(p)) {
        RPLang.sendMessage(p, "playerlistener.region.cantuse");
        e.setCancelled(true);
        return;
    }
    if (RPUtil.denyPotion(e.getEntity().getItem())) {
        e.setCancelled(true);
        if (e.getEntity().getShooter() instanceof Player) {
            RPLang.sendMessage((Player) e.getEntity().getShooter(), RPLang.get("playerlistener.denypotion"));
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EventHandler(org.bukkit.event.EventHandler)

Example 29 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPMine19 method onChangeBlock.

@EventHandler
public void onChangeBlock(EntityChangeBlockEvent e) {
    if (e.isCancelled()) {
        return;
    }
    if (e.getEntity() instanceof Player) {
        Player p = (Player) e.getEntity();
        Block b = e.getBlock();
        Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
        if (r != null && !r.canBuild(p)) {
            RPLang.sendMessage(p, "blocklistener.region.cantbreak");
            e.setCancelled(true);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) Block(org.bukkit.block.Block) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EventHandler(org.bukkit.event.EventHandler)

Example 30 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPMine19 method onPlayerInteract.

@EventHandler(priority = EventPriority.LOW)
public void onPlayerInteract(PlayerInteractEvent event) {
    Player p = event.getPlayer();
    Block b = event.getClickedBlock();
    ItemStack itemInHand = event.getItem();
    Location l = null;
    if (b != null) {
        l = b.getLocation();
        RedProtect.get().logger.debug("RPPlayerListener - Is PlayerInteractEvent event. The block is " + b.getType().name());
    } else {
        l = p.getLocation();
    }
    if (RedProtect.get().tpWait.contains(p.getName())) {
        RedProtect.get().tpWait.remove(p.getName());
        RPLang.sendMessage(p, "cmdmanager.region.tpcancelled");
    }
    if (itemInHand != null && (event.getAction().name().equals("RIGHT_CLICK_BLOCK") || b == null)) {
        Material hand = itemInHand.getType();
        Region r = RedProtect.get().rm.getTopRegion(l);
        if (r != null && hand.equals(Material.CHORUS_FRUIT) && !r.canTeleport(p)) {
            RPLang.sendMessage(p, "playerlistener.region.cantuse");
            event.setCancelled(true);
            event.setUseItemInHand(Event.Result.DENY);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) Block(org.bukkit.block.Block) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Material(org.bukkit.Material) ItemStack(org.bukkit.inventory.ItemStack) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)113 EventHandler (org.bukkit.event.EventHandler)92 Player (org.bukkit.entity.Player)69 Region (br.net.fabiozumbi12.RedProtect.Sponge.Region)47 Listener (org.spongepowered.api.event.Listener)46 Location (org.bukkit.Location)43 World (org.spongepowered.api.world.World)30 Block (org.bukkit.block.Block)26 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)20 PvPlayer (me.NoChance.PvPManager.PvPlayer)20 Entity (org.bukkit.entity.Entity)20 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)19 Entity (org.spongepowered.api.entity.Entity)19 LivingEntity (org.bukkit.entity.LivingEntity)16 Player (org.spongepowered.api.entity.living.player.Player)16 World (org.bukkit.World)10 Monster (org.bukkit.entity.Monster)10 Material (org.bukkit.Material)9 ClanPlayer (net.sacredlabyrinth.phaed.simpleclans.ClanPlayer)8 OfflinePlayer (org.bukkit.OfflinePlayer)8