コード例 #1
0
 public void clearNearbyItems() {
   if (item == null) {
     return;
   }
   List<Entity> nearbyEntities = item.getNearbyEntities(7, 7, 7);
   for (Entity entity : nearbyEntities) {
     if (entity instanceof Item) {
       Item nearbyItem = (Item) entity;
       boolean display = false;
       for (MetadataValue cmeta : nearbyItem.getMetadata("HyperConomy")) {
         if (cmeta.asString().equalsIgnoreCase("item_display")) {
           display = true;
           break;
         }
       }
       if (!nearbyItem.equals(item) && !display) {
         if (nearbyItem.getItemStack().getType() == item.getItemStack().getType()) {
           HyperItemStack near = new HyperItemStack(nearbyItem.getItemStack());
           HyperItemStack displayItem = new HyperItemStack(item.getItemStack());
           if (near.getDamageValue() == displayItem.getDamageValue()) {
             entity.remove();
           }
         }
       }
     }
   }
 }
コード例 #2
0
ファイル: Fishing.java プロジェクト: bigggan/mcMMO
  /**
   * Get item results from Fishing.
   *
   * @param player The player that was fishing
   * @param event The event to modify
   */
  private static void getFishingResults(Player player, PlayerFishEvent event) {
    PlayerProfile PP = Users.getProfile(player);
    List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
    Item theCatch = (Item) event.getCaught();

    switch (getFishingLootTier(PP)) {
      case 1:
        rewards = LoadTreasures.fishingRewardsTier1;
        break;

      case 2:
        rewards = LoadTreasures.fishingRewardsTier2;
        break;

      case 3:
        rewards = LoadTreasures.fishingRewardsTier3;
        break;

      case 4:
        rewards = LoadTreasures.fishingRewardsTier4;
        break;

      case 5:
        rewards = LoadTreasures.fishingRewardsTier5;
        break;

      default:
        break;
    }

    if (LoadProperties.fishingDrops) {
      FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));

      if (random.nextDouble() * 100 <= treasure.getDropChance()) {
        Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp());
        theCatch.setItemStack(treasure.getDrop());
      }
    } else {
      theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
    }

    short maxDurability = theCatch.getItemStack().getType().getMaxDurability();

    if (maxDurability > 0) {
      theCatch
          .getItemStack()
          .setDurability(
              (short) (random.nextInt(maxDurability))); // Change durability to random value
    }

    m.mcDropItem(player.getLocation(), new ItemStack(Material.RAW_FISH)); // Always drop a fish
    PP.addXP(SkillType.FISHING, LoadProperties.mfishing);
    Skills.XpCheckSkill(SkillType.FISHING, player);
  }
コード例 #3
0
  /**
   * Called when a player attempts to pickup an item
   *
   * @param event Relevant event details
   */
  @Override
  public void onPlayerPickupItem(PlayerPickupItemEvent event) {

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

    GlobalConfiguration cfg = plugin.getGlobalConfiguration();
    WorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());

    if (wcfg.getBlacklist() != null) {
      Item ci = event.getItem();

      if (!wcfg.getBlacklist()
          .check(
              new ItemAcquireBlacklistEvent(
                  BukkitPlayer.wrapPlayer(plugin, event.getPlayer()),
                  toVector(ci.getLocation()),
                  ci.getItemStack().getTypeId()),
              false,
              false)) {
        event.setCancelled(true);
        return;
      }
    }
  }
