@Override
  public void onBypassFeedback(Player player, String command) {
    if (!canBypassCheck(player, this)) return;

    UndergroundColiseumEvent coliseumEvent =
        EventHolder.getInstance().getEvent(EventType.MAIN_EVENT, _coliseumId);

    if (command.equals("register")) {
      Party party = player.getParty();
      if (party == null) showChatWindow(player, "events/kerthang_manager008.htm");
      else if (party.getPartyLeader() != player)
        showChatWindow(player, "events/kerthang_manager004.htm");
      else
        for (Player $player : party)
          if ($player.getLevel() < coliseumEvent.getMinLevel()
              || $player.getLevel() > coliseumEvent.getMaxLevel()) {
            showChatWindow(player, "events/kerthang_manager011.htm", "%name%", $player.getName());
            return;
          }
    } else if (command.equals("viewTeams")) {

      List<Player> reg = coliseumEvent.getRegisteredPlayers();

      NpcHtmlMessage msg = new NpcHtmlMessage(player, this);
      msg.setFile("events/kerthang_manager003.htm");
      for (int i = 0; i < 5; i++) {
        Player $player = CollectionUtils.safeGet(reg, i);

        msg.replace("%team" + i + "%", $player == null ? StringUtils.EMPTY : $player.getName());
      }

      player.sendPacket(msg);
    } else super.onBypassFeedback(player, command);
  }
