示例#1
0
文件: Core.java 项目: Crnsxx/Cardinal
 /**
  * Checks if lava has reached the leak distance below this core.
  *
  * @param event The event.
  */
 @EventHandler(ignoreCancelled = true)
 public void onBlockFromTo(BlockFromToEvent event) {
   Block to = event.getToBlock();
   if (lava.contains(to)) {
     event.setCancelled(true);
     return;
   }
   Material type = event.getBlock().getType();
   if ((type.equals(Material.STATIONARY_LAVA) || type.equals(Material.LAVA))
       && to.getType().equals(Material.AIR)
       && Cardinal.getModule(CoreModule.class)
           .getClosestCore(getMatch(), to.getLocation().toVector())
           .equals(this)
       && !complete) {
     Block bottomBlock = getBottomBlock();
     if (bottomBlock != null) {
       int distance = getBottomBlock().getY() - to.getY();
       if (distance >= leak) {
         complete = true;
         Channels.getGlobalChannel(Cardinal.getMatchThread(getMatch()))
             .sendMessage(
                 new LocalizedComponentBuilder(
                         ChatConstant.getConstant("objective.core.completed"),
                         new TeamComponent(team),
                         new UnlocalizedComponentBuilder(name).color(ChatColor.RED).build())
                     .color(ChatColor.RED)
                     .build());
         Bukkit.getPluginManager().callEvent(new ObjectiveCompleteEvent(this, null));
       }
     }
   }
 }
示例#2
0
文件: Core.java 项目: Crnsxx/Cardinal
 /**
  * Checks if the core has been touched when a player breaks a block.
  *
  * @param event The event.
  */
 @EventHandler(ignoreCancelled = true)
 public void onBlockBreak(BlockBreakEvent event) {
   Player player = event.getPlayer();
   Block block = event.getBlock();
   Team team = Team.getTeam(player);
   if (getBlocks().contains(block) && (team == null || !team.equals(this.team))) {
     touched = true;
     boolean showMessage = false;
     if (isShow() && !touchedPlayers.contains(player)) {
       touchedPlayers.add(player);
       showMessage = true;
       Channels.getTeamChannel(getMatch(), team)
           .sendMessage(
               Components.appendTeamPrefix(
                   team,
                   new LocalizedComponent(
                       ChatConstant.getConstant("objective.core.touched"),
                       new TeamComponent(this.team),
                       new UnlocalizedComponent(name),
                       Components.getNameComponentBuilder(player).flairs(false).build())));
     }
     Bukkit.getPluginManager().callEvent(new ObjectiveTouchEvent(this, player, showMessage));
   }
 }