コード例 #4
0
ファイル: Fishing.java プロジェクト: bigggan/mcMMO
  /**
   * Process results from Fishing.
   *
   * @param event The event to modify
   */
  public static void processResults(PlayerFishEvent event) {
    Player player = event.getPlayer();
    PlayerProfile PP = Users.getProfile(player);

    getFishingResults(player, event);
    Item theCatch = (Item) event.getCaught();

    if (theCatch.getItemStack().getType() != Material.RAW_FISH) {
      final int ENCHANTMENT_CHANCE = 10;
      boolean enchanted = false;
      ItemStack fishingResults = theCatch.getItemStack();

      player.sendMessage(mcLocale.getString("Fishing.ItemFound"));
      if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) {
        if (random.nextInt(100) <= ENCHANTMENT_CHANCE) {
          for (Enchantment newEnchant : Enchantment.values()) {
            if (newEnchant.canEnchantItem(fishingResults)) {
              Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments();

              for (Enchantment oldEnchant : resultEnchantments.keySet()) {
                if (oldEnchant.conflictsWith(newEnchant)) {
                  return;
                }
              }

              /* Actual chance to have an enchantment is related to your fishing skill */
              if (random.nextInt(15) < Fishing.getFishingLootTier(PP)) {
                enchanted = true;
                int randomEnchantLevel = random.nextInt(newEnchant.getMaxLevel()) + 1;

                if (randomEnchantLevel < newEnchant.getStartLevel()) {
                  randomEnchantLevel = newEnchant.getStartLevel();
                }

                fishingResults.addEnchantment(newEnchant, randomEnchantLevel);
              }
            }
          }
        }
      }

      if (enchanted) {
        player.sendMessage(mcLocale.getString("Fishing.MagicFound"));
      }
    }
  }
コード例 #5
0
ファイル: DropTransferModule.java プロジェクト: Carpeeet/LWC
  @Override
  @SuppressWarnings("deprecation")
  public void onDropItem(LWCDropItemEvent event) {
    Player bPlayer = event.getPlayer();
    Item item = event.getEvent().getItemDrop();
    ItemStack itemStack = item.getItemStack();

    LWCPlayer player = lwc.wrapPlayer(bPlayer);
    int protectionId = getPlayerDropTransferTarget(player);

    if (protectionId == -1) {
      return;
    }

    if (!isPlayerDropTransferring(player)) {
      return;
    }

    Protection protection = lwc.getPhysicalDatabase().loadProtection(protectionId);

    if (protection == null) {
      lwc.sendLocale(player, "lwc.nolongerexists");
      player.disableMode(player.getMode("dropTransfer"));
      return;
    }

    // load the world and the inventory
    World world = player.getServer().getWorld(protection.getWorld());

    if (world == null) {
      lwc.sendLocale(player, "lwc.invalidworld");
      player.disableMode(player.getMode("dropTransfer"));
      return;
    }

    // Don't allow them to transfer items across worlds
    if (bPlayer.getWorld() != world
        && !lwc.getConfiguration().getBoolean("modes.droptransfer.crossWorld", false)) {
      lwc.sendLocale(player, "lwc.dropxfer.acrossworlds");
      player.disableMode(player.getMode("dropTransfer"));
      return;
    }

    Block block = world.getBlockAt(protection.getX(), protection.getY(), protection.getZ());
    Map<Integer, ItemStack> remaining = lwc.depositItems(block, itemStack);

    if (remaining.size() > 0) {
      lwc.sendLocale(player, "lwc.dropxfer.chestfull");

      for (ItemStack temp : remaining.values()) {
        bPlayer.getInventory().addItem(temp);
      }
    }

    bPlayer.updateInventory(); // if they're in the chest and dropping items, this is required
    item.remove();
  }
コード例 #6
0
 public void onPlayerPickupItem(PlayerPickupItemEvent event) {
   SpoutPlayer sPlayer = SpoutManager.getPlayer(event.getPlayer());
   Item item = event.getItem();
   String music = plugin.config.getString("effect." + item.getItemStack().getType().name(), "");
   if (music == "") {
     music = plugin.config.getString("effect.DEFAULT", "");
   }
   if (music != "") {
     SpoutManager.getSoundManager().playCustomSoundEffect(plugin, sPlayer, music, true);
   }
 }
コード例 #7
0
 public boolean blockItemDrop(Item droppedItem) {
   HyperItemStack dropped = new HyperItemStack(droppedItem.getItemStack());
   HyperItemStack displayItem = new HyperItemStack(item.getItemStack());
   Location l = droppedItem.getLocation();
   Material dropType = droppedItem.getItemStack().getType();
   int dropda = dropped.getDamageValue();
   double dropx = l.getX();
   double dropy = l.getY();
   double dropz = l.getZ();
   World dropworld = l.getWorld();
   Material type = item.getItemStack().getType();
   int da = displayItem.getDamageValue();
   if (type == dropType) {
     if (da == dropda) {
       if (dropworld.equals(location.getWorld())) {
         if (Math.abs(dropx - location.getX()) < 10) {
           if (Math.abs(dropz - location.getZ()) < 10) {
             if (Math.abs(dropy - location.getY()) < 30) {
               return true;
             } else {
               droppedItem.setVelocity(new Vector(0, 0, 0));
               Block dblock = droppedItem.getLocation().getBlock();
               while (dblock.getType().equals(Material.AIR)) {
                 dblock = dblock.getRelative(BlockFace.DOWN);
               }
               if (dblock.getLocation().getY() <= (location.getBlockY() + 10)) {
                 return true;
               }
             }
           }
         }
       }
     }
   }
   return false;
 }