Example #2
0
  public void restore() {
    _listByIndex.clear();
    _listByClassId.clear();
    List<SubClass> subclasses = CharacterSubclassDAO.getInstance().restore(_owner);
    int lastFreeIndex = 2;
    for (SubClass sub : subclasses) {
      if (sub == null) // Невозможно, но хай будет.
      continue;

      if (size() >= MAX_SUB_COUNT) {
        _log.warn(
            "SubClassList:restore: Limit is subclass! Player: "
                + _owner.getName()
                + "("
                + _owner.getObjectId()
                + ")");
        break;
      }

      if (sub.isActive()) {
        _activeSubClass = sub;
      }

      if (sub.isBase()) {
        _baseSubClass = sub;
        sub.setIndex(1);
      } else {
        sub.setIndex(lastFreeIndex);
        lastFreeIndex++;
      }

      if (_listByIndex.containsKey(sub.getIndex()))
        _log.warn(
            "SubClassList:restore: Duplicate index in player subclasses! Player: "
                + _owner.getName()
                + "("
                + _owner.getObjectId()
                + ")");
      _listByIndex.put(sub.getIndex(), sub);

      if (_listByClassId.containsKey(sub.getClassId()))
        _log.warn(
            "SubClassList:restore: Duplicate class_id in player subclasses! Player: "
                + _owner.getName()
                + "("
                + _owner.getObjectId()
                + ")");
      _listByClassId.put(sub.getClassId(), sub);
    }

    _lastFreeIndex = lastFreeIndex;

    if (_listByIndex.size() != _listByClassId.size()) // Невозможно, но хай будет.
    _log.warn(
          "SubClassList:restore: The size of the lists do not match! Player: "
              + _owner.getName()
              + "("
              + _owner.getObjectId()
              + ")");
  }
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (!canBypassCheck(player, this)) return;

    if (player.getEnchantScroll() != null) {
      Log.add(
          "Player "
              + player.getName()
              + " trying to use enchant exploit[Warehouse], ban this player!",
          "illegal-actions");
      player.setEnchantScroll(null);
      return;
    }

    if (command.startsWith("WithdrawP")) {
      int val = Integer.parseInt(command.substring(10));
      if (val == 99) {
        NpcHtmlMessage html = new NpcHtmlMessage(player, this);
        html.setFile("warehouse/personal.htm");
        html.replace("%npcname%", getName());
        player.sendPacket(html);
      } else WarehouseFunctions.showRetrieveWindow(player, val);
    } else if (command.equals("DepositP")) WarehouseFunctions.showDepositWindow(player);
    else if (command.startsWith("WithdrawC")) {
      int val = Integer.parseInt(command.substring(10));
      if (val == 99) {
        NpcHtmlMessage html = new NpcHtmlMessage(player, this);
        html.setFile("warehouse/clan.htm");
        html.replace("%npcname%", getName());
        player.sendPacket(html);
      } else WarehouseFunctions.showWithdrawWindowClan(player, val);
    } else if (command.equals("DepositC")) WarehouseFunctions.showDepositWindowClan(player);
    else super.onBypassFeedback(player, command);
  }
  @Override
  protected void runImpl() {
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    if (PetitionManager.getInstance().isPlayerInConsultation(activeChar)) {
      if (activeChar.isGM()) PetitionManager.getInstance().endActivePetition(activeChar);
      else activeChar.sendPacket(new SystemMessage(SystemMessage.PETITION_UNDER_PROCESS));
    } else if (PetitionManager.getInstance().isPlayerPetitionPending(activeChar)) {
      if (PetitionManager.getInstance().cancelActivePetition(activeChar)) {
        int numRemaining =
            Config.MAX_PETITIONS_PER_PLAYER
                - PetitionManager.getInstance().getPlayerTotalPetitionCount(activeChar);

        activeChar.sendPacket(
            new SystemMessage(
                    SystemMessage.THE_PETITION_WAS_CANCELED_YOU_MAY_SUBMIT_S1_MORE_PETITIONS_TODAY)
                .addString(String.valueOf(numRemaining)));

        // Notify all GMs that the player's pending petition has been cancelled.
        String msgContent = activeChar.getName() + " has canceled a pending petition.";
        GmListTable.broadcastToGMs(
            new Say2(activeChar.getObjectId(), ChatType.HERO_VOICE, "Petition System", msgContent));
      } else
        activeChar.sendPacket(
            new SystemMessage(SystemMessage.FAILED_TO_CANCEL_PETITION_PLEASE_TRY_AGAIN_LATER));
    } else
      activeChar.sendPacket(new SystemMessage(SystemMessage.YOU_HAVE_NOT_SUBMITTED_A_PETITION));
  }
    public GuardiansSpawner(NpcInstance npc, QuestState st, int _count) {
      NpcTemplate template = NpcHolder.getInstance().getTemplate(Soul_of_Tree_Guardian);
      if (template == null) return;
      try {
        _spawn = new SimpleSpawner(template);
      } catch (Exception e) {
        e.printStackTrace();
      }
      for (int i = 0; i < _count; i++) {
        _spawn.setLoc(Location.findPointToStay(npc, 50, 200));
        _spawn.setHeading(Rnd.get(0, 0xFFFF));
        _spawn.setAmount(1);
        _spawn.doSpawn(true);

        agressor = st.getPlayer().getName();
        if (st.getPlayer().getSummonList().getPet() != null)
          agressors_pet = st.getPlayer().getSummonList().getPet().getName();
        if (st.getPlayer().getParty() != null) {
          agressors_party = new ArrayList<String>();
          for (Player _member : st.getPlayer().getParty().getPartyMembers())
            if (!_member.equals(st.getPlayer())) agressors_party.add(_member.getName());
        }
      }
      _spawn.stopRespawn();
      updateAgression();
    }
Example #6
0
  @Override
  public boolean useUserCommand(int id, Player player) {
    if (!player.isClanLeader()) {
      player.sendPacket(SystemMsg.ONLY_THE_CLAN_LEADER_MAY_ISSUE_COMMANDS);
      return false;
    }

    Castle castle = player.getCastle();
    if (castle == null) return false;

    if (castle.getSiegeEvent().isInProgress())
      if (!player.isNoble()) {
        player.sendPacket(
            SystemMsg
                .ONLY_A_CLAN_LEADER_THAT_IS_A_NOBLESSE_CAN_VIEW_THE_SIEGE_WAR_STATUS_WINDOW_DURING_A_SIEGE_WAR);
        return false;
      }

    NpcHtmlMessage msg = new NpcHtmlMessage(5);
    msg.setFile("siege_status.htm");
    msg.replace("%name%", player.getName());
    msg.replace("%kills%", String.valueOf(0));
    msg.replace("%deaths%", String.valueOf(0));
    msg.replace("%type%", String.valueOf(0));

    player.sendPacket(msg);
    return true;
  }
