当前位置: 首页>>代码示例>>Java>>正文


Java EnderDragon类代码示例

本文整理汇总了Java中org.bukkit.entity.EnderDragon的典型用法代码示例。如果您正苦于以下问题:Java EnderDragon类的具体用法?Java EnderDragon怎么用?Java EnderDragon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EnderDragon类属于org.bukkit.entity包,在下文中一共展示了EnderDragon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: walkToPlayer

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
public static void walkToPlayer(Entity e, Player p) {
    // Tamed animals already handle their own following
    if (e instanceof Tameable) {
        if (((Tameable) e).isTamed()) {
            return;
        }
    }
    if (e.getPassenger() instanceof Player) {
        return;
    }

    // Moving the dragon is too buggy
    if (e instanceof EnderDragon) {
        return;
    }
    // Once this is set we can't unset it.
    //((Creature)e).setTarget(p);

    // If the pet is too far just teleport instead of attempt navigation
    if (e.getLocation().distance(p.getLocation()) > 20) {
        e.teleport(p);
    } else {
        Navigation n = ((CraftLivingEntity) e).getHandle().getNavigation();
        n.a(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), 0.30f);
    }
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:27,代码来源:Control.java

示例2: run

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
@Override
public void run() {
	// Ender dragon was not found. Forcibly respawn it
	if (world.getEntitiesByClass(EnderDragon.class).size() == 0) {
		this.plugin.getLogger().warning("Something went wrong! Had to forcibly reset dragon battle...");
		
		this.battle.resetBattleState();
		this.removeCrystals();
		
		plugin.getDEDManager().getWorldWrapper(world).startRespawn(0);
		return;
	}
	
	// Ensure all crystals are not invulnerable
	this.world.getEntitiesByClass(EnderCrystal.class).forEach(c -> {
		c.setInvulnerable(false);
		c.setBeamTarget(null);
	});
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:20,代码来源:RespawnSafeguardRunnable.java

示例3: onPlayerSwitchWorlds

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
@EventHandler
public void onPlayerSwitchWorlds(PlayerChangedWorldEvent event) {
	World world = event.getPlayer().getWorld();
	if (world.getEnvironment() != Environment.THE_END) return;
	
	EndWorldWrapper worldWrapper = manager.getWorldWrapper(world);
	
	// Start the respawn countdown if joining an empty world
	if (plugin.getConfig().getBoolean("respawn-on-join", false)) {
		if (world.getPlayers().size() > 1 || worldWrapper.isRespawnInProgress()
				|| world.getEntitiesByClass(EnderDragon.class).size() == 0) 
			return;
		
		manager.getWorldWrapper(world).startRespawn(RespawnType.JOIN);
	}
	
	// Reset end crystal states just in case something went awry
	if (!worldWrapper.isRespawnInProgress()) {
		world.getEntitiesByClass(EnderCrystal.class).forEach(e -> {
			e.setInvulnerable(false);
			e.setBeamTarget(null);
		});
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:25,代码来源:RespawnListeners.java

示例4: onDragonDeath

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
@EventHandler
public void onDragonDeath(EntityDeathEvent event) {
	if (!(event.getEntity() instanceof EnderDragon)) return;
	
	EnderDragon dragon = (EnderDragon) event.getEntity();
	DragonBattle dragonBattle = plugin.getNMSAbstract().getEnderDragonBattleFromDragon(dragon);
	
	World world = event.getEntity().getWorld();
	EndWorldWrapper worldWrapper = plugin.getDEDManager().getWorldWrapper(world);
	
	BattleStateChangeEvent bscEventCrystals = new BattleStateChangeEvent(dragonBattle, dragon, BattleState.BATTLE_COMMENCED, BattleState.BATTLE_END);
	Bukkit.getPluginManager().callEvent(bscEventCrystals);

	new BukkitRunnable() {
		@Override
		public void run() {
			if (plugin.getNMSAbstract().getEnderDragonDeathAnimationTime(dragon) >= 185) { // Dragon is dead at 200
				new DragonDeathRunnable(plugin, worldWrapper, dragon);
				this.cancel();
			}
		}
	}.runTaskTimer(plugin, 0L, 1L);
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:24,代码来源:DragonLifeListeners.java

示例5: applyToBattle

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
/**
 * Apply this templates data to an EnderDragonBattle object
 * 
 * @param nmsAbstract an instance of the NMSAbstract interface
 * @param dragon the dragon to modify
 * @param battle the battle to modify
 */
public void applyToBattle(NMSAbstract nmsAbstract, EnderDragon dragon, DragonBattle battle) {
	Validate.notNull(nmsAbstract, "Instance of NMSAbstract cannot be null. See DragonEggDrop#getNMSAbstract()");
	Validate.notNull(dragon, "Ender Dragon cannot be null");
	Validate.notNull(battle, "Instance of DragonBattle cannot be null");
	
	if (name != null) {
		dragon.setCustomName(name);
		battle.setBossBarTitle(name);
	}
	
	battle.setBossBarStyle(barStyle, barColour);
	this.attributes.forEach((a, v) -> {
		AttributeInstance attribute = dragon.getAttribute(a);
		if (attribute != null) {
			attribute.setBaseValue(v);
		}
	});
	
	// Set health... max health attribute doesn't do that for me. -,-
	if (attributes.containsKey(Attribute.GENERIC_MAX_HEALTH)) {
		dragon.setHealth(attributes.get(Attribute.GENERIC_MAX_HEALTH));
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:31,代码来源:DragonTemplate.java

示例6: onDragonCreatesPortal

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public void onDragonCreatesPortal(EntityCreatePortalEvent event)
{
	if (event.isCancelled())
		return;
	
	Entity entity = event.getEntity();

	if (!(entity instanceof EnderDragon))
		return;
	
	log("The dragon has been killed!");
	
	Location enderEggLoc = entity.getLocation();
	
	if (enderEggLoc != null) {
		End.getBlockAt(enderEggLoc).setTypeId(122);
	} else {
		log("Failed to process portal, cancelling event anyway!");
	}
	event.setCancelled(true);
}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:23,代码来源:EndDragonRespawn.java

示例7: RemoteEnderDragon

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
public RemoteEnderDragon(int inID, RemoteEnderDragonEntity inEntity, EntityManager inManager)
{
	super(inID, RemoteEntityType.EnderDragon, inManager);
	this.m_entity = inEntity;

	Bukkit.getPluginManager().registerEvents(new Listener() {
			@EventHandler
			public void onEntityExplode(EntityExplodeEvent event)
			{
				if(event.getEntity() instanceof EnderDragon)
				{
					if(event.getEntity() == getBukkitEntity() && !shouldDestroyBlocks())
						event.setCancelled(true);
				}
				else if(event.getEntity() instanceof ComplexEntityPart)
				{
					if(((ComplexEntityPart)event.getEntity()).getParent() == getBukkitEntity() && !shouldDestroyBlocks())
						event.setCancelled(true);
				}
			}
		}, this.m_manager.getPlugin()
	);
}
 
开发者ID:MeRPG2,项目名称:EndHQ-Libraries,代码行数:24,代码来源:RemoteEnderDragon.java

示例8: onEndChunkUnload

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
/**
 * Remove the unloaded EnderDragons from the loaded set
 *
 * @param event a Chunk Unload Event
 */
@EventHandler(priority = EventPriority.NORMAL)
public void onEndChunkUnload(final ChunkUnloadEvent event) {
    if (event.getWorld().getEnvironment() == Environment.THE_END) {
        final String worldName = event.getWorld().getName();
        final EndWorldHandler handler = this.plugin.getHandler(StringUtil.toLowerCamelCase(worldName));
        if (handler != null) {
            EndChunk chunk = handler.getChunks().getChunk(event.getChunk());
            if (chunk == null) {
                chunk = handler.getChunks().addChunk(event.getChunk());
            }
            for (final Entity e : event.getChunk().getEntities()) {
                if (e.getType() == EntityType.ENDER_DRAGON) {
                    final EnderDragon ed = (EnderDragon)e;
                    handler.getLoadedDragons().remove(ed.getUniqueId());
                    chunk.incrementSavedDragons();
                }
            }
        }
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:26,代码来源:ChunkListener.java

示例9: run

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
@Override
public void run() {
    boolean found = false;

    final Iterator<UUID> it = this.handler.getLoadedDragons().iterator();
    final Collection<EnderDragon> dragons = this.handler.getEndWorld().getEntitiesByClass(EnderDragon.class);
    while (it.hasNext()) {
        final UUID id = it.next();
        for (final EnderDragon ed : dragons) {
            if (id == ed.getUniqueId()) {
                found = true;
                break;
            }
        }
        if (!found) {
            // This EnderDragon was deleted some other way than after his death, forget about him
            this.handler.getDragons().remove(id);
            it.remove();
            for (final String line : this.message) {
                this.handler.getPlugin().getLogger().warning(line);
            }
        }
        found = false;
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:26,代码来源:UnexpectedDragonDeathHandlerTask.java

示例10: ControllableEnderDragonBase

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
public ControllableEnderDragonBase(int id, EntityManager manager) {
    super(id, ControllableEntityType.ENDERDRAGON, manager);
    Bukkit.getPluginManager().registerEvents(new Listener() {

        @EventHandler
        public void onEntityExplode(EntityExplodeEvent event) {
            if (!shouldDestroyBlocks()) {
                Entity entity = event.getEntity();
                if (entity instanceof EnderDragon && entity.equals(getBukkitEntity())) {
                    event.setCancelled(true);
                } else if (entity instanceof ComplexEntityPart && ((ComplexEntityPart) entity).getParent().equals(getBukkitEntity())) {
                    event.setCancelled(true);
                }
            }
        }

    }, EntityAPI.getCore());
}
 
开发者ID:EntityAPIDev,项目名称:EntityAPI,代码行数:19,代码来源:ControllableEnderDragonBase.java

示例11: onEntityExplode

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
@EventHandler(ignoreCancelled = false, priority = EventPriority.HIGH)
public void onEntityExplode(EntityExplodeEvent event) {
    event.blockList().clear();
    if (event.getEntity() instanceof EnderDragon) {
        event.setCancelled(true);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:8,代码来源:WorldListener.java

示例12: onWitherChangeBlock

import org.bukkit.entity.EnderDragon; //导入依赖的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);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:8,代码来源:WorldListener.java

示例13: readTempData

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
private void readTempData(File file) {
	try (FileReader reader = new FileReader(tempDataFile)) {
		JsonObject root = GSON.fromJson(reader, JsonObject.class);
		if (root == null) return;
		
		for (Entry<String, JsonElement> entry : root.entrySet()) {
			World world = Bukkit.getWorld(entry.getKey());
			if (world == null) return;
			
			EndWorldWrapper wrapper = dedManager.getWorldWrapper(world);
			JsonObject element = entry.getValue().getAsJsonObject();
			
			if (element.has("respawnTime")) {
				if (wrapper.isRespawnInProgress()) wrapper.stopRespawn();
				
				wrapper.startRespawn(element.get("respawnTime").getAsInt());
			}
			
			Collection<EnderDragon> dragons = world.getEntitiesByClass(EnderDragon.class);
			if (element.has("activeTemplate") && !dragons.isEmpty()) {
				DragonTemplate template = dedManager.getTemplate(element.get("activeTemplate").getAsString());
				if (template == null) return;
				
				wrapper.setActiveBattle(template);
				template.applyToBattle(nmsAbstract, Iterables.get(dragons, 0), nmsAbstract.getEnderDragonBattleFromWorld(world));
			}
		}
	} catch (IOException | JsonParseException e) {
		e.printStackTrace();
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:32,代码来源:DragonEggDrop.java

示例14: getEnderDragonBattleFromDragon

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
@Override
public DragonBattle getEnderDragonBattleFromDragon(EnderDragon dragon) {
	if (dragon == null) return null;
	
	EntityEnderDragon nmsDragon = ((CraftEnderDragon) dragon).getHandle();
	return new DragonBattle1_10_R1(nmsDragon.cZ());
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:8,代码来源:NMSAbstract1_10_R1.java

示例15: hasBeenPreviouslyKilled

import org.bukkit.entity.EnderDragon; //导入依赖的package包/类
@Override
public boolean hasBeenPreviouslyKilled(EnderDragon dragon) {
	if (dragon == null) return false;
	
	EnderDragonBattle battle = ((DragonBattle1_10_R1) this.getEnderDragonBattleFromDragon(dragon)).getHandle();
	return battle.d();
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:8,代码来源:NMSAbstract1_10_R1.java


注:本文中的org.bukkit.entity.EnderDragon类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。