@EventHandler
 public void onBreak(BlockBreakEvent bbe) {
   if (!(bbe.isCancelled())) {
     Block block = bbe.getBlock();
     if (bbe.getPlayer() != null) {
       Player breaker = bbe.getPlayer();
       UUID uuid = breaker.getUniqueId();
       if (block.getState().getType().equals(Material.REDSTONE_ORE)
           || block.getType().equals(Material.REDSTONE_ORE)) {
         boolean notSilkTouch = true;
         if (breaker.getInventory().getItemInHand() != null) {
           ItemStack handItem = breaker.getInventory().getItemInHand();
           if (handItem.containsEnchantment(Enchantment.SILK_TOUCH)) {
             notSilkTouch = false;
           }
         }
         boolean lowLevel = true;
         int level = LevelManager.getLevel(breaker);
         if (level > 30) {
           lowLevel = false;
         }
         if (notSilkTouch && lowLevel) {
           int broke = LevelingXP_Breaking.get(uuid);
           broke += 1;
           if (broke >= (10 * LevelManager.getLevel(breaker))) {
             XPmanager.giveXP(breaker, 80);
           } else {
             LevelingXP_Breaking.set(uuid, broke);
           }
         }
       }
     }
   }
 }
예제 #2
0
  @EventHandler(priority = EventPriority.HIGH) // , ignoreCancelled = true
  public void onBlockBreak(final BlockBreakEvent event) {
    Block b = event.getBlock();

    if (PlotManager.isPlotWorld(b)) {
      Player p = event.getPlayer();
      boolean canbuild = PlotMe.cPerms(event.getPlayer(), "plotme.admin.buildanywhere");
      String id = PlotManager.getPlotId(b.getLocation());

      if (id.equalsIgnoreCase("")) {
        if (!canbuild) {
          p.sendMessage(PlotMe.caption("ErrCannotBuild"));
          event.setCancelled(true);
        }
      } else {
        Plot plot = PlotManager.getMap(p).plots.get(id);

        if (plot == null) {
          if (!canbuild) {
            p.sendMessage(PlotMe.caption("ErrCannotBuild"));
            event.setCancelled(true);
          }
        } else if (!plot.isAllowed(p.getName())) {
          if (!canbuild) {
            p.sendMessage(PlotMe.caption("ErrCannotBuild"));
            event.setCancelled(true);
          }
        } else {
          plot.resetExpire(PlotManager.getMap(b).DaysToExpiration);
        }
      }
    }
  }
예제 #3
0
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void BlockBreakEvent(BlockBreakEvent e) {

    if (e.getBlock().hasMetadata("ce.Ice")) e.setCancelled(true);

    CEventHandler.handleEvent(e.getPlayer(), e, blockBroken);
    if (e.getBlock().hasMetadata("ce.mine")) {
      Block b = e.getBlock();
      b.removeMetadata("ce.mine", Main.plugin);
      Block[] blocks = {
        b.getRelative(0, 1, 0),
        b.getRelative(1, 0, 0),
        b.getRelative(-1, 0, 0),
        b.getRelative(0, 0, 1),
        b.getRelative(0, 0, -1)
      };

      for (Block block : blocks) {
        if (block.hasMetadata("ce.mine.secondary")) {
          String[] s = block.getMetadata("ce.mine.secondary").get(0).asString().split(" ");
          Location loc =
              new Location(
                  e.getPlayer().getWorld(),
                  Integer.parseInt(s[0]),
                  Integer.parseInt(s[1]),
                  Integer.parseInt(s[2]));
          Location blockLoc = b.getLocation();
          if (loc.getBlockX() == blockLoc.getBlockX()
              && loc.getBlockY() == blockLoc.getBlockY()
              && loc.getBlockZ() == blockLoc.getBlockZ())
            block.removeMetadata("ce.mine.secondary", Main.plugin);
        }
      }
    }
  }
