本文整理汇总了Java中org.bukkit.block.BlockFace.equals方法的典型用法代码示例。如果您正苦于以下问题:Java BlockFace.equals方法的具体用法?Java BlockFace.equals怎么用?Java BlockFace.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.block.BlockFace
的用法示例。
在下文中一共展示了BlockFace.equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleAOE
import org.bukkit.block.BlockFace; //导入方法依赖的package包/类
private void handleAOE(BlockBreakEvent event) {
Player player = event.getPlayer();
BlockFace playerDir = Convert.yawToFace(player.getLocation().getYaw());
Block block = event.getBlock();
Block up = block.getRelative(BlockFace.UP);
Block left = block.getRelative(BlockFace.EAST);
Block right = block.getRelative(BlockFace.WEST);
if(playerDir.equals(BlockFace.EAST) || playerDir.equals(BlockFace.WEST)) {
left = block.getRelative(BlockFace.NORTH);
right = block.getRelative(BlockFace.SOUTH);
}
if(canAOEBreak(player, block)) {
player.getInventory().addItem(new ItemStack(block.getType()));
block.setType(Material.AIR);
}
if(canAOEBreak(player, up)) {
player.getInventory().addItem(new ItemStack(up.getType()));
up.setType(Material.AIR);
}
if(canAOEBreak(player, left)) {
player.getInventory().addItem(new ItemStack(left.getType()));
left.setType(Material.AIR);
}
if(canAOEBreak(player, right)) {
player.getInventory().addItem(new ItemStack(right.getType()));
right.setType(Material.AIR);
}
}
示例2: onBlockBreak
import org.bukkit.block.BlockFace; //导入方法依赖的package包/类
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
if(player.getInventory().getItemInMainHand() == null)
return;
if(!player.getInventory().getItemInMainHand().hasItemMeta())
return;
if(player.getInventory().getItemInMainHand().getItemMeta().getLore() == null)
return;
List<String> lore = player.getInventory().getItemInMainHand().getItemMeta().getLore();
if(contains(lore,"2x2 Explosion")) {
if(ConfigFile.isEnchantDisabled(player.getWorld().getName()))
return;
BlockFace playerDir = Convert.yawToFace(player.getLocation().getYaw());
Block block = event.getBlock();
Block up = block.getRelative(BlockFace.UP);
Block left = block.getRelative(BlockFace.EAST);
Block right = block.getRelative(BlockFace.WEST);
if(playerDir.equals(BlockFace.EAST) || playerDir.equals(BlockFace.WEST)) {
left = block.getRelative(BlockFace.NORTH);
right = block.getRelative(BlockFace.SOUTH);
}
if(plugin.getWorldGuard().canBuild(player, block)) {
player.getInventory().addItem(new ItemStack(block.getType()));
block.setType(Material.AIR);
}
if(plugin.getWorldGuard().canBuild(player, up)) {
player.getInventory().addItem(new ItemStack(up.getType()));
up.setType(Material.AIR);
}
if(plugin.getWorldGuard().canBuild(player, left)) {
player.getInventory().addItem(new ItemStack(left.getType()));
left.setType(Material.AIR);
}
if(plugin.getWorldGuard().canBuild(player, right)) {
player.getInventory().addItem(new ItemStack(right.getType()));
right.setType(Material.AIR);
}
}
}