@Override
 public void onPlayerUsedSkill(int skillId, Player player) {
   final Npc vera = getNpc(231050);
   VisibleObject target = player.getTarget();
   if (target instanceof Npc) {
     if ((((Npc) target).getNpcId() == 231050) && skillId == 21437) {
       Dissipshield += 1;
       if (Dissipshield == 3) {
         vera.getEffectController().removeEffect(21438);
       }
     }
   }
 }
  @Override
  public void execute(Player player, String... params) {
    if (params.length != 2) {
      PacketSendUtility.sendMessage(player, "syntax .reskin <Old Item> <New Item>");
      return;
    }

    @SuppressWarnings("unused")
    Player target = player;
    VisibleObject creature = player.getTarget();
    if (player.getTarget() instanceof Player) {
      target = (Player) creature;
    }

    int oldItemId = 0;
    int newItemId = 0;

    try {
      String item = params[0];

      if (item.startsWith("[item:")) {
        Pattern id = Pattern.compile("\\[item:(\\d{9})");
        Matcher result = id.matcher(item);

        if (result.find()) {
          oldItemId = Integer.parseInt(result.group(1));
        } else {
          oldItemId = Integer.parseInt(params[0]);
        }
        item = params[1];
        if (item.startsWith("[item:")) {
          id = Pattern.compile("\\[item:(\\d{9})");
          result = id.matcher(item);

          if (result.find()) {
            newItemId = Integer.parseInt(result.group(1));
          } else {
            newItemId = Integer.parseInt(params[0]);
          }
        } else {
          PacketSendUtility.sendMessage(player, "syntax .reskin <Old Item> <New Item>");
          return;
        }
      } else {
        PacketSendUtility.sendMessage(player, "syntax .reskin <Old Item> <New Item>");
        return;
      }
    } catch (NumberFormatException e) {
      PacketSendUtility.sendMessage(player, "syntax .reskin <Old Item> <New Item>");
      return;
    }

    Storage storage = player.getInventory();
    List<Item> oldItems = player.getInventory().getItemsByItemId(oldItemId);
    List<Item> newItems = player.getInventory().getItemsByItemId(newItemId);
    // Iterator Ancien Item
    Iterator<Item> oldIter = oldItems.iterator();
    Item oldItem = oldIter.next();
    // Iterator Nouveau Item
    Iterator<Item> newIter = newItems.iterator();
    Item newItem = newIter.next();
    // verification que l'ancien item est dans l'inventaire
    if (oldItems.isEmpty()) {
      PacketSendUtility.sendMessage(player, "You do not have this item in your inventory.");
      return;
    }
    // verification que les items sont du même type.
    if (newItem.getItemTemplate().isWeapon() && oldItem.getItemTemplate().isWeapon()) {
      if (newItem.getItemTemplate().getWeaponType() != oldItem.getItemTemplate().getWeaponType()) {
        PacketSendUtility.sendMessage(player, "You can not remodel different types of item.");
        return;
      }
    } else if (newItem.getItemTemplate().isArmor() && oldItem.getItemTemplate().isArmor()) {
      if (newItem.getItemTemplate().getItemSlot() == oldItem.getItemTemplate().getItemSlot()) {
        if (newItem.getItemTemplate().getArmorType() != oldItem.getItemTemplate().getArmorType()) {
          PacketSendUtility.sendMessage(player, "You can not remodel different types of item.");
          return;
        }
      } else {
        PacketSendUtility.sendMessage(player, "You can not remodel different types of item.");
        return;
      }
    }

    final int tollPrice = 750;
    final long tolls = player.getClientConnection().getAccount().getToll();
    RequestResponseHandler responseHandler =
        new RequestResponseHandler(player) {
          @Override
          public void acceptRequest(Creature p2, Player p) {
            if (tolls < tollPrice) {
              PacketSendUtility.sendMessage(
                  p,
                  "You don't have enought Vote Points ("
                      + tolls
                      + "). You need : "
                      + tollPrice
                      + " Vote Points.");
              return;
            }
            p.getClientConnection().getAccount().setToll(tolls - tollPrice);
          }

          @Override
          public void denyRequest(Creature p2, Player p) {}
        };

    boolean requested = player.getResponseRequester().putRequest(902247, responseHandler);
    if (requested) {
      oldItem.setItemSkinTemplate(DataManager.ITEM_DATA.getItemTemplate(newItemId));
      storage.decreaseByItemId(newItemId, storage.getItemCountByItemId(newItemId));
      PacketSendUtility.sendBrightYellowMessage(
          player,
          "Your item " + params[0] + " just take the appearance of the item " + params[1] + ".");
      PacketSendUtility.sendMessage(
          player, "For changing the skin, you have use " + tollPrice + " Vote Points!");
    }
  }
