本文整理匯總了Java中org.bukkit.entity.ExperienceOrb.setExperience方法的典型用法代碼示例。如果您正苦於以下問題:Java ExperienceOrb.setExperience方法的具體用法?Java ExperienceOrb.setExperience怎麽用?Java ExperienceOrb.setExperience使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.entity.ExperienceOrb
的用法示例。
在下文中一共展示了ExperienceOrb.setExperience方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
}
}
}
}
示例2: 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);
}
}
}
示例3: 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);
}
}
}
示例4: 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);
}
示例5: 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;
}
示例6: 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);
}
}
}
}
示例7: 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();
}
}
示例8: drop
import org.bukkit.entity.ExperienceOrb; //導入方法依賴的package包/類
private static void drop(Material material, int amount, Location location) {
location.getWorld().dropItem(location, new ItemStack(material, amount));
ExperienceOrb exp = location.getWorld().spawn(location, ExperienceOrb.class);
exp.setExperience(1);
}
示例9: set
import org.bukkit.entity.ExperienceOrb; //導入方法依賴的package包/類
@Override
public void set(final ExperienceOrb entity) {
if (xp != -1)
entity.setExperience(xp);
}