Beispiel #1
0
  protected void drop(Block block, Set<Material> dropTypes, int maxRecursion, int rDepth) {
    registerForUndo(block);
    Collection<ItemStack> drops = block.getDrops();
    for (ItemStack drop : drops) {
      block.getWorld().dropItemNaturally(block.getLocation(), drop);
    }

    block.setType(Material.AIR);

    if (rDepth < maxRecursion) {
      tryDrop(block.getRelative(BlockFace.NORTH), dropTypes, maxRecursion, rDepth + 1);
      tryDrop(block.getRelative(BlockFace.WEST), dropTypes, maxRecursion, rDepth + 1);
      tryDrop(block.getRelative(BlockFace.SOUTH), dropTypes, maxRecursion, rDepth + 1);
      tryDrop(block.getRelative(BlockFace.EAST), dropTypes, maxRecursion, rDepth + 1);
      tryDrop(block.getRelative(BlockFace.UP), dropTypes, maxRecursion, rDepth + 1);
      tryDrop(block.getRelative(BlockFace.DOWN), dropTypes, maxRecursion, rDepth + 1);
    }
  }
Beispiel #2
0
 @EventHandler
 public final void BEE(final BlockExplodeEvent event) {
   if (event.blockList().size() <= 0) return;
   final Block block = event.getBlock();
   for (final Entity entity :
       block.getWorld().getNearbyEntities(block.getLocation(), 1.5, 1.5, 1.5)) {
     if (entity.hasMetadata("isminebomb")) {
       final Player player =
           getServer().getPlayerExact(entity.getMetadata("isminebomb").get(0).asString());
       if (player != null) {
         final PlayerInventory inv = player.getInventory();
         for (final Block b : event.blockList()) {
           for (final ItemStack item : b.getDrops(dropItem)) {
             inv.addItem(item);
           }
           b.setType(Material.AIR);
         }
       }
       event.blockList().clear();
       entity.remove();
     }
   }
 }