Example #3
0
  @Override
  public void executeCommand(Player admin, String[] params) {
    if (admin.getAccessLevel() < AdminConfig.COMMAND_POWERUP) {
      PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
      return;
    }
    int index = 2;
    int i = 0;
    Player player = null;
    if (params.length != 0) {
      if ("help".startsWith(params[i])) {
        PacketSendUtility.sendMessage(admin, "0 to return to normal state");
        PacketSendUtility.sendMessage(admin, "//powerup <Multiplier = 2>");
        PacketSendUtility.sendMessage(
            admin,
            "Syntax:  //powerup [playerName] [Multiplier = 2]\n"
                + "  This command multiplies your actual power to the number given.\n"
                + "  Using 0 as the Multiplier resets the power to normal.\n"
                + "  Notice: You can ommit parameters between [], especially playerName.\n"
                + "  Target: Named player, then targeted player, only then self.\n"
                + "  Default Value: Multiplier is 2.");
        return;
      }
      player = World.getInstance().findPlayer(Util.convertName(params[i]));
      if (player == null) {
        VisibleObject target = admin.getTarget();
        if (target instanceof Player) player = (Player) target;
        else player = admin;
      } else i++;
      try {
        index = Integer.parseInt(params[i]);
      } catch (NumberFormatException ex) {
        PacketSendUtility.sendMessage(admin, "Wrong input use //powerup help");
        return;
      } catch (Exception ex2) {
        PacketSendUtility.sendMessage(admin, "Occurs an error.");
        return;
      }
    }
    if (index == 0) {
      player.getGameStats().recomputeStats();
      player.getLifeStats().increaseHp(TYPE.HP, admin.getLifeStats().getMaxHp() + 1);
      player.getLifeStats().increaseMp(TYPE.MP, admin.getLifeStats().getMaxMp() + 1);
      PacketSendUtility.sendPacket(player, new SM_STATS_INFO(admin));
      if (player == admin) PacketSendUtility.sendMessage(player, "You are now normal again.");
      else {
        PacketSendUtility.sendMessage(
            admin, "Player " + player.getName() + " is now normal again.");
        PacketSendUtility.sendMessage(
            player, "Admin " + admin.getName() + " made you normal again.");
      }
      return;
    }
    player.getGameStats().setStat(StatEnum.MAXMP, admin.getLifeStats().getMaxHp() * index);
    player.getGameStats().setStat(StatEnum.MAXHP, admin.getLifeStats().getMaxMp() * index);

    player
        .getGameStats()
        .setStat(StatEnum.BLOCK, admin.getGameStats().getStatBonus(StatEnum.BLOCK) * index);
    player
        .getGameStats()
        .setStat(StatEnum.EVASION, admin.getGameStats().getStatBonus(StatEnum.EVASION) * index);
    player
        .getGameStats()
        .setStat(StatEnum.HEALTH, admin.getGameStats().getStatBonus(StatEnum.HEALTH) * index);
    player
        .getGameStats()
        .setStat(StatEnum.ACCURACY, admin.getGameStats().getStatBonus(StatEnum.ACCURACY) * index);
    player
        .getGameStats()
        .setStat(StatEnum.PARRY, admin.getGameStats().getStatBonus(StatEnum.PARRY) * index);

    player
        .getGameStats()
        .setStat(
            StatEnum.MAIN_HAND_ACCURACY,
            admin.getGameStats().getStatBonus(StatEnum.MAIN_HAND_ACCURACY) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAIN_HAND_CRITICAL,
            admin.getGameStats().getStatBonus(StatEnum.MAIN_HAND_CRITICAL) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAIN_HAND_POWER,
            admin.getGameStats().getStatBonus(StatEnum.MAIN_HAND_POWER) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAIN_HAND_ATTACK_SPEED,
            admin.getGameStats().getStatBonus(StatEnum.MAIN_HAND_POWER) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.OFF_HAND_ACCURACY,
            admin.getGameStats().getStatBonus(StatEnum.OFF_HAND_ACCURACY) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.OFF_HAND_CRITICAL,
            admin.getGameStats().getStatBonus(StatEnum.OFF_HAND_CRITICAL) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.OFF_HAND_POWER,
            admin.getGameStats().getStatBonus(StatEnum.OFF_HAND_POWER) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.OFF_HAND_ATTACK_SPEED,
            admin.getGameStats().getStatBonus(StatEnum.OFF_HAND_ATTACK_SPEED) * index);

    player
        .getGameStats()
        .setStat(
            StatEnum.MAGICAL_ATTACK,
            admin.getGameStats().getStatBonus(StatEnum.MAGICAL_ATTACK) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAGICAL_ACCURACY,
            admin.getGameStats().getStatBonus(StatEnum.MAGICAL_ACCURACY) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAGICAL_CRITICAL,
            admin.getGameStats().getStatBonus(StatEnum.MAGICAL_CRITICAL) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAGICAL_RESIST,
            admin.getGameStats().getStatBonus(StatEnum.MAGICAL_RESIST) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.BOOST_MAGICAL_SKILL,
            admin.getGameStats().getStatBonus(StatEnum.BOOST_MAGICAL_SKILL) * index * 15);

    player
        .getGameStats()
        .setStat(StatEnum.REGEN_MP, admin.getGameStats().getStatBonus(StatEnum.REGEN_MP) * index);
    player
        .getGameStats()
        .setStat(StatEnum.REGEN_HP, admin.getGameStats().getStatBonus(StatEnum.REGEN_HP) * index);

    player.getLifeStats().increaseHp(TYPE.HP, admin.getLifeStats().getMaxHp() + 1);
    player.getLifeStats().increaseMp(TYPE.MP, admin.getLifeStats().getMaxMp() + 1);
    PacketSendUtility.sendPacket(player, new SM_STATS_INFO(admin));
    if (player == admin)
      PacketSendUtility.sendMessage(
          player, "You are now " + index + " times more powerfull than before.");
    else {
      PacketSendUtility.sendMessage(
          admin,
          "Player " + player.getName() + " is now " + index + " times more powerfull than before.");
      PacketSendUtility.sendMessage(
          player,
          "Admin " + admin.getName() + " made you " + index + " times more powerfull than before.");
    }
  }