Java Code Examples for org.bukkit.entity.ArmorStand#setCustomName()
The following examples show how to use
org.bukkit.entity.ArmorStand#setCustomName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainListener.java From ArmorStandTools with MIT License | 6 votes |
private ArmorStand spawnArmorStand(Location l) { ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND); as.setHelmet(Config.helmet); as.setChestplate(Config.chest); as.setLeggings(Config.pants); as.setBoots(Config.boots); as.getEquipment().setItemInMainHand(Config.itemInHand); as.getEquipment().setItemInOffHand(Config.itemInOffHand); as.setVisible(Config.isVisible); as.setSmall(Config.isSmall); as.setArms(Config.hasArms); as.setBasePlate(Config.hasBasePlate); as.setGravity(Config.hasGravity); as.setInvulnerable(Config.invulnerable); if(Config.defaultName.length() > 0) { as.setCustomName(Config.defaultName); as.setCustomNameVisible(true); } Main.nms.setSlotsDisabled(as, Config.equipmentLock); return as; }
Example 2
Source File: ReactorHologram.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
public static ArmorStand getArmorStand(Location reactor, boolean createIfNoneExists) { Location l = new Location(reactor.getWorld(), reactor.getX() + 0.5, reactor.getY() + 0.7, reactor.getZ() + 0.5); for (Entity n : l.getChunk().getEntities()) { if (n instanceof ArmorStand && l.distanceSquared(n.getLocation()) < 0.4D) { return (ArmorStand) n; } } if (!createIfNoneExists) { return null; } ArmorStand hologram = SimpleHologram.create(l); hologram.setCustomNameVisible(false); hologram.setCustomName(null); return hologram; }
Example 3
Source File: HologramProjector.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
private static ArmorStand getArmorStand(Block projector, boolean createIfNoneExists) { String nametag = BlockStorage.getLocationInfo(projector.getLocation(), "text"); double offset = Double.parseDouble(BlockStorage.getLocationInfo(projector.getLocation(), "offset")); Location l = new Location(projector.getWorld(), projector.getX() + 0.5, projector.getY() + offset, projector.getZ() + 0.5); for (Entity n : l.getChunk().getEntities()) { if (n instanceof ArmorStand && n.getCustomName() != null && n.getCustomName().equals(nametag) && l.distanceSquared(n.getLocation()) < 0.4D) { return (ArmorStand) n; } } if (!createIfNoneExists) { return null; } ArmorStand hologram = SimpleHologram.create(l); hologram.setCustomName(nametag); return hologram; }
Example 4
Source File: Holograms.java From HubBasics with GNU Lesser General Public License v3.0 | 6 votes |
private JSONArray spawnLines(Location loc, String[] lines) { int lineIndex = 0; JSONArray array = new JSONArray(); for (String str : lines) { ArmorStand armorStand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND); armorStand.setGravity(false); armorStand.setVisible(false); armorStand.setCustomName(ChatColor.translateAlternateColorCodes('&', str)); armorStand.setCustomNameVisible(true); armorStand.setRemoveWhenFarAway(false); loc.setY(loc.getY() - 0.25); JSONObject object = new JSONObject(); object.put(ARMORSTAND_LINE, lineIndex); object.put(ARMORSTAND_TEXT, str); object.put(ARMORSTAND_UUID, armorStand.getUniqueId().toString()); array.put(lineIndex, object); lineIndex++; } return array; }
Example 5
Source File: TimebombListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
private void spawnChest(){ spawned = true; block1 = loc.getBlock(); loc.add(-1, 0, 0); block2 = loc.getBlock(); block1.setType(Material.CHEST); block2.setType(Material.CHEST); Chest chest1 = (Chest) block1.getState(); Chest chest2 = (Chest) block2.getState(); String chestName = Lang.SCENARIO_TIMEBOMB_CHEST.replace("%player%", name); VersionUtils.getVersionUtils().setChestName(chest1, chestName); VersionUtils.getVersionUtils().setChestName(chest2, chestName); // Make double chest for 1.13 and up VersionUtils.getVersionUtils().setChestSide(chest1, false); VersionUtils.getVersionUtils().setChestSide(chest2, true); Inventory inv = chest1.getInventory(); for (ItemStack drop : drops){ inv.addItem(drop); } loc.add(1,-1,.5); armorStand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND); armorStand.setCustomNameVisible(true); armorStand.setGravity(false); armorStand.setVisible(false); armorStand.setCustomName(""); }
Example 6
Source File: FlagObjective.java From CardinalPGM with MIT License | 5 votes |
private ArmorStand createArmorStand() { Location loc = getCurrentFlagLocation().add(0,0.6875,0); ArmorStand armorStand = GameHandler.getGameHandler().getMatchWorld().spawn(loc, ArmorStand.class); armorStand.setGravity(false); armorStand.setVisible(false); armorStand.setSmall(true); armorStand.setBasePlate(false); armorStand.setCustomNameVisible(true); armorStand.setCustomName(getDisplayName()); return armorStand; }
Example 7
Source File: DamageDisplay.java From EliteMobs with GNU General Public License v3.0 | 4 votes |
public static void displayDamage(Entity entity, double damage) { if (!ConfigValues.mobCombatSettingsConfig.getBoolean(MobCombatSettingsConfig.DISPLAY_DAMAGE_ON_HIT)) return; Location entityLocation = entity.getLocation(); Random random = new Random(); double randomCoordX = (random.nextDouble() * 2) - 1 + entityLocation.getX(); double randomCoordZ = (random.nextDouble() * 2) - 1 + entityLocation.getZ(); Location newLocation = new Location(entityLocation.getWorld(), randomCoordX, entityLocation.getY() + 1.7, randomCoordZ); /* Dirty fix: armorstands don't render invisibly on their first tick, so it gets moved elsewhere temporarily */ ArmorStand armorStand = (ArmorStand) newLocation.getWorld().spawnEntity(newLocation.add(new Vector(0, -50, 0)), EntityType.ARMOR_STAND); armorStand.setVisible(false); armorStand.setMarker(true); int newDisplayDamage = (int) damage; armorStand.setCustomName(ChatColor.RED + "" + ChatColor.BOLD + "" + newDisplayDamage + ""); armorStand.setGravity(false); EntityTracker.registerArmorStands(armorStand); armorStand.setCustomNameVisible(false); new BukkitRunnable() { int taskTimer = 0; @Override public void run() { if (taskTimer == 0) { armorStand.teleport(new Location(armorStand.getWorld(), armorStand.getLocation().getX(), armorStand.getLocation().getY() + 50, armorStand.getLocation().getZ())); } else armorStand.teleport(new Location(armorStand.getWorld(), armorStand.getLocation().getX(), armorStand.getLocation().getY() + 0.1, armorStand.getLocation().getZ())); if (taskTimer == 1) armorStand.setCustomNameVisible(true); taskTimer++; if (taskTimer > 15) { EntityTracker.unregisterArmorStand(armorStand); cancel(); } } }.runTaskTimer(Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS), 0, 1); }
Example 8
Source File: NPCChatBubble.java From EliteMobs with GNU General Public License v3.0 | 4 votes |
public NPCChatBubble(String message, NPCEntity npcEntity, Player player) { if (npcEntity.getVillager().hasPotionEffect(PotionEffectType.INVISIBILITY)) return; if (npcEntity.getIsTalking()) return; npcEntity.startTalkingCooldown(); int lineCounter = 0; for (String substring : message.split("\\\\n")) { Location newLocation = npcEntity.getVillager().getEyeLocation().clone() .add(player.getLocation().clone().subtract(npcEntity.getVillager().getLocation()).toVector().normalize().multiply(0.5)) .add(new Vector(0, -50 - (0.2 * lineCounter), 0)); ArmorStand messageBubble = (ArmorStand) newLocation.getWorld().spawnEntity(newLocation, EntityType.ARMOR_STAND); EntityTracker.registerArmorStands(messageBubble); messageBubble.setVisible(false); messageBubble.setMarker(true); messageBubble.setCustomName(ChatColorConverter.convert(substring)); messageBubble.setCustomNameVisible(true); messageBubble.setGravity(false); new BukkitRunnable() { int counter = 0; @Override public void run() { if (counter > 20 * 3) { messageBubble.remove(); cancel(); return; } if (counter == 1) messageBubble.teleport(messageBubble.getLocation().add(new Vector(0, 49.2, 0))); if (counter > 1) messageBubble.teleport(messageBubble.getLocation().clone().add(new Vector(0, 0.01, 0))); counter++; } }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1); lineCounter++; } }
Example 9
Source File: MainListener.java From ArmorStandTools with MIT License | 4 votes |
@EventHandler public void onSignChange(final SignChangeEvent event) { if(event.getBlock().hasMetadata("armorStand")) { final Block b = event.getBlock(); final ArmorStand as = getArmorStand(b); if (as != null) { StringBuilder sb = new StringBuilder(); for (String line : event.getLines()) { if (line != null && line.length() > 0) { sb.append(ChatColor.translateAlternateColorCodes('&', line)); } } String input = sb.toString(); if(b.hasMetadata("setName")) { if (input.length() > 0) { as.setCustomName(input); as.setCustomNameVisible(true); } else { as.setCustomName(""); as.setCustomNameVisible(false); as.setCustomNameVisible(false); } } else if(b.hasMetadata("setSkull")) { if(MC_USERNAME_PATTERN.matcher(input).matches()) { b.setMetadata("protected", new FixedMetadataValue(plugin, true)); event.getPlayer().sendMessage(ChatColor.GOLD + Config.pleaseWait); String cmd = "minecraft:give " + event.getPlayer().getName() + " minecraft:player_head{SkullOwner:\"" + input + "\"} 1"; String current = b.getWorld().getGameRuleValue("sendCommandFeedback"); b.getWorld().setGameRuleValue("sendCommandFeedback", "false"); Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd); b.getWorld().setGameRuleValue("sendCommandFeedback", current); boolean found = false; for(int slot : event.getPlayer().getInventory().all(Material.PLAYER_HEAD).keySet()) { ItemStack skull = event.getPlayer().getInventory().getItem(slot); SkullMeta sm = (SkullMeta) skull.getItemMeta(); if(sm.hasOwner() && input.equalsIgnoreCase(sm.getOwningPlayer().getName())) { as.setHelmet(skull); event.getPlayer().sendMessage(ChatColor.GREEN + Config.appliedHead + ChatColor.GOLD + " " + input); event.getPlayer().getInventory().setItem(slot, null); found = true; break; } } if(!found) { event.getPlayer().sendMessage(ChatColor.GOLD + Config.headFailed); } } else { event.getPlayer().sendMessage(ChatColor.RED + input + " " + Config.invalidName); } } } event.setCancelled(true); b.removeMetadata("armorStand", plugin); b.removeMetadata("setName", plugin); b.removeMetadata("setSkull", plugin); b.setType(Material.AIR); } }
Example 10
Source File: DeathStandsModule.java From UHC with MIT License | 4 votes |
@EventHandler(priority = EventPriority.HIGH) public void on(PlayerDeathEvent event) { if (!isEnabled()) return; final Player player = event.getEntity(); // make the player invisible for the duration of their death animation player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, DEATH_ANIMATION_TIME, 1)); final Location location = player.getLocation(); // create an armour stand at the player final ArmorStand stand = player.getWorld().spawn(location.clone().add(0, .2D, 0), ArmorStand.class); stand.setBasePlate(false); stand.setArms(true); // give the armour stand the death message as a name stand.setCustomName(STAND_PREFIX + event.getDeathMessage()); stand.setCustomNameVisible(true); // face the same direction as the player stand.getLocation().setDirection(location.getDirection()); // set the armour stand helmet to be looking at the same yaw stand.setHeadPose(new EulerAngle(Math.toRadians(location.getPitch()), 0, 0)); // use the player's velocity as a base and apply it to the stand stand.setVelocity( player.getVelocity() .clone() .multiply(PLAYER_VELOCITY_MULTIPLIER) .add(new Vector(0D, PLAYER_VELOICY_Y_ADDITIONAL, 0D)) ); // start with player's existing items in each slot (if exists) Map<EquipmentSlot, ItemStack> toSet = getItems(player.getInventory()); // overide with any saved items in the metadata toSet.putAll(getSavedSlots(player)); // filter out the invalid items toSet = Maps.filterValues(toSet, Predicates.not(EMPTY_ITEM)); final List<ItemStack> drops = event.getDrops(); for (final Map.Entry<EquipmentSlot, ItemStack> entry : toSet.entrySet()) { final ItemStack stack = entry.getValue(); if (stack == null) continue; // remove the first matching stack in the drop list removeFirstEquals(drops, stack); // set the item on the armour stand in the correct slot switch (entry.getKey()) { case HAND: stand.setItemInHand(stack); break; case HEAD: stand.setHelmet(stack); break; case CHEST: stand.setChestplate(stack); break; case LEGS: stand.setLeggings(stack); break; case FEET: stand.setBoots(stack); break; default: } } }
Example 11
Source File: HealthDisplay.java From EliteMobs with GNU General Public License v3.0 | 2 votes |
public static void displayHealth(LivingEntity livingEntity, double damage) { if (!ConfigValues.mobCombatSettingsConfig.getBoolean(MobCombatSettingsConfig.DISPLAY_HEALTH_ON_HIT)) return; int maxHealth = (int) livingEntity.getMaxHealth(); int currentHealth = (int) (livingEntity.getHealth() - damage); Location entityLocation = new Location(livingEntity.getWorld(), livingEntity.getLocation().getX(), livingEntity.getLocation().getY() + livingEntity.getEyeHeight() + 0.5, livingEntity.getLocation().getZ()); /* Dirty fix: armorstands don't render invisibly on their first tick, so it gets moved elsewhere temporarily */ ArmorStand armorStand = (ArmorStand) entityLocation.getWorld().spawnEntity(entityLocation.add(new Vector(0, -50, 0)), EntityType.ARMOR_STAND); armorStand.setVisible(false); armorStand.setMarker(true); armorStand.setCustomName(setHealthColor(currentHealth, maxHealth) + "" + currentHealth + "/" + maxHealth); armorStand.setGravity(false); EntityTracker.registerArmorStands(armorStand); armorStand.setCustomNameVisible(false); new BukkitRunnable() { int taskTimer = 0; @Override public void run() { Location newLocation = new Location(livingEntity.getWorld(), livingEntity.getLocation().getX(), livingEntity.getLocation().getY() + livingEntity.getEyeHeight() + 0.5, livingEntity.getLocation().getZ()); armorStand.teleport(newLocation); if (taskTimer == 1) armorStand.setCustomNameVisible(true); taskTimer++; if (taskTimer > 15) { EntityTracker.unregisterArmorStand(armorStand); cancel(); } } }.runTaskTimer(Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS), 0, 1L); }