コード例 #1
0
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    // You cannot do anything while fishing
    if (activeChar.isFishing()) {
      activeChar.sendPacket(SystemMessageId.CANNOT_DO_WHILE_FISHING_3);
      return;
    }

    // check if the actionId is allowed
    if (_actionId < 2 || _actionId > 13) {
      Util.handleIllegalPlayerAction(
          activeChar,
          activeChar.getName()
              + " of account "
              + activeChar.getAccountName()
              + " requested an internal Social Action.",
          Config.DEFAULT_PUNISH);
      return;
    }

    if (!activeChar.isInStoreMode()
        && activeChar.getActiveRequester() == null
        && !activeChar.isAlikeDead()
        && (!activeChar.isAllSkillsDisabled() || activeChar.isInDuel())
        && activeChar.getAI().getIntention() == CtrlIntention.IDLE) {
      if (Config.DEBUG) _log.fine("Social Action: " + _actionId);

      activeChar.broadcastPacket(new SocialAction(activeChar, _actionId));
    }
  }
コード例 #2
0
ファイル: Monastery.java プロジェクト: WildReiser/Interlude
  @Override
  public String onSpawn(L2Npc npc) {
    for (L2PcInstance target : npc.getKnownList().getKnownType(L2PcInstance.class)) {
      if (!target.isDead()
          && GeoData.getInstance().canSeeTarget(npc, target)
          && Util.checkIfInRange(npc.getAggroRange(), npc, target, true)) {
        if (target.getActiveWeaponInstance() != null
            && !npc.isInCombat()
            && npc.getTarget() == null) {
          npc.setTarget(target);
          npc.broadcastNpcSay(
              ((target.getAppearance().getSex()) ? "Sister " : "Brother ")
                  + target.getName()
                  + ", move your weapon away!");

          switch (npc.getNpcId()) {
            case 22124:
            case 22126:
            case 22127:
              npc.doCast(SkillTable.getInstance().getInfo(4589, 8));
              break;

            default:
              attack(((L2Attackable) npc), target);
              break;
          }
        }
      }
    }
    return super.onSpawn(npc);
  }
コード例 #3
0
ファイル: AdminBan.java プロジェクト: WildReiser/Interlude
  private static boolean changeCharAccessLevel(
      L2PcInstance targetPlayer, String player, L2PcInstance activeChar, int lvl) {
    if (targetPlayer != null) {
      targetPlayer.setAccessLevel(lvl);
      targetPlayer.logout();
      activeChar.sendMessage(targetPlayer.getName() + " has been banned.");
    } else {
      try (Connection con = L2DatabaseFactory.getInstance().getConnection()) {
        PreparedStatement statement =
            con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?");
        statement.setInt(1, lvl);
        statement.setString(2, player);
        statement.execute();
        int count = statement.getUpdateCount();
        statement.close();

        if (count == 0) {
          activeChar.sendMessage("Character not found or access level unaltered.");
          return false;
        }

        activeChar.sendMessage(player + " now has an access level of " + lvl + ".");
      } catch (SQLException se) {
        activeChar.sendMessage("SQLException while changing character's access level");
        if (Config.DEBUG) se.printStackTrace();

        return false;
      }
    }
    return true;
  }
コード例 #4
0
  private void setTargetKarma(L2PcInstance activeChar, int newKarma) {
    // function to change karma of selected char
    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;
    if (target instanceof L2PcInstance) player = (L2PcInstance) target;
    else return;

    if (newKarma >= 0) {
      // for display
      int oldKarma = player.getKarma();
      // update karma
      player.setKarma(newKarma);
      // Common character information
      player.sendPacket(
          new SystemMessage(SystemMessageId.YOUR_KARMA_HAS_BEEN_CHANGED_TO)
              .addString(String.valueOf(newKarma)));
      // Admin information
      L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[275]);
      cm.addString(player.getName());
      cm.addNumber(oldKarma);
      cm.addNumber(newKarma);
      cm.sendMessage(activeChar);
      if (Config.DEBUG)
        _log.fine(
            "[SET KARMA] [GM]"
                + activeChar.getName()
                + " Changed karma for "
                + player.getName()
                + " from ("
                + oldKarma
                + ") to ("
                + newKarma
                + ").");
    } else {
      // tell admin of mistake
      activeChar.sendMessage(569);
      if (Config.DEBUG)
        _log.fine(
            "[SET KARMA] ERROR: [GM]"
                + activeChar.getName()
                + " entered an incorrect value for new karma: "
                + newKarma
                + " for "
                + player.getName()
                + ".");
    }
  }
コード例 #5
0
 /**
  * @param activeChar
  * @param player
  */
 private void gatherCharacterInfo(L2PcInstance activeChar, L2PcInstance player, String filename) {
   String ip = "N/A";
   String account = "N/A";
   try {
     String clientInfo = player.getClient().toString();
     account =
         clientInfo.substring(clientInfo.indexOf("Account: ") + 9, clientInfo.indexOf(" - IP: "));
     ip = clientInfo.substring(clientInfo.indexOf(" - IP: ") + 7, clientInfo.lastIndexOf("]"));
   } catch (Exception e) {
   }
   NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
   adminReply.setFile("data/html/admin/" + filename);
   adminReply.replace("%name%", player.getName());
   adminReply.replace("%level%", String.valueOf(player.getLevel()));
   adminReply.replace(
       "%clan%", String.valueOf(ClanTable.getInstance().getClan(player.getClanId())));
   adminReply.replace("%xp%", String.valueOf(player.getExp()));
   adminReply.replace("%sp%", String.valueOf(player.getSp()));
   adminReply.replace("%class%", player.getTemplate().className);
   adminReply.replace("%ordinal%", String.valueOf(player.getClassId().ordinal()));
   adminReply.replace("%classid%", String.valueOf(player.getClassId()));
   adminReply.replace("%x%", String.valueOf(player.getX()));
   adminReply.replace("%y%", String.valueOf(player.getY()));
   adminReply.replace("%z%", String.valueOf(player.getZ()));
   adminReply.replace("%currenthp%", String.valueOf((int) player.getCurrentHp()));
   adminReply.replace("%maxhp%", String.valueOf(player.getMaxHp()));
   adminReply.replace("%karma%", String.valueOf(player.getKarma()));
   adminReply.replace("%currentmp%", String.valueOf((int) player.getCurrentMp()));
   adminReply.replace("%maxmp%", String.valueOf(player.getMaxMp()));
   adminReply.replace("%pvpflag%", String.valueOf(player.getPvpFlag()));
   adminReply.replace("%currentcp%", String.valueOf((int) player.getCurrentCp()));
   adminReply.replace("%maxcp%", String.valueOf(player.getMaxCp()));
   adminReply.replace("%pvpkills%", String.valueOf(player.getPvpKills()));
   adminReply.replace("%pkkills%", String.valueOf(player.getPkKills()));
   adminReply.replace("%currentload%", String.valueOf(player.getCurrentLoad()));
   adminReply.replace("%maxload%", String.valueOf(player.getMaxLoad()));
   adminReply.replace(
       "%percent%",
       String.valueOf(
           Util.roundTo(
               ((float) player.getCurrentLoad() / (float) player.getMaxLoad()) * 100, 2)));
   adminReply.replace("%patk%", String.valueOf(player.getPAtk(null)));
   adminReply.replace("%matk%", String.valueOf(player.getMAtk(null, null)));
   adminReply.replace("%pdef%", String.valueOf(player.getPDef(null)));
   adminReply.replace("%mdef%", String.valueOf(player.getMDef(null, null)));
   adminReply.replace("%accuracy%", String.valueOf(player.getAccuracy()));
   adminReply.replace("%evasion%", String.valueOf(player.getEvasionRate(null)));
   adminReply.replace("%critical%", String.valueOf(player.getCriticalHit(null, null)));
   adminReply.replace("%runspeed%", String.valueOf(player.getRunSpeed()));
   adminReply.replace("%patkspd%", String.valueOf(player.getPAtkSpd()));
   adminReply.replace("%matkspd%", String.valueOf(player.getMAtkSpd()));
   adminReply.replace("%access%", String.valueOf(player.getAccessLevel().getLevel()));
   adminReply.replace("%account%", account);
   adminReply.replace("%ip%", ip);
   activeChar.sendPacket(adminReply);
 }
