Search in sources :

Example 6 with ArmorStand

use of org.bukkit.entity.ArmorStand in project Towny by ElgarL.

the class TownyEntityListener method onEntityDamageByEntityEvent.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
    if (plugin.isError()) {
        return;
    }
    TownyWorld townyWorld = null;
    Entity entity = event.getEntity();
    if (entity instanceof ArmorStand) {
        String damager = event.getDamager().getType().name();
        if (damager == "PRIMED_TNT" || damager == "WITHER_SKULL" || damager == "FIREBALL" || damager == "SMALL_FIREBALL" || damager == "LARGE_FIREBALL" || damager == "WITHER") {
            try {
                townyWorld = TownyUniverse.getDataSource().getWorld(entity.getWorld().getName());
            } catch (NotRegisteredException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (!locationCanExplode(townyWorld, entity.getLocation())) {
                event.setCancelled(true);
                return;
            }
        }
        if (event.getDamager() instanceof Projectile) {
            try {
                townyWorld = TownyUniverse.getDataSource().getWorld(entity.getWorld().getName());
            } catch (NotRegisteredException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Object remover = event.getDamager();
            remover = ((Projectile) remover).getShooter();
            if (remover instanceof Monster) {
                event.setCancelled(true);
            } else if (remover instanceof Player) {
                Player player = (Player) remover;
                // Get destroy permissions (updates if none exist)
                boolean bDestroy = PlayerCacheUtil.getCachePermission(player, entity.getLocation(), 416, (byte) 0, TownyPermission.ActionType.DESTROY);
                // Allow the removal if we are permitted
                if (bDestroy)
                    return;
                /*
					 * Fetch the players cache
					 */
                PlayerCache cache = plugin.getCache(player);
                event.setCancelled(true);
            }
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ArmorStand(org.bukkit.entity.ArmorStand) NotRegisteredException(com.palmergames.bukkit.towny.exceptions.NotRegisteredException) Monster(org.bukkit.entity.Monster) PlayerCache(com.palmergames.bukkit.towny.object.PlayerCache) TownyWorld(com.palmergames.bukkit.towny.object.TownyWorld) Projectile(org.bukkit.entity.Projectile) EventHandler(org.bukkit.event.EventHandler)

Example 7 with ArmorStand

use of org.bukkit.entity.ArmorStand in project Denizen-For-Bukkit by DenizenScript.

the class EntityArmorPose method getPoseList.

private dList getPoseList() {
    ArmorStand armorStand = (ArmorStand) entity.getBukkitEntity();
    dList list = new dList();
    for (PosePart posePart : PosePart.values()) {
        list.add(CoreUtilities.toLowerCase(posePart.name()));
        list.add(fromEulerAngle(posePart.getAngle(armorStand)).identify());
    }
    return list;
}
Also used : ArmorStand(org.bukkit.entity.ArmorStand) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList)

Example 8 with ArmorStand

use of org.bukkit.entity.ArmorStand in project Minigames by AddstarMC.

the class RegionDisplayManager method showInfo.

private void showInfo(Region region, MinigamePlayer player) {
    activeWatchers.put(region, player);
    ArmorStand stand = nameDisplay.get(region);
    if (stand == null) {
        Location midPoint = region.getFirstPoint().clone().add(region.getSecondPoint()).add(1, 1, 1).multiply(0.5).subtract(0, 1.4, 0);
        stand = region.getFirstPoint().getWorld().spawn(midPoint, ArmorStand.class);
        stand.setGravity(false);
        stand.setSmall(true);
        stand.setVisible(false);
        stand.setCustomNameVisible(true);
        nameDisplay.put(region, stand);
    }
    StringBuilder info = new StringBuilder();
    info.append(ChatColor.BLUE);
    info.append("Region: ");
    info.append(ChatColor.WHITE);
    info.append(region.getName());
    info.append("Enabled: " + region.getEnabled());
    stand.setCustomName(info.toString());
}
Also used : ArmorStand(org.bukkit.entity.ArmorStand) Location(org.bukkit.Location)

Aggregations

ArmorStand (org.bukkit.entity.ArmorStand)8 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)2 net.aufdemrand.denizencore.objects.dList (net.aufdemrand.denizencore.objects.dList)2 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)1 PlayerCache (com.palmergames.bukkit.towny.object.PlayerCache)1 TownyWorld (com.palmergames.bukkit.towny.object.TownyWorld)1 InvisibleTrait (net.aufdemrand.denizen.npc.traits.InvisibleTrait)1 net.aufdemrand.denizen.objects.dEntity (net.aufdemrand.denizen.objects.dEntity)1 Element (net.aufdemrand.denizencore.objects.Element)1 NPC (net.citizensnpcs.api.npc.NPC)1 Location (org.bukkit.Location)1 Entity (org.bukkit.entity.Entity)1 LivingEntity (org.bukkit.entity.LivingEntity)1 Monster (org.bukkit.entity.Monster)1 Player (org.bukkit.entity.Player)1 Projectile (org.bukkit.entity.Projectile)1 EventHandler (org.bukkit.event.EventHandler)1 PotionEffect (org.bukkit.potion.PotionEffect)1