コード例 #8
0
  void removeItems(Material material, org.bukkit.Location location, float maximumDistance) {
    // find items to remove
    List<Item> itemsToRemove = new ArrayList<Item>();
    for (Item item : location.getWorld().getEntitiesByClass(Item.class)) {
      ItemStack stack = item.getItemStack();
      if (stack.getType() == material) {
        if (item.getLocation().distance(location) <= maximumDistance) {
          itemsToRemove.add(item);
        }
      }
    }

    // remove items
    for (Item item : itemsToRemove) {
      item.remove();
    }
  }
コード例 #9
0
ファイル: ItemListener.java プロジェクト: NuclearW/DropTime
  @EventHandler
  public void onChunkUnload(ChunkUnloadEvent event) {
    ArrayList<Item> items = new ArrayList<Item>();

    for (Entity entity : event.getChunk().getEntities()) {
      if (entity instanceof Item) {
        items.add((Item) entity);
      }
    }

    for (ItemStack itemStack : plugin.items.keySet()) {
      for (Item item : items) {
        if (item.getItemStack().equals(itemStack)) {
          event.setCancelled(true);
          return;
        }
      }
    }
  }
コード例 #10
0
ファイル: PedestalBase.java プロジェクト: Schmoller/SkyQuest
  /** Called when loading data. If overriding, remember to call this version */
  public void readFromNBT(NBTTagCompound root) {
    mLocation =
        new Location(
            Bukkit.getWorld(root.getString("World")),
            root.getDouble("X"),
            root.getDouble("Y"),
            root.getDouble("Z"));

    mHoverItemTemplate = Util.readItemStackFromNBT(root);

    // Check for existing item
    Collection<Item> items = mLocation.getWorld().getEntitiesByClass(Item.class);
    Location loc = mLocation.clone().add(0, 1, 0);

    for (Item item : items) {
      if (item.getItemStack().equals(mHoverItemTemplate)
          && item.getLocation().distanceSquared(loc) < 1D
          && !item.isDead()) {
        SkyQuestPlugin.instance.getLogger().fine("Attaching old item");
        // Reattach the item
        mHoveringItem = item;
        break;
      }
    }
    // Spawn a new item if needed
    if (mHoveringItem == null) {
      SkyQuestPlugin.instance.getLogger().fine("Spawning new item");
      mHoveringItem =
          mLocation.getWorld().dropItem(mLocation.clone().add(0.5, 1, 0.5), mHoverItemTemplate);
      mHoveringItem.setVelocity(new Vector(0, 0, 0));
    }

    // Register the event listener
    mEventListener = new PedestalListener();
    SkyQuestPlugin.instance
        .getServer()
        .getPluginManager()
        .registerEvents(mEventListener, SkyQuestPlugin.instance);
  }