コード例 #6
0
ファイル: AdminBan.java プロジェクト: WildReiser/Interlude
  private static void auditAction(String fullCommand, L2PcInstance activeChar, String target) {
    if (!Config.GMAUDIT) return;

    String[] command = fullCommand.split(" ");

    GMAudit.auditGMAction(
        activeChar.getName() + " [" + activeChar.getObjectId() + "]",
        command[0],
        (target.equals("") ? "no-target" : target),
        (command.length > 2 ? command[2] : ""));
  }
コード例 #7
0
ファイル: AdminTeleport.java プロジェクト: sonizs123/Acis
  private static void teleportToCharacter(L2PcInstance activeChar, L2PcInstance target) {
    if (target.getObjectId() == activeChar.getObjectId())
      activeChar.sendPacket(SystemMessageId.CANNOT_USE_ON_YOURSELF);
    else {
      int x = target.getX();
      int y = target.getY();
      int z = target.getZ();

      activeChar.getAI().setIntention(CtrlIntention.IDLE);
      activeChar.teleToLocation(x, y, z, 0);
      activeChar.sendMessage("You have teleported to " + target.getName() + ".");
    }
  }
コード例 #8
0
  /**
   * @param activeChar
   * @param CharacterToFind
   */
  private void findCharacter(L2PcInstance activeChar, String CharacterToFind) {
    int CharactersFound = 0;
    String name;
    Collection<L2PcInstance> allPlayers = L2World.getInstance().getAllPlayers().values();
    L2PcInstance[] players;
    // synchronized (L2World.getInstance().getAllPlayers())
    {
      players = allPlayers.toArray(new L2PcInstance[allPlayers.size()]);
    }
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    adminReply.setFile("data/html/admin/charfind.htm");

    final StringBuilder replyMSG = new StringBuilder(1000);

    for (L2PcInstance player : players) { // Add player info into new Table row
      name = player.getName();
      if (name.toLowerCase().contains(CharacterToFind.toLowerCase())) {
        CharactersFound = CharactersFound + 1;
        StringUtil.append(
            replyMSG,
            "<tr><td width=80><a action=\"bypass -h admin_character_list ",
            name,
            "\">",
            name,
            "</a></td><td width=110>",
            player.getTemplate().className,
            "</td><td width=40>",
            String.valueOf(player.getLevel()),
            "</td></tr>");
      }
      if (CharactersFound > 20) break;
    }
    adminReply.replace("%results%", replyMSG.toString());

    final String replyMSG2;

    if (CharactersFound == 0) {
      replyMSG2 = MessageTable.Messages[678].getMessage();
    } else if (CharactersFound > 20) {
      adminReply.replace("%number%", MessageTable.Messages[679].getMessage());
      replyMSG2 = MessageTable.Messages[680].getMessage();
    } else if (CharactersFound == 1) {
      replyMSG2 = MessageTable.Messages[1196].getMessage();
    } else {
      replyMSG2 = MessageTable.Messages[1197].getMessage();
    }

    adminReply.replace("%number%", String.valueOf(CharactersFound));
    adminReply.replace("%end%", replyMSG2);
    activeChar.sendPacket(adminReply);
  }
コード例 #9
0
ファイル: ChatTrade.java プロジェクト: RostMyr/aCis
  @Override
  public void handleChat(int type, L2PcInstance activeChar, String target, String text) {
    if (!FloodProtectors.performAction(activeChar.getClient(), Action.TRADE_CHAT)) return;

    final CreatureSay cs =
        new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
    final int region = MapRegionTable.getMapRegion(activeChar.getX(), activeChar.getY());

    for (L2PcInstance player : L2World.getInstance().getPlayers()) {
      if (!BlockList.isBlocked(player, activeChar)
          && region == MapRegionTable.getMapRegion(player.getX(), player.getY()))
        player.sendPacket(cs);
    }
  }
コード例 #10
0
ファイル: Monastery.java プロジェクト: WildReiser/Interlude
 @Override
 public String onSkillSee(
     L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet) {
   if (skill.getSkillType() == L2SkillType.AGGDAMAGE && targets.length != 0) {
     for (L2Object obj : targets) {
       if (obj.equals(npc)) {
         npc.broadcastNpcSay(
             ((caster.getAppearance().getSex()) ? "Sister " : "Brother ")
                 + caster.getName()
                 + ", move your weapon away!");
         attack(((L2Attackable) npc), caster);
         break;
       }
     }
   }
   return super.onSkillSee(npc, caster, skill, targets, isPet);
 }
コード例 #11
0
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    // Noblesse can bestow a title to themselves
    if (activeChar.isNoble() && _target.matches(activeChar.getName())) {
      activeChar.setTitle(_title);
      activeChar.sendPacket(SystemMessageId.TITLE_CHANGED);
      activeChar.broadcastTitleInfo();
    } else {
      // Can the player change/give a title?
      if ((activeChar.getClanPrivileges() & L2Clan.CP_CL_GIVE_TITLE) != L2Clan.CP_CL_GIVE_TITLE) {
        activeChar.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
        return;
      }

      if (activeChar.getClan().getLevel() < 3) {
        activeChar.sendPacket(SystemMessageId.CLAN_LVL_3_NEEDED_TO_ENDOWE_TITLE);
        return;
      }

      final L2ClanMember member = activeChar.getClan().getClanMember(_target);
      if (member != null) {
        final L2PcInstance playerMember = member.getPlayerInstance();
        if (playerMember != null) {
          playerMember.setTitle(_title);

          playerMember.sendPacket(SystemMessageId.TITLE_CHANGED);
          if (activeChar != playerMember)
            activeChar.sendPacket(
                SystemMessage.getSystemMessage(SystemMessageId.CLAN_MEMBER_S1_TITLE_CHANGED_TO_S2)
                    .addPcName(playerMember)
                    .addString(_title));

          playerMember.broadcastTitleInfo();
        } else activeChar.sendPacket(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
      } else activeChar.sendPacket(SystemMessageId.TARGET_MUST_BE_IN_CLAN);
    }
  }
コード例 #12
0
ファイル: Monastery.java プロジェクト: WildReiser/Interlude
  @Override
  public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isPet) {
    if (!npc.isInCombat()) {
      if (player.getActiveWeaponInstance() != null) {
        npc.setTarget(player);
        npc.broadcastNpcSay(
            ((player.getAppearance().getSex()) ? "Sister " : "Brother ")
                + player.getName()
                + ", move your weapon away!");

        switch (npc.getNpcId()) {
          case 22124:
          case 22126:
            npc.doCast(SkillTable.getInstance().getInfo(4589, 8));
            break;

          default:
            attack(((L2Attackable) npc), player);
            break;
        }
      } else if (((L2Attackable) npc).getMostHated() == null) return null;
    }
    return super.onAggroRangeEnter(npc, player, isPet);
  }
