當前位置: 首頁>>代碼示例>>Java>>正文


Java ExperienceOrb類代碼示例

本文整理匯總了Java中org.bukkit.entity.ExperienceOrb的典型用法代碼示例。如果您正苦於以下問題:Java ExperienceOrb類的具體用法?Java ExperienceOrb怎麽用?Java ExperienceOrb使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ExperienceOrb類屬於org.bukkit.entity包,在下文中一共展示了ExperienceOrb類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
public void run(){
    switch (rain){
        case EXP:
            locs.forEach(l -> {
                experienceOrb = (ExperienceOrb)l.getWorld().spawnEntity(l, EntityType.EXPERIENCE_ORB);
                experienceOrb.setExperience(levels);
            });
            break;
        case MAT:
            locs.forEach(l -> l.getWorld().dropItemNaturally(l, new ItemStack(material)));
            break;
        default:
            cancel();
            break;
    }
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:17,代碼來源:RainTask.java

示例2: onTarget

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onTarget(EntityTargetEvent event) {
    if(!(event.getEntity() instanceof ExperienceOrb)) {
        ParticipantState victimState = null;
        if(event.getTarget() instanceof Player) {
            // Don't target allies
            MatchPlayer victim = getVictim(event.getTarget());
            if(victim == null) return;
            victimState = victim.getParticipantState();
        } else if(event.getTarget() != null) {
            // Don't target other mobs owned by allies
            victimState = entityResolver.getOwner(event.getTarget());
        }
        if(victimState == null) return;
        DamageInfo damageInfo = damageResolver.resolveDamage(EntityDamageEvent.DamageCause.ENTITY_ATTACK, event.getTarget(), event.getEntity());
        if(queryHostile(event, victimState, damageInfo).isDenied()) {
            event.setCancelled(true);
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:21,代碼來源:DamageMatchModule.java

示例3: repellExpOrb

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
final void repellExpOrb(final Player player, final ExperienceOrb orb) {
	final Location pLoc = player.getLocation();
	final Location oLoc = orb.getLocation();
	final Vector dir = oLoc.toVector().subtract(pLoc.toVector());
	final double dx = Math.abs(dir.getX());
	final double dz = Math.abs(dir.getZ());
	if ( (dx == 0.0) && (dz == 0.0)){
		// Special case probably never happens
		dir.setX(0.001);
	}
	if ((dx < 3.0) && (dz < 3.0)){
		final Vector nDir = dir.normalize();
		final Vector newV = nDir.clone().multiply(0.3);
		newV.setY(0);
		orb.setVelocity(newV);
		if ((dx < 1.0) && (dz < 1.0)){
			// maybe oLoc
			orb.teleport(oLoc.clone().add(nDir.multiply(1.0)), TeleportCause.PLUGIN);
		} 
		if ((dx < 0.5) && (dz < 0.5)){
			orb.remove();
		} 
	} 
}
 
開發者ID:smessie,項目名稱:SkyWarsReloaded,代碼行數:25,代碼來源:SpectatorListener.java

示例4: onEntityExplode

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityExplode(EntityExplodeEvent event) {
    if (!event.isCancelled()) {
        Player player = TntTracker.getWhoPlaced(event.getEntity()) != null && Bukkit.getOfflinePlayer(TntTracker.getWhoPlaced(event.getEntity())).isOnline() ? Bukkit.getPlayer(TntTracker.getWhoPlaced(event.getEntity())) : null;
        if (player != null) {
            for (Block block : event.blockList()) {
                if (filter == null || filter.evaluate(player, block).equals(FilterState.ALLOW)) {
                    if (region == null || region.contains(new BlockRegion(null, block.getLocation().toVector().add(new Vector(0.5, 0.5, 0.5))))) {
                        for (ItemStack drop : this.drops) {
                            GameHandler.getGameHandler().getMatchWorld().dropItemNaturally(block.getLocation(), drop);
                        }
                        if (this.experience != 0) {
                            ExperienceOrb xp = GameHandler.getGameHandler().getMatchWorld().spawn(block.getLocation(), ExperienceOrb.class);
                            xp.setExperience(this.experience);
                        }
                        block.setType(replace);
                    }
                }
            }
        }
    }
}
 
開發者ID:dentmaged,項目名稱:Cardinal-Plus,代碼行數:23,代碼來源:Blockdrops.java

示例5: onEntityExplode

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityExplode(EntityExplodeEvent event) {
    if (!event.isCancelled()) {
        Player player = TntTracker.getWhoPlaced(event.getEntity()) != null && Bukkit.getOfflinePlayer(TntTracker.getWhoPlaced(event.getEntity())).isOnline() ? Bukkit.getPlayer(TntTracker.getWhoPlaced(event.getEntity())) : null;
        if (player != null) {
            List<Block> toRemove = new ArrayList<>();
            for (Block block : event.blockList()) {
                if (filter == null || filter.evaluate(player, block, event).equals(FilterState.ALLOW)) {
                    if (region == null || region.contains(block.getLocation().toVector().add(new Vector(0.5, 0.5, 0.5)))) {
                        for (ItemStack drop : this.drops) {
                            GameHandler.getGameHandler().getMatchWorld().dropItemNaturally(block.getLocation(), drop);
                        }
                        if (this.experience != 0) {
                            ExperienceOrb xp = GameHandler.getGameHandler().getMatchWorld().spawn(block.getLocation(), ExperienceOrb.class);
                            xp.setExperience(this.experience);
                        }
                        toRemove.add(block);
                        block.setType(replaceType);
                        block.setData((byte) replaceDamage);
                    }
                }
            }
            event.blockList().removeAll(toRemove);
        }
    }
}
 
開發者ID:twizmwazin,項目名稱:CardinalPGM,代碼行數:27,代碼來源:Blockdrops.java

示例6: tick

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
protected void tick(Block b)
        throws Exception
    {
        for(Iterator iterator = me.mrCookieSlime.Slimefun.holograms.XPCollector.getArmorStand(b).getNearbyEntities(4D, 4D, 4D).iterator(); iterator.hasNext();)
        {
            Entity n = (Entity)iterator.next();
            if(n instanceof ExperienceOrb)
            {
                if(ChargableBlock.getCharge(b) < getEnergyConsumption())
                    return;
                if(n.isValid())
                {
                    int xp = getEXP(b) + ((ExperienceOrb)n).getExperience();
                    ChargableBlock.addCharge(b, -getEnergyConsumption());
                    n.remove();
                    int withdrawn = 0;
                    for(int level = 0; level < getEXP(b); level += 10)
                        if(fits(b, new ItemStack[] {
    new CustomItem(Material.EXP_BOTTLE, "&a\u5B66\u8BC6\u4E4B\u74F6", 0)
}))
                        {
                            withdrawn += 10;
                            pushItems(b, new ItemStack[] {
                                new CustomItem(Material.EXP_BOTTLE, "&a\u5B66\u8BC6\u4E4B\u74F6", 0)
                            });
                        }

                    BlockStorage.addBlockInfo(b, "stored-exp", String.valueOf(xp - withdrawn));
                    return;
                }
            }
        }

    }
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:35,代碼來源:XPCollector.java

示例7: dropExperience

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
private void dropExperience(BlockDrops drops, Location location) {
    if(drops.experience != 0) {
        ExperienceOrb expOrb = (ExperienceOrb) location.getWorld().spawnEntity(BlockUtils.center(location), EntityType.EXPERIENCE_ORB);
        if(expOrb != null) {
            expOrb.setExperience(drops.experience);
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:9,代碼來源:BlockDropsMatchModule.java

示例8: onEntityTarget

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
@EventHandler
protected void onEntityTarget(EntityTargetEvent e) {
	// On entity target - Stop mobs targeting spectators
	// Check to make sure it isn't an NPC (Citizens NPC's will be detectable using 'entity.hasMetadata("NPC")')
	if (e.getTarget() != null && e.getTarget() instanceof Player && !e.getTarget().hasMetadata("NPC") && SkyWarsReloaded.getPC().getPlayer(((Player) e.getTarget()).getUniqueId()).isSpectating()) {
		e.setCancelled(true);
	}
	if (e.getTarget() instanceof Player && e.getTarget() != null && SkyWarsReloaded.getPC().getPlayer(((Player) e.getTarget()).getUniqueId()).isSpectating()) {
		if (e.getEntity() instanceof ExperienceOrb) {
			repellExpOrb((Player) e.getTarget(), (ExperienceOrb) e.getEntity());
			e.setCancelled(true);
			e.setTarget(null);
		}
	}
}
 
開發者ID:smessie,項目名稱:SkyWarsReloaded,代碼行數:16,代碼來源:SpectatorListener.java

示例9: XpManager

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
public XpManager() {
    new BukkitRunnable() {
        public void run() {
            if (TaskID == -1) {
                TaskID = this.getTaskId();
            }
            for (Arena arena : ArenaManager.getArenas()) {
                if (arena.getPlayers().size() != 0) {
                    for (XpGen gen : arena.getXpGenerators()) {
                        if (!data.containsKey(gen)) {
                            data.put(gen, 1);
                        } else {
                            int value = data.get(gen);
                            data.remove(gen);
                            data.put(gen, value + 1);
                        }
                        if (data.get(gen) == gen.getInterval()) {
                            ExperienceOrb exp = (ExperienceOrb) gen.getLocation().getWorld().spawnEntity(gen.getLocation(), EntityType.EXPERIENCE_ORB);
                            exp.setExperience(1);
                            data.remove(gen);
                        }
                    }
                }
            }
        }
    }.runTaskTimer(Main.getInstance(), 20L, 20L);
}
 
開發者ID:Soldier233,項目名稱:ArchersBattle,代碼行數:28,代碼來源:XpManager.java

示例10: onDeath

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
@EventHandler
public void onDeath(PlayerDeathEvent e) {
    Player p = e.getEntity();
    if (!Utils.isInArena(p)) {
        return;
    }
    int level = p.getLevel();
    ExperienceOrb exp = (ExperienceOrb) p.getWorld().spawnEntity(p.getLocation(), EntityType.EXPERIENCE_ORB);
    exp.setExperience(level * 2);
}
 
開發者ID:Soldier233,項目名稱:ArchersBattle,代碼行數:11,代碼來源:PlayerListener.java

示例11: onCExpDrop

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
@EventHandler
public void onCExpDrop(KMCExpDropEvent e) {
    if (e.isCancelled()) {
        return;
    }

    e.getLocation().getWorld().spawn(e.getLocation(), ExperienceOrb.class).setExperience(e.getValue());
}
 
開發者ID:diecode,項目名稱:KillerMoney,代碼行數:9,代碼來源:CExpHandler.java

示例12: spawn

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
@Override
@Nullable
public ExperienceOrb spawn(final Location loc) {
	final ExperienceOrb orb = super.spawn(loc);
	if (orb == null)
		return null;
	if (xp == -1)
		orb.setExperience(1);
	return orb;
}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:11,代碼來源:XpOrbData.java

示例13: doXP

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
private void doXP(DropConfig dc, String biomeName, ToolConfig dropModifier, Location loc, Player p) {
	double xpChance = dc.getXPChance(biomeName) 
			* (dropModifier == null ? 1.0 : dropModifier.getDropChanceModifier())
			* dc.getStateChance(biomeName, p);
	if (xpChance > Math.random()) {
		int toXP = dc.renderXP(biomeName, dropModifier);
		if (toXP > 0) {
			Entity xp = loc.getWorld().spawnEntity(loc, EntityType.EXPERIENCE_ORB);
			if (xp instanceof ExperienceOrb) {
				ExperienceOrb eo = (ExperienceOrb) xp;
				eo.setExperience(toXP);
			}
		}
	}
}
 
開發者ID:DevotedMC,項目名稱:HiddenOre,代碼行數:16,代碼來源:BlockBreakListener.java

示例14: dropItems

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
public void dropItems() {
	try {
		if (entity == null) {
			return;
		}
		
		LinkedList<MobDrop> dropped = getRandomDrops();
		World world = entity.getBukkitEntity().getWorld();
		Location loc = getLocation(entity);
		
		for (MobDrop d : dropped) {
			ItemStack stack;
			if (d.isVanillaDrop) {
				stack = ItemManager.createItemStack(d.vanillaType, 1, d.vanillaData);
			} else {
				LoreCraftableMaterial craftMat = LoreCraftableMaterial.getCraftMaterialFromId(d.craftMatId);
				stack = LoreCraftableMaterial.spawn(craftMat);
			}
			
			world.dropItem(loc, stack);
		}
		
		if (this.coinMax != 0 && this.coinMin != 0) {
			ExperienceOrb orb = (ExperienceOrb)world.spawn(loc, ExperienceOrb.class);
			Random random = new Random();
			int coins = random.nextInt(this.coinMax - this.coinMin) + this.coinMin;
			orb.setExperience(coins);

		}
	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:34,代碼來源:CommonCustomMob.java

示例15: tick

import org.bukkit.entity.ExperienceOrb; //導入依賴的package包/類
protected void tick(Block b) throws Exception {
	Iterator<Entity> iterator = me.mrCookieSlime.Slimefun.holograms.XPCollector.getArmorStand(b).getNearbyEntities(4D, 4D, 4D).iterator();
	while (iterator.hasNext()) {
		Entity n = iterator.next();
		if (n instanceof ExperienceOrb) {
			if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
			
			if (n.isValid()) {
				int xp = getEXP(b) + ((ExperienceOrb) n).getExperience();
				
				ChargableBlock.addCharge(b, -getEnergyConsumption());
				n.remove();
				
				int withdrawn = 0;
				for (int level = 0; level < getEXP(b); level = level + 10) {
					if (fits(b, new CustomItem(Material.EXP_BOTTLE, "&aFlask of Knowledge", 0))) {
						withdrawn = withdrawn + 10;
						pushItems(b, new CustomItem(Material.EXP_BOTTLE, "&aFlask of Knowledge", 0));
					}
				}
				BlockStorage.addBlockInfo(b, "stored-exp", String.valueOf(xp - withdrawn));
				
				return;
			}
		}
	}
}
 
開發者ID:TheBusyBiscuit,項目名稱:Slimefun4,代碼行數:28,代碼來源:XPCollector.java


注:本文中的org.bukkit.entity.ExperienceOrb類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。