Search in sources :

Example 1 with ArmorStand

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

the class EntityArmorPose method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if (mechanism.matches("armor_pose")) {
        ArmorStand armorStand = (ArmorStand) entity.getBukkitEntity();
        dList list = mechanism.getValue().asType(dList.class);
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            String name = iterator.next();
            String angle = iterator.next();
            PosePart posePart = PosePart.fromName(name);
            if (posePart == null) {
                dB.echoError("Invalid pose part specified: " + name + "; ignoring next: " + angle);
            } else {
                posePart.setAngle(armorStand, toEulerAngle(dLocation.valueOf(angle)));
            }
        }
    }
}
Also used : ArmorStand(org.bukkit.entity.ArmorStand) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList)

Example 2 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 3 with ArmorStand

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

the class InvisibleCommand method execute.

@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
    // Get objects
    Element state = scriptEntry.getElement("state");
    dEntity target = (dEntity) scriptEntry.getObject("target");
    // Report to dB
    dB.report(scriptEntry, getName(), state.debug() + target.debug());
    if (target.isCitizensNPC()) {
        NPC npc = target.getDenizenNPC().getCitizen();
        if (!npc.hasTrait(InvisibleTrait.class)) {
            npc.addTrait(InvisibleTrait.class);
        }
        InvisibleTrait trait = npc.getTrait(InvisibleTrait.class);
        switch(Action.valueOf(state.asString().toUpperCase())) {
            case FALSE:
                trait.setInvisible(false);
                break;
            case TRUE:
                trait.setInvisible(true);
                break;
            case TOGGLE:
                trait.toggle();
                break;
        }
    } else {
        switch(Action.valueOf(state.asString().toUpperCase())) {
            case FALSE:
                if (target.getBukkitEntity() instanceof ArmorStand) {
                    ((ArmorStand) target.getBukkitEntity()).setVisible(true);
                } else {
                    target.getLivingEntity().removePotionEffect(PotionEffectType.INVISIBILITY);
                }
                break;
            case TRUE:
                if (target.getBukkitEntity() instanceof ArmorStand) {
                    ((ArmorStand) target.getBukkitEntity()).setVisible(false);
                } else {
                    new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1).apply(target.getLivingEntity());
                }
                break;
            case TOGGLE:
                if (target.getBukkitEntity() instanceof ArmorStand) {
                    if (((ArmorStand) target.getBukkitEntity()).isVisible()) {
                        ((ArmorStand) target.getBukkitEntity()).setVisible(true);
                    } else {
                        ((ArmorStand) target.getBukkitEntity()).setVisible(false);
                    }
                } else {
                    if (target.getLivingEntity().hasPotionEffect(PotionEffectType.INVISIBILITY)) {
                        target.getLivingEntity().removePotionEffect(PotionEffectType.INVISIBILITY);
                    } else {
                        new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1).apply(target.getLivingEntity());
                    }
                }
                break;
        }
    }
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) ArmorStand(org.bukkit.entity.ArmorStand) PotionEffect(org.bukkit.potion.PotionEffect) net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) Element(net.aufdemrand.denizencore.objects.Element) InvisibleTrait(net.aufdemrand.denizen.npc.traits.InvisibleTrait)

Example 4 with ArmorStand

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

the class RegionDisplayManager method update.

public void update(Region region) {
    Set<MinigamePlayer> watchers = Sets.newHashSet(activeWatchers.get(region));
    ArmorStand stand = nameDisplay.remove(region);
    if (stand != null)
        stand.remove();
    for (MinigamePlayer player : watchers) {
        hide(region, player);
        show(region, player);
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) ArmorStand(org.bukkit.entity.ArmorStand)

Example 5 with ArmorStand

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

the class RegionDisplayManager method showInfo.

private void showInfo(Node node, MinigamePlayer player) {
    activeWatchers.put(node, player);
    ArmorStand stand = nameDisplay.get(node);
    if (stand == null) {
        stand = node.getLocation().getWorld().spawn(node.getLocation().clone().subtract(0, 0.75, 0), ArmorStand.class);
        stand.setGravity(false);
        stand.setSmall(true);
        stand.setVisible(false);
        stand.setCustomNameVisible(true);
        nameDisplay.put(node, stand);
    }
    StringBuilder info = new StringBuilder();
    info.append(ChatColor.RED);
    info.append("Node: ");
    info.append(ChatColor.WHITE);
    info.append(node.getName());
    // TODO: Add more info
    stand.setCustomName(info.toString());
}
Also used : ArmorStand(org.bukkit.entity.ArmorStand)

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