예제 #4
0
  @EventHandler
  public void onBlockBreak(BlockBreakEvent event) {
    if (event.isCancelled() || event.getPlayer() == null) {
      return;
    }

    Player player = event.getPlayer();
    String name = player.getName().toLowerCase();

    if (CitizensCommunicator.isNPC(player)) {
      return;
    }

    if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
      return;
    }

    if (!data.isAuthAvailable(name)) {
      if (!settings.isForcedRegistrationEnabled()) {
        return;
      }
    }

    event.setCancelled(true);
  }
예제 #5
0
  /** Removes chests when they're destroyed. */
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onBreak(final BlockBreakEvent e) {
    if (e.isCancelled()) return;

    Block b = e.getBlock();
    Player p = e.getPlayer();

    // If the chest was a chest
    if (b.getType() == Material.CHEST) {
      Shop shop = plugin.getShopManager().getShop(b.getLocation());
      // If it was a shop
      if (shop != null) {
        if (plugin.lock) {
          // If they owned it or have bypass perms, they can destroy it
          if (!shop.getOwner().equalsIgnoreCase(p.getName())
              && !p.hasPermission("quickshop.other.destroy")) {
            e.setCancelled(true);
            p.sendMessage(MsgUtil.getMessage("no-permission"));
            return;
          }
        }

        // If they're either survival or the owner, they can break it
        if (p.getGameMode() == GameMode.CREATIVE
            && !p.getName().equalsIgnoreCase(shop.getOwner())) {
          e.setCancelled(true);
          p.sendMessage(MsgUtil.getMessage("no-creative-break"));
          return;
        }

        // Cancel their current menu... Doesnt cancel other's menu's.
        Info action = plugin.getShopManager().getActions().get(p.getName());
        if (action != null) {
          action.setAction(ShopAction.CANCELLED);
        }
        shop.delete();
        p.sendMessage(MsgUtil.getMessage("success-removed-shop"));
      }
    } else if (b.getType() == Material.WALL_SIGN) {
      Shop shop = getShopNextTo(e.getBlock().getLocation());
      if (shop != null) { // It is a shop sign we're dealing with.
        if (plugin.lock) {
          // If they're the shop owner or have bypass perms, they can destroy it.
          if (!shop.getOwner().equalsIgnoreCase(p.getName())
              && !e.getPlayer().hasPermission("quickshop.other.destroy")) {
            e.setCancelled(true);
            p.sendMessage(MsgUtil.getMessage("no-permission"));
            return;
          }
        }
        // If they're in creative and not the owner, don't let them (accidents happen)
        if (p.getGameMode() == GameMode.CREATIVE
            && !p.getName().equalsIgnoreCase(shop.getOwner())) {
          e.setCancelled(true);
          p.sendMessage(MsgUtil.getMessage("no-creative-break"));
          return;
        }
      }
    }
  }
 @HawkEvent(dataType = DataType.BLOCK_BREAK)
 public void onBlockBreak(BlockBreakEvent event) {
   Block block = event.getBlock();
   if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)
     DataManager.addEntry(new SignEntry(event.getPlayer(), DataType.SIGN_BREAK, event.getBlock()));
   DataManager.addEntry(new BlockEntry(event.getPlayer(), DataType.BLOCK_BREAK, block));
 }
예제 #7
0
 @EventHandler(ignoreCancelled = true)
 public void onBlockBreak(BlockBreakEvent event) {
   if (!event.getPlayer().hasPermission("permissions.build")) {
     bother(event.getPlayer());
     event.setCancelled(true);
   }
 }
예제 #8
0
 @EventHandler
 public void onBlockBreak(BlockBreakEvent e) {
   if (Store.jailed.contains(e.getPlayer().getName())) {
     e.setCancelled(true);
     e.getPlayer().sendMessage(Util.colour(pl.getConfig().getString("law.crimeMessage")));
   }
 }
 // If block was removed, get rid of it from the HashMap
 @EventHandler
 public void onBlockBreak(BlockBreakEvent event) {
   if (plugin.getBlockCommandMap().get(event.getBlock().getLocation()) != null) {
     // Only remove a command block if the player is op
     if (event.getPlayer().hasPermission("autoruncommands.removeblock"))
       plugin.getBlockCommandMap().remove(event.getBlock().getLocation());
     else {
       event.getPlayer().sendMessage("You don't have permission to remove this block");
       event.setCancelled(true);
     }
   }
 }