コード例 #13
0
ファイル: AdminTeleport.java プロジェクト: sonizs123/Acis
  @Override
  public boolean useAdminCommand(String command, L2PcInstance activeChar) {
    // runmod
    if (command.equals("admin_runmod") || command.equals("admin_instant_move"))
      activeChar.setTeleMode(1);
    if (command.equals("admin_runmod tele")) activeChar.setTeleMode(2);
    if (command.equals("admin_runmod norm")) activeChar.setTeleMode(0);

    // teleport via panels
    if (command.equals("admin_tele")) AdminHelpPage.showHelpPage(activeChar, "teleports.htm");
    if (command.equals("admin_tele_areas"))
      AdminHelpPage.showHelpPage(activeChar, "tele/other.htm");

    // recalls / goto types
    if (command.startsWith("admin_goto") || command.startsWith("admin_teleportto")) {
      StringTokenizer st = new StringTokenizer(command);
      if (st.countTokens() > 1) {
        st.nextToken();
        String plyr = st.nextToken();
        L2PcInstance player = L2World.getInstance().getPlayer(plyr);
        if (player == null) {
          activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
          return false;
        }

        teleportToCharacter(activeChar, player);
      }
    } else if (command.startsWith("admin_recall ")) {
      try {
        String targetName = command.substring(13);
        L2PcInstance player = L2World.getInstance().getPlayer(targetName);
        if (player == null) {
          activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
          return false;
        }

        teleportCharacter(player, activeChar.getX(), activeChar.getY(), activeChar.getZ());
      } catch (StringIndexOutOfBoundsException e) {
      }
    } else if (command.startsWith("admin_recall_party")) {
      try {
        String targetName = command.substring(19);
        L2PcInstance player = L2World.getInstance().getPlayer(targetName);
        if (player == null) {
          activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
          return false;
        }

        if (player.isInParty()) {
          for (L2PcInstance pm : player.getParty().getPartyMembers())
            teleportCharacter(pm, activeChar.getX(), activeChar.getY(), activeChar.getZ());

          activeChar.sendMessage("You recall " + player.getName() + "'s party.");
        } else {
          activeChar.sendMessage("You recall " + player.getName() + ", but he isn't in a party.");
          teleportCharacter(player, activeChar.getX(), activeChar.getY(), activeChar.getZ());
        }
      } catch (StringIndexOutOfBoundsException e) {
      }
    } else if (command.startsWith("admin_recall_clan")) {
      try {
        String targetName = command.substring(18);
        L2PcInstance player = L2World.getInstance().getPlayer(targetName);
        if (player == null) {
          activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
          return false;
        }

        L2Clan clan = player.getClan();
        if (clan != null) {
          for (L2PcInstance member : clan.getOnlineMembers())
            teleportCharacter(member, activeChar.getX(), activeChar.getY(), activeChar.getZ());

          activeChar.sendMessage("You recall " + player.getName() + "'s clan.");
        } else {
          activeChar.sendMessage(
              "You recall " + player.getName() + ", but he isn't a clan member.");
          teleportCharacter(player, activeChar.getX(), activeChar.getY(), activeChar.getZ());
        }
      } catch (StringIndexOutOfBoundsException e) {
      }
    } else if (command.startsWith("admin_move_to")) {
      try {
        String val = command.substring(14);
        teleportTo(activeChar, val);
      } catch (Exception e) {
        // Case of empty or missing coordinates
        AdminHelpPage.showHelpPage(activeChar, "teleports.htm");
      }
    } else if (command.startsWith("admin_sendhome")) {
      StringTokenizer st = new StringTokenizer(command);
      if (st.countTokens() > 1) {
        st.nextToken();
        String plyr = st.nextToken();
        L2PcInstance player = L2World.getInstance().getPlayer(plyr);
        if (player == null) {
          activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
          return false;
        }

        sendHome(player);
      } else {
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;

        // if target isn't a player, select yourself as target
        if (target instanceof L2PcInstance) player = (L2PcInstance) target;
        else player = activeChar;

        sendHome(player);
      }
    }
    return true;
  }
コード例 #14
0
  public boolean useAdminCommand(String command, L2PcInstance activeChar) {
    if (command.equals("admin_current_player")) {
      showCharacterInfo(activeChar, null);
    } else if ((command.startsWith("admin_character_list"))
        || (command.startsWith("admin_character_info"))) {
      try {
        String val = command.substring(21);
        L2PcInstance target = L2World.getInstance().getPlayer(val);
        if (target != null) showCharacterInfo(activeChar, target);
        else activeChar.sendPacket(new SystemMessage(SystemMessageId.CHARACTER_DOES_NOT_EXIST));
      } catch (StringIndexOutOfBoundsException e) {
        activeChar.sendMessage(385);
      }
    } else if (command.startsWith("admin_show_characters")) {
      try {
        String val = command.substring(22);
        int page = Integer.parseInt(val);
        listCharacters(activeChar, page);
      } catch (StringIndexOutOfBoundsException e) {
        // Case of empty page number
        activeChar.sendMessage(421);
      }
    } else if (command.startsWith("admin_find_character")) {
      try {
        String val = command.substring(21);
        findCharacter(activeChar, val);
      } catch (StringIndexOutOfBoundsException e) { // Case of empty character name
        activeChar.sendMessage(392);
        listCharacters(activeChar, 0);
      }
    } else if (command.startsWith("admin_find_ip")) {
      try {
        String val = command.substring(14);
        findCharactersPerIp(activeChar, val);
      } catch (Exception e) { // Case of empty or malformed IP number
        activeChar.sendMessage(393);
        listCharacters(activeChar, 0);
      }
    } else if (command.startsWith("admin_find_account")) {
      try {
        String val = command.substring(19);
        findCharactersPerAccount(activeChar, val);
      } catch (Exception e) { // Case of empty or malformed player name
        activeChar.sendMessage(391);
        listCharacters(activeChar, 0);
      }
    } else if (command.equals("admin_edit_character")) editCharacter(activeChar);
    // Karma control commands
    else if (command.equals("admin_nokarma")) setTargetKarma(activeChar, 0);
    else if (command.startsWith("admin_setkarma")) {
      try {
        String val = command.substring(15);
        int karma = Integer.parseInt(val);
        setTargetKarma(activeChar, karma);
      } catch (Exception e) {
        if (Config.DEVELOPER) _log.warning("Set karma error: " + e);
        activeChar.sendMessage(419);
      }
    } else if (command.startsWith("admin_setfame")) {
      try {
        String val = command.substring(14);
        int fame = Integer.parseInt(val);
        L2Object target = activeChar.getTarget();
        if (target instanceof L2PcInstance) {
          L2PcInstance player = (L2PcInstance) target;
          player.setFame(fame);
          player.sendPacket(new UserInfo(player));
          player.sendPacket(new ExBrExtraUserInfo(player));
          L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[261]);
          cm.addNumber(fame);
          cm.sendMessage(player);
        } else {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
        }
      } catch (Exception e) {
        if (Config.DEVELOPER) _log.warning("Set Fame error: " + e);
        activeChar.sendMessage(316);
      }
    } else if (command.startsWith("admin_save_modifications")) {
      try {
        String val = command.substring(24);
        adminModifyCharacter(activeChar, val);
      } catch (StringIndexOutOfBoundsException e) { // Case of empty character name
        activeChar.sendMessage(113);
        listCharacters(activeChar, 0);
      }
    } else if (command.startsWith("admin_rec")) {
      try {
        String val = command.substring(10);
        int recVal = Integer.parseInt(val);
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        if (target instanceof L2PcInstance) {
          player = (L2PcInstance) target;
        } else {
          return false;
        }
        player.setRecomHave(recVal);
        player.sendMessage(528);
        player.broadcastUserInfo();
      } catch (Exception e) {
        activeChar.sendMessage(414);
      }
    } else if (command.startsWith("admin_setclass")) {
      try {
        String val = command.substring(15);
        int classidval = Integer.parseInt(val);
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        if (target instanceof L2PcInstance) player = (L2PcInstance) target;
        else return false;
        boolean valid = false;
        for (ClassId classid : ClassId.values()) if (classidval == classid.getId()) valid = true;
        if (valid && (player.getClassId().getId() != classidval)) {
          player.setClassId(classidval);
          if (!player.isSubClassActive()) player.setBaseClass(classidval);
          String newclass = player.getTemplate().className;
          player.store();
          L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[14]);
          cm.addString(newclass);
          cm.sendMessage(player);
          player.broadcastUserInfo();
          cm = new L2CoreMessage(MessageTable.Messages[670]);
          cm.addString(player.getName());
          cm.addString(newclass);
          cm.sendMessage(activeChar);
        }
        activeChar.sendMessage(418);
      } catch (StringIndexOutOfBoundsException e) {
        AdminHelpPage.showHelpPage(activeChar, "charclasses.htm");
      }
    } else if (command.startsWith("admin_settitle")) {
      try {
        String val = command.substring(15);
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        if (target instanceof L2PcInstance) {
          player = (L2PcInstance) target;
        } else {
          return false;
        }
        player.setTitle(val);
        player.sendMessage(644);
        player.broadcastTitleInfo();
      } catch (StringIndexOutOfBoundsException e) { // Case of empty character title
        activeChar.sendMessage(584);
      }
    } else if (command.startsWith("admin_changename")) {
      try {
        String val = command.substring(17);
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        if (target instanceof L2PcInstance) {
          player = (L2PcInstance) target;
        } else {
          return false;
        }
        L2World.getInstance().removeFromAllPlayers(player);
        player.setName(val);
        player.store();
        L2World.getInstance().addToAllPlayers(player);

        player.sendMessage(623);
        player.broadcastUserInfo();

        if (player.isInParty()) {
          // Delete party window for other party members
          player.getParty().broadcastToPartyMembers(player, new PartySmallWindowDeleteAll());
          for (L2PcInstance member : player.getParty().getPartyMembers()) {
            // And re-add
            if (member != player)
              member.sendPacket(new PartySmallWindowAll(member, player.getParty()));
          }
        }
        if (player.getClan() != null) {
          player.getClan().broadcastClanStatus();
        }

        RegionBBSManager.getInstance().changeCommunityBoard();
      } catch (StringIndexOutOfBoundsException e) { // Case of empty character name
        activeChar.sendMessage(420);
      }
    } else if (command.startsWith("admin_setsex")) {
      L2Object target = activeChar.getTarget();
      L2PcInstance player = null;
      if (target instanceof L2PcInstance) {
        player = (L2PcInstance) target;
      } else {
        return false;
      }
      player.getAppearance().setSex(player.getAppearance().getSex() ? false : true);
      player.sendMessage(621);
      player.broadcastUserInfo();
      player.decayMe();
      player.spawnMe(player.getX(), player.getY(), player.getZ());
    } else if (command.startsWith("admin_setcolor")) {
      try {
        String val = command.substring(15);
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        if (target instanceof L2PcInstance) {
          player = (L2PcInstance) target;
        } else {
          return false;
        }
        player.getAppearance().setNameColor(Integer.decode("0x" + val));
        player.sendMessage(622);
        player.broadcastUserInfo();
      } catch (Exception e) { // Case of empty color or invalid hex string
        activeChar.sendMessage(583);
      }
    } else if (command.startsWith("admin_fullfood")) {
      L2Object target = activeChar.getTarget();
      if (target instanceof L2PetInstance) {
        L2PetInstance targetPet = (L2PetInstance) target;
        targetPet.setCurrentFed(targetPet.getMaxFed());
        targetPet
            .getOwner()
            .sendPacket(new SetSummonRemainTime(targetPet.getMaxFed(), targetPet.getCurrentFed()));
      } else activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
    } else if (command.startsWith("admin_unpenalty")) {
      try {
        StringTokenizer st = new StringTokenizer(command, " ");
        if (st.countTokens() != 3) {
          activeChar.sendMessage(364);
          return false;
        }

        st.nextToken();

        boolean changeCreateExpiryTime = st.nextToken().equalsIgnoreCase("create");

        String playerName = st.nextToken();
        L2PcInstance player = null;
        player = L2World.getInstance().getPlayer(playerName);

        if (player == null) {
          Connection con = L2DatabaseFactory.getInstance().getConnection();
          PreparedStatement ps =
              con.prepareStatement(
                  "UPDATE characters SET "
                      + (changeCreateExpiryTime
                          ? "clan_create_expiry_time"
                          : "clan_join_expiry_time")
                      + " WHERE char_name=? LIMIT 1");

          ps.setString(1, playerName);
          ps.execute();
        } else {
          // removing penalty
          if (changeCreateExpiryTime) player.setClanCreateExpiryTime(0);
          else player.setClanJoinExpiryTime(0);
        }

        L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[470]);
        cm.addString(playerName);
        cm.sendMessage(activeChar);
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else if (command.startsWith("admin_find_dualbox")) {
      int multibox = 2;
      try {
        String val = command.substring(19);
        multibox = Integer.parseInt(val);
        if (multibox < 1) {
          activeChar.sendMessage(97);
          return false;
        }
      } catch (Exception e) {
      }
      findDualbox(activeChar, multibox);
    }

    return true;
  }
