Пример #1
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onBlockPlace(BlockPlaceEvent event) {
   if (event.getBlock().equals(place.getBlock())) {
     if (event.getBlock().getType().equals(Material.WOOL)) {
       if (((Wool) event.getBlock().getState().getData()).getColor().equals(color)) {
         if (Teams.getTeamByPlayer(event.getPlayer()).orNull() == team) {
           this.complete = true;
           if (this.show)
             ChatUtil.getGlobalChannel()
                 .sendLocalizedMessage(
                     new UnlocalizedChatMessage(
                         ChatColor.WHITE + "{0}",
                         new LocalizedChatMessage(
                             ChatConstant.UI_OBJECTIVE_PLACED,
                             team.getColor() + event.getPlayer().getName() + ChatColor.WHITE,
                             team.getCompleteName() + ChatColor.WHITE,
                             MiscUtil.convertDyeColorToChatColor(color)
                                 + name.toUpperCase().replaceAll("_", " ")
                                 + ChatColor.WHITE)));
           Fireworks.spawnFirework(
               event.getPlayer().getLocation(),
               event.getPlayer().getWorld(),
               MiscUtil.convertChatColorToColor(MiscUtil.convertDyeColorToChatColor(color)));
           ObjectiveCompleteEvent compEvent = new ObjectiveCompleteEvent(this, event.getPlayer());
           Bukkit.getServer().getPluginManager().callEvent(compEvent);
           event.setCancelled(false);
         } else {
           event.setCancelled(true);
           if (this.show)
             ChatUtil.sendWarningMessage(
                 event.getPlayer(), "You may not complete the other team's objective.");
         }
       } else {
         event.setCancelled(true);
         if (this.show)
           ChatUtil.sendWarningMessage(
               event.getPlayer(),
               new LocalizedChatMessage(
                   ChatConstant.ERROR_BLOCK_PLACE,
                   MiscUtil.convertDyeColorToChatColor(color)
                       + color.name().toUpperCase().replaceAll("_", " ")
                       + " WOOL"
                       + ChatColor.RED));
       }
     } else {
       event.setCancelled(true);
       if (this.show)
         ChatUtil.sendWarningMessage(
             event.getPlayer(),
             new LocalizedChatMessage(
                 ChatConstant.ERROR_BLOCK_PLACE,
                 MiscUtil.convertDyeColorToChatColor(color)
                     + color.name().toUpperCase().replaceAll("_", " ")
                     + " WOOL"
                     + ChatColor.RED));
     }
   }
 }
Пример #2
0
 @EventHandler
 public void onBlockBreak(BlockBreakEvent event) {
   if (event.getBlock().equals(place.getBlock())) {
     event.setCancelled(true);
   }
 }