@Override public void run() { ArmorStand hologram = getArmorStand(l); if (!hologram.isCustomNameVisible()) hologram.setCustomNameVisible(true); hologram.setCustomName(ChatColor.translateAlternateColorCodes('&', name)); } });
/** * Saves the ball asynchronously when it is inside of a chunk which gets unloaded. Replaces the entity with an invisible armorstands which holds the * ball information for respawning. * * @param event event */ @EventHandler public void onChunkSaveEvent(ChunkUnloadEvent event) { for (final Entity entity : event.getChunk().getEntities()) { final Optional<BukkitBall> ball; if (entity instanceof LivingEntity) { if ((ball = this.ballController.getBallFromEntity((LivingEntity) entity)).isPresent()) { if (ball.get().isPersistent()) { this.pushToCache(ball.get()); this.ballController.remove(ball.get()); this.ballController.saveAndDestroy(ball.get(), true); final ArmorStand armorStand = (ArmorStand) event.getWorld().spawnEntity(((Location) ball.get().getLocation()), EntityType.ARMOR_STAND); armorStand.setCustomNameVisible(false); armorStand.setRemoveWhenFarAway(false); armorStand.setVisible(false); armorStand.setCustomName("balluuid-" + ball.get().getUUID().toString()); } else { ball.get().remove(); } } } } }
public void createTimedHologram(final Location location, String text, Long timeout) { ArmorStand as = (ArmorStand) location.add(0.5, 1, 0.5).getWorld().spawnEntity(location, EntityType.ARMOR_STAND); //Spawn the ArmorStand as.setVisible(false); //Makes the ArmorStand invisible as.setGravity(false); //Make sure it doesn't fall as.setCanPickupItems(false); //I'm not sure what happens if you leave this as it is, but you might as well disable it as.setCustomName(SavageFactions.plugin.color(text)); //Set this to the text you want as.setCustomNameVisible(true); //This makes the text appear no matter if your looking at the entity or not final ArmorStand armorStand = as; Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, () -> { armorStand.remove(); getLogger().info("Removing Hologram."); } , timeout * 20); }
public static ArmorStand getArmorStand(Location reactor) { Location l = new Location(reactor.getWorld(), reactor.getX() + 0.5, reactor.getY(), reactor.getZ() + 0.5); for (Entity n : l.getChunk().getEntities()) { if (n instanceof ArmorStand) { if (l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n; } } ArmorStand hologram = ArmorStandFactory.createHidden(l); hologram.setCustomNameVisible(false); hologram.setCustomName(null); return hologram; }
public static ArmorStand getArmorStand(Block hopper) { Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY(), hopper.getZ() + 0.5); for (Entity n: l.getChunk().getEntities()) { if (n instanceof ArmorStand) { if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n; } } ArmorStand hologram = ArmorStandFactory.createHidden(l); hologram.setCustomNameVisible(false); hologram.setCustomName(null); return hologram; }
public static ArmorStand getArmorStand(Block hopper) { Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY() + offset, hopper.getZ() + 0.5); for (Entity n: l.getChunk().getEntities()) { if (n instanceof ArmorStand) { if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n; } } ArmorStand hologram = ArmorStandFactory.createHidden(l); hologram.setCustomNameVisible(false); hologram.setCustomName(null); return hologram; }
@SuppressWarnings("deprecation") @Override public void run() { if (arrow.isDead() || !arrow.isValid()) { cancel(); return; } if (arrow.isInBlock() || arrow.isOnGround()) { translocatorPlayerMap.invalidate(arrow.getUniqueId()); playerTranslocatorMap.invalidate(player.getUniqueId()); Location location = arrow.getLocation(); arrow.remove(); ArmorStand armorStand = location.getWorld().spawn(location, ArmorStand.class); armorStand.setCanPickupItems(false); armorStand.setSmall(true); armorStand.setMarker(false); armorStand.setPersistent(false); armorStand.setCustomName(I18n.format("message.translocator", player.getName())); armorStand.setCustomNameVisible(true); playerTranslocatorMap.put(player.getUniqueId(), armorStand.getUniqueId()); translocatorPlayerMap.put(armorStand.getUniqueId(), player.getUniqueId()); cancel(); } } }.runTaskTimer(plugin, 0L, 5L);
public static ArmorStand getArmorStand(Block hopper) { Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY() + offset, hopper.getZ() + 0.5); for (Entity n: l.getChunk().getEntities()) { if (n instanceof ArmorStand) { if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n; } } ArmorStand hologram = ArmorStandFactory.createHidden(l); hologram.setCustomNameVisible(false); hologram.setCustomName(null); return hologram; }
private static ArmorStand getArmorStand(Block b) { Location l = new Location(b.getWorld(), b.getX() + 0.5, b.getY() + offset, b.getZ() + 0.5); for (Entity n: l.getChunk().getEntities()) { if (n instanceof ArmorStand) { if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n; } } ArmorStand hologram = ArmorStandFactory.createHidden(l); hologram.setCustomNameVisible(false); hologram.setCustomName(null); return hologram; }
public static ArmorStand getArmorStand(Block hopper, boolean createIfNoneFound) { Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY() + offset, hopper.getZ() + 0.5); for (Entity n: l.getChunk().getEntities()) { if (n instanceof ArmorStand) { if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n; } } if (!createIfNoneFound) { return null; } ArmorStand hologram = ArmorStandFactory.createHidden(l); hologram.setCustomNameVisible(false); hologram.setCustomName(null); return hologram; }
CustomHitbox(Location location, BukkitBall ball) { super(((CraftWorld) location.getWorld()).getHandle()); this.ball = ball; final World mcWorld = ((CraftWorld) location.getWorld()).getHandle(); this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.a(compound); this.getSpigotEntity().setCustomName("ResourceBallsPlugin"); this.getSpigotEntity().setCustomNameVisible(false); }
CustomHitbox(Location location, BukkitBall ball) { super(((CraftWorld) location.getWorld()).getHandle()); this.ball = ball; final World mcWorld = ((CraftWorld) location.getWorld()).getHandle(); this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.a(compound); this.getSpigotEntity().setCustomName("ResourceBallsPlugin"); this.getSpigotEntity().setCustomNameVisible(false); }
CustomHitbox(Location location, BukkitBall ball) { super(((CraftWorld) location.getWorld()).getHandle()); this.ball = ball; final World mcWorld = ((CraftWorld) location.getWorld()).getHandle(); this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.a(compound); this.getSpigotEntity().setCustomName("ResourceBallsPlugin"); this.getSpigotEntity().setCustomNameVisible(false); }
CustomHitbox(Location location, BukkitBall ball) { super(((CraftWorld) location.getWorld()).getHandle()); this.ball = ball; final World mcWorld = ((CraftWorld) location.getWorld()).getHandle(); this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.a(compound); this.getSpigotEntity().setCustomName("ResourceBallsPlugin"); this.getSpigotEntity().setCustomNameVisible(false); }
CustomHitbox(Location location, BukkitBall ball) { super(((CraftWorld) location.getWorld()).getHandle()); this.ball = ball; final World mcWorld = ((CraftWorld) location.getWorld()).getHandle(); this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.a(compound); this.getSpigotEntity().setCustomName("ResourceBallsPlugin"); this.getSpigotEntity().setCustomNameVisible(false); }
CustomHitbox(Location location, BukkitBall ball) { super(((CraftWorld) location.getWorld()).getHandle()); this.ball = ball; final World mcWorld = ((CraftWorld) location.getWorld()).getHandle(); this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.a(compound); this.getSpigotEntity().setCustomName("ResourceBallsPlugin"); this.getSpigotEntity().setCustomNameVisible(false); }
CustomHitbox(Location location, BukkitBall ball) { super(((CraftWorld) location.getWorld()).getHandle()); this.ball = ball; final World mcWorld = ((CraftWorld) location.getWorld()).getHandle(); this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.a(compound); this.getSpigotEntity().setCustomName("ResourceBallsPlugin"); this.getSpigotEntity().setCustomNameVisible(false); }
CustomHitbox(Location location, BukkitBall ball) { super(((CraftWorld) location.getWorld()).getHandle()); this.ball = ball; final World mcWorld = ((CraftWorld) location.getWorld()).getHandle(); this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.a(compound); this.getSpigotEntity().setCustomName("ResourceBallsPlugin"); this.getSpigotEntity().setCustomNameVisible(false); }
CustomHitbox(Location location, BukkitBall ball) { super(((CraftWorld) location.getWorld()).getHandle()); this.ball = ball; final World mcWorld = ((CraftWorld) location.getWorld()).getHandle(); this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.a(compound); this.getSpigotEntity().setCustomName("ResourceBallsPlugin"); this.getSpigotEntity().setCustomNameVisible(false); }
this.a(compound); this.getSpigotEntity().setCustomName("ResourceBallsPlugin"); this.getSpigotEntity().setCustomNameVisible(false); final ItemStack itemStack = new ItemStack(Material.SKULL_ITEM, 1, (short) 3); try {