コード例 #15
0
ファイル: AdminBan.java プロジェクト: WildReiser/Interlude
  @Override
  public boolean useAdminCommand(String command, L2PcInstance activeChar) {
    StringTokenizer st = new StringTokenizer(command);
    st.nextToken();
    String player = "";
    int duration = -1;
    L2PcInstance targetPlayer = null;

    // One parameter, player name
    if (st.hasMoreTokens()) {
      player = st.nextToken();
      targetPlayer = L2World.getInstance().getPlayer(player);

      // Second parameter, duration
      if (st.hasMoreTokens()) {
        try {
          duration = Integer.parseInt(st.nextToken());
        } catch (NumberFormatException nfe) {
          activeChar.sendMessage("Invalid number format used: " + nfe);
          return false;
        }
      }
    } else {
      // If there is no name, select target
      if (activeChar.getTarget() != null && activeChar.getTarget() instanceof L2PcInstance)
        targetPlayer = (L2PcInstance) activeChar.getTarget();
    }

    // Can't ban yourself
    if (targetPlayer != null && targetPlayer.equals(activeChar)) {
      activeChar.sendPacket(SystemMessageId.CANNOT_USE_ON_YOURSELF);
      return false;
    }

    if (command.startsWith("admin_ban ") || command.equalsIgnoreCase("admin_ban")) {
      activeChar.sendMessage("Available ban commands: //ban_acc, //ban_char, //ban_chat");
      return false;
    } else if (command.startsWith("admin_ban_acc")) {
      if (targetPlayer == null && player.equals("")) {
        activeChar.sendMessage(
            "Usage: //ban_acc <account_name> (if none, target char's account gets banned).");
        return false;
      } else if (targetPlayer == null) {
        LoginServerThread.getInstance().sendAccessLevel(player, -100);
        activeChar.sendMessage("Ban request sent for account " + player + ".");
        auditAction(command, activeChar, player);
      } else {
        targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.ACC, 0);
        activeChar.sendMessage(targetPlayer.getAccountName() + " account is now banned.");
        auditAction(command, activeChar, targetPlayer.getAccountName());
      }
    } else if (command.startsWith("admin_ban_char")) {
      if (targetPlayer == null && player.equals("")) {
        activeChar.sendMessage("Usage: //ban_char <char_name> (if none, target char is banned)");
        return false;
      }

      auditAction(command, activeChar, (targetPlayer == null ? player : targetPlayer.getName()));
      return changeCharAccessLevel(targetPlayer, player, activeChar, -100);
    } else if (command.startsWith("admin_ban_chat")) {
      if (targetPlayer == null && player.equals("")) {
        activeChar.sendMessage("Usage: //ban_chat <char_name> [penalty_minutes]");
        return false;
      }

      if (targetPlayer != null) {
        if (targetPlayer.getPunishLevel().value() > 0) {
          activeChar.sendMessage(targetPlayer.getName() + " is already jailed or banned.");
          return false;
        }

        String banLengthStr = "";
        targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.CHAT, duration);

        if (duration > 0) banLengthStr = " for " + duration + " minutes";

        activeChar.sendMessage(targetPlayer.getName() + " is now chat banned" + banLengthStr + ".");
        auditAction(command, activeChar, targetPlayer.getName());
      } else {
        banChatOfflinePlayer(activeChar, player, duration, true);
        auditAction(command, activeChar, player);
      }
    } else if (command.startsWith("admin_unban ") || command.equalsIgnoreCase("admin_unban")) {
      activeChar.sendMessage("Available unban commands: //unban_acc, //unban_char, //unban_chat");
      return false;
    } else if (command.startsWith("admin_unban_acc")) {
      if (targetPlayer != null) {
        activeChar.sendMessage(
            targetPlayer.getName() + " is currently online so mustn't be banned.");
        return false;
      } else if (!player.equals("")) {
        LoginServerThread.getInstance().sendAccessLevel(player, 0);
        activeChar.sendMessage("Unban request sent for account " + player + ".");
        auditAction(command, activeChar, player);
      } else {
        activeChar.sendMessage("Usage: //unban_acc <account_name>");
        return false;
      }
    } else if (command.startsWith("admin_unban_char")) {
      if (targetPlayer == null && player.equals("")) {
        activeChar.sendMessage("Usage: //unban_char <char_name>");
        return false;
      } else if (targetPlayer != null) {
        activeChar.sendMessage(
            targetPlayer.getName() + " is currently online so mustn't be banned.");
        return false;
      } else {
        auditAction(command, activeChar, player);
        return changeCharAccessLevel(null, player, activeChar, 0);
      }
    } else if (command.startsWith("admin_unban_chat")) {
      if (targetPlayer == null && player.equals("")) {
        activeChar.sendMessage("Usage: //unban_chat <char_name>");
        return false;
      }

      if (targetPlayer != null) {
        if (targetPlayer.isChatBanned()) {
          targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.NONE, 0);
          activeChar.sendMessage(targetPlayer.getName() + "'s chat ban has been lifted.");
          auditAction(command, activeChar, targetPlayer.getName());
        } else activeChar.sendMessage(targetPlayer.getName() + " isn't currently chat banned.");
      } else {
        banChatOfflinePlayer(activeChar, player, 0, false);
        auditAction(command, activeChar, player);
      }
    } else if (command.startsWith("admin_jail")) {
      if (targetPlayer == null && player.equals("")) {
        activeChar.sendMessage(
            "Usage: //jail <charname> [penalty_minutes] (if no name is given, selected target is jailed forever).");
        return false;
      }

      if (targetPlayer != null) {
        targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.JAIL, duration);
        activeChar.sendMessage(
            targetPlayer.getName()
                + " have been jailed for "
                + (duration > 0 ? duration + " minutes." : "ever !"));
        auditAction(command, activeChar, targetPlayer.getName());
      } else {
        jailOfflinePlayer(activeChar, player, duration);
        auditAction(command, activeChar, player);
      }
    } else if (command.startsWith("admin_unjail")) {
      if (targetPlayer == null && player.equals("")) {
        activeChar.sendMessage("Usage: //unjail <charname> (If no name is given target is used).");
        return false;
      } else if (targetPlayer != null) {
        targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.NONE, 0);
        activeChar.sendMessage(targetPlayer.getName() + " have been unjailed.");
        auditAction(command, activeChar, targetPlayer.getName());
      } else {
        unjailOfflinePlayer(activeChar, player);
        auditAction(command, activeChar, player);
      }
    }
    return true;
  }
