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


Java EnderCrystal类代码示例

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


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

示例1: spawn

import org.bukkit.entity.EnderCrystal; //导入依赖的package包/类
public void spawn() {
    Location location = data.region().getRandom(match.getRandom()).toLocation(world);
    effects(Sound.BLOCK_NOTE_BASEDRUM, Particle.CLOUD);
    Entity entity = world.spawn(location, (Class) data.appearance().getEntityClass());
    entity.setKnockbackReduction(1);
    data.name().ifPresent(name -> {
        entity.setCustomName(ChatColor.translateAlternateColorCodes('`', name));
        entity.setCustomNameVisible(true);
    });
    switch(data.appearance()) { // TODO: Support more appearances later
        case ENDER_CRYSTAL:
            ifInstance(entity, EnderCrystal.class, crystal -> crystal.setShowingBottom(false)); break;
        case PRIMED_TNT:
            ifInstance(entity, TNTPrimed.class, tnt -> tnt.setFuseTicks(Integer.MAX_VALUE)); break;
    }
    this.entity = Optional.of(entity);
    spawnAt = Optional.empty();
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:19,代码来源:Pickup.java

示例2: run

import org.bukkit.entity.EnderCrystal; //导入依赖的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.EnderCrystal; //导入依赖的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: takeFlag

import org.bukkit.entity.EnderCrystal; //导入依赖的package包/类
public void takeFlag(BPPlayer bpHolder, EnderCrystal flag, Team damagerTeam, Team flagTeam)
{
	int flagTeamId = Team.getId(flagTeam);
	holders[flagTeamId] = bpHolder;
	String holderName = bpHolder.getPVPName();
	isDropped[flagTeamId] = false;
	Player holder = bpHolder.getPlayer();
	
	SoundManager.playTeamSound(game, Sound.ENDERDRAGON_HIT, 1F, 1F, flagTeam);
	SoundManager.playTeamSound(game, Sound.ORB_PICKUP, 1F, 1F, damagerTeam);
	bpHolder.getStatistics().increaseFlagTakes(1);
	Achievement.checkFlagTakes(bpHolder);
	slowDown(holder);
	showHolderEffect(holder, flagTeam);
	colorArmorByFlag(holder, flagTeam);
	giveCompass(holder);
	NametagEditManager.updateNametag(bpHolder);
	bpHolder.setPlayerListName();
	
	if(flagTeam == Team.RED)
		game.broadcast(MessageType.FLAG_TAKE_RED.getTranslation().getValue(holderName));
	else if(flagTeam == Team.BLUE)
		game.broadcast(MessageType.FLAG_TAKE_BLUE.getTranslation().getValue(holderName));
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:25,代码来源:FlagManager.java

示例5: destroyGarbage

import org.bukkit.entity.EnderCrystal; //导入依赖的package包/类
public void destroyGarbage()
{
    int i = 0;
    for (Location loc : DespawningIce)
    {
        loc.getBlock().setType(Material.AIR);
        i++;
    }

    plugin.getLogger().info("Destroying " + i + " undeleted Ice Powerup blocks.");

    List<Track> tracks = plugin.getTrackRegistry().getTracks();
    for (Track track : tracks)
    {
        track.getItemBoxes().forEach(ItemBox::despawn);

        Collection<Marker> markers = track.getMarkerHandler().getMarkers().values();

        for (Marker marker : markers)
        {
            marker.setVisualized(false);
        }

        track.getWorld().getEntities().stream().filter(e -> e instanceof EnderCrystal || e instanceof Horse || e.hasMetadata("MarkerLocation") || e.getName().startsWith("§9Marker")).forEach(Entity::remove);
    }
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:27,代码来源:GarbageControl.java

示例6: reloadConfigs

import org.bukkit.entity.EnderCrystal; //导入依赖的package包/类
public void reloadConfigs()
{
    reloadConfig();
    //EquestrianDash.getInstance().setupItemBoxes();

    getTrackRegistry().getTracks().forEach(track -> {
        track.getWorld().getEntitiesByClass(EnderCrystal.class).forEach(EnderCrystal::remove);
        track.reloadTrackData();
        track.reloadItemBoxData();

        new BukkitRunnable()
        {
            @Override
            public void run()
            {
                track.getItemBoxes().stream().filter(itembox -> itembox.getEnderCrystal() == null || itembox.getEnderCrystal().isDead()).forEach(ItemBox::spawn);
            }
        }.runTaskLater(plugin, 1);
    });
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:21,代码来源:EquestrianDash.java

示例7: despawnEntities

import org.bukkit.entity.EnderCrystal; //导入依赖的package包/类
public static void despawnEntities(Entity[] list) {
    for (Entity e : list) {
        if (e == null || e.getUniqueId() == null)
            continue;
        if (e instanceof Player)
            continue;
        try {
            if (MobManager.spawnedMobs != null && MobManager.spawnedMobs.containsKey(e.getUniqueId())) {
                MobManager.spawnedMobs.get(e.getUniqueId()).despawn();
            }
            if (NPCManager.npcs != null && NPCManager.npcs.containsKey(e.getUniqueId())) {
                NPCManager.npcs.remove(e.getUniqueId()).despawn();
            }
            if (e instanceof Item || e instanceof LivingEntity || e instanceof ArmorStand || e instanceof Projectile || e instanceof EnderCrystal) {
                if (e instanceof LivingEntity)
                    ((LivingEntity) e).setHealth(0.0);
                DropManager dm = plugin.getInstance(DropManager.class);
                if (dm != null) {
                    Entity label = dm.removeLabel(e.getUniqueId());
                    if (label != null)
                        label.remove();
                    e.remove();
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:31,代码来源:EnvironmentManager.java

示例8: onPlayerJoin

import org.bukkit.entity.EnderCrystal; //导入依赖的package包/类
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
	// Version notification
	Player player = event.getPlayer();
	if (player.isOp() && plugin.isNewVersionAvailable()) {
		this.plugin.sendMessage(player, ChatColor.GRAY + "A new version is available for download (Version " + this.plugin.getNewVersion() + "). " + RESOURCE_PAGE);
	}
	
	World world = player.getWorld();
	if (world.getEnvironment() != Environment.THE_END) return;
	
	EndWorldWrapper worldWrapper = manager.getWorldWrapper(world);
	
	// 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);
		});
	}
	
	// Dragon respawn logic
	if (!plugin.getConfig().getBoolean("respawn-on-join", false)) return;
	if (!world.getPlayers().isEmpty() || manager.getWorldWrapper(world).isRespawnInProgress()
			|| world.getEntitiesByClass(EnderDragon.class).size() == 0) 
		return;
	
	manager.getWorldWrapper(world).startRespawn(RespawnType.JOIN);
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:30,代码来源:RespawnListeners.java

示例9: onEntityDamageByEntity

import org.bukkit.entity.EnderCrystal; //导入依赖的package包/类
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
	Entity entity = event.getEntity();
	
	if (!(entity instanceof EnderCrystal) || event.getEntity().getWorld().getEnvironment() != Environment.THE_END
			|| !entity.isInvulnerable()) return;
	
	event.setCancelled(true);
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:10,代码来源:LootListeners.java

示例10: onAttemptRespawn

import org.bukkit.entity.EnderCrystal; //导入依赖的package包/类
@EventHandler
public void onAttemptRespawn(PlayerInteractEvent event) {
	Player player = event.getPlayer();
	ItemStack item = event.getItem();
	
	if (item == null || item.getType() != Material.END_CRYSTAL) return;
	if (plugin.getConfig().getBoolean("allow-crystal-respawns")) return;
	
	World world = player.getWorld();
	EndWorldWrapper worldWrapper = plugin.getDEDManager().getWorldWrapper(world);
	if (worldWrapper.isRespawnInProgress() || !world.getEntitiesByClass(EnderDragon.class).isEmpty()) {
		Set<EnderCrystal> crystals = PortalCrystal.getAllSpawnedCrystals(world);
		
		// Check for 3 crystals because PlayerInteractEvent is fired first
		if (crystals.size() < 3) return;
		
		for (EnderCrystal crystal : crystals) {
			crystal.getLocation().getBlock().setType(Material.AIR); // Remove fire
			world.dropItem(crystal.getLocation(), END_CRYSTAL_ITEM);
			crystal.remove();
		}
		
		plugin.getNMSAbstract().sendActionBar(ChatColor.RED + "You cannot manually respawn a dragon!", player);
		player.sendMessage(ChatColor.RED + "You cannot manually respawn a dragon!");
		event.setCancelled(true);
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:28,代码来源:DragonLifeListeners.java

示例11: onRuneHit

import org.bukkit.entity.EnderCrystal; //导入依赖的package包/类
@EventHandler
public void onRuneHit(EntityDamageByEntityEvent event){
	if(event.getEntity() instanceof EnderCrystal){
		if(event.getDamager() instanceof Player){
			event.setCancelled(true);
			event.getEntity().remove();
			Player player = (Player) event.getDamager();
			int rand = ThreadLocalRandom.current().nextInt(100);
			if(rand <= 50){
				World world = event.getEntity().getWorld();
				Location loc = event.getEntity().getLocation();
				world.createExplosion(loc.getX(), loc.getY(), loc.getZ(), 0, false, false);
				Message.sendCenteredMessage(player, ChatColor.GREEN+"----------------------------------------------------");
				Message.sendCenteredMessage(player, ChatColor.BOLD + "Rune");
				Message.sendCenteredMessage(player, ChatColor.YELLOW + "You fail to harvest any runes.");
				Message.sendCenteredMessage(player, ChatColor.GREEN+"----------------------------------------------------");
				return;
			}else{
				Enchantments[] enchants = Enchantments.values();
				Enchantments ench = enchants[ThreadLocalRandom.current().nextInt(enchants.length - 1)];
				int level = ThreadLocalRandom.current().nextInt(enchantclass.getMaxLevel(ench));
				if(level == 0)
					level = 1;
				event.getEntity().getWorld().dropItem(event.getEntity().getLocation(), new ca.damocles.itemblueprints.Rune(ench, level, ThreadLocalRandom.current().nextInt(100), ThreadLocalRandom.current().nextInt(100)).getItemStack());
				Message.sendCenteredMessage(player, ChatColor.GREEN+"----------------------------------------------------");
				Message.sendCenteredMessage(player, ChatColor.BOLD + "Rune");
				Message.sendCenteredMessage(player, ChatColor.YELLOW + "You successefuly harvest some runes.");
				Message.sendCenteredMessage(player, ChatColor.GREEN+"----------------------------------------------------");
				return;
			}
		}
	}
}
 
开发者ID:DamoclesProject,项目名称:Damocles,代码行数:34,代码来源:EventCanceller.java

示例12: runeCreation

import org.bukkit.entity.EnderCrystal; //导入依赖的package包/类
@EventHandler
public void runeCreation(PlayerInteractEntityEvent event){
	if(event.getRightClicked() instanceof EnderCrystal){
		event.setCancelled(true);
		if(event.getHand().equals(EquipmentSlot.OFF_HAND))
			return;
		
		event.getRightClicked().remove();
		Player player = event.getPlayer();
		int rand = ThreadLocalRandom.current().nextInt(100);
		if(rand <= 50){
			World world = event.getRightClicked().getWorld();
			Location loc = event.getRightClicked().getLocation();
			world.createExplosion(loc.getX(), loc.getY(), loc.getZ(), 2, false, false);
			Message.sendCenteredMessage(player, ChatColor.GREEN+"----------------------------------------------------");
			Message.sendCenteredMessage(player, ChatColor.BOLD + "Rune");
			Message.sendCenteredMessage(player, ChatColor.YELLOW + "You fail to harvest any runes.");
			Message.sendCenteredMessage(player, ChatColor.GREEN+"----------------------------------------------------");
			return;
		}else{
			Enchantments[] enchants = Enchantments.values();
			Enchantments ench = enchants[ThreadLocalRandom.current().nextInt(enchants.length - 1)];
			int level = ThreadLocalRandom.current().nextInt(enchantclass.getMaxLevel(ench) + 1);
			if(level == 0)
				level = 1;
			event.getRightClicked().getWorld().dropItem(event.getRightClicked().getLocation(), new ca.damocles.itemblueprints.Rune(ench, level, ThreadLocalRandom.current().nextInt(100), ThreadLocalRandom.current().nextInt(100)).getItemStack());
			Message.sendCenteredMessage(player, ChatColor.GREEN+"----------------------------------------------------");
			Message.sendCenteredMessage(player, ChatColor.BOLD + "Rune");
			Message.sendCenteredMessage(player, ChatColor.YELLOW + "You successefuly harvest some runes.");
			Message.sendCenteredMessage(player, ChatColor.GREEN+"----------------------------------------------------");
			return;
		}
	}
	return;
}
 
开发者ID:DamoclesProject,项目名称:Damocles,代码行数:36,代码来源:EventCanceller.java

示例13: FlagManager

import org.bukkit.entity.EnderCrystal; //导入依赖的package包/类
public FlagManager(CTFGame game)
{
	this.game = game;
	defaultFlagLocations = new Location[2];
	flags = new EnderCrystal[2];
	holders = new BPPlayer[2];
	score = new int[2];
	timeoutIn = new int[2];
	isDropped = new boolean[] { false, false };
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:11,代码来源:FlagManager.java

示例14: spawnFlag

import org.bukkit.entity.EnderCrystal; //导入依赖的package包/类
public EnderCrystal spawnFlag(Location loc, Team team)
{
	int teamId = Team.getId(team);
	loc = ground(loc);
	World world = loc.getWorld();
	Chunk chunk = world.getChunkAt(loc);
	
	if (!chunk.isLoaded())
		chunk.load();
	
	EnderCrystal ec = (EnderCrystal) world.spawnEntity(loc, EntityType.ENDER_CRYSTAL);
	flags[teamId] = ec;
	
	return ec;
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:16,代码来源:FlagManager.java

示例15: onTryFlagTake

import org.bukkit.entity.EnderCrystal; //导入依赖的package包/类
public void onTryFlagTake(EntityDamageByEntityEvent event)
{
	Entity damagerEntity = event.getDamager();
	EntityType damagerEntityType = damagerEntity.getType();
	
	if (damagerEntityType == EntityType.PLAYER)
	{
		Player damager = (Player) damagerEntity;
		
		if (damager.isDead())
			return;
		
		BPPlayer bpDamager = BPPlayer.get(damager);
		
		if(!bpDamager.isInGame())
			return;
		
		Game damagerGame = bpDamager.getGame();
		
		if(!damagerGame.equals(game))
			return;
		
		EnderCrystal flag = (EnderCrystal) event.getEntity();
		Team damagerTeam = ((CTFProperties) bpDamager.getGameProperties()).getTeam();
		
		if(damagerTeam != null)
			flagTouch(bpDamager, flag, damagerTeam, true);
	}
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:30,代码来源:FlagManager.java


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