Example #7
0
  public static int addOrder(
      Player player, String name, int killsCount, int itemcount, String itemname) {
    if (!checkPlayer(player)) return -1;

    if (Functions.getItemCount(player, Config.EVENT_HITMAN_COST_ITEM_ID)
        < Config.EVENT_HITMAN_COST_ITEM_COUNT) return 0;

    if (Functions.getItemCount(player, _allowedItems.get(itemname)) < itemcount) return 0;

    if (isRegistered(player)) return 1;

    if (World.getPlayer(name) == null) return 2;

    if (World.getPlayer(name).getObjectId() == player.getObjectId()) return 3;

    final Order order =
        new Order(player.getName(), name, _allowedItems.get(itemname), itemcount, killsCount);

    _orderMap.put(player.getObjectId(), order);
    _inList.add(0, player.getObjectId());
    saveToDatabase(
        player.getObjectId(),
        player.getName(),
        name,
        _allowedItems.get(itemname),
        itemcount,
        killsCount);
    Functions.removeItem(
        player, Config.EVENT_HITMAN_COST_ITEM_ID, Config.EVENT_HITMAN_COST_ITEM_COUNT);
    Functions.removeItem(player, _allowedItems.get(itemname), itemcount * killsCount);

    Announcements.getInstance()
        .announceToAll(
            new CustomMessage(
                    "scripts.events.Hitman.Announce",
                    player,
                    player.getName(),
                    itemcount,
                    itemname,
                    name)
                .toString());

    World.getPlayer(name).setIsOrdered(true);

    return 5;
  }
Example #8
0
 private boolean cmd_Show(Quest _quest, String[] wordList, Player activeChar) {
   // quest id|name SHOW [target]
   Player targetChar = getTargetChar(wordList, 3, activeChar);
   QuestState qs = targetChar.getQuestState(_quest.getName());
   if (qs == null) {
     activeChar.sendMessage(
         "Player " + targetChar.getName() + " havn't Quest [" + _quest.getName() + "]");
     return false;
   }
   return ShowQuestState(qs, activeChar);
 }
Example #9
0
  private static boolean ShowQuestList(Player targetChar, Player activeChar) {
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    StringBuilder replyMSG = new StringBuilder("<html><body><table width=260>");
    for (QuestState qs : targetChar.getAllQuestsStates())
      if (qs != null && qs.getQuest().getQuestIntId() != 255)
        replyMSG.append(
            fmtListRow.sprintf(
                new Object[] {
                  qs.getQuest().getQuestIntId(),
                  targetChar.getName(),
                  qs.getQuest().getName(),
                  qs.getStateName()
                }));
    replyMSG.append(fmtListNew.sprintf(new Object[] {targetChar.getName()}));
    replyMSG.append("</table></body></html>");

    adminReply.setHtml(replyMSG.toString());
    activeChar.sendPacket(adminReply);

    return true;
  }
Example #10
0
 private boolean cmd_Clear(Quest _quest, String[] wordList, Player activeChar) {
   // quest id|name CLEAR [target]
   Player targetChar = getTargetChar(wordList, 3, activeChar);
   QuestState qs = targetChar.getQuestState(_quest.getName());
   if (qs == null) {
     activeChar.sendMessage(
         "Player " + targetChar.getName() + " havn't Quest [" + _quest.getName() + "]");
     return false;
   }
   qs.exitCurrentQuest(true);
   return ShowQuestList(targetChar, activeChar);
 }