コード例 #16
0
ファイル: ValidatePosition.java プロジェクト: Bahu90/l2j_acis
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null || activeChar.isTeleporting() || activeChar.inObserverMode()) return;

    final int realX = activeChar.getX();
    final int realY = activeChar.getY();
    int realZ = activeChar.getZ();

    if (Config.DEVELOPER)
      _log.fine(
          "C(S) pos: "
              + _x
              + "("
              + realX
              + ") "
              + _y
              + "("
              + realY
              + ") "
              + _z
              + "("
              + realZ
              + ") / "
              + _heading
              + "("
              + activeChar.getHeading()
              + ")");

    if (_x == 0 && _y == 0) {
      if (realX != 0) // in this case this seems like a client error
      return;
    }

    int dx, dy, dz;
    double diffSq;

    if (activeChar.isInBoat()) {
      if (Config.COORD_SYNCHRONIZE == 2) {
        dx = _x - activeChar.getInVehiclePosition().getX();
        dy = _y - activeChar.getInVehiclePosition().getY();
        dz = _z - activeChar.getInVehiclePosition().getZ();
        diffSq = (dx * dx + dy * dy);
        if (diffSq > 250000)
          sendPacket(
              new GetOnVehicle(activeChar.getObjectId(), _data, activeChar.getInVehiclePosition()));
      }
      return;
    }

    if (activeChar.isFalling(_z)) return; // disable validations during fall to avoid "jumping"

    dx = _x - realX;
    dy = _y - realY;
    dz = _z - realZ;
    diffSq = (dx * dx + dy * dy);

    if (activeChar.isFlying() || activeChar.isInsideZone(ZoneId.WATER)) {
      activeChar.setXYZ(realX, realY, _z);
      if (diffSq > 90000) // validate packet, may also cause z bounce if close to land
      activeChar.sendPacket(new ValidateLocation(activeChar));
    } else if (diffSq < 360000) // if too large, messes observation
    {
      if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server,
      // mainly used when no geodata but can be used also with geodata
      {
        activeChar.setXYZ(realX, realY, _z);
        return;
      }
      if (Config.COORD_SYNCHRONIZE
          == 1) // Trusting also client x,y coordinates (should not be used with geodata)
      {
        // Heading changed on client = possible obstacle
        if (!activeChar.isMoving() || !activeChar.validateMovementHeading(_heading)) {
          // character is not moving, take coordinates from client
          if (diffSq
              < 2500) // 50*50 - attack won't work fluently if even small differences are corrected
          activeChar.setXYZ(realX, realY, _z);
          else activeChar.setXYZ(_x, _y, _z);
        } else activeChar.setXYZ(realX, realY, _z);

        activeChar.setHeading(_heading);
        return;
      }
      // Sync 2 (or other),
      // intended for geodata. Sends a validation packet to client
      // when too far from server calculated true coordinate.
      // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution)
      // Important: this code part must work together with L2Character.updatePosition
      if (Config.GEODATA > 0 && (diffSq > 250000 || Math.abs(dz) > 200)) {
        if (Math.abs(dz) > 200
            && Math.abs(dz) < 1500
            && Math.abs(_z - activeChar.getClientZ()) < 800) {
          activeChar.setXYZ(realX, realY, _z);
          realZ = _z;
        } else {
          if (Config.DEVELOPER)
            _log.info(activeChar.getName() + ": Synchronizing position Server --> Client");

          activeChar.sendPacket(new ValidateLocation(activeChar));
        }
      }
    }

    activeChar.setClientX(_x);
    activeChar.setClientY(_y);
    activeChar.setClientZ(_z);
    activeChar.setClientHeading(_heading); // No real need to validate heading.
    activeChar.setLastServerPosition(realX, realY, realZ);
  }
コード例 #17
0
  /**
   * @param activeChar
   * @param IpAdress
   * @throws IllegalArgumentException
   */
  private void findCharactersPerIp(L2PcInstance activeChar, String IpAdress)
      throws IllegalArgumentException {
    boolean findDisconnected = false;

    if (IpAdress.equals("disconnected")) {
      findDisconnected = true;
    } else {
      if (!IpAdress.matches(
          "^(?:(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))$"))
        throw new IllegalArgumentException("Malformed IPv4 number");
    }
    Collection<L2PcInstance> allPlayers = L2World.getInstance().getAllPlayers().values();
    L2PcInstance[] players;
    // synchronized (L2World.getInstance().getAllPlayers())
    {
      players = allPlayers.toArray(new L2PcInstance[allPlayers.size()]);
    }
    int CharactersFound = 0;
    L2GameClient client;
    String name, ip = "0.0.0.0";
    final StringBuilder replyMSG = new StringBuilder(1000);
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    adminReply.setFile("data/html/admin/ipfind.htm");
    for (L2PcInstance player : players) {
      client = player.getClient();
      if (client.isDetached()) {
        if (!findDisconnected) {
          continue;
        }
      } else {
        if (findDisconnected) {
          continue;
        } else {
          ip = client.getConnection().getInetAddress().getHostAddress();
          if (!ip.equals(IpAdress)) continue;
        }
      }

      name = player.getName();
      CharactersFound = CharactersFound + 1;
      StringUtil.append(
          replyMSG,
          "<tr><td width=80><a action=\"bypass -h admin_character_list ",
          name,
          "\">",
          name,
          "</a></td><td width=110>",
          player.getTemplate().className,
          "</td><td width=40>",
          String.valueOf(player.getLevel()),
          "</td></tr>");

      if (CharactersFound > 20) break;
    }
    adminReply.replace("%results%", replyMSG.toString());

    final String replyMSG2;

    if (CharactersFound == 0) {
      replyMSG2 = MessageTable.Messages[681].getMessage();
    } else if (CharactersFound > 20) {
      adminReply.replace(
          "%number%", MessageTable.Messages[1213].getMessage() + String.valueOf(CharactersFound));
      replyMSG2 = MessageTable.Messages[682].getMessage();
    } else if (CharactersFound == 1) {
      replyMSG2 = MessageTable.Messages[1196].getMessage();
    } else {
      replyMSG2 = MessageTable.Messages[1197].getMessage();
    }
    adminReply.replace("%ip%", ip);
    adminReply.replace("%number%", String.valueOf(CharactersFound));
    adminReply.replace("%end%", replyMSG2);
    activeChar.sendPacket(adminReply);
  }
