本文整理匯總了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);
}