Search in sources :

Example 91 with EventHandler

use of org.bukkit.event.EventHandler in project xAuth by CypherX.

the class xAuthEntityListener method onEntityDamage.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) {
    Entity entity = event.getEntity();
    if (entity instanceof Player && ((Player) entity).isOnline()) {
        // player taking damage
        xAuthPlayer xp = plyrMngr.getPlayer(((Player) entity).getName());
        if (plyrMngr.isRestricted(xp, event) || plyrMngr.hasGodmode(xp, event.getCause()))
            event.setCancelled(true);
    }
    if (event instanceof EntityDamageByEntityEvent) {
        // player dealing damage to other entity
        EntityDamageByEntityEvent edbeEvent = (EntityDamageByEntityEvent) event;
        Entity damager = edbeEvent.getDamager();
        if (damager instanceof Player) {
            xAuthPlayer player = plyrMngr.getPlayer(((Player) damager).getName());
            if (plyrMngr.isRestricted(player, edbeEvent)) {
                plyrMngr.sendNotice(player);
                event.setCancelled(true);
            }
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) com.cypherx.xauth.xAuthPlayer(com.cypherx.xauth.xAuthPlayer) EntityDamageByEntityEvent(org.bukkit.event.entity.EntityDamageByEntityEvent) com.cypherx.xauth.xAuthPlayer(com.cypherx.xauth.xAuthPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 92 with EventHandler

use of org.bukkit.event.EventHandler in project xAuth by CypherX.

the class xAuthPlayerListener method onPlayerInteract.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) {
    xAuthPlayer p = plyrMngr.getPlayer(event.getPlayer().getName());
    if (plyrMngr.isRestricted(p, event)) {
        Action action = event.getAction();
        Material type = event.getClickedBlock().getType();
        // TODO add missing blocks
        if (action == Action.LEFT_CLICK_BLOCK) {
            if (type == Material.NOTE_BLOCK || type == Material.WOODEN_DOOR || type == Material.LEVER || type == Material.IRON_DOOR || type == Material.STONE_BUTTON || type == Material.TRAP_DOOR) {
                plyrMngr.sendNotice(p);
                event.setCancelled(true);
            }
        } else if (action == Action.RIGHT_CLICK_BLOCK) {
            if (type == Material.DISPENSER || type == Material.NOTE_BLOCK || type == Material.BED || type == Material.CHEST || type == Material.WORKBENCH || type == Material.FURNACE || type == Material.SIGN || type == Material.WOODEN_DOOR || type == Material.LEVER || type == Material.IRON_DOOR || type == Material.STONE_BUTTON || type == Material.JUKEBOX || type == Material.TRAP_DOOR || type == Material.ENCHANTMENT_TABLE) {
                plyrMngr.sendNotice(p);
                event.setCancelled(true);
            }
        } else if (action == Action.PHYSICAL) {
            if (type == Material.SOIL || type == Material.STONE_PLATE || type == Material.WOOD_PLATE)
                event.setCancelled(true);
        }
    }
}
Also used : Action(org.bukkit.event.block.Action) com.cypherx.xauth.xAuthPlayer(com.cypherx.xauth.xAuthPlayer) Material(org.bukkit.Material) EventHandler(org.bukkit.event.EventHandler)

Example 93 with EventHandler

use of org.bukkit.event.EventHandler in project xAuth by CypherX.

the class xAuthPlayerListener method onPlayerMove.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) {
    xAuthPlayer p = plyrMngr.getPlayer(event.getPlayer());
    if (plyrMngr.isRestricted(p, event)) {
        World w = p.getPlayer().getWorld();
        Location loc = plugin.getConfig().getBoolean("guest.protect-location") ? plugin.getLocMngr().getLocation(w) : p.getPlayerData().getLocation();
        Location testLoc = new Location(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ());
        while ((w.getBlockAt(testLoc).isEmpty() || w.getBlockAt(testLoc).isLiquid()) && testLoc.getY() >= 0) testLoc.setY((int) testLoc.getY() - 1);
        if (testLoc.getY() > 0)
            loc.setY(testLoc.getY() + 1);
        event.setTo(loc);
        plyrMngr.sendNotice(p);
    }
}
Also used : com.cypherx.xauth.xAuthPlayer(com.cypherx.xauth.xAuthPlayer) World(org.bukkit.World) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 94 with EventHandler

use of org.bukkit.event.EventHandler in project xAuth by CypherX.

the class xAuthPlayerListener method onPlayerQuit.

@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(final PlayerQuitEvent event) {
    xAuthPlayer p = plyrMngr.getPlayer(event.getPlayer());
    if (p.isProtected())
        plyrMngr.unprotect(p);
    plugin.getAuthClass(p).offline(event.getPlayer().getName());
}
Also used : com.cypherx.xauth.xAuthPlayer(com.cypherx.xauth.xAuthPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 95 with EventHandler

use of org.bukkit.event.EventHandler in project xAuth by CypherX.

the class xAuthPlayerListener method onInventoryClick.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onInventoryClick(final InventoryClickEvent event) {
    if (!plugin.getConfig().getBoolean("guest.hide-inventory")) {
        HumanEntity entity = event.getWhoClicked();
        if (entity instanceof Player) {
            xAuthPlayer p = plyrMngr.getPlayer(((Player) entity).getName());
            if (plyrMngr.isRestricted(p, event)) {
                plyrMngr.sendNotice(p);
                event.setCancelled(true);
            }
        }
    }
}
Also used : Player(org.bukkit.entity.Player) com.cypherx.xauth.xAuthPlayer(com.cypherx.xauth.xAuthPlayer) com.cypherx.xauth.xAuthPlayer(com.cypherx.xauth.xAuthPlayer) HumanEntity(org.bukkit.entity.HumanEntity) 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