예제 #10
0
 @EventHandler
 public void onBlockBreak(BlockBreakEvent event) {
   if (event.getPlayer() == player) {
     if (step == -1) {
       double lengthX = Math.abs(event.getBlock().getX() - event.getPlayer().getLocation().getX());
       double lengthZ = Math.abs(event.getBlock().getZ() - event.getPlayer().getLocation().getZ());
       double v = getMaxDouble(lengthX >= lengthZ ? lengthX : lengthZ);
       if (v != -1) {
         blockBreakMax = v;
       }
     }
   }
 }
 @Override
 public void onBlockBreak(BlockBreakEvent event) {
   Shop s = plugin.GetShop(event.getBlock().getLocation());
   if (s == null) return;
   if (s.getOwner().equalsIgnoreCase(event.getPlayer().getName())) {
     for (int i = s.getStock(); i > 0; i -= 64) {
       if (i >= 64)
         event
             .getBlock()
             .getWorld()
             .dropItemNaturally(event.getBlock().getLocation(), new ItemStack(s.getItemId(), 64));
       else
         event
             .getBlock()
             .getWorld()
             .dropItemNaturally(event.getBlock().getLocation(), new ItemStack(s.getItemId(), i));
     }
     for (int i = s.getBalance(); i > 0; i -= 64) {
       if (i >= 64)
         event
             .getBlock()
             .getWorld()
             .dropItemNaturally(event.getBlock().getLocation(), new ItemStack(s.getCurId(), 64));
       else
         event
             .getBlock()
             .getWorld()
             .dropItemNaturally(event.getBlock().getLocation(), new ItemStack(s.getCurId(), i));
     }
     plugin.getDatabase().delete(s);
     event.getPlayer().sendMessage("Sign shop removed.");
   } else {
     Sign block = new CraftSign(event.getBlock());
     event.setCancelled(true);
     if (s.getItemId() != 0) {
       block.setLine(0, s.getOwner());
       block.setLine(1, Material.getMaterial(s.getItemId()).toString());
       block.setLine(2, s.getCount() + " for " + s.getPrice() + " " + s.getCurName());
       block.setLine(3, s.getStock() + " items.");
     } else {
       block.setLine(0, s.getOwner());
       block.setLine(1, s.getPrice() + " " + s.getCurName());
       block.setLine(2, "Right click me");
       block.setLine(3, "with something");
     }
     block.update();
     event.getPlayer().sendMessage("Stop trying to grief " + s.getOwner() + "'s shops.");
   }
 }
 @EventHandler
 public void onBlockBreak(BlockBreakEvent event) {
   if (VAR.config.getBoolean("enableRules")) {
     if (VAR.config.getString("PreventNotAccepted").toLowerCase().contains("blockbreak")) {
       if (!VAR.pLog
           .getString("players." + event.getPlayer().getName() + ".Has accepted rules")
           .equalsIgnoreCase("true")) {
         String msg = VAR.config.getString("RulesNotAcceptedMsg");
         msg = ip.replace(msg, event.getPlayer());
         event.getPlayer().sendMessage(msg);
         event.setCancelled(true);
       }
     }
   }
 }
