本文整理匯總了Java中cn.nukkit.Player.getExperience方法的典型用法代碼示例。如果您正苦於以下問題:Java Player.getExperience方法的具體用法?Java Player.getExperience怎麽用?Java Player.getExperience使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cn.nukkit.Player
的用法示例。
在下文中一共展示了Player.getExperience方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onEnchant
import cn.nukkit.Player; //導入方法依賴的package包/類
public void onEnchant(Player who, Item before, Item after) {
Item result = (before.getId() == Item.BOOK) ? new ItemBookEnchanted() : before;
if (!before.hasEnchantments() && after.hasEnchantments() && after.getId() == result.getId() && this.levels != null && this.entries != null) {
Enchantment[] enchantments = after.getEnchantments();
for (int i = 0; i < 3; i++) {
if (Arrays.equals(enchantments, this.entries[i].getEnchantments())) {
Item lapis = this.getItem(1);
int level = who.getExperienceLevel();
int exp = who.getExperience();
int cost = this.entries[i].getCost();
if (lapis.getId() == Item.DYE && lapis.getDamage() == DyeColor.BLUE.getDyeData() && lapis.getCount() > i && level >= cost) {
result.addEnchantment(enchantments);
this.setItem(0, result);
lapis.setCount(lapis.getCount() - i - 1);
this.setItem(1, lapis);
who.setExperience(exp, level - cost);
break;
}
}
}
}
}