Java Code Examples for org.bukkit.entity.ArmorStand#remove()
The following examples show how to use
org.bukkit.entity.ArmorStand#remove() .
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: SitListener.java From NyaaUtils with MIT License | 6 votes |
@EventHandler public void onDismount(EntityDismountEvent event) { if (event.getDismounted() instanceof ArmorStand) { ArmorStand armorStand = (ArmorStand) event.getDismounted(); if (armorStand.hasMetadata(metadata_key)) { for (Entity p : armorStand.getPassengers()) { if (p.isValid()) { Location loc = safeLocations.get(p.getUniqueId()); safeLocations.remove(p.getUniqueId()); new BukkitRunnable() { @Override public void run() { if (p.isValid() && loc != null) { p.teleport(loc); } } }.runTask(plugin); } } } armorStand.remove(); } }
Example 2
Source File: DeathStandsModule.java From UHC with MIT License | 6 votes |
@EventHandler public void on(PlayerArmorStandManipulateEvent event) { final ArmorStand stand = event.getRightClicked(); if (!isProtectedArmourStand(stand)) return; final ItemStack players = event.getPlayerItem(); final ItemStack stands = event.getArmorStandItem(); // if the player is holding something it will be a swap if (players == null || players.getType() != Material.AIR) return; // if the stand hasn't got something then the player is adding // items or nothing will happen if (stands == null || stands.getType() == Material.AIR) return; // they're removing an item from the armour stand. If there // is only 1 item on the stand then this is the final item // on the armour stand so kill it (fire optional) if (Maps.filterValues(getItems(stand), Predicates.not(EMPTY_ITEM)).values().size() == 1) { stand.remove(); } }
Example 3
Source File: AreaTarget.java From Civs with GNU General Public License v3.0 | 5 votes |
public Set<?> getTargets() { int level = getLevel(); Spell spell = getSpell(); Set<LivingEntity> returnSet = new HashSet<>(); if (!(getOrigin() instanceof LivingEntity)) { return returnSet; } LivingEntity player = (LivingEntity) getOrigin(); ConfigurationSection config = getConfig(); int range = (int) Math.round(Spell.getLevelAdjustedValue(getConfig().getString("range","15"), level, null, spell)); int radius = (int) Math.round(Spell.getLevelAdjustedValue(getConfig().getString("radius", "5"), level, null, spell)); int maxTargets = (int) Math.round(Spell.getLevelAdjustedValue(getConfig().getString("max-targets", "-1"), level, null, spell)); Collection<Entity> nearbyEntities; if (range < 1) { nearbyEntities = player.getNearbyEntities(radius, radius, radius); } else { HashSet<Material> materialHashSet = new HashSet<>(); Location center = player.getTargetBlock(materialHashSet, range).getLocation(); center = applyTargetSettings(center); ArmorStand removeMe = (ArmorStand) center.getWorld().spawnEntity(center, EntityType.ARMOR_STAND); removeMe.setVisible(false); nearbyEntities = removeMe.getNearbyEntities(radius, radius, radius); removeMe.remove(); } for (Entity target : nearbyEntities) { if (maxTargets > 0 && returnSet.size() >= maxTargets) { break; } if (target != player && target instanceof LivingEntity) { returnSet.add((LivingEntity) target); } } return returnSet; }
Example 4
Source File: Main.java From ArmorStandTools with MIT License | 5 votes |
void returnArmorStand(ArmorStand as) { if(as.hasMetadata("startLoc")) { for (MetadataValue value : as.getMetadata("startLoc")) { if (value.getOwningPlugin() == this) { as.teleport((Location) value.value()); as.removeMetadata("startLoc", this); return; } } } as.remove(); }
Example 5
Source File: DeathStandsModule.java From UHC with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void on(EntityDamageEvent event) { if (event.getEntityType() != EntityType.ARMOR_STAND) return; if (!isProtectedArmourStand(event.getEntity())) return; // always cancel events, we choose when to break the stand event.setCancelled(true); final ArmorStand stand = (ArmorStand) event.getEntity(); final Location loc = stand.getLocation(); final World world = stand.getWorld(); // for the first 2 seconds don't allow breaking // to avoid accidental breaks after kill if (event.getEntity().getTicksLived() < 2 * TICKS_PER_SECOND) { world.playEffect(stand.getEyeLocation(), Effect.WITCH_MAGIC, 0); return; } // drop each of it's worn items for (final ItemStack stack : Maps.filterValues(getItems(stand), Predicates.not(EMPTY_ITEM)).values()) { world.dropItemNaturally(loc, stack); } // kill the stand now stand.remove(); }
Example 6
Source File: HologramProjector.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
private static void remove(Block b) { ArmorStand hologram = getArmorStand(b, false); if (hologram != null) { hologram.remove(); } }
Example 7
Source File: SitListener.java From NyaaUtils with MIT License | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onClickBlock(PlayerInteractEvent event) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasBlock() && !event.hasItem()) { Block block = event.getClickedBlock(); BlockFace face = event.getBlockFace(); if (face == BlockFace.DOWN || block.isLiquid() || !plugin.cfg.sit_blocks.contains(block.getType())) { return; } Block relative = block.getRelative(0, 1, 0); Player player = event.getPlayer(); if (messageCooldown.getIfPresent(player.getUniqueId()) != null) { return; } messageCooldown.put(player.getUniqueId(), true); if (!player.hasPermission("nu.sit") || !enabledPlayers.contains(player.getUniqueId()) || player.isInsideVehicle() || !player.getPassengers().isEmpty() || player.getGameMode() == GameMode.SPECTATOR || !player.isOnGround()) { return; } if (relative.isLiquid() || !(relative.isEmpty() || relative.isPassable())) { player.sendMessage(I18n.format("user.sit.invalid_location")); return; } Vector vector = block.getBoundingBox().getCenter().clone(); Location loc = vector.setY(block.getBoundingBox().getMaxY()).toLocation(player.getWorld()).clone(); for (SitLocation sl : plugin.cfg.sit_locations.values()) { if (sl.blocks != null && sl.x != null && sl.y != null && sl.z != null && sl.blocks.contains(block.getType().name())) { loc.add(sl.x, sl.y, sl.z); } } if (block.getBlockData() instanceof Directional) { face = ((Directional) block.getBlockData()).getFacing(); if (face == BlockFace.EAST) { loc.setYaw(90); } else if (face == BlockFace.WEST) { loc.setYaw(-90); } else if (face == BlockFace.NORTH) { loc.setYaw(0); } else if (face == BlockFace.SOUTH) { loc.setYaw(-180); } } else { if (face == BlockFace.WEST) { loc.setYaw(90); } else if (face == BlockFace.EAST) { loc.setYaw(-90); } else if (face == BlockFace.SOUTH) { loc.setYaw(0); } else if (face == BlockFace.NORTH) { loc.setYaw(-180); } else { loc.setYaw(player.getEyeLocation().getYaw()); } } for (Entity e : loc.getWorld().getNearbyEntities(loc, 0.5, 0.7, 0.5)) { if (e instanceof LivingEntity) { if (e.hasMetadata(metadata_key) || (e instanceof Player && e.isInsideVehicle() && e.getVehicle().hasMetadata(metadata_key))) { player.sendMessage(I18n.format("user.sit.invalid_location")); return; } } } Location safeLoc = player.getLocation().clone(); ArmorStand armorStand = loc.getWorld().spawn(loc, ArmorStand.class, (e) -> { e.setVisible(false); e.setPersistent(false); e.setCanPickupItems(false); e.setBasePlate(false); e.setArms(false); e.setMarker(true); e.setInvulnerable(true); e.setGravity(false); }); if (armorStand != null) { armorStand.setMetadata(metadata_key, new FixedMetadataValue(plugin, true)); if (armorStand.addPassenger(player)) { safeLocations.put(player.getUniqueId(), safeLoc); } else { armorStand.remove(); } } } }