Example #11
0
 public void NewAccount(String[] name) {
   Player player = getSelf();
   if (player == null) return;
   if (player.getInventory().getCountOf(ACC_MOVE_ITEM) < ACC_MOVE_PRICE) {
     player.sendMessage(
         "У вас нету "
             + ACC_MOVE_PRICE
             + " "
             + ItemHolder.getInstance().getTemplate(ACC_MOVE_ITEM));
     CharToAcc();
     return;
   }
   String _name = name[0];
   Connection con = null;
   Connection conGS = null;
   PreparedStatement offline = null;
   Statement statement = null;
   ResultSet rs = null;
   try {
     con = DatabaseFactory.getInstance().getConnection();
     offline = con.prepareStatement("SELECT `login` FROM `accounts` WHERE `login` = ?");
     offline.setString(1, _name);
     rs = offline.executeQuery();
     if (rs.next()) {
       removeItem(player, ACC_MOVE_ITEM, ACC_MOVE_PRICE);
       conGS = DatabaseFactory.getInstance().getConnection();
       statement = conGS.createStatement();
       statement.executeUpdate(
           "UPDATE `characters` SET `account_name` = '"
               + _name
               + "' WHERE `char_name` = '"
               + player.getName()
               + "'");
       player.sendMessage("Персонаж успешно перенесен.");
       player.logout();
     } else {
       player.sendMessage("Введенный аккаунт не найден.");
       CharToAcc();
     }
   } catch (Exception e) {
     e.printStackTrace();
     return;
   } finally {
     DbUtils.closeQuietly(con, offline, rs);
     DbUtils.closeQuietly(conGS, statement);
   }
 }
 @Override
 public void showChatWindow(Player player, int val, Object... arg) {
   if (!validateCondition(player)) {
     NpcHtmlMessage html = new NpcHtmlMessage(player, this);
     html.setFile("wyvern/lord_only.htm");
     html.replace("%npcname%", "Wyvern Manager " + getName());
     player.sendPacket(html);
     player.sendActionFailed();
     return;
   }
   NpcHtmlMessage html = new NpcHtmlMessage(player, this);
   html.setFile("wyvern/lord_here.htm");
   html.replace("%Char_name%", String.valueOf(player.getName()));
   html.replace("%npcname%", "Wyvern Manager " + getName());
   player.sendPacket(html);
   player.sendActionFailed();
 }
Example #13
0
 public void CharToAcc() {
   Player player = getSelf();
   if (player == null) return;
   String append = "Перенос персонажей между аккаунтами.<br>";
   append +=
       "Цена: "
           + ACC_MOVE_PRICE
           + " "
           + ItemHolder.getInstance().getTemplate(ACC_MOVE_ITEM).getName()
           + ".<br>";
   append +=
       "Внимание !!! При переносе персонажа на другой аккаунт, убедитесь что персонажей там меньше чем 7, иначе могут возникнуть непредвиденные ситуации за которые Администрация не отвечает.<br>";
   append += "Внимательно вводите логин куда переносите, администрация не возвращает персонажей.";
   append += "Вы переносите персонажа " + player.getName() + ", на какой аккаунт его перенести ?";
   append += "<edit var=\"new_acc\" width=150>";
   append +=
       "<button value=\"Перенести\" action=\"bypass -h scripts_services.Account:NewAccount $new_acc\" width=150 height=15><br>";
   show(append, player, null);
 }