コード例 #11
0
ファイル: PedestalBase.java プロジェクト: Schmoller/SkyQuest
  protected PedestalBase(ItemStack pedistalType, ItemStack hoverItem, Location pedestalLocation) {
    mIsLoaded = true;
    mLocation = pedestalLocation.clone();
    mLocation
        .getBlock()
        .setTypeIdAndData(pedistalType.getTypeId(), pedistalType.getData().getData(), true);

    mHoverItemTemplate = hoverItem.clone();

    // Check for existing item
    Collection<Item> items = mLocation.getWorld().getEntitiesByClass(Item.class);
    Location loc = mLocation.clone().add(0, 1, 0);

    for (Item item : items) {
      if (item.getItemStack().equals(hoverItem)
          && item.getLocation().distanceSquared(loc) < 1D
          && !item.isDead()) {
        // Reattach the item
        mHoveringItem = item;
        SkyQuestPlugin.instance.getLogger().fine("Attaching old item");
        break;
      }
    }
    // Spawn a new item if needed
    if (mHoveringItem == null) {
      SkyQuestPlugin.instance.getLogger().fine("Spawning new item");
      mHoveringItem =
          mLocation.getWorld().dropItem(mLocation.clone().add(0.5, 1, 0.5), mHoverItemTemplate);
      mHoveringItem.setVelocity(new Vector(0, 0, 0));
    }

    // Register the event listener
    mEventListener = new PedestalListener();
    SkyQuestPlugin.instance
        .getServer()
        .getPluginManager()
        .registerEvents(mEventListener, SkyQuestPlugin.instance);
  }
コード例 #12
0
ファイル: UpgradeTask.java プロジェクト: finelime/Zombies
 @SuppressWarnings("deprecation")
 public void run() {
   int timeleft = (time - runtime);
   runtime++;
   if (timeleft == 8) {
     EffectUtils.playExplodeEffect(loc);
     item.getItemStack().addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 1);
     zplayer.sendMessage("Your upgraded weapon is available.");
     if (player.getTargetBlock(null, 4).getType() == Material.ENDER_CHEST) {
       zplayer.sendActionBar(
           ChatColor.GRAY
               + "Press right-click to accept weapon. ["
               + ChatColor.RED
               + weapon.getUpgradedName()
               + ChatColor.GRAY
               + "]");
     }
     waiting = true;
   } else if (timeleft == 0) {
     zplayer.sendMessage("You failed to accept your upgraded weapon in time.");
     this.cancelTask();
   }
 }
コード例 #13
0
 @SuppressWarnings("deprecation")
 public WorldCounter(World wld, String[] div, int j, int l) {
   if (div[4 + j].equalsIgnoreCase("player")) {
     if (wld.getPlayers() != null) {
       if (div.length == 6 + l) {
         for (Player p : wld.getPlayers()) {
           if (p.getName().equalsIgnoreCase(div[5 + j])) {
             count++;
           }
         }
       } else {
         count = wld.getPlayers().size();
       }
     }
   } else if (div[4 + j].equalsIgnoreCase("mob")) {
     if (div.length == 6 + l) {
       if (Utils.isEntity(div[5 + j])) {
         for (Entity e : wld.getEntities()) {
           if (e.getType().name().toLowerCase().equalsIgnoreCase(div[5 + j])) {
             count++;
           }
         }
       }
     } else {
       for (Entity e : wld.getEntities()) {
         if (e instanceof Monster) {
           count++;
         }
       }
     }
   } else if (div[4 + j].equalsIgnoreCase("animal")) {
     if (div.length == 6 + l) {
       if (Utils.isEntity(div[5 + j])) {
         for (Entity e : wld.getEntities()) {
           if (e.getType().name().toLowerCase().equalsIgnoreCase(div[5 + j])) {
             count++;
           }
         }
       }
     } else {
       for (Entity e : wld.getEntities()) {
         if (e instanceof Animals) {
           count++;
         }
       }
     }
   } else if (div[4 + j].equalsIgnoreCase("item")) {
     if (div.length == 6 + l) {
       if (Utils.isInteger(div[5 + j])
           && Material.getMaterial(Integer.parseInt(div[5 + j])) != null) {
         for (Entity e : wld.getEntities()) {
           if (e instanceof Item) {
             Item i = (Item) e;
             if (i.getItemStack()
                 .getType()
                 .equals(Material.getMaterial(Integer.parseInt(div[5 + j])))) {
               count += i.getItemStack().getAmount();
             }
           }
         }
       }
     } else {
       for (Entity e : wld.getEntities()) {
         if (e instanceof Item) {
           Item i = (Item) e;
           count += i.getItemStack().getAmount();
         }
       }
     }
   } else if (div[4 + j].equalsIgnoreCase("custommob")) {
     if (div.length == 6 + l) {
       if (Utils.isCustomEntity(div[5 + j])) {
         for (Entity e : wld.getEntities()) {
           if (e.hasMetadata("IAmFromConsoleScript")) {
             if (e.getMetadata("IAmFromConsoleScript")
                 .get(0)
                 .asString()
                 .equalsIgnoreCase(div[5 + j])) {
               count++;
             }
           }
         }
       }
     }
   } else if (div[4 + j].equalsIgnoreCase("customitem")) {
     if (div.length == 6 + l) {
       for (Entity e : wld.getEntities()) {
         if (e instanceof Item) {
           if (e.hasMetadata("IAmFromConsoleScript")) {
             if (e.getMetadata("IAmFromConsoleScript")
                 .get(0)
                 .asString()
                 .equalsIgnoreCase(div[5 + j])) {
               count++;
             }
           }
         }
       }
     }
   }
 }
