org.bukkit.entity.Wither Java Examples
The following examples show how to use
org.bukkit.entity.Wither.
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: ReflectionUtil.java From CloudNet with Apache License 2.0 | 6 votes |
public static Object armorstandCreation(Location location, Entity entity, ServerMob serverMob) { try { Object armorstand = entity.getWorld().spawnEntity(entity.getLocation() .clone() .add(0, ((LivingEntity) entity).getEyeHeight() - (entity instanceof Wither ? 0.15 : 0.3), 0), EntityType.valueOf("ARMOR_STAND")); armorstand.getClass().getMethod("setVisible", boolean.class).invoke(armorstand, false); armorstand.getClass().getMethod("setCustomNameVisible", boolean.class).invoke(armorstand, true); armorstand.getClass().getMethod("setGravity", boolean.class).invoke(armorstand, false); armorstand.getClass().getMethod("setBasePlate", boolean.class).invoke(armorstand, false); armorstand.getClass().getMethod("setSmall", boolean.class).invoke(armorstand, true); armorstand.getClass().getMethod("setCanPickupItems", boolean.class).invoke(armorstand, false); return armorstand; } catch (Exception ex) { ex.printStackTrace(); } return null; }
Example #2
Source File: DefaultComparators.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override public Relation compare(final DamageCause dc, final EntityData e) { switch (dc) { case ENTITY_ATTACK: return Relation.get(e.isSupertypeOf(EntityData.fromClass(Entity.class))); case PROJECTILE: return Relation.get(e.isSupertypeOf(EntityData.fromClass(Projectile.class))); case WITHER: return Relation.get(e.isSupertypeOf(EntityData.fromClass(Wither.class))); case FALLING_BLOCK: return Relation.get(e.isSupertypeOf(EntityData.fromClass(FallingBlock.class))); //$CASES-OMITTED$ default: return Relation.NOT_EQUAL; } }
Example #3
Source File: SpawnEvents.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { if (event == null || !plugin.getWorldManager().isSkyAssociatedWorld(event.getLocation().getWorld())) { return; // Bail out, we don't care } if (!event.isCancelled() && ADMIN_INITIATED.contains(event.getSpawnReason())) { return; // Allow it, the above method would have blocked it if it should be blocked. } checkLimits(event, event.getEntity().getType(), event.getLocation()); if (event.getEntity() instanceof WaterMob) { Location loc = event.getLocation(); if (isDeepOceanBiome(loc) && isPrismarineRoof(loc)) { loc.getWorld().spawnEntity(loc, EntityType.GUARDIAN); event.setCancelled(true); } } if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.BUILD_WITHER && event.getEntity() instanceof Wither) { IslandInfo islandInfo = plugin.getIslandInfo(event.getLocation()); if (islandInfo != null && islandInfo.getLeader() != null) { event.getEntity().setCustomName(I18nUtil.tr("{0}''s Wither", islandInfo.getLeader())); event.getEntity().setMetadata("fromIsland", new FixedMetadataValue(plugin, islandInfo.getName())); } } }
Example #4
Source File: GriefEvents.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onTargeting(EntityTargetLivingEntityEvent e) { if (!witherEnabled || !plugin.getWorldManager().isSkyAssociatedWorld(e.getEntity().getWorld())) { return; } if (e.getEntity() instanceof Wither && e.getTarget() != null) { handleWitherRampage(e, (Wither) e.getEntity(), e.getTarget().getLocation()); } }
Example #5
Source File: GriefEvents.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onWitherSkullExplosion(EntityDamageByEntityEvent e) { if (!witherEnabled || !(e.getEntity() instanceof WitherSkull) || !plugin.getWorldManager().isSkyAssociatedWorld(e.getEntity().getWorld())) { return; } // Find owner ProjectileSource shooter = ((WitherSkull) e.getEntity()).getShooter(); if (shooter instanceof Wither) { handleWitherRampage(e, (Wither) shooter, e.getDamager().getLocation()); } }
Example #6
Source File: GriefEvents.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
private void handleWitherRampage(Cancellable e, Wither shooter, Location targetLocation) { String islandName = getOwningIsland(shooter); String targetIsland = WorldGuardHandler.getIslandNameAt(targetLocation); if (targetIsland == null || !targetIsland.equals(islandName)) { e.setCancelled(true); checkWitherLeash(shooter, islandName); } }
Example #7
Source File: GriefEvents.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
private void checkWitherLeash(Wither shooter, String islandName) { String currentIsland = WorldGuardHandler.getIslandNameAt(shooter.getLocation()); if (currentIsland == null || !currentIsland.equals(islandName)) { shooter.remove(); IslandInfo islandInfo = plugin.getIslandInfo(islandName); if (islandInfo != null) { islandInfo.sendMessageToOnlineMembers(I18nUtil.tr("\u00a7cWither Despawned!\u00a7e It wandered too far from your island.")); } } }
Example #8
Source File: GriefEvents.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
private String getOwningIsland(Wither wither) { if (wither.hasMetadata("fromIsland")) { return wither.getMetadata("fromIsland").get(0).asString(); } try { Object[] parse = new MessageFormat(I18nUtil.marktr("{0}''s Wither")).parse(wither.getCustomName()); if (parse != null && parse.length == 1 && parse[0] instanceof String) { return (String) parse[0]; } } catch (ParseException e) { // Ignore } return null; }
Example #9
Source File: WitherListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onWitherDestroy(EntityChangeBlockEvent e) { if (e.getEntity().getType() == EntityType.WITHER) { String id = BlockStorage.checkID(e.getBlock()); if (id != null) { WitherProof witherproof = SlimefunPlugin.getRegistry().getWitherProofBlocks().get(id); if (witherproof != null) { e.setCancelled(true); witherproof.onAttack(e.getBlock(), (Wither) e.getEntity()); } } } }
Example #10
Source File: WitherProofBlock.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
@Override public void onAttack(Block block, Wither wither) { // In this implementation we simply do nothing. }
Example #11
Source File: FlyingMobEvents.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Deal with pre-explosions */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void WitherExplode(final ExplosionPrimeEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } // Only cover withers in the island world if (!IslandGuard.inWorld(e.getEntity()) || e.getEntity() == null) { return; } // The wither or wither skulls can both blow up if (e.getEntityType() == EntityType.WITHER) { //plugin.getLogger().info("DEBUG: Wither"); // Check the location if (mobSpawnInfo.containsKey(e.getEntity())) { // We know about this wither if (DEBUG) { plugin.getLogger().info("DEBUG: We know about this wither"); } if (!mobSpawnInfo.get(e.getEntity()).inIslandSpace(e.getEntity().getLocation())) { // Cancel the explosion if (DEBUG) { plugin.getLogger().info("DEBUG: cancelling wither pre-explosion"); } e.setCancelled(true); } } // Testing only e.setCancelled(true); } if (e.getEntityType() == EntityType.WITHER_SKULL) { //plugin.getLogger().info("DEBUG: Wither skull"); // Get shooter Projectile projectile = (Projectile)e.getEntity(); if (projectile.getShooter() instanceof Wither) { //plugin.getLogger().info("DEBUG: shooter is wither"); Wither wither = (Wither)projectile.getShooter(); // Check the location if (mobSpawnInfo.containsKey(wither)) { // We know about this wither if (DEBUG) { plugin.getLogger().info("DEBUG: We know about this wither"); } if (!mobSpawnInfo.get(wither).inIslandSpace(e.getEntity().getLocation())) { // Cancel the explosion if (DEBUG) { plugin.getLogger().info("DEBUG: cancel wither skull explosion"); } e.setCancelled(true); } } } } }
Example #12
Source File: WitherProof.java From Slimefun4 with GNU General Public License v3.0 | 2 votes |
/** * This method is called when a {@link Wither} tried to attack the given {@link Block}. * You can use this method to play particles or even damage the {@link Wither}. * * @param block * The {@link Block} which was attacked. * @param wither * The {@link Wither} who attacked. */ void onAttack(Block block, Wither wither);