Example #14
0
 public boolean insert(Player player) {
   Connection con = null;
   PreparedStatement statement = null;
   try {
     con = DatabaseFactory.getInstance().getConnection();
     statement =
         con.prepareStatement(
             "INSERT INTO `characters` (account_name, obj_Id, char_name, face, hairStyle, hairColor, sex, karma, pvpkills, pkkills, clanid, createtime, deletetime, title, accesslevel, online, leaveclan, deleteclan, nochannel, pledge_type, pledge_rank, lvl_joined_academy, apprentice) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
     statement.setString(1, player.getAccountName());
     statement.setInt(2, player.getObjectId());
     statement.setString(3, player.getName());
     statement.setInt(4, player.getFace());
     statement.setInt(5, player.getHairStyle());
     statement.setInt(6, player.getHairColor());
     statement.setInt(7, player.getSex());
     statement.setInt(8, player.getKarma());
     statement.setInt(9, player.getPvpKills());
     statement.setInt(10, player.getPkKills());
     statement.setInt(11, player.getClanId());
     statement.setLong(12, player.getCreateTime() / 1000);
     statement.setInt(13, player.getDeleteTimer());
     statement.setString(14, player.getTitle());
     statement.setInt(15, player.getAccessLevel());
     statement.setInt(16, player.isOnline() ? 1 : 0);
     statement.setLong(17, player.getLeaveClanTime() / 1000);
     statement.setLong(18, player.getDeleteClanTime() / 1000);
     statement.setLong(
         19, player.getNoChannel() > 0 ? player.getNoChannel() / 1000 : player.getNoChannel());
     statement.setInt(20, player.getPledgeType());
     statement.setInt(21, player.getPowerGrade());
     statement.setInt(22, player.getLvlJoinedAcademy());
     statement.setInt(23, player.getApprentice());
     statement.executeUpdate();
   } catch (final Exception e) {
     _log.error("", e);
     return false;
   } finally {
     DbUtils.closeQuietly(con, statement);
   }
   return true;
 }
Example #15
0
  private void showTeleportCharWindow(Player activeChar) {
    GameObject target = activeChar.getTarget();
    Player player = null;
    if (target.isPlayer()) player = (Player) target;
    else {
      activeChar.sendPacket(Msg.INVALID_TARGET);
      return;
    }
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);

    StringBuilder replyMSG = new StringBuilder("<html><title>Teleport Character</title>");
    replyMSG.append("<body>");
    replyMSG.append("The character you will teleport is " + player.getName() + ".");
    replyMSG.append("<br>");

    replyMSG.append("Co-ordinate x");
    replyMSG.append("<edit var=\"char_cord_x\" width=110>");
    replyMSG.append("Co-ordinate y");
    replyMSG.append("<edit var=\"char_cord_y\" width=110>");
    replyMSG.append("Co-ordinate z");
    replyMSG.append("<edit var=\"char_cord_z\" width=110>");
    replyMSG.append(
        "<button value=\"Teleport\" action=\"bypass -h admin_teleport_character $char_cord_x $char_cord_y $char_cord_z\" width=60 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\">");
    replyMSG.append(
        "<button value=\"Teleport near you\" action=\"bypass -h admin_teleport_character "
            + activeChar.getX()
            + " "
            + activeChar.getY()
            + " "
            + activeChar.getZ()
            + "\" width=115 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\">");
    replyMSG.append(
        "<center><button value=\"Back\" action=\"bypass -h admin_current_player\" width=40 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
    replyMSG.append("</body></html>");

    adminReply.setHtml(replyMSG.toString());
    activeChar.sendPacket(adminReply);
  }
Example #16
0
  private boolean cmd_Var(Quest _quest, String[] wordList, Player activeChar) {
    if (wordList.length < 5) {
      activeChar.sendMessage("USAGE: //quest id|name VAR varname newvalue [target]");
      return false;
    }

    Player targetChar = getTargetChar(wordList, 5, activeChar);
    QuestState qs = targetChar.getQuestState(_quest.getName());
    if (qs == null) {
      activeChar.sendMessage(
          "Player "
              + targetChar.getName()
              + " havn't Quest ["
              + _quest.getName()
              + "], init quest by command:");
      activeChar.sendMessage("//quest id|name STATE 1|2|3 [target]");
      return false;
    }
    if (wordList[4].equalsIgnoreCase("~") || wordList[4].equalsIgnoreCase("#"))
      qs.unset(wordList[3]);
    else qs.set(wordList[3], wordList[4]);
    return ShowQuestState(qs, activeChar);
  }
Example #17
0
  private boolean cmd_State(Quest _quest, String[] wordList, Player activeChar) {
    if (wordList.length < 4) {
      activeChar.sendMessage("USAGE: //quest id|name STATE 1|2|3 [target]");
      return false;
    }

    int state = 0;
    try {
      state = Integer.parseInt(wordList[3]);
    } catch (Exception e) {
      activeChar.sendMessage("Wrong State ID: " + wordList[3]);
      return false;
    }

    Player targetChar = getTargetChar(wordList, 4, activeChar);
    QuestState qs = targetChar.getQuestState(_quest.getName());
    if (qs == null) {
      activeChar.sendMessage("Init Quest [" + _quest.getName() + "] for " + targetChar.getName());
      qs = _quest.newQuestState(targetChar, state);
      qs.set("cond", "1");
    } else qs.setState(state);

    return ShowQuestState(qs, activeChar);
  }
Example #18
0
 @Override
 public String toString() {
   return "SubClassList[owner=" + _owner.getName() + "]";
 }