예제 #13
0
 @EventHandler
 public void onBlockBreak(BlockBreakEvent event) {
   if (config.logXRay()) {
     Player p = event.getPlayer();
     String player = p.getName();
     if (checkManager.willCheck(p, CheckType.XRAY)) {
       Material m = event.getBlock().getType();
       if (m == Material.DIAMOND_ORE) {
         tracker.addDiamond(player);
       } else if (m == Material.IRON_ORE) {
         tracker.addIron(player);
       } else if (m == Material.COAL_ORE) {
         tracker.addCoal(player);
       } else if (m == Material.GOLD_ORE) {
         tracker.addGold(player);
       } else if (m == Material.LAPIS_ORE) {
         tracker.addLapis(player);
       } else if (m == Material.REDSTONE_ORE) {
         tracker.addRedstone(player);
       } else if (m == Material.GOLD_ORE) {
         tracker.addGold(player);
       } else {
         tracker.addBlock(player);
       }
       tracker.addTotal(player);
     }
   }
 }
예제 #14
0
  public void onBlockBreak(BlockBreakEvent event) {

    Block blockBreaked = event.getBlock();
    World world = blockBreaked.getWorld();
    Player player = event.getPlayer();

    // Sand/Gravel check when destroying a block

    if (world.getBlockTypeIdAt(blockBreaked.getX(), blockBreaked.getY() + 1, blockBreaked.getZ())
            == 12
        || world.getBlockTypeIdAt(blockBreaked.getX(), blockBreaked.getY() + 1, blockBreaked.getZ())
            == 13) {

      if (WorldGuard.getWorldGuardState() == false) {
        player.sendMessage(ChatColor.DARK_RED + "The required plugin is not enabled.");
        event.setCancelled(true);
        return;
      }

      for (int i = blockBreaked.getY() - 1; i >= 1; i = i - 1) {
        int xx = blockBreaked.getX();
        int yy = i;
        int zz = blockBreaked.getZ();
        Location location = new Location(world, xx, yy, zz);
        if (world.getBlockTypeIdAt(xx, yy, zz) != 0) {
          return;
        }
        if (!WorldGuard.IsMemberOnLocation(player, location)) {
          player.sendMessage(ChatColor.RED + "A block on this one is going to fall into a region.");
          event.setCancelled(true);
          return;
        }
      }
    }
  }
예제 #15
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onBlockBreak(BlockBreakEvent event) {
    Player p = event.getPlayer();
    int pid = GameManager.getInstance().getPlayerGameId(p);

    if (pid == -1) {
      int blockgameid = GameManager.getInstance().getBlockGameId(event.getBlock().getLocation());

      if (blockgameid != -1) {
        if (GameManager.getInstance().getGame(blockgameid).getGameMode()
            != Game.GameMode.DISABLED) {
          event.setCancelled(true);
        }
      }
      return;
    }

    Game g = GameManager.getInstance().getGame(pid);

    if (g.getMode() == Game.GameMode.DISABLED) {
      return;
    }
    if (g.getMode() != Game.GameMode.INGAME) {
      event.setCancelled(true);
      return;
    }

    if (!allowedBreak.contains(event.getBlock().getTypeId())) event.setCancelled(true);
  }
  @Override
  public void onBlockBreak(BlockBreakEvent inEvent) {
    Player thePlayer = inEvent.getPlayer();
    Block theBlock = inEvent.getBlock();

    if ((theBlock.getType() != Material.MOB_SPAWNER) || (inEvent.isCancelled())) return;

    if (creaturebox.permissions != null) {
      if (creaturebox.permissions.has(thePlayer, "creaturebox.dropspawner") == false) {
        return;
      }
    } else {
      if (thePlayer.isOp() == false) {
        return;
      }
    }

    World theWorld = theBlock.getWorld();
    Location theLocation =
        new Location(theWorld, theBlock.getX(), theBlock.getY(), theBlock.getZ(), 0, 0);
    CreatureSpawner theSpawner = (CreatureSpawner) theBlock.getState();
    int theCreatureIndex = plugin.creatureIndex(theSpawner.getCreatureTypeId());

    MaterialData theMaterial = new MaterialData(Material.MOB_SPAWNER, (byte) theCreatureIndex);
    ItemStack theItem = new ItemStack(Material.MOB_SPAWNER, 1, (short) theCreatureIndex);

    theWorld.dropItemNaturally(theLocation, theItem);

    thePlayer.sendMessage(
        String.format(
            ChatColor.YELLOW + "creaturebox: %s spawner dropped.", theSpawner.getCreatureTypeId()));
  }