コード例 #14
0
  protected boolean collect() {

    Block b = SignUtil.getBackBlock(BukkitUtil.toSign(getSign()).getBlock());

    int x = b.getX();
    int y = b.getY() + 1;
    int z = b.getZ();
    Block bl = BukkitUtil.toSign(getSign()).getBlock().getWorld().getBlockAt(x, y, z);
    for (Entity en : BukkitUtil.toSign(getSign()).getChunk().getEntities()) {
      if (!(en instanceof Item)) {
        continue;
      }
      Item item = (Item) en;
      if (!ItemUtil.isStackValid(item.getItemStack()) || item.isDead() || !item.isValid()) {
        continue;
      }
      int ix = item.getLocation().getBlockX();
      int iy = item.getLocation().getBlockY();
      int iz = item.getLocation().getBlockZ();
      if (ix == getSign().getX() && iy == getSign().getY() && iz == getSign().getZ()) {

        // Create two test stacks to check against
        ItemStack[] testStacks = new ItemStack[] {null, null};

        // Create test stack #1
        try {
          if (getSign().getLine(2).contains(":")) {
            int id = Integer.parseInt(getSign().getLine(2).split(":")[0]);
            int data = Integer.parseInt(getSign().getLine(2).split(":")[1]);
            testStacks[0] = new ItemStack(id, 0, (short) data);
          } else {
            int id = Integer.parseInt(getSign().getLine(2));
            testStacks[1] = new ItemStack(id, 1, (short) 0, (byte) 0);
          }
        } catch (Exception ignored) {
        }

        // Create test stack #2
        try {
          if (getSign().getLine(3).contains(":")) {
            int id = Integer.parseInt(getSign().getLine(3).split(":")[0]);
            int data = Integer.parseInt(getSign().getLine(3).split(":")[1]);
            testStacks[1] = new ItemStack(id, 0, (short) data);
          } else {
            int id = Integer.parseInt(getSign().getLine(2));
            testStacks[1] = new ItemStack(id, 1, (short) 0, (byte) 0);
          }
        } catch (Exception ignored) {
        }

        // Check to see if it matches either test stack, if not stop
        if (testStacks[0] != null)
          if (ItemUtil.areItemsIdentical(testStacks[0], item.getItemStack())) {
            continue;
          }
        if (testStacks[1] != null)
          if (!ItemUtil.areItemsIdentical(testStacks[1], item.getItemStack())) {
            continue;
          }

        // Add the items to a container, and destroy them.
        if (bl.getTypeId() == BlockID.CHEST)
          if (((Chest) bl.getState()).getInventory().firstEmpty() != -1) {

            ((Chest) bl.getState()).getInventory().addItem(item.getItemStack());
            item.remove();
            return true;
          }

        if (bl.getTypeId() == BlockID.DISPENSER)
          if (((Dispenser) bl.getState()).getInventory().firstEmpty() != -1) {

            ((Dispenser) bl.getState()).getInventory().addItem(item.getItemStack());
            item.remove();
            return true;
          }

        if (bl.getTypeId() == BlockID.BREWING_STAND) {

          if (!ItemUtil.isAPotionIngredient(item.getItemStack())) return false;
          if (((BrewingStand) bl.getState()).getInventory().getIngredient() == null
              || ItemUtil.areItemsIdentical(
                  ((BrewingStand) bl.getState()).getInventory().getIngredient(),
                  item.getItemStack())) {

            if (((BrewingStand) bl.getState()).getInventory().getIngredient() == null) {
              ((BrewingStand) bl.getState()).getInventory().setIngredient(item.getItemStack());
            } else {
              ItemUtil.addToStack(
                  ((BrewingStand) bl.getState()).getInventory().getIngredient(),
                  item.getItemStack());
            }
            item.remove();
            return true;
          }
        }

        if (bl.getTypeId() == BlockID.FURNACE || bl.getTypeId() == BlockID.BURNING_FURNACE) {

          Furnace fur = (Furnace) bl.getState();

          if (ItemUtil.isFurnacable(item.getItemStack())
              && (fur.getInventory().getSmelting() == null
                  || ItemUtil.areItemsIdentical(
                      item.getItemStack(), fur.getInventory().getSmelting()))) {
            if (fur.getInventory().getSmelting() == null) {
              fur.getInventory().setSmelting(item.getItemStack());
            } else {
              ItemUtil.addToStack(
                  ((Furnace) bl.getState()).getInventory().getSmelting(), item.getItemStack());
            }
            item.remove();
            return true;
          }

          if (ItemUtil.isAFuel(item.getItemStack())
              && (fur.getInventory().getFuel() == null
                  || ItemUtil.areItemsIdentical(
                      item.getItemStack(), fur.getInventory().getFuel()))) {
            if (fur.getInventory().getFuel() == null) {
              fur.getInventory().setFuel(item.getItemStack());
            } else {
              ItemUtil.addToStack(
                  ((Furnace) bl.getState()).getInventory().getFuel(), item.getItemStack());
            }
            item.remove();
            return true;
          }
        }
      }
    }
    return false;
  }