コード例 #18
0
  private void adminModifyCharacter(L2PcInstance activeChar, String modifications) {
    L2Object target = activeChar.getTarget();

    if (!(target instanceof L2PcInstance)) return;

    L2PcInstance player = (L2PcInstance) target;
    StringTokenizer st = new StringTokenizer(modifications);

    if (st.countTokens() != 6) {
      editCharacter(player);
      return;
    }

    String hp = st.nextToken();
    String mp = st.nextToken();
    String cp = st.nextToken();
    String pvpflag = st.nextToken();
    String pvpkills = st.nextToken();
    String pkkills = st.nextToken();

    int hpval = Integer.parseInt(hp);
    int mpval = Integer.parseInt(mp);
    int cpval = Integer.parseInt(cp);
    int pvpflagval = Integer.parseInt(pvpflag);
    int pvpkillsval = Integer.parseInt(pvpkills);
    int pkkillsval = Integer.parseInt(pkkills);

    // Common character information
    L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[30]);
    cm.addNumber(hpval);
    cm.addNumber(mpval);
    cm.addNumber(cpval);
    cm.addNumber(pvpflagval);
    cm.addNumber(pvpkillsval);
    cm.addNumber(pkkillsval);
    cm.sendMessage(player);
    player.setCurrentHp(hpval);
    player.setCurrentMp(mpval);
    player.setCurrentCp(cpval);
    player.setPvpFlag(pvpflagval);
    player.setPvpKills(pvpkillsval);
    player.setPkKills(pkkillsval);

    // Save the changed parameters to the database.
    player.store();

    StatusUpdate su = new StatusUpdate(player.getObjectId());
    su.addAttribute(StatusUpdate.CUR_HP, hpval);
    su.addAttribute(StatusUpdate.MAX_HP, player.getMaxHp());
    su.addAttribute(StatusUpdate.CUR_MP, mpval);
    su.addAttribute(StatusUpdate.MAX_MP, player.getMaxMp());
    su.addAttribute(StatusUpdate.CUR_CP, cpval);
    su.addAttribute(StatusUpdate.MAX_CP, player.getMaxCp());
    player.sendPacket(su);

    // Admin information
    cm = new L2CoreMessage(MessageTable.Messages[70]);
    cm.addString(player.getName());
    cm.addNumber(hpval);
    cm.addNumber(mpval);
    cm.addNumber(cpval);
    cm.addNumber(pvpflagval);
    cm.addNumber(pvpkillsval);
    cm.addNumber(pkkillsval);
    cm.sendMessage(activeChar);

    if (Config.DEBUG)
      _log.fine(
          "[GM]"
              + activeChar.getName()
              + " changed stats of "
              + player.getName()
              + ". "
              + " HP: "
              + hpval
              + " MP: "
              + mpval
              + " CP: "
              + cpval
              + " PvP: "
              + pvpflagval
              + " / "
              + pvpkillsval);

    showCharacterInfo(activeChar, null); // Back to start

    player.broadcastPacket(new CharInfo(player));
    player.sendPacket(new UserInfo(player));
    player.broadcastPacket(new ExBrExtraUserInfo(player));
    player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
    player.decayMe();
    player.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  }
コード例 #19
0
  @Override
  protected void runImpl() {
    if (_items == null) return;

    final L2PcInstance player = getClient().getActiveChar();
    if (player == null) return;

    if (player.isProcessingTransaction()) {
      player.sendPacket(SystemMessageId.ALREADY_TRADING);
      return;
    }

    if (player.getActiveEnchantItem() != null) {
      player.setActiveEnchantItem(null);
      player.sendPacket(EnchantResult.CANCELLED);
      player.sendPacket(SystemMessageId.ENCHANT_SCROLL_CANCELLED);
    }

    final ItemContainer warehouse = player.getActiveWarehouse();
    if (warehouse == null) return;

    final boolean isPrivate = warehouse instanceof PcWarehouse;

    final L2Npc manager = player.getCurrentFolkNPC();
    if ((manager == null || !manager.isWarehouse() || !manager.canInteract(player))
        && !player.isGM()) return;

    if (!isPrivate && !player.getAccessLevel().allowTransaction()) {
      player.sendMessage("Transactions are disabled for your Access Level.");
      return;
    }

    // Alt game - Karma punishment
    if (!Config.KARMA_PLAYER_CAN_USE_WH && player.getKarma() > 0) return;

    // Freight price from config or normal price per item slot (30)
    final int fee = _items.length * 30;
    int currentAdena = player.getAdena();
    int slots = 0;

    for (WarehouseItem i : _items) {
      ItemInstance item = player.checkItemManipulation(i.getObjectId(), i.getCount());
      if (item == null) {
        _log.warning(
            "Error depositing a warehouse object for char "
                + player.getName()
                + " (validity check)");
        return;
      }

      // Calculate needed adena and slots
      if (item.getItemId() == ADENA_ID) currentAdena -= i.getCount();
      if (!item.isStackable()) slots += i.getCount();
      else if (warehouse.getItemByItemId(item.getItemId()) == null) slots++;
    }

    // Item Max Limit Check
    if (!warehouse.validateCapacity(slots)) {
      sendPacket(
          SystemMessage.getSystemMessage(
              SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED));
      return;
    }

    // Check if enough adena and charge the fee
    if (currentAdena < fee || !player.reduceAdena(warehouse.getName(), fee, manager, false)) {
      sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
      return;
    }

    // get current tradelist if any
    if (player.getActiveTradeList() != null) return;

    // Proceed to the transfer
    InventoryUpdate playerIU = new InventoryUpdate();
    for (WarehouseItem i : _items) {
      // Check validity of requested item
      ItemInstance oldItem = player.checkItemManipulation(i.getObjectId(), i.getCount());
      if (oldItem == null) {
        _log.warning(
            "Error depositing a warehouse object for char "
                + player.getName()
                + " (olditem == null)");
        return;
      }

      if (!oldItem.isDepositable(isPrivate) || !oldItem.isAvailable(player, true, isPrivate))
        continue;

      final ItemInstance newItem =
          player
              .getInventory()
              .transferItem(
                  warehouse.getName(), i.getObjectId(), i.getCount(), warehouse, player, manager);
      if (newItem == null) {
        _log.warning(
            "Error depositing a warehouse object for char "
                + player.getName()
                + " (newitem == null)");
        continue;
      }

      if (oldItem.getCount() > 0 && oldItem != newItem) playerIU.addModifiedItem(oldItem);
      else playerIU.addRemovedItem(oldItem);
    }

    // Send updated item list to the player
    player.sendPacket(playerIU);

    // Update current load status on player
    StatusUpdate su = new StatusUpdate(player);
    su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
    player.sendPacket(su);
  }
コード例 #20
0
ファイル: ConfirmDlg.java プロジェクト: sonizs123/Acis
 public ConfirmDlg addPcName(L2PcInstance pc) {
   return addString(pc.getName());
 }