예제 #17
0
  @Override
  protected void onBlockBreak(BlockBreakEvent evt, Block blk) {
    // TODO Auto-generated method stub
    super.onBlockBreak(evt, blk);
    Player ply = evt.getPlayer();

    Cuboid cub = pMapaActual().ObtenirCuboid("RegC", getWorld());
    if (cub.contains(blk)) {
      evt.setCancelled(true);
    }
    if (blk.getType() != Material.HARD_CLAY && blk.getData() != 11) {
      //			if(blk.getType() == Material.BEACON){
      //				for (Objectiu obj : obtenirObjectiusPly(ply)){
      //
      //	//Bukkit.broadcastMessage(Double.toString(obj.getLocation().distance(blk.getLocation())));
      //					if (obj.getLocation().distance(blk.getLocation()) < 2){
      //						obj.complete(ply);
      //
      //					}
      //
      //				}
      //			}else{
      //
      //			}
      //			//Bukkit.broadcastMessage("Retard!");
    } else {
      evt.setCancelled(true);
    }
  }
예제 #18
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onBlockBreak(BlockBreakEvent event) {
   Player p = event.getPlayer();
   SFPlayer sfp = SFPlayer.getSFPlayer(p);
   if (!p.isOp()) {
     if (plugin.getConfig().getBoolean("features.spawnprotect", true)) {
       boolean inspawn = SFPlugin.isInSpawnProtect(event.getBlock().getLocation(), plugin);
       if (inspawn) {
         event.setCancelled(true);
         p.sendMessage(ChatColor.RED + sfp.translateString("general.inspawnprotect"));
       }
     }
     if (plugin.getConfig().getBoolean("features.bedrockprotect", true)) {
       if (p.getGameMode().equals(GameMode.CREATIVE)) {
         if (!event.isCancelled()) {
           if (event.getBlock().getY() < Double.valueOf(7)
               && event.getBlock().getType().equals(Material.BEDROCK)) {
             event.setCancelled(true);
             p.sendMessage(ChatColor.RED + sfp.translateString("general.bedrockblocked.removal"));
           }
         }
       }
     }
   }
 }
