Search in sources :

Example 11 with RPPlayerListener

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

the class RPPlayerListener method onPlayerFrostWalk.

@EventHandler(priority = EventPriority.LOW)
public void onPlayerFrostWalk(EntityBlockFormEvent e) {
    if (!(e.getEntity() instanceof Player)) {
        return;
    }
    RedProtect.get().logger.debug("RPPlayerListener - EntityBlockFormEvent canceled? " + e.isCancelled());
    Player p = (Player) e.getEntity();
    Region r = RedProtect.get().rm.getTopRegion(e.getBlock().getLocation());
    if (r != null && e.getNewState().getType().name().contains("FROSTED_ICE") && !r.canIceForm(p)) {
        e.setCancelled(true);
    }
}
Also used : Player(org.bukkit.entity.Player) PvPlayer(me.NoChance.PvPManager.PvPlayer) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EventHandler(org.bukkit.event.EventHandler)

Example 12 with RPPlayerListener

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

the class RPPlayerListener method onHangingDamaged.

@EventHandler
public void onHangingDamaged(HangingBreakByEntityEvent e) {
    if (e.isCancelled()) {
        return;
    }
    RedProtect.get().logger.debug("Is RPPlayerListener - HangingBreakByEntityEvent event");
    Entity ent = e.getRemover();
    Location loc = e.getEntity().getLocation();
    Region r = RedProtect.get().rm.getTopRegion(loc);
    if (ent instanceof Player) {
        Player player = (Player) ent;
        if (r != null && !r.canBuild(player) && !r.canBreak(e.getEntity().getType())) {
            RPLang.sendMessage(player, "blocklistener.region.cantbuild");
            e.setCancelled(true);
        }
    }
    if (ent instanceof Monster) {
        if (r != null && !r.canMobLoot()) {
            e.setCancelled(true);
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) MyPetBukkitEntity(de.Keyle.MyPet.api.entity.MyPetBukkitEntity) Player(org.bukkit.entity.Player) PvPlayer(me.NoChance.PvPManager.PvPlayer) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) Monster(org.bukkit.entity.Monster) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)7 Player (org.bukkit.entity.Player)7 EventHandler (org.bukkit.event.EventHandler)7 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)6 PvPlayer (me.NoChance.PvPManager.PvPlayer)6 Location (org.bukkit.Location)6 Listener (org.spongepowered.api.event.Listener)4 Region (br.net.fabiozumbi12.RedProtect.Sponge.Region)3 MyPetBukkitEntity (de.Keyle.MyPet.api.entity.MyPetBukkitEntity)3 Entity (org.bukkit.entity.Entity)3 World (org.spongepowered.api.world.World)3 Material (org.bukkit.Material)2 Block (org.bukkit.block.Block)2 ItemStack (org.bukkit.inventory.ItemStack)2 PotionEffect (org.bukkit.potion.PotionEffect)2 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)2 RedProtectAPI (br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI)1 EnterExitRegionEvent (br.net.fabiozumbi12.RedProtect.Bukkit.events.EnterExitRegionEvent)1 MPListener (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.MPListener)1 McMMoListener (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.McMMoListener)1