本文整理汇总了Java中org.bukkit.entity.Wither类的典型用法代码示例。如果您正苦于以下问题:Java Wither类的具体用法?Java Wither怎么用?Java Wither使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Wither类属于org.bukkit.entity包,在下文中一共展示了Wither类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: armorstandCreation
import org.bukkit.entity.Wither; //导入依赖的package包/类
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: onEntityChangeBlock
import org.bukkit.entity.Wither; //导入依赖的package包/类
@EventHandler(priority=EventPriority.LOWEST)
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
if (e.getEntity() instanceof FallingBlock) {
if (Variables.blocks.contains(e.getEntity().getUniqueId())) {
e.setCancelled(true);
e.getEntity().remove();
}
}
else if (e.getEntity() instanceof Wither) {
SlimefunItem item = BlockStorage.check(e.getBlock());
if (item != null) {
if (item.getName().equals("WITHER_PROOF_OBSIDIAN")) e.setCancelled(true);
if (item.getName().equals("WITHER_PROOF_GLASS")) e.setCancelled(true);
}
}
}
示例3: compare
import org.bukkit.entity.Wither; //导入依赖的package包/类
@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;
}
}
示例4: onCreatureSpawn
import org.bukkit.entity.Wither; //导入依赖的package包/类
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
if (event == null || event.isCancelled() || event.getLocation() == null || !plugin.isSkyWorld(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.isCancelled() && event.getEntity() instanceof Squid) {
Location loc = event.getLocation();
int z = loc.getBlockZ();
int x = loc.getBlockX();
if (loc.getWorld().getBiome(x, z) == Biome.DEEP_OCEAN && LocationUtil.findRoofBlock(loc).getType() == Material.PRISMARINE) {
loc.getWorld().spawnEntity(loc, EntityType.GUARDIAN);
event.setCancelled(true);
}
}
if (!event.isCancelled() && 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()));
}
}
}
示例5: onEntityChangeBlock
import org.bukkit.entity.Wither; //导入依赖的package包/类
@EventHandler(priority=EventPriority.LOWEST)
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
if (e.getEntity() instanceof FallingBlock) {
if (Variables.blocks.contains(e.getEntity().getUniqueId())) {
e.setCancelled(true);
e.getEntity().remove();
}
}
else if (e.getEntity() instanceof Wither) {
SlimefunItem item = BlockStorage.check(e.getBlock());
if (item != null) {
if (item.getID().equals("WITHER_PROOF_OBSIDIAN")) e.setCancelled(true);
if (item.getID().equals("WITHER_PROOF_GLASS")) e.setCancelled(true);
}
}
}
示例6: announce
import org.bukkit.entity.Wither; //导入依赖的package包/类
public void announce(String message, AnnouncementType at, Player[] players) throws IllegalArgumentException {
if(at == AnnouncementType.BOSS_HEALTH) {
for(Player p : players) {
final Wither w = (Wither) p.getWorld().spawnEntity(p.getLocation(), EntityType.WITHER);
final Location l = w.getLocation();
w.setCustomName(message);
plugin.getServer().getScheduler().runTaskLater(plugin, new BukkitRunnable() {
public void run() {
w.remove();
}
}, 500);
plugin.getServer().getScheduler().runTaskTimer(plugin, new BukkitRunnable() {
public void run() {
w.teleport(l);
}
}, 0, 1);
}
}
}
示例7: onWitherChangeBlock
import org.bukkit.entity.Wither; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onWitherChangeBlock(EntityChangeBlockEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Wither || entity instanceof EnderDragon) {
event.setCancelled(true);
}
}
示例8: onEntityDamageByEntityListener
import org.bukkit.entity.Wither; //导入依赖的package包/类
@EventHandler
public void onEntityDamageByEntityListener(EntityDamageByEntityEvent e)
{
User user = null;
if (e.getDamager() instanceof Player)
{
user = MWAPI.getUserHandler().findById(e.getDamager().getUniqueId());
}
else if (e.getDamager() instanceof Projectile)
{
Projectile p = (Projectile) e.getDamager();
if (p.getShooter() instanceof Player)
{
user = MWAPI.getUserHandler().findById(((Player) p.getShooter()).getUniqueId());
}
}
if (user == null || !user.isPlaying()) return;
if (e.getEntity() instanceof Wither)
{
Wither wither = (Wither) e.getEntity();
if (((BasicWither) user.getGame().getTeam(user).getWither()).getWither().getEntityId().equals(wither.getUniqueId()))
{
e.setCancelled(true);
}
}
else if (e.getEntity() instanceof Player)
{
User target = MWAPI.getUserHandler().findById(e.getEntity().getUniqueId());
if (target.getGame().getTeam(target).getTeamColor() == user.getGame().getTeam(user).getTeamColor())
{
e.setCancelled(true);
}
}
}
示例9: onCreatureSpawn
import org.bukkit.entity.Wither; //导入依赖的package包/类
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
RedProtect.get().logger.debug("RPGlobalListener - Is CreatureSpawnEvent event! Cancelled? " + event.isCancelled());
if (event.isCancelled()) {
return;
}
Entity e = event.getEntity();
if (e == null) {
return;
}
Location l = event.getLocation();
Region r = RedProtect.get().rm.getTopRegion(l);
if (r != null){
return;
}
if (e instanceof Wither && event.getSpawnReason().equals(SpawnReason.BUILD_WITHER) && !RPConfig.getGlobalFlagBool(e.getWorld().getName()+".spawn-wither")){
event.setCancelled(true);
return;
}
if (e instanceof Monster && !RPConfig.getGlobalFlagBool(e.getWorld().getName()+".spawn-monsters")) {
if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.NATURAL)
|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER)
|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.CHUNK_GEN)
|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.DEFAULT)) {
event.setCancelled(true);
return;
}
}
if ((e instanceof Animals || e instanceof Villager || e instanceof Golem) && !RPConfig.getGlobalFlagBool(e.getWorld().getName()+".spawn-passives")) {
if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.NATURAL)
|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER)
|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.CHUNK_GEN)
|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.DEFAULT)) {
event.setCancelled(true);
}
}
}
示例10: onTargeting
import org.bukkit.entity.Wither; //导入依赖的package包/类
@EventHandler
public void onTargeting(EntityTargetLivingEntityEvent e) {
if (!witherEnabled || e == null || e.isCancelled() || !plugin.isSkyAssociatedWorld(e.getEntity().getWorld())) {
return;
}
if (e.getEntity() instanceof Wither && e.getTarget() != null) {
handleWitherRampage(e, (Wither) e.getEntity(), e.getTarget().getLocation());
}
}
示例11: onWitherSkullExplosion
import org.bukkit.entity.Wither; //导入依赖的package包/类
@EventHandler
public void onWitherSkullExplosion(EntityDamageByEntityEvent e) {
if (!witherEnabled || e == null || !(e.getEntity() instanceof WitherSkull) || !plugin.isSkyAssociatedWorld(e.getEntity().getWorld())) {
return;
}
// Find owner
ProjectileSource shooter = ((WitherSkull) e.getEntity()).getShooter();
if (shooter instanceof Wither) {
handleWitherRampage(e, (Wither) shooter, e.getDamager().getLocation());
}
}
示例12: handleWitherRampage
import org.bukkit.entity.Wither; //导入依赖的package包/类
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);
}
}
示例13: checkWitherLeash
import org.bukkit.entity.Wither; //导入依赖的package包/类
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."));
}
}
}
示例14: getOwningIsland
import org.bukkit.entity.Wither; //导入依赖的package包/类
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;
}
示例15: onMobSpawn
import org.bukkit.entity.Wither; //导入依赖的package包/类
@EventHandler
public void onMobSpawn(CreatureSpawnEvent event) {
LivingEntity mob = event.getEntity();
if (mob instanceof Wither) {
if (NoWither.getWitherSetting()) {
//TODO display message to player
event.setCancelled(true);
NoWither.log("Wither spawn averted");
}
}
}