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)));
}
}
}
}
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);
}
}
}
}
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;
}
}
}
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);
}
}
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());
}
Aggregations