예제 #1
0
 @EventHandler(ignoreCancelled = true)
 public void onBlockBreak(BlockBreakEvent event) {
   if (!event.getPlayer().hasPermission("permissions.build")) {
     bother(event.getPlayer());
     event.setCancelled(true);
   }
 }
예제 #2
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);
     }
   }
 }
예제 #3
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);
    }
  }
 @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);
           }
         }
       }
     }
   }
 }
예제 #5
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())});
       }
     }
   }
 }
예제 #6
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;
        }
      }
    }
  }
 @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));
 }
예제 #8
0
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void onBlockBreak(BlockBreakEvent event) {
    if (event.getBlock().getType() != Material.OBSIDIAN) return;

    Block block = event.getBlock();
    ArrayList<PortalLocation> portals = SQLite.obsidian_checker(block);

    for (PortalLocation portal : portals) {
      if (PortalCheck.is_valid_portal(portal.block, block) == false) {
        Portals.instance
            .getLogger()
            .info(
                "Query returned positive. "
                    + "Disabling this portal at "
                    + portal.block.getWorld().getName()
                    + " "
                    + portal.block.getX()
                    + " "
                    + portal.block.getY()
                    + " "
                    + portal.block.getZ());
        SQLite.delete_portal_pair(portal.id);
      }
    }
  }
예제 #9
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")));
   }
 }
  @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()));
  }
예제 #11
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);
  }
예제 #12
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");
   }
 }
예제 #13
0
 @Override
 public void onBlockBreak(BlockBreakEvent event) {
   if (!event.isCancelled()) {
     if (BlockUtil.isSign(event.getBlock())) {
       SignActionDetector.removeDetector(event.getBlock());
     }
   }
 }
예제 #14
0
  @EventHandler
  public void onPlayerBreakBlock(BlockBreakEvent e) {

    Player p = e.getPlayer();

    if (ArenaManager.isPlayerPlaying(p)) {
      e.setCancelled(true);
    }
  }
예제 #15
0
 @EventHandler
 public void onBlockBreak_Appliance(final BlockBreakEvent event) {
   if (MadeToBreak.appliances.contains(event.getBlock().getTypeId())) {
     plugin.l.remove(event.getBlock().getLocation()); // remove location from map
     event.setCancelled(true); // cancel entire vanilla event, cancelling the drops as well
     event.getBlock().setTypeId(0); // set the block to air
     // add any extra drops (which are not technically needed in this case)
   }
 }
예제 #16
0
  @EventHandler
  public void onPlayerBreakBlock(BlockBreakEvent event) {
    SpleefPlayer player = getHeavySpleef().getSpleefPlayer(event.getPlayer());
    if (!isSpectating(player)) {
      return;
    }

    event.setCancelled(true);
  }
예제 #17
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);
			}
		}
예제 #18
0
  /**
   * ブロックを破壊した
   *
   * @param event
   */
  @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  public void onBlockBreak(final BlockBreakEvent event) {
    Block block = event.getBlock();
    Player player = event.getPlayer();

    if (!canBuild(block.getLocation(), player, true)) {
      event.setCancelled(true);
    }
  }
예제 #19
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!");
    }
  }
예제 #20
0
  @EventHandler(priority = EventPriority.MONITOR)
  public void onBlockBreak(BlockBreakEvent e) {
    arbre = new ArrayList<Block>();

    if (e.isCancelled()) {
      return;
    }

    final Block initialBloc = e.getBlock();

    if (initialBloc.getTypeId() != 17) {
      return;
    }

    final byte data = initialBloc.getData();
    Player p = e.getPlayer();

    boolean permEntire = Methods.hasPerm(p, "amatree.entiretree");
    boolean permReplant = Methods.hasPerm(p, "amatree.replanting");

    if (!permEntire && !permReplant) {
      return;
    }

    if (permEntire) {
      gessThree(initialBloc);
      for (Block b : arbre) {
        breakFoliage(b);
        b.breakNaturally();
      }
    }

    if (permReplant) {
      int id = initialBloc.getRelative(BlockFace.DOWN).getTypeId();

      if (id != 2 && id != 3) {
        return;
      }

      Core.plugin
          .getServer()
          .getScheduler()
          .scheduleSyncDelayedTask(
              Core.plugin,
              new Runnable() {

                public void run() {
                  if (initialBloc.getTypeId() == 0) {
                    initialBloc.setTypeId(6);
                    initialBloc.setData(data);
                  }
                }
              },
              1 * 20L);
    }
  }
예제 #21
0
  // No block breaking allowed on server.
  @EventHandler(priority = EventPriority.NORMAL)
  public void onBlockBreak(BlockBreakEvent event) {
    Player player = event.getPlayer();

    // Block breaking allowed if the player has creative immunity.
    if (mobfighter.getConfig().getList("Creative Immunity").contains(player.getDisplayName()))
      return;

    event.setCancelled(true);
  }
예제 #22
0
  @EventHandler
  public void playerBreakBlock(BlockBreakEvent e) {
    if (e.isCancelled()) return;
    if (!Minegusta.getServer().containsWorld(e.getPlayer().getWorld())) return;

    DwarfPower mine = DwarfPower.miningBoost(e);
    if (mine.isPlayer() && mine.isDwarf()) {
      mine.applyMiningBoost();
    }
  }