예제 #19
0
 /**
  * Blocks block breaking inside an arena for players not in that arena,<br>
  * or if the block's material is not whitelisted for breaking.
  *
  * <p>Stops blocks with ug signs attached from breaking.
  */
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onBlockBreak(BlockBreakEvent event) {
   Arena arena = ultimateGames.getArenaManager().getLocationArena(event.getBlock().getLocation());
   if (arena != null) {
     String playerName = event.getPlayer().getName();
     if (ultimateGames.getPlayerManager().isPlayerInArena(playerName)) {
       if (!ultimateGames.getPlayerManager().getArenaPlayer(playerName).isEditing()) {
         if (arena.getStatus() == ArenaStatus.RUNNING
             && ultimateGames
                 .getWhitelistManager()
                 .getBlockBreakWhitelist()
                 .canBreakMaterial(arena.getGame(), event.getBlock().getType())) {
           Block block = event.getBlock();
           if ((block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
               && ultimateGames.getUGSignManager().isUGSign((Sign) block.getState())) {
             event.setCancelled(true);
             return;
           }
           for (Sign attachedSign : UGUtils.getAttachedSigns(block, true)) {
             if (ultimateGames.getUGSignManager().isUGSign(attachedSign)) {
               event.setCancelled(true);
               return;
             }
           }
           arena.getGame().getGamePlugin().onBlockBreak(arena, event);
         } else {
           event.setCancelled(true);
         }
       }
     } else {
       event.setCancelled(true);
     }
   }
 }
예제 #20
0
 @EventHandler
 public void onBlockBreak(BlockBreakEvent event) {
   String playerID = PlayerConverter.getID(event.getPlayer());
   // if the player has this objective, the event isn't canceled,
   // the block is correct and conditions are met
   if (containsPlayer(playerID)
       && !event.isCancelled()
       && event.getBlock().getType().equals(material)
       && (data < 0 || event.getBlock().getData() == data)
       && checkConditions(playerID)) {
     // remove the block from the total amount
     BlockData playerData = (BlockData) dataMap.get(playerID);
     playerData.remove();
     // complete the objective
     if (playerData.getAmount() == neededAmount) {
       completeObjective(playerID);
     } else if (notify) {
       // or maybe display a notification
       if (playerData.getAmount() > neededAmount) {
         Config.sendMessage(
             playerID,
             "blocks_to_break",
             new String[] {String.valueOf(playerData.getAmount() - neededAmount)});
       } else {
         Config.sendMessage(
             playerID,
             "blocks_to_place",
             new String[] {String.valueOf(neededAmount - playerData.getAmount())});
       }
     }
   }
 }
예제 #21
0
  /**
   * Lobby break.
   *
   * @param BlockBreakEvent the event
   */
  @EventHandler(priority = EventPriority.LOW)
  public void lobbyBreak(BlockBreakEvent e) {
    if (this.blacklist.contains(e.getPlayer().getWorld().getName())) return;
    if (!this.protectionSet) return;

    Player player = e.getPlayer();
    String wo = player.getWorld().getName();

    if (!VaultManager.getInstance().perms.has(player, "ssba.admin.breakblocks")) {
      if (SkyApi.getLobbyManager().getLobbyRg().isAABB(e.getBlock().getLocation().toVector())) {
        e.setCancelled(true);
        player.sendMessage(
            SkyApi.getMessageManager().getErrorMessage("listeners.blockbreak.lobbyBreak"));
      }
    }
  }
예제 #22
0
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onBlockBreak(BlockBreakEvent event) {
    ZoneManager manager = m_plugin.getZoneManager();
    Zone zone = manager.getZone(event.getBlock().getLocation());

    if (zone == null) {
      return;
    }

    if (!zone.canPlayerUse(event.getPlayer(), event.getBlock())) {
      sendMessageNoSpam(event.getPlayer(), UI.getMessage("NoBuild"));
      event.setCancelled(true);
      if (shouldBurn(event.getBlock())) {
        event.getPlayer().setFireTicks(100);
      }
    }
  }
예제 #23
0
 @EventHandler(priority = EventPriority.LOWEST)
 public void onBlockBreak(BlockBreakEvent e) {
   if (!plugin.isProtected()) return;
   if (plugin.checkBlocks(e.getBlock().getLocation())) {
     e.setCancelled(true);
     e.getPlayer().sendMessage("Cannot edit blocks in Town Warp zone");
   }
 }
예제 #24
0
파일: JL.java 프로젝트: rakerz/JailLikeHell
  @EventHandler
  public void onBlockBreak(BlockBreakEvent event) {
    Block block = event.getBlock();
    Player player = event.getPlayer();

    if (!plugin.hasPermission(player, "JailLikeHell.bypassProtection")) {
      if (isProtected(block)) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(ChatColor.RED + "[JailLikeHell] You cannot escape the jail!");

        int jbt = plugin.getConfig().getInt("jailBreakPunishTime", 120);
        if (jbt > 0) {
          plugin.increaseSentence(player, jbt);
        }
      }
    }
  }
 @EventHandler(priority = EventPriority.MONITOR)
 public void onBlockBreak(BlockBreakEvent event) {
   for (Player player : Bukkit.getOnlinePlayers()) {
     Location location = event.getBlock().getLocation();
     location.setY(location.getY() + 1);
     Location playerLoc = player.getLocation();
     if (playerLoc.getBlockX() == location.getBlockX()
         && playerLoc.getBlockY() == location.getBlockY()
         && playerLoc.getBlockZ() == location.getBlockZ()) {
       Bukkit.getServer()
           .getPluginManager()
           .callEvent(
               new TrackerSpleefEvent(
                   player, event.getPlayer(), event.getPlayer().getItemInHand(), Type.PLAYER));
     }
   }
 }
 public void callBlockEvent(BlockEvent event) {
   if (event instanceof BlockBreakEvent) {
     BlockBreakEvent blockBreakEvent = (BlockBreakEvent) event;
     List<BlockMechanic> mechanicsList =
         blockMechanicMap.get(blockBreakEvent.getBlock().getType());
     if (mechanicsList == null) {
       mechanicsList = new ArrayList<BlockMechanic>();
     }
     if (blockMechanicMap.containsKey(null)) {
       mechanicsList.addAll(blockMechanicMap.get(null));
     }
     if (redstoneBlockMechanicMap.containsKey(blockBreakEvent.getBlock().getType())) {
       mechanicsList.addAll(redstoneBlockMechanicMap.get(blockBreakEvent.getBlock().getType()));
     }
     for (BlockMechanic mechanic : mechanicsList) {
       if (mechanic.getMechanicActivator() == null
           || mechanic
               .getMechanicActivator()
               .contains(blockBreakEvent.getPlayer().getItemInHand().getType())) {
         mechanic.onBlockBreak(blockBreakEvent.getPlayer(), blockBreakEvent.getBlock());
       }
     }
   } else if (event instanceof BlockPlaceEvent) {
     BlockPlaceEvent blockPlaceEvent = (BlockPlaceEvent) event;
     List<BlockMechanic> mechanicsList =
         blockMechanicMap.get(blockPlaceEvent.getBlock().getType());
     if (mechanicsList == null) {
       mechanicsList = new ArrayList<BlockMechanic>();
     }
     if (blockMechanicMap.containsKey(null)) {
       mechanicsList.addAll(blockMechanicMap.get(null));
     }
     if (redstoneBlockMechanicMap.containsKey(blockPlaceEvent.getBlock().getType())) {
       mechanicsList.addAll(redstoneBlockMechanicMap.get(blockPlaceEvent.getBlock().getType()));
     }
     for (BlockMechanic mechanic : mechanicsList) {
       if (mechanic.getMechanicActivator() == null
           || mechanic
               .getMechanicActivator()
               .contains(blockPlaceEvent.getPlayer().getItemInHand().getType())) {
         mechanic.onBlockBreak(blockPlaceEvent.getPlayer(), blockPlaceEvent.getBlock());
       }
     }
   }
 }
