类org.bukkit.entity.Wither源码实例Demo

下面列出了怎么用org.bukkit.entity.Wither的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: CloudNet   文件: ReflectionUtil.java
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;
}
 
源代码2 项目: Skript   文件: DefaultComparators.java
@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;
	}
}
 
源代码3 项目: uSkyBlock   文件: SpawnEvents.java
@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()));
        }
    }
}
 
源代码4 项目: uSkyBlock   文件: GriefEvents.java
@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());
    }
}
 
源代码5 项目: uSkyBlock   文件: GriefEvents.java
@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());
    }
}
 
源代码6 项目: uSkyBlock   文件: GriefEvents.java
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);
    }
}
 
源代码7 项目: uSkyBlock   文件: GriefEvents.java
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."));
        }
    }
}
 
源代码8 项目: uSkyBlock   文件: GriefEvents.java
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;
}
 
源代码9 项目: Slimefun4   文件: WitherListener.java
@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());
            }
        }
    }
}
 
源代码10 项目: Slimefun4   文件: WitherProofBlock.java
@Override
public void onAttack(Block block, Wither wither) {
    // In this implementation we simply do nothing.
}
 
源代码11 项目: askyblock   文件: FlyingMobEvents.java
/**
 * 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);
                }
            }
        }
    }
}
 
源代码12 项目: Slimefun4   文件: WitherProof.java
/**
 * 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);
 
 类所在包
 类方法
 同包方法