Ejemplo n.º 1
0
  /**
   * Method activate.
   *
   * @param player Player
   * @param item ItemInstance
   */
  public void activate(Player player, ItemInstance item) {
    if ((player == null) || player.isInOlympiadMode()) {
      return;
    }

    CursedWeapon cw = _cursedWeaponsMap.get(item.getId());

    if (cw == null) {
      return;
    }

    if (player.isCursedWeaponEquipped()) {
      if (player.getCursedWeaponEquippedId() != item.getId()) {
        CursedWeapon cw2 = _cursedWeaponsMap.get(player.getCursedWeaponEquippedId());
        cw2.setNbKills(cw2.getStageKills() - 1);
        cw2.increaseKills();
      }

      endOfLife(cw);
      player.getInventory().destroyItem(item, 1);
    } else if (cw.getTimeLeft() > 0) {
      cw.activate(player, item);
      saveData(cw);
      announce(
          new SystemMessage(SystemMessage.THE_OWNER_OF_S2_HAS_APPEARED_IN_THE_S1_REGION)
              .addZoneName(player.getLoc())
              .addString(cw.getName()));
    } else {
      endOfLife(cw);
      player.getInventory().destroyItem(item, 1);
    }
  }
Ejemplo n.º 2
0
  /**
   * Method dropPlayer.
   *
   * @param player Player
   */
  public void dropPlayer(Player player) {
    CursedWeapon cw = _cursedWeaponsMap.get(player.getCursedWeaponEquippedId());

    if (cw == null) {
      return;
    }

    if (cw.dropIt(null, null, player)) {
      saveData(cw);
      announce(
          new SystemMessage(SystemMessage.S2_WAS_DROPPED_IN_THE_S1_REGION)
              .addZoneName(player.getLoc())
              .addItemName(cw.getItemId()));
    } else {
      endOfLife(cw);
    }
  }