本文整理汇总了Java中org.bukkit.block.Block.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Block.equals方法的具体用法?Java Block.equals怎么用?Java Block.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.block.Block
的用法示例。
在下文中一共展示了Block.equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEvent
import org.bukkit.block.Block; //导入方法依赖的package包/类
@Override
public void onEvent(BlockTransformEvent event) {
super.onEvent(event);
Block block = event.getOldState().getBlock();
Block flagBlock = this.location.getBlock();
if(block.equals(flagBlock) || block.equals(flagBlock.getRelative(BlockFace.UP))) {
event.setCancelled(true, new TranslatableComponent("match.flag.cannotBreak"));
} else if(block.equals(flagBlock.getRelative(BlockFace.DOWN))) {
event.setCancelled(true, new TranslatableComponent("match.flag.cannotBreakBlockUnder"));
}
}
示例2: onBlockBreak
import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBlockBreak(final BlockBreakEvent event) {
final Player player = event.getPlayer();
if(player.getGameMode() == GameMode.CREATIVE) {
return;
}
if(player.getItemInHand().getEnchantments().containsKey(Enchantment.SILK_TOUCH)) return;;
final Block block = event.getBlock();
final Location blockLocation = block.getLocation();
if(block.getType() == FoundDiamondsListener.SEARCH_TYPE && this.foundLocations.add(blockLocation.toString())) {
int count = 1;
for(int x = -5; x < 5; ++x) {
for(int y = -5; y < 5; ++y) {
for(int z = -5; z < 5; ++z) {
final Block otherBlock = blockLocation.clone().add((double) x, (double) y, (double) z).getBlock();
if(!otherBlock.equals(block) && otherBlock.getType() == FoundDiamondsListener.SEARCH_TYPE && this.foundLocations.add(otherBlock.getLocation().toString())) {
++count;
}
}
}
}
String message;
for(Player on : Bukkit.getOnlinePlayers()) {
if(plugin.getFactionManager().getPlayerFaction(player.getUniqueId()) != null) {
message = plugin.getFactionManager().getPlayerFaction(player.getUniqueId()).getRelation(on).toChatColour() + player.getName() + ChatColor.GRAY + " has found " + ChatColor.AQUA + count + ChatColor.GRAY + " diamond(s).";
on.sendMessage(message);
}else{
message = ChatColor.AQUA + "[" + ChatColor.GRAY + "♠" + ChatColor.AQUA + "]" + ChatColor.GRAY + " " + ChatColor.AQUA + player.getName() + ChatColor.GRAY + " has just spotted " + ChatColor.BLUE + count + ChatColor.GRAY +" diamonds!";
on.sendMessage(message);
}
}
}
}
示例3: isBlock
import org.bukkit.block.Block; //导入方法依赖的package包/类
public boolean isBlock(Block block) {
if (block == null || this.block == null)
return false;
return block.equals(this.block);
}