本文整理汇总了Java中org.bukkit.event.block.BlockBreakEvent.setExpToDrop方法的典型用法代码示例。如果您正苦于以下问题:Java BlockBreakEvent.setExpToDrop方法的具体用法?Java BlockBreakEvent.setExpToDrop怎么用?Java BlockBreakEvent.setExpToDrop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.block.BlockBreakEvent
的用法示例。
在下文中一共展示了BlockBreakEvent.setExpToDrop方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
/**
* Drops the smelted form of items that spawn when a block is broken.
*
* @param event The event
*/
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
Material type = block.getType();
BlockDropModule module = OpenUHC.getCurrentGame().getModuleHandler().getModule(BlockDropModule.class);
if (type.equals(Material.IRON_ORE)) {
module.addBlockDrop(block, new BlockDrop(new ItemStack(Material.IRON_INGOT), true));
event.setExpToDrop(4);
} else if (type.equals(Material.GOLD_ORE)) {
module.addBlockDrop(block, new BlockDrop(new ItemStack(Material.GOLD_INGOT), true));
event.setExpToDrop(8);
} else if (type.equals(Material.POTATO)) {
module.addBlockDrop(block, new BlockDrop(new ItemStack(Material.BAKED_POTATO), true));
event.setExpToDrop(2);
}
}
示例2: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
/**
* Cancel ore break event
*
* @param event Event
*/
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event)
{
switch (event.getBlock().getType())
{
case DIAMOND_ORE:
case LAPIS_ORE:
case GOLD_ORE:
case OBSIDIAN:
case IRON_ORE:
case REDSTONE_ORE:
case QUARTZ_ORE:
case QUARTZ_BLOCK:
event.setExpToDrop(0);
event.getBlock().breakNaturally(new ItemStack(Material.DIAMOND_PICKAXE));
event.setCancelled(true);
break;
default:
break;
}
}
示例3: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的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);
}
}
}
示例4: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
Location loc = block.getLocation();
if (!player.getGameMode().equals(GameMode.CREATIVE)) {
if (inMineLocation(loc)) {
if (block.getType().equals(Material.COAL_ORE)) {
event.setExpToDrop(0);
new BukkitRunnable() {
@Override
public void run() {
loc.getBlock().setType(Material.COAL_ORE);
}
}.runTaskLater(this.plugin, 1200);
} else if (block.getType().equals(Material.IRON_ORE)) {
event.setExpToDrop(0);
new BukkitRunnable() {
@Override
public void run() {
loc.getBlock().setType(Material.IRON_ORE);
}
}.runTaskLater(this.plugin, 6000);
} else if (block.getType().equals(Material.DIAMOND_ORE)) {
event.setCancelled(true);
block.setType(Material.AIR);
event.setExpToDrop(0);
loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.DIAMOND_ORE));
new BukkitRunnable() {
@Override
public void run() {
loc.getBlock().setType(Material.DIAMOND_ORE);
}
}.runTaskLater(this.plugin, 12000);
} else {
event.setCancelled(true);
}
} else {
event.setCancelled(true);
}
}
}