本文整理汇总了Java中org.bukkit.inventory.ItemStack.getEnchantmentLevel方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.getEnchantmentLevel方法的具体用法?Java ItemStack.getEnchantmentLevel怎么用?Java ItemStack.getEnchantmentLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.ItemStack
的用法示例。
在下文中一共展示了ItemStack.getEnchantmentLevel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calcSurvivalFastBreak
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public static long calcSurvivalFastBreak(ItemStack tool, Material block) {
if (isInstantBreak(block) || (tool.getType() == Material.SHEARS && block == Material.LEAVES)) {
return 0;
}
double bhardness = BlockHardness.getBlockHardness(block);
double thardness = ToolHardness.getToolHardness(tool.getType());
long enchantlvl = (long) tool.getEnchantmentLevel(Enchantment.DIG_SPEED);
long result = Math.round((bhardness * thardness) * 0.10 * 10000);
if (enchantlvl > 0) {
result /= enchantlvl * enchantlvl + 1L;
}
result = result > 25000 ? 25000 : result < 0 ? 0 : result;
if (isQuickCombo(tool, block)) {
result = result / 2;
}
return result;
}
示例2: onEntityDeath
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
double amount = event.getDroppedExp();
Player killer = event.getEntity().getKiller();
if (killer != null && amount > 0) {
ItemStack stack = killer.getItemInHand();
if (stack != null && stack.getType() != Material.AIR) {
int enchantmentLevel = stack.getEnchantmentLevel(Enchantment.LOOT_BONUS_MOBS);
if (enchantmentLevel > 0L) {
double multiplier = enchantmentLevel * SettingsYML.EXP_MULTIPLIER_LOOTING_PER_LEVEL;
int result = (int) Math.ceil(amount * multiplier);
event.setDroppedExp(result);
}
}
}
}
示例3: onPlayerFish
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerFish(PlayerFishEvent event) {
double amount = event.getExpToDrop();
if (amount > 0) {
amount = Math.ceil(amount * SettingsYML.EXP_MULTIPLIER_FISHING);
ProjectileSource projectileSource = event.getHook().getShooter();
if (projectileSource instanceof Player) {
ItemStack stack = ((Player) projectileSource).getItemInHand();
int enchantmentLevel = stack.getEnchantmentLevel(Enchantment.LUCK);
if (enchantmentLevel > 0L) {
amount = Math.ceil(amount * (enchantmentLevel * SettingsYML.EXP_MULTIPLIER_LUCK_PER_LEVEL));
}
}
event.setExpToDrop((int) amount);
}
}
示例4: onBlockBreak
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onBlockBreak(BlockBreakEvent event) {
double amount = event.getExpToDrop();
Player player = event.getPlayer();
ItemStack stack = player.getItemInHand();
if (stack != null && stack.getType() != Material.AIR && amount > 0) {
int enchantmentLevel = stack.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS);
if (enchantmentLevel > 0) {
double multiplier = enchantmentLevel * SettingsYML.EXP_MULTIPLIER_FORTUNE_PER_LEVEL;
int result = (int) Math.ceil(amount * multiplier);
event.setExpToDrop(result);
}
}
}
示例5: doDamage
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
void doDamage(boolean unbreaking, Player player)
{
ItemStack tool = player.getInventory().getItemInMainHand();
int unbreakingLevel = tool.getEnchantmentLevel(Enchantment.DURABILITY);
if ( ! unbreaking)
{
tool.setDurability((short)(tool.getDurability() + 1));
}else if (unbreakingLevel > 0)
{
Random r = new Random();
int chanceToReduce = (100/(unbreakingLevel + 1));
int roll = r.nextInt(100);
if (roll <= chanceToReduce)
{
tool.setDurability((short)(tool.getDurability() + 1));
}
}
if (tool.getDurability() > tool.getType().getMaxDurability())
{
String pick = "";
if (Xpick.isPick(tool))
{
pick = Config.EXPLOSIVE_COLOR + "Explosive Pick";
}else if (Pickoplenty.isPick(tool))
{
pick = Config.PICK_O_PLENTY_COLOR + "Pick 'o' Plenty";
}else if (XPickoPlenty.isPick(tool))
{
pick = Config.EXPLOSIVE_COLOR + "Explosive " + Config.PICK_O_PLENTY_COLOR + " Pick 'o' plenty";
}
Bukkit.broadcastMessage(Config.CHAT_PICK_BREAK + player.getName() + " just broke their " + pick + Config.CHAT_PICK_BREAK + " while mining... Press 'F' to pay respects.");
if(Config.DEBUG)
{
System.out.println("-------------------------------------");
System.out.println("Player: " + player.getName());
System.out.println("UUID: " + player.getUniqueId());
System.out.println("Pick type: " + pick);
System.out.println("Pick Current Durability: " + tool.getDurability());
System.out.println("Pick Max Durability: " + tool.getType().getMaxDurability());
System.out.println("-------------------------------------");
}
//break the pick
player.getInventory().remove(tool);
}
}
示例6: isHoldingWeapon
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
boolean isHoldingWeapon() {
ItemStack holding = player.getBukkit().getItemInHand();
return holding != null && (ItemUtils.isWeapon(holding) ||
holding.getEnchantmentLevel(Enchantment.DAMAGE_ALL) > 0);
}