public static boolean isRocketBlock(Block b) {
   for (CustomPlayer cp : Core.getCustomPlayers()) {
     if (cp.currentGadget != null && cp.currentGadget.getType() == Gadget.GadgetType.ROCKET) {
       GadgetRocket rocket = (GadgetRocket) cp.currentGadget;
       if (rocket.blocks.contains(b)) return true;
     }
   }
   return false;
 }
 /**
  * Replaces a block with a new material and data, and after delay, restore it.
  *
  * @param b The block.
  * @param newType The new material.
  * @param newData The new data.
  * @param tickDelay The delay after which the block is restored.
  */
 public static void setToRestore(final Block b, Material newType, byte newData, int tickDelay) {
   if (blocksToRestore.containsKey(b.getLocation())) return;
   Block bUp = b.getRelative(BlockFace.UP);
   if (b.getType() != Material.AIR
       && b.getType() != Material.SIGN_POST
       && b.getType() != Material.CHEST
       && b.getType() != Material.STONE_PLATE
       && b.getType() != Material.WOOD_PLATE
       && b.getType() != Material.WALL_SIGN
       && b.getType() != Material.WALL_BANNER
       && b.getType() != Material.STANDING_BANNER
       && b.getType() != Material.CROPS
       && b.getType() != Material.LONG_GRASS
       && b.getType() != Material.SAPLING
       && b.getType() != Material.DEAD_BUSH
       && b.getType() != Material.RED_ROSE
       && b.getType() != Material.RED_MUSHROOM
       && b.getType() != Material.BROWN_MUSHROOM
       && b.getType() != Material.TORCH
       && b.getType() != Material.LADDER
       && b.getType() != Material.VINE
       && b.getType() != Material.DOUBLE_PLANT
       && b.getType() != Material.PORTAL
       && b.getType() != Material.CACTUS
       && b.getType() != Material.WATER
       && b.getType() != Material.STATIONARY_WATER
       && b.getType() != Material.LAVA
       && b.getType() != Material.STATIONARY_LAVA
       && b.getType() != Material.PORTAL
       && b.getType() != Material.ENDER_PORTAL
       && b.getType() != Material.SOIL
       && b.getType() != Material.BARRIER
       && b.getType() != Material.COMMAND
       && !isPortalBlock(b)
       && !isRocketBlock(b)
       && net.minecraft.server.v1_8_R3.Block.getById(b.getTypeId()).getMaterial().isSolid()
       && a(bUp)
       && b.getType().getId() != 43
       && b.getType().getId() != 44) {
     if (!blocksToRestore.containsKey(b.getLocation())) {
       blocksToRestore.put(b.getLocation(), b.getType().toString() + "," + b.getData());
       b.setType(newType);
       b.setData(newData);
       Bukkit.getScheduler()
           .runTaskLater(
               Core.getPlugin(),
               new Runnable() {
                 @Override
                 public void run() {
                   restoreBlockAt(b.getLocation());
                 }
               },
               tickDelay);
     }
   }
 }
 public GadgetMelonThrower(UUID owner) {
   super(
       Material.MELON,
       (byte) 0x0,
       "MelonThrower",
       "ultracosmetics.gadgets.melonthrower",
       1.5f,
       owner,
       GadgetType.MELONTHROWER);
   Core.registerListener(this);
 }
 @Override
 void onUpdate() {
   try {
     for (Item item : melonBlocks) {
       if (item.isOnGround()) {
         item.getWorld().playEffect(item.getLocation(), Effect.STEP_SOUND, 103);
         for (int i = 0; i < 8; i++) {
           final Item melon =
               getPlayer()
                   .getWorld()
                   .dropItem(
                       item.getLocation(),
                       ItemFactory.create(
                           Material.MELON, (byte) 0x0, UUID.randomUUID().toString()));
           melon.setVelocity(
               new Vector(
                       random.nextDouble() - 0.5,
                       random.nextDouble() / 2.0,
                       random.nextDouble() - 0.5)
                   .multiply(0.75D));
           melons.add(melon);
           Bukkit.getScheduler()
               .runTaskLaterAsynchronously(
                   Core.getPlugin(),
                   new BukkitRunnable() {
                     @Override
                     public void run() {
                       if (melon.isValid()) {
                         melon.remove();
                         melons.remove(melon);
                       }
                     }
                   },
                   100);
         }
         melonBlocks.remove(item);
         item.remove();
       }
     }
   } catch (Exception exc) {
   }
 }