コード例 #21
0
  @Override
  protected void runImpl() {
    if (!FloodProtectors.performAction(getClient(), Action.SERVER_BYPASS)) return;

    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    if (_command.isEmpty()) {
      _log.info(activeChar.getName() + " sent an empty requestBypass packet.");
      activeChar.logout();
      return;
    }

    try {
      if (_command.startsWith("admin_")) {
        String command = _command.split(" ")[0];

        IAdminCommandHandler ach =
            AdminCommandHandler.getInstance().getAdminCommandHandler(command);
        if (ach == null) {
          if (activeChar.isGM())
            activeChar.sendMessage("The command " + command.substring(6) + " doesn't exist.");

          _log.warning("No handler registered for admin command '" + command + "'");
          return;
        }

        if (!AdminCommandAccessRights.getInstance()
            .hasAccess(command, activeChar.getAccessLevel())) {
          activeChar.sendMessage("You don't have the access rights to use this command.");
          _log.warning(
              activeChar.getName()
                  + " tried to use admin command "
                  + command
                  + " without proper Access Level.");
          return;
        }

        if (Config.GMAUDIT)
          GMAudit.auditGMAction(
              activeChar.getName() + " [" + activeChar.getObjectId() + "]",
              _command,
              (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"));

        ach.useAdminCommand(_command, activeChar);
      } else if (_command.startsWith("player_help ")) {
        playerHelp(activeChar, _command.substring(12));
      } else if (_command.startsWith("npc_")) {
        if (!activeChar.validateBypass(_command)) return;

        int endOfId = _command.indexOf('_', 5);
        String id;
        if (endOfId > 0) id = _command.substring(4, endOfId);
        else id = _command.substring(4);

        try {
          final L2Object object = L2World.getInstance().getObject(Integer.parseInt(id));

          if (object != null
              && object instanceof L2Npc
              && endOfId > 0
              && ((L2Npc) object).canInteract(activeChar))
            ((L2Npc) object).onBypassFeedback(activeChar, _command.substring(endOfId + 1));

          activeChar.sendPacket(ActionFailed.STATIC_PACKET);
        } catch (NumberFormatException nfe) {
        }
      }
      // Navigate throught Manor windows
      else if (_command.startsWith("manor_menu_select?")) {
        L2Object object = activeChar.getTarget();
        if (object instanceof L2Npc) ((L2Npc) object).onBypassFeedback(activeChar, _command);
      } else if (_command.startsWith("bbs_")
          || _command.startsWith("_bbs")
          || _command.startsWith("_friend")
          || _command.startsWith("_mail")
          || _command.startsWith("_block")) {
        CommunityBoard.getInstance().handleCommands(getClient(), _command);
      } else if (_command.startsWith("Quest ")) {
        if (!activeChar.validateBypass(_command)) return;

        String[] str = _command.substring(6).trim().split(" ", 2);
        if (str.length == 1) activeChar.processQuestEvent(str[0], "");
        else activeChar.processQuestEvent(str[0], str[1]);
      } else if (_command.startsWith("_match")) {
        String params = _command.substring(_command.indexOf("?") + 1);
        StringTokenizer st = new StringTokenizer(params, "&");
        int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
        int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
        int heroid = Hero.getInstance().getHeroByClass(heroclass);
        if (heroid > 0) Hero.getInstance().showHeroFights(activeChar, heroclass, heroid, heropage);
      } else if (_command.startsWith("_diary")) {
        String params = _command.substring(_command.indexOf("?") + 1);
        StringTokenizer st = new StringTokenizer(params, "&");
        int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
        int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
        int heroid = Hero.getInstance().getHeroByClass(heroclass);
        if (heroid > 0) Hero.getInstance().showHeroDiary(activeChar, heroclass, heroid, heropage);
      } else if (_command.startsWith("arenachange")) // change
      {
        final boolean isManager =
            activeChar.getCurrentFolkNPC() instanceof L2OlympiadManagerInstance;
        if (!isManager) {
          // Without npc, command can be used only in observer mode on arena
          if (!activeChar.inObserverMode()
              || activeChar.isInOlympiadMode()
              || activeChar.getOlympiadGameId() < 0) return;
        }

        if (OlympiadManager.getInstance().isRegisteredInComp(activeChar)) {
          activeChar.sendPacket(
              SystemMessageId
                  .WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME);
          return;
        }

        final int arenaId = Integer.parseInt(_command.substring(12).trim());
        activeChar.enterOlympiadObserverMode(arenaId);
      }
    } catch (Exception e) {
      _log.log(Level.WARNING, "Bad RequestBypassToServer: ", e);
    }
  }
コード例 #22
0
ファイル: Q021_HiddenTruth.java プロジェクト: Barrog/aCis
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = event;
    QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    if (event.equalsIgnoreCase("31522-02.htm")) {
      st.setState(STATE_STARTED);
      st.set("cond", "1");
      st.playSound(QuestState.SOUND_ACCEPT);
    } else if (event.equalsIgnoreCase("31523-03.htm")) {
      st.set("cond", "2");
      st.playSound(QuestState.SOUND_MIDDLE);
      spawnVonHellmann(st);
    } else if (event.equalsIgnoreCase("31524-06.htm")) {
      st.set("cond", "3");
      st.playSound(QuestState.SOUND_MIDDLE);

      // Spawn the page.
      if (_vonHellmannPage == null) {
        _vonHellmannPage = addSpawn(VON_HELLMAN_PAGE, 51462, -54539, -3176, 0, false, 90000, true);
        _vonHellmannPage.broadcastNpcSay(
            "My master has instructed me to be your guide, " + player.getName() + ".");

        // Make it move.
        startQuestTimer("1", 4000, _vonHellmannPage, player, false);
        startQuestTimer("pageDespawn", 88000, _vonHellmannPage, player, false);
      }
    } else if (event.equalsIgnoreCase("31526-08.htm")) {
      st.set("cond", "5");
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if (event.equalsIgnoreCase("31526-14.htm")) {
      st.set("cond", "6");
      st.playSound(QuestState.SOUND_MIDDLE);
      st.giveItems(CROSS_OF_EINHASAD, 1);
    } else if (event.equalsIgnoreCase("1")) {
      _vonHellmannPage
          .getAI()
          .setIntention(CtrlIntention.MOVE_TO, new L2CharPosition(52373, -54296, -3136, 0));
      _vonHellmannPage.broadcastNpcSay("Follow me...");
      startQuestTimer("2", 5000, _vonHellmannPage, player, false);
      return null;
    } else if (event.equalsIgnoreCase("2")) {
      _vonHellmannPage
          .getAI()
          .setIntention(CtrlIntention.MOVE_TO, new L2CharPosition(52279, -53064, -3161, 0));
      startQuestTimer("3", 12000, _vonHellmannPage, player, false);
      return null;
    } else if (event.equalsIgnoreCase("3")) {
      _vonHellmannPage
          .getAI()
          .setIntention(CtrlIntention.MOVE_TO, new L2CharPosition(51909, -51725, -3125, 0));
      startQuestTimer("4", 15000, _vonHellmannPage, player, false);
      return null;
    } else if (event.equalsIgnoreCase("4")) {
      _vonHellmannPage
          .getAI()
          .setIntention(CtrlIntention.MOVE_TO, new L2CharPosition(52438, -51240, -3097, 0));
      _vonHellmannPage.broadcastNpcSay("This where that here...");
      startQuestTimer("5", 5000, _vonHellmannPage, player, false);
      return null;
    } else if (event.equalsIgnoreCase("5")) {
      _vonHellmannPage
          .getAI()
          .setIntention(CtrlIntention.MOVE_TO, new L2CharPosition(52143, -51418, -3085, 0));
      _vonHellmannPage.broadcastNpcSay("I want to speak to you...");
      return null;
    } else if (event.equalsIgnoreCase("31328-05.htm")) {
      if (st.hasQuestItems(CROSS_OF_EINHASAD)) {
        st.takeItems(CROSS_OF_EINHASAD, 1);
        st.giveItems(CROSS_OF_EINHASAD_NEXT_QUEST, 1);
        st.playSound(QuestState.SOUND_FINISH);
        st.exitQuest(false);
      }
    } else if (event.equalsIgnoreCase("pageDespawn")) _vonHellmannPage = null;

    return htmltext;
  }
コード例 #23
0
ファイル: RequestPackageSend.java プロジェクト: D3XV/D3X
  @Override
  protected void runImpl() {
    if (_items == null || _items.isEmpty() || !Config.ALLOW_FREIGHT) return;

    final L2PcInstance player = getClient().getActiveChar();
    if (player == null) return;

    // player attempts to send freight to the different account
    if (!player.getAccountChars().containsKey(_objectID)) return;

    final PcFreight freight = player.getDepositedFreight(_objectID);
    player.setActiveWarehouse(freight);

    final ItemContainer warehouse = player.getActiveWarehouse();
    if (warehouse == null) return;

    final L2Npc manager = player.getCurrentFolkNPC();
    if ((manager == null
            || !player.isInsideRadius(manager, L2Npc.INTERACTION_DISTANCE, false, false))
        && !player.isGM()) return;

    if (warehouse instanceof PcFreight && !player.getAccessLevel().allowTransaction()) {
      player.sendMessage("Transactions are disabled for your Access Level.");
      return;
    }

    // Alt game - Karma punishment
    if (!Config.KARMA_PLAYER_CAN_USE_WH && player.getKarma() > 0) return;

    // Freight price from config or normal price per item slot (30)
    int fee = _items.size() * Config.ALT_GAME_FREIGHT_PRICE;
    int currentAdena = player.getAdena();
    int slots = 0;

    for (Item i : _items) {
      int objectId = i.id;
      int count = i.count;

      // Check validity of requested item
      ItemInstance item = player.checkItemManipulation(objectId, count);
      if (item == null) {
        _log.warning(
            "Error depositing a warehouse object for char "
                + player.getName()
                + " (validity check)");
        i.id = 0;
        i.count = 0;
        continue;
      }

      if (!item.isTradable() || item.isQuestItem()) return;

      // Calculate needed adena and slots
      if (item.getItemId() == 57) currentAdena -= count;

      if (!item.isStackable()) slots += count;
      else if (warehouse.getItemByItemId(item.getItemId()) == null) slots++;
    }

    // Item Max Limit Check
    if (!warehouse.validateCapacity(slots)) {
      sendPacket(
          SystemMessage.getSystemMessage(
              SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED));
      return;
    }

    // Check if enough adena and charge the fee
    if (currentAdena < fee
        || !player.reduceAdena("Warehouse", fee, player.getCurrentFolkNPC(), false)) {
      sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
      return;
    }

    // Proceed to the transfer
    InventoryUpdate playerIU = new InventoryUpdate();
    for (Item i : _items) {
      int objectId = i.id;
      int count = i.count;

      // check for an invalid item
      if (objectId == 0 && count == 0) continue;

      ItemInstance oldItem = player.getInventory().getItemByObjectId(objectId);
      if (oldItem == null) {
        _log.warning(
            "Error depositing a warehouse object for char "
                + player.getName()
                + " (olditem == null)");
        continue;
      }

      if (oldItem.isHeroItem()) continue;

      ItemInstance newItem =
          player
              .getInventory()
              .transferItem(
                  "Warehouse", objectId, count, warehouse, player, player.getCurrentFolkNPC());
      if (newItem == null) {
        _log.warning(
            "Error depositing a warehouse object for char "
                + player.getName()
                + " (newitem == null)");
        continue;
      }

      if (oldItem.getCount() > 0 && oldItem != newItem) playerIU.addModifiedItem(oldItem);
      else playerIU.addRemovedItem(oldItem);
    }

    // Send updated item list to the player
    player.sendPacket(playerIU);

    // Update current load status on player
    StatusUpdate su = new StatusUpdate(player);
    su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
    player.sendPacket(su);
  }
コード例 #24
0
ファイル: AdminSiege.java プロジェクト: sonizs123/Acis
  @Override
  public boolean useAdminCommand(String command, L2PcInstance activeChar) {
    StringTokenizer st = new StringTokenizer(command, " ");
    command = st.nextToken(); // Get actual command

    // Get castle
    Castle castle = null;
    ClanHall clanhall = null;

    if (command.startsWith("admin_clanhall"))
      clanhall = ClanHallManager.getInstance().getClanHallById(Integer.parseInt(st.nextToken()));
    else if (st.hasMoreTokens()) castle = CastleManager.getInstance().getCastle(st.nextToken());

    if (clanhall == null && (castle == null || castle.getCastleId() < 0)) {
      showCastleSelectPage(activeChar);
      return true;
    }

    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;
    if (target instanceof L2PcInstance) player = (L2PcInstance) target;

    if (castle != null) {
      if (command.equalsIgnoreCase("admin_add_attacker")) {
        if (player == null) activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
        else castle.getSiege().registerAttacker(player);
      } else if (command.equalsIgnoreCase("admin_add_defender")) {
        if (player == null) activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
        else castle.getSiege().registerDefender(player);
      } else if (command.equalsIgnoreCase("admin_add_guard")) {
        try {
          int npcId = Integer.parseInt(st.nextToken());
          castle.getSiege().getSiegeGuardManager().addSiegeGuard(activeChar, npcId);
        } catch (Exception e) {
          activeChar.sendMessage("Usage: //add_guard npcId");
        }
      } else if (command.equalsIgnoreCase("admin_clear_siege_list")) {
        castle.getSiege().clearSiegeClan();
      } else if (command.equalsIgnoreCase("admin_endsiege")) {
        castle.getSiege().endSiege();
      } else if (command.equalsIgnoreCase("admin_list_siege_clans")) {
        castle.getSiege().listRegisterClan(activeChar);
        return true;
      } else if (command.equalsIgnoreCase("admin_move_defenders")) {
        activeChar.sendPacket(SystemMessage.sendString("Not implemented yet."));
      } else if (command.equalsIgnoreCase("admin_setcastle")) {
        if (player == null || player.getClan() == null)
          activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
        else if (player.getClan().hasCastle())
          activeChar.sendMessage(player.getName() + "'s clan already owns a castle.");
        else castle.setOwner(player.getClan());
      } else if (command.equalsIgnoreCase("admin_removecastle")) {
        L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
        if (clan != null) castle.removeOwner(clan);
        else activeChar.sendMessage("Unable to remove castle for this clan.");
      } else if (command.equalsIgnoreCase("admin_spawn_doors")) {
        castle.spawnDoors(false);
      } else if (command.equalsIgnoreCase("admin_startsiege")) {
        castle.getSiege().startSiege();
      }
      showSiegePage(activeChar, castle.getName());
    } else if (clanhall != null) {
      if (command.equalsIgnoreCase("admin_clanhallset")) {
        if (player == null || player.getClan() == null)
          activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
        else if (!ClanHallManager.getInstance().isFree(clanhall.getId()))
          activeChar.sendMessage("This ClanHall isn't free!");
        else if (!player.getClan().hasHideout()) {
          ClanHallManager.getInstance().setOwner(clanhall.getId(), player.getClan());
          if (AuctionManager.getInstance().getAuction(clanhall.getId()) != null)
            AuctionManager.getInstance().getAuction(clanhall.getId()).deleteAuctionFromDB();
        } else activeChar.sendMessage("You have already a ClanHall!");
      } else if (command.equalsIgnoreCase("admin_clanhalldel")) {
        if (!ClanHallManager.getInstance().isFree(clanhall.getId())) {
          ClanHallManager.getInstance().setFree(clanhall.getId());
          AuctionManager.getInstance().initNPC(clanhall.getId());
        } else activeChar.sendMessage("This ClanHall is already Free!");
      } else if (command.equalsIgnoreCase("admin_clanhallopendoors")) {
        clanhall.openCloseDoors(true);
      } else if (command.equalsIgnoreCase("admin_clanhallclosedoors")) {
        clanhall.openCloseDoors(false);
      } else if (command.equalsIgnoreCase("admin_clanhallteleportself")) {
        L2ClanHallZone zone = clanhall.getZone();
        if (zone != null) activeChar.teleToLocation(zone.getSpawnLoc(), 0);
      }
      showClanHallPage(activeChar, clanhall);
    }
    return true;
  }