예제 #23
0
 /*    */ @EventHandler
 /*    */ public void onBlockBreak(BlockBreakEvent event) /*    */ {
   /* 48 */ if ((event.getBlock().getType() == Material.ICE) && (this.iceDrop))
   /*    */ {
     /* 50 */ ItemStack item = new ItemStack(Material.ICE, 1);
     /* 51 */ event.getPlayer().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
     /*    */ }
   /* 53 */ if ((!this.iceWater) && (event.getBlock().getType() == Material.ICE))
     /* 54 */ event.getBlock().setType(Material.AIR);
   /*    */ }
예제 #24
0
  /**
   * Handle the Tree Feller ability.
   *
   * @param event Event to modify
   */
  public static void treeFeller(BlockBreakEvent event) {
    Player player = event.getPlayer();
    Block firstBlock = event.getBlock();
    PlayerProfile profile = Users.getProfile(player);
    ArrayList<Block> toBeFelled = new ArrayList<Block>();

    /* NOTE: Tree Feller will cut upwards like how you actually fell trees */
    processTreeFelling(firstBlock, toBeFelled);
    removeBlocks(toBeFelled, player, profile);
  }
예제 #25
0
 public void onBlockBreak(BlockBreakEvent event) {
   if (event.isCancelled()) return;
   Block block = event.getBlock();
   if (block.getType() == Material.BOOKSHELF) {
     AdvShelf shelf = new AdvShelf(block.getLocation());
     shelf.delete();
     ItemStack stack = new ItemStack(block.getType(), 1);
     block.getWorld().dropItemNaturally(block.getLocation(), stack);
   }
 }
예제 #26
0
 @EventHandler(ignoreCancelled = true)
 public void onBeaconBreak(BlockBreakEvent event) {
   if (!(event.getBlock().getState() instanceof Beacon)) {
     return;
   }
   Beacon beacon = (Beacon) event.getBlock().getState();
   if (this.config.isDropBeacon(beacon)) {
     this.config.removeBeacon();
   }
 }
예제 #27
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void onBlockBreak(BlockBreakEvent event) {
   Block block = event.getBlock();
   if ((block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)) {
     Sign s = (Sign) block.getState();
     if (!plugin.loc.containsKey(block.getLocation())) {
       for (int i = 0; i < s.getLines().length; i++) {
         if (s.getLine(i).toLowerCase().contains("[sortal]")
             || s.getLine(i).toLowerCase().contains(plugin.signContains)) {
           if (!event.getPlayer().hasPermission("sortal.delsign")) {
             event
                 .getPlayer()
                 .sendMessage("[Sortal] You do not have permissions to destroy a [Sortal] sign!");
             event.setCancelled(true);
           }
         }
       }
       return;
     }
     if (!event.getPlayer().hasPermission("sortal.delsign")) {
       event
           .getPlayer()
           .sendMessage("[Sortal] You do not have permissions to destroy a registered sign!");
       event.setCancelled(true);
       return;
     }
     delLoc(block.getLocation());
     plugin.log.info(
         "Registered sign destroyed by "
             + event.getPlayer().getDisplayName()
             + ", AKA "
             + event.getPlayer().getName()
             + "!");
   }
 }
  @EventHandler(priority = EventPriority.NORMAL)
  public void onBlockBreak(BlockBreakEvent event) {
    Player p = event.getPlayer();
    Location block_pos = event.getBlock().getLocation();

    if (TotalFreedomMod.nukeMonitor) {
      TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);

      Location player_pos = p.getLocation();

      boolean out_of_range = false;
      if (!player_pos.getWorld().equals(block_pos.getWorld())) {
        out_of_range = true;
      } else if (player_pos.distanceSquared(block_pos)
          > (TotalFreedomMod.nukeMonitorRange * TotalFreedomMod.nukeMonitorRange)) {
        out_of_range = true;
      }

      if (out_of_range) {
        playerdata.incrementFreecamDestroyCount();
        if (playerdata.getFreecamDestroyCount() > TotalFreedomMod.freecamTriggerCount) {
          TFM_Util.bcastMsg(
              p.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
          TFM_Util.autoEject(
              p, "Freecam (extended range) block breaking is not permitted on this server.");

          playerdata.resetFreecamDestroyCount();

          event.setCancelled(true);
          return;
        }
      }

      playerdata.incrementBlockDestroyCount();
      if (playerdata.getBlockDestroyCount() > TotalFreedomMod.nukeMonitorCountBreak) {
        TFM_Util.bcastMsg(p.getName() + " is breaking blocks too fast!", ChatColor.RED);
        TFM_Util.autoEject(
            p, "You are breaking blocks too fast. Nukers are not permitted on this server.");

        playerdata.resetBlockDestroyCount();

        event.setCancelled(true);
        return;
      }
    }

    if (TotalFreedomMod.protectedAreasEnabled) {
      if (!TFM_SuperadminList.isUserSuperadmin(p)) {
        if (TFM_ProtectedArea.isInProtectedArea(block_pos)) {
          event.setCancelled(true);
          return;
        }
      }
    }
  }
예제 #29
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;
        }
      }
    }
  }
예제 #30
0
 @Override
 public void onBlockBreak(BlockBreakEvent event) {
   if (event.isCancelled()) return;
   /* Call listeners */
   List<Listener> ll = event_handlers.get(event.getType());
   if (ll != null) {
     for (Listener l : ll) {
       ((BlockListener) l).onBlockBreak(event);
     }
   }
 }