BrewListener.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:NoStrengthII 作者:
@EventHandler
  public void onBrew(BrewEvent event) {
    BrewerInventory inv = event.getContents();

    // if the inventory doesn't contain glowstone AND a strength potion, return.
    if (!containsStrengthOrGlowstone(inv)) {
        return;
      }

    // cancel. 
    event.setCancelled(true);

Block block = event.getBlock();
Location blockL = block.getLocation();

// loop thru everyone online.
for (Player online : Bukkit.getOnlinePlayers()) {
    Location playerL = online.getLocation();

    // if they're within a radius send them a message.
    if (block.getWorld() == online.getWorld() && playerL.distance(blockL) < 15) {
        online.sendMessage(ChatColor.RED + "Strength II is disabled, brewing cancelled.");
    }
}
  }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号