예제 #27
0
		@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
		public void onBlockBreak(final BlockBreakEvent event)
		{
			final User user = ess.getUser(event.getPlayer());
			if (user.isJailed())
			{
				event.setCancelled(true);
			}
		}
예제 #28
0
  @EventHandler
  public void onPlayerBreakBlock(BlockBreakEvent event) {
    SpleefPlayer player = getHeavySpleef().getSpleefPlayer(event.getPlayer());
    if (!isSpectating(player)) {
      return;
    }

    event.setCancelled(true);
  }
예제 #29
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void onBlockBreak(BlockBreakEvent event) {
   if (event.isCancelled()) return;
   PlayerEvent playerEvent;
   if (SignUtil.isSign(event.getBlock())) {
     playerEvent =
         new PlayerEvent(
             SignUtil.getSign(event.getBlock()),
             PlayerEvent.Action.BREAK,
             event.getPlayer(),
             event);
   } else {
     playerEvent =
         new PlayerEvent(event.getBlock(), PlayerEvent.Action.BREAK, event.getPlayer(), event);
   }
   mechanicsHandler.callPlayerEvent(playerEvent);
   event.setCancelled(playerEvent.isCancelled());
 }
예제 #30
0
  @EventHandler(ignoreCancelled = true)
  public void onBlockBreak(BlockBreakEvent event) {

    if (!plugin.getConfiguration().chairEnabled) return;
    if (hasChair(event.getBlock())) {
      event.setCancelled(true);
      plugin.wrapPlayer(event.getPlayer()).print("This seat is in use!");
    }
  }