Beispiel #3
0
 @EventHandler
 public void onBlockBreak(BlockBreakEvent event) {
   Player player = event.getPlayer();
   int itemID = player.getItemInHand().getTypeId();
   boolean allowed = false;
   if (playersActive.containsKey(player.getName())) {
     switch (itemID) {
       case 256:
         if (player.hasPermission("quickdig.iron.shovel")) {
           allowed = true;
         }
         break;
       case 257:
         if (player.hasPermission("quickdig.iron.pickaxe")) {
           allowed = true;
         }
         break;
       case 258:
         if (player.hasPermission("quickdig.iron.axe")) {
           allowed = true;
         }
         break;
       case 269:
         if (player.hasPermission("quickdig.wooden.shovel")) {
           allowed = true;
         }
         break;
       case 270:
         if (player.hasPermission("quickdig.wooden.pickaxe")) {
           allowed = true;
         }
         break;
       case 271:
         if (player.hasPermission("quickdig.wooden.axe")) {
           allowed = true;
         }
         break;
       case 273:
         if (player.hasPermission("quickdig.stone.shovel")) {
           allowed = true;
         }
         break;
       case 274:
         if (player.hasPermission("quickdig.stone.pickaxe")) {
           allowed = true;
         }
         break;
       case 275:
         if (player.hasPermission("quickdig.stone.axe")) {
           allowed = true;
         }
         break;
       case 277:
         if (player.hasPermission("quickdig.diamond.shovel")) {
           allowed = true;
         }
         break;
       case 278:
         if (player.hasPermission("quickdig.diamond.pickaxe")) {
           allowed = true;
         }
         break;
       case 279:
         if (player.hasPermission("quickdig.diamond.axe")) {
           allowed = true;
         }
         break;
       case 284:
         if (player.hasPermission("quickdig.gold.shovel")) {
           allowed = true;
         }
         break;
       case 285:
         if (player.hasPermission("quickdig.gold.pickaxe")) {
           allowed = true;
         }
         break;
       case 286:
         if (player.hasPermission("quickdig.gold.axe")) {
           allowed = true;
         }
         break;
       default:
         allowed = false;
         break;
     }
     if (allowed == false) {
       return;
     }
     Location loc = event.getBlock().getLocation();
     int i = 0;
     String dir = getCardinalDirection(player);
     if (!dir.isEmpty()) {
       while (i < 4) {
         switch (dir) {
           case "N":
             loc =
                 new Location(
                     player.getWorld(),
                     loc.getX(),
                     loc.getY(),
                     loc.getZ() - 1,
                     loc.getYaw(),
                     loc.getPitch());
             break;
           case "E":
             loc =
                 new Location(
                     player.getWorld(),
                     loc.getX() + 1,
                     loc.getY(),
                     loc.getZ(),
                     loc.getYaw(),
                     loc.getPitch());
             break;
           case "S":
             loc =
                 new Location(
                     player.getWorld(),
                     loc.getX(),
                     loc.getY(),
                     loc.getZ() + 1,
                     loc.getYaw(),
                     loc.getPitch());
             break;
           case "W":
             loc =
                 new Location(
                     player.getWorld(),
                     loc.getX() - 1,
                     loc.getY(),
                     loc.getZ(),
                     loc.getYaw(),
                     loc.getPitch());
             break;
           default:
             break;
         }
         Block block = player.getWorld().getBlockAt(loc);
         if (block.getDrops(player.getItemInHand()).isEmpty() == false) {
           if (block.getType() != Material.BEDROCK) {
             block.breakNaturally(player.getItemInHand());
             player
                 .getItemInHand()
                 .setDurability((short) (player.getItemInHand().getDurability() + 2));
             i++;
           } else {
             break;
           }
         } else {
           break;
         }
       }
     }
   }
 }
 @SuppressWarnings("deprecation")
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onBlockBreak(BlockBreakEvent event) {
   if (!plugin.getConfig().getBoolean("track_creative_place.enabled")) {
     return;
   }
   Player p = event.getPlayer();
   Block block = event.getBlock();
   if (block.getType().equals(Material.AIR)) {
     return;
   }
   if (!plugin
       .getConfig()
       .getStringList("track_creative_place.worlds")
       .contains(block.getWorld().getName())) {
     return;
   }
   if (plugin.getNoTrackList().contains(block.getType())) {
     String gmiwc =
         block.getWorld().getName()
             + ","
             + block.getChunk().getX()
             + ","
             + block.getChunk().getZ();
     if (!plugin.getCreativeBlocks().containsKey(gmiwc)) {
       return;
     }
     if (plugin.getCreativeBlocks().get(gmiwc).contains(block.getLocation().toString())) {
       if (p.getGameMode().equals(GameMode.CREATIVE)) {
         plugin.getBlock().removeBlock(gmiwc, block.getLocation().toString());
       } else {
         String message;
         if (plugin.getConfig().getBoolean("track_creative_place.break_no_drop")) {
           // remove the location from the creative blocks list because we're removing the block!
           plugin.getBlock().removeBlock(gmiwc, block.getLocation().toString());
           if (plugin.getBlockLogger().isLogging()) {
             Location loc = block.getLocation();
             String pname = p.getName();
             switch (plugin.getBlockLogger().getWhichLogger()) {
               case CORE_PROTECT: // log the block removal
                 int type = block.getTypeId();
                 byte data = block.getData();
                 plugin.getBlockLogger().getCoreProtectAPI().logRemoval(pname, loc, type, data);
                 break;
               case LOG_BLOCK:
                 plugin
                     .getBlockLogger()
                     .getLogBlockConsumer()
                     .queueBlockBreak(pname, block.getState());
                 break;
               case PRISM:
                 if (plugin.getBlockLogger().getPrism() != null) {
                   GameModeInventoriesPrismHandler.log(loc, block, pname);
                 }
                 break;
               default:
                 break;
             }
           }
           block.setType(Material.AIR);
           block.getDrops().clear();
           message = plugin.getM().getMessage().get("NO_CREATIVE_DROPS");
         } else {
           event.setCancelled(true);
           message = plugin.getM().getMessage().get("NO_CREATIVE_BREAK");
         }
         if (!plugin.getConfig().getBoolean("dont_spam_chat")) {
           p.sendMessage(plugin.MY_PLUGIN_NAME + message);
         }
       }
     }
   }
 }