コード例 #15
0
 @Override
 public void run() {
   try {
     while (this.plugin.buffer.size() > 0) {
       final Item item = this.plugin.buffer.pollFirstEntry().getValue();
       if (item.isValid()) {
         final Location cauldronLoc = item.getLocation().getBlock().getLocation().clone();
         if (this.plugin.magicBenches.contains(cauldronLoc)) { // So now we act !
           final ItemStack itemStack = item.getItemStack();
           if (itemStack.getEnchantments().size() != 0) {
             final Result res =
                 this.plugin.randomizer.randomize(itemStack); // The itemStack/item is now modified
             byte data = 0; // Wool color
             float ratio = 1f; // Volume & pitch of thunder sound
             switch (res) {
               case CLEAN:
                 data = 15; // Black
                 ratio = 0.2f;
                 break;
               case LOSS:
                 data = 14; // Red
                 ratio = 0.4f;
                 break;
               case NONE:
                 data = 0; // White
                 ratio = 0.6f;
                 break;
               case BOOST:
                 data = 4; // Yellow
                 ratio = 0.8f;
                 break;
               case OVERBOOST:
                 data = 5; // Green
                 ratio = 1f;
                 break;
             }
             this.plugin.magicBenches.remove(cauldronLoc);
             cauldronLoc
                 .getWorld()
                 .playSound(cauldronLoc, Sound.AMBIENCE_THUNDER, ratio, ratio * 2f);
             cauldronLoc.subtract(0, 1, 0); // Is now Egg location
             cauldronLoc.getWorld().playEffect(item.getLocation(), Effect.ENDER_SIGNAL, 0);
             if (cauldronLoc.getBlock().getType() != Material.DRAGON_EGG) {
               // Prevent possible cheat : if the player remove the egg before this happen, we
               // remove every enchants
               // As the interact event is cancelled in ME_Listener, this should never happen.
               for (final Enchantment e : itemStack.getEnchantments().keySet()) {
                 itemStack.removeEnchantment(e);
               }
               cauldronLoc.getWorld().playSound(cauldronLoc, Sound.ENDERDRAGON_DEATH, 1.0f, 1.5f);
             }
             cauldronLoc.getBlock().setType(Material.AIR); // Delete the Egg
             this.plugin.fakeWool(
                 cauldronLoc,
                 data,
                 this.plugin.getNearbyPlayers(item, 10, 5, 10)); // Wool color effect
           }
         }
       }
       if (item.isValid()) {
         item.setPickupDelay(0);
       }
     }
   } catch (final Exception e) {
     e.printStackTrace();
   }
 }