当前位置: 首页>>代码示例>>Java>>正文


Java Block.equals方法代码示例

本文整理汇总了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"));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:14,代码来源:Uncarried.java

示例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);
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:35,代码来源:FoundDiamondsListener.java

示例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);
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:6,代码来源:PlayerBlockTracking.java


注:本文中的org.bukkit.block.Block.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。