Package com.l2jfrozen.gameserver.model.actor.instance

Examples of com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance


  }

  @Override
  protected void runImpl()
  {
     L2PcInstance activeChar = getClient().getActiveChar();
       if (activeChar == null)
       return;
                
       L2PcInstance player = L2World.getInstance().getPlayer(_partyLeaderId);
       if (player != null && player.getParty() != null)
       activeChar.sendPacket(new ExMPCCShowPartyMemberInfo(player.getParty()));
  }
View Full Code Here


  }

  @Override
  protected void runImpl()
  {
    L2PcInstance activeChar = getClient().getActiveChar();

    if(activeChar == null)
      return;

    if (!getClient().getFloodProtectors().getServerBypass().tryPerformAction(_command))
      return;
   

    try
    {
      if(_command.startsWith("admin_"))
      {
        // DaDummy: this way we log _every_ admincommand with all related info
        String command;

        if(_command.indexOf(" ") != -1)
        {
          command = _command.substring(0, _command.indexOf(" "));
        }
        else
        {
          command = _command;
        }

        IAdminCommandHandler ach = AdminCommandHandler.getInstance().getAdminCommandHandler(command);

        if(ach == null)
        {
          if(activeChar.isGM())
          {
            activeChar.sendMessage("The command " + command + " does not exists!");
          }

          _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 right to use this command!");
          if(Config.DEBUG)
          {
            _log.warning("Character " + activeChar.getName() + " tried to use admin command " + command + ", but doesn't have access to it!");
          }
          return;
        }

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

        ach.useAdminCommand(_command, activeChar);
      }
      else if(_command.equals("come_here") && activeChar.isGM())
      {
        comeHere(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
        {
          L2Object object = L2World.getInstance().findObject(Integer.parseInt(id));

          if(_command.substring(endOfId + 1).startsWith("event_participate"))
          {
            L2Event.inscribePlayer(activeChar);
          }
          else if(_command.substring(endOfId + 1).startsWith("tvt_player_join "))
          {
            String teamName = _command.substring(endOfId + 1).substring(16);

            if(TvT.is_joining())
            {
              TvT.addPlayer(activeChar, teamName);
            }
            else
            {
              activeChar.sendMessage("The event is already started. You can not join now!");
            }
          }

          else if(_command.substring(endOfId + 1).startsWith("tvt_player_leave"))
          {
            if(TvT.is_joining())
            {
              TvT.removePlayer(activeChar);
            }
            else
            {
              activeChar.sendMessage("The event is already started. You can not leave now!");
            }
          }

          else if(_command.substring(endOfId+1).startsWith("dmevent_player_join"))
          {
            if(DM.is_joining())
              DM.addPlayer(activeChar);
            else
              activeChar.sendMessage("The event is already started. You can't join now!");
          }

          else if(_command.substring(endOfId+1).startsWith("dmevent_player_leave"))
          {
            if(DM.is_joining())
              DM.removePlayer(activeChar);
            else
              activeChar.sendMessage("The event is already started. You can't leave now!");
          }
         
          else if (_command.substring(endOfId+1).startsWith("raid_player_join"))
          {
            if (Raid._joining)
              Raid.addPlayer(activeChar);
            else
              activeChar.sendMessage("The event has already started. You cant join now!");
          }
         
          else if (_command.substring(endOfId+1).startsWith("raid_player_leave"))
          {
            if (Raid._joining)
              Raid.removePlayer(activeChar);
            else
              activeChar.sendMessage("The event has already started. You cant leave now!");
          }

          else if(_command.substring(endOfId+1).startsWith("ctf_player_join "))
          {
            String teamName = _command.substring(endOfId+1).substring(16);
            if(CTF.is_joining())
              CTF.addPlayer(activeChar, teamName);
            else
              activeChar.sendMessage("The event is already started. You can't join now!");
          }

          else if(_command.substring(endOfId+1).startsWith("ctf_player_leave"))
          {
            if(CTF.is_joining())
              CTF.removePlayer(activeChar);
            else
              activeChar.sendMessage("The event is already started. You can't leave now!");
          }

          if(_command.substring(endOfId+1).startsWith("vip_joinVIPTeam"))
          {
              VIP.addPlayerVIP(activeChar);
          }

          if(_command.substring(endOfId+1).startsWith("vip_joinNotVIPTeam"))
          {
              VIP.addPlayerNotVIP(activeChar);
          }

          if(_command.substring(endOfId+1).startsWith("vip_finishVIP"))
          {
              VIP.vipWin(activeChar);
          }

          if(_command.substring(endOfId+1).startsWith("event_participate"))
          {
            L2Event.inscribePlayer(activeChar);
          }

          else if((Config.ALLOW_CLASS_MASTERS && Config.ALLOW_REMOTE_CLASS_MASTERS && object instanceof L2ClassMasterInstance)
            || (object instanceof L2NpcInstance && endOfId > 0 && activeChar.isInsideRadius(object, L2NpcInstance.INTERACTION_DISTANCE, false, false)))
          {
            ((L2NpcInstance) object).onBypassFeedback(activeChar, _command.substring(endOfId + 1));
          }

          activeChar.sendPacket(ActionFailed.STATIC_PACKET);
        }
        catch(NumberFormatException nfe)
        {
          if(Config.ENABLE_ALL_EXCEPTIONS)
            nfe.printStackTrace();
         
        }
      }
      //  Draw a Symbol
      else if(_command.equals("Draw"))
      {
        L2Object object = activeChar.getTarget();
        if(object instanceof L2NpcInstance)
        {
          ((L2SymbolMakerInstance) object).onBypassFeedback(activeChar, _command);
        }
      }
      else if(_command.equals("RemoveList"))
      {
        L2Object object = activeChar.getTarget();
        if(object instanceof L2NpcInstance)
        {
          ((L2SymbolMakerInstance) object).onBypassFeedback(activeChar, _command);
        }
      }
      else if(_command.equals("Remove "))
      {
        L2Object object = activeChar.getTarget();

        if(object instanceof L2NpcInstance)
        {
          ((L2SymbolMakerInstance) object).onBypassFeedback(activeChar, _command);
        }
      }
      // Navigate throught Manor windows
      else if(_command.startsWith("manor_menu_select?"))
      {
        L2Object object = activeChar.getTarget();
        if(object instanceof L2NpcInstance)
        {
          ((L2NpcInstance) object).onBypassFeedback(activeChar, _command);
        }
      }
      else if(_command.startsWith("bbs_"))
      {
        CommunityBoard.getInstance().handleCommands(getClient(), _command);
      }
      else if(_command.startsWith("_bbs"))
      {
        CommunityBoard.getInstance().handleCommands(getClient(), _command);
      }
      else if(_command.startsWith("RPS.")) // Rank PvP System by Masterio
      {
        RankPvpSystemBypass.execute(activeChar, _command);
      }
      else if (_command.startsWith("voiced_"))
      {
      String command = _command.split(" ")[0];

      IVoicedCommandHandler ach = VoicedCommandHandler.getInstance().getVoicedCommandHandler(_command.substring(7));

      if (ach == null)
      {
      activeChar.sendMessage("The command " + command.substring(7) + " does not exist!");

      _log.info("No handler registered for command '" + _command + "'");
      return;
      }
        }
      else if (_command.startsWith("voice "))
      {
         //only voice commands allowed in bypass
        if (_command.length() > 7
            && _command.charAt(6) == '.')
        {
          final String vc, vparams;
          final int endOfCommand = _command.indexOf(" ", 7);
          if (endOfCommand > 0)
          {
            vc = _command.substring(7, endOfCommand).trim();
            vparams = _command.substring(endOfCommand).trim();
          }
          else
          {
            vc = _command.substring(7).trim();
            vparams = null;
          }
          if (vc.length() > 0)
          {
            final IVoicedCommandHandler vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(vc);
            if (vch != null)
              vch.useVoicedCommand(vc, activeChar, vparams);
          }
        }
      }
      else if(_command.startsWith("Quest "))
      {
        if(!activeChar.validateBypass(_command))
          return;

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

        String p = _command.substring(6).trim();
        int idx = p.indexOf(' ');

        if(idx < 0)
        {
          player.processQuestEvent(p, "");
        }
        else
        {
          player.processQuestEvent(p.substring(0, idx), p.substring(idx).trim());
        }
      }

      // Jstar's Custom Bypass Caller!
      else if(_command.startsWith("custom_"))
      {
        L2PcInstance player = getClient().getActiveChar();
        CustomBypassHandler.getInstance().handleBypass(player, _command);
      }
      else if (_command.startsWith("OlympiadArenaChange"))
      {
        Olympiad.bypassChangeArena(_command, activeChar);
View Full Code Here

    else if(command.equals("admin_remove_all_skills"))
    {
      if(activeChar.getTarget() instanceof L2PcInstance)
      {
        L2PcInstance player = (L2PcInstance) activeChar.getTarget();

        for(L2Skill skill : player.getAllSkills())
        {
          player.removeSkill(skill);
        }

        activeChar.sendMessage("You removed all skills from " + player.getName());
        player.sendMessage("Admin removed all skills from you.");
        player.sendSkillList();
        player = null;
      }
    }
    else if(command.startsWith("admin_add_clan_skill"))
    {
View Full Code Here

   * @param activeChar the gm char
   */
  private void adminGiveAllSkills(L2PcInstance activeChar)
  {
    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;

    if(target instanceof L2PcInstance)
    {
      player = (L2PcInstance) target;
    }
    else
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
      return;
    }

    boolean countUnlearnable = true;
    int unLearnable = 0;
    int skillCounter = 0;

    L2SkillLearn[] skills = SkillTreeTable.getInstance().getAvailableSkills(player, player.getClassId());

    while(skills.length > unLearnable)
    {
      for(L2SkillLearn s : skills)
      {
        L2Skill sk = SkillTable.getInstance().getInfo(s.getId(), s.getLevel());

        if(sk == null || !sk.getCanLearn(player.getClassId()))
        {
          if(countUnlearnable)
          {
            unLearnable++;
          }

          continue;
        }

        if(player.getSkillLevel(sk.getId()) == -1)
        {
          skillCounter++;
        }

        player.addSkill(sk, true);

        sk = null;
      }

      countUnlearnable = false;
      skills = SkillTreeTable.getInstance().getAvailableSkills(player, player.getClassId());
    }

    //Notify player and admin
    player.sendMessage("A GM gave you " + skillCounter + " skills.");
    activeChar.sendMessage("You gave " + skillCounter + " skills to " + player.getName());
    player.sendSkillList();

    skills = null;
    player = null;
    target = null;
  }
View Full Code Here

  private void removeSkillsPage(L2PcInstance activeChar, int page)
  {
    //TODO: Externalize HTML
    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;

    if(target instanceof L2PcInstance)
    {
      player = (L2PcInstance) target;
    }
    else
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
      return;
    }

    L2Skill[] skills = player.getAllSkills();

    int MaxSkillsPerPage = 10;
    int MaxPages = skills.length / MaxSkillsPerPage;

    if(skills.length > MaxSkillsPerPage * MaxPages)
    {
      MaxPages++;
    }

    if(page > MaxPages)
    {
      page = MaxPages;
    }

    int SkillsStart = MaxSkillsPerPage * page;
    int SkillsEnd = skills.length;

    if(SkillsEnd - SkillsStart > MaxSkillsPerPage)
    {
      SkillsEnd = SkillsStart + MaxSkillsPerPage;
    }

    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    TextBuilder replyMSG = new TextBuilder("<html><body>");
    replyMSG.append("<table width=260><tr>");
    replyMSG.append("<td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
    replyMSG.append("<td width=180><center>Character Selection Menu</center></td>");
    replyMSG.append("<td width=40><button value=\"Back\" action=\"bypass -h admin_show_skills\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
    replyMSG.append("</tr></table>");
    replyMSG.append("<br><br>");
    replyMSG.append("<center>Editing <font color=\"LEVEL\">" + player.getName() + "</font></center>");
    replyMSG.append("<br><table width=270><tr><td>Lv: " + player.getLevel() + " " + player.getTemplate().className + "</td></tr></table>");
    replyMSG.append("<br><table width=270><tr><td>Note: Dont forget that modifying players skills can</td></tr>");
    replyMSG.append("<tr><td>ruin the game...</td></tr></table>");
    replyMSG.append("<br><center>Click on the skill you wish to remove:</center>");
    replyMSG.append("<br>");
    String pages = "<center><table width=270><tr>";
View Full Code Here

  }
 
  @Override
  protected void runImpl()
  {
    L2PcInstance player = getClient().getActiveChar();
    if (player != null)
    {
      L2PcInstance requestor = player.getActiveRequester();
      if (requestor == null)
        return;
     
      if (_response == 1)
      {
        Connection con = null;
        try
        {
          con = L2DatabaseFactory.getInstance().getConnection(false);
          PreparedStatement statement = con.prepareStatement("INSERT INTO character_friends (char_id, friend_id, friend_name, not_blocked) VALUES (?, ?, ?, ?), (?, ?, ?,?)");
          statement.setInt(1, requestor.getObjectId());
          statement.setInt(2, player.getObjectId());
          statement.setString(3, player.getName());
          statement.setInt(4, 1);
          statement.setInt(5, player.getObjectId());
          statement.setInt(6, requestor.getObjectId());
          statement.setString(7, requestor.getName());
          statement.setInt(8, 1);
          statement.execute();
          statement.close();
          SystemMessage msg = new SystemMessage(SystemMessageId.YOU_HAVE_SUCCEEDED_INVITING_FRIEND);
          requestor.sendPacket(msg);
         
          // Player added to your friendlist
          msg = new SystemMessage(SystemMessageId.S1_ADDED_TO_FRIENDS);
          msg.addString(player.getName());
          requestor.sendPacket(msg);
          requestor.getFriendList().add(player.getName());
         
          // has joined as friend.
          msg = new SystemMessage(SystemMessageId.S1_JOINED_AS_FRIEND);
          msg.addString(requestor.getName());
          player.sendPacket(msg);
          player.getFriendList().add(requestor.getName());
         
          msg = null;
         
          // friend list rework ;)
          notifyFriends(player);
          notifyFriends(requestor);
          player.sendPacket(new FriendList(player));
          requestor.sendPacket(new FriendList(requestor));
        }
        catch (Exception e)
        {
          if (Config.ENABLE_ALL_EXCEPTIONS)
            e.printStackTrace();
         
          _log.warning("could not add friend objectid: " + e);
        }
        finally
        {
          CloseUtil.close(con);
          con = null;
        }
      }
      else
      {
        SystemMessage msg = new SystemMessage(SystemMessageId.FAILED_TO_INVITE_A_FRIEND);
        requestor.sendPacket(msg);
      }
     
      player.setActiveRequester(null);
      requestor.onTransactionResponse();
    }
  }
View Full Code Here

  }

  private void showMainPage(L2PcInstance activeChar)
  {
    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;

    if(target instanceof L2PcInstance)
    {
      player = (L2PcInstance) target;
    }
    else
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
      return;
    }

    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    adminReply.setFile("data/html/admin/charskills.htm");
    adminReply.replace("%name%", player.getName());
    adminReply.replace("%level%", String.valueOf(player.getLevel()));
    adminReply.replace("%class%", player.getTemplate().className);
    activeChar.sendPacket(adminReply);

    adminReply = null;
    player = null;
    target = null;
View Full Code Here

  }

  private void adminGetSkills(L2PcInstance activeChar)
  {
    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;

    if(target instanceof L2PcInstance)
    {
      player = (L2PcInstance) target;
    }
    else
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
      return;
    }

    if(player.getName().equals(activeChar.getName()))
    {
      player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_ON_YOURSELF));
    }
    else
    {
      L2Skill[] skills = player.getAllSkills();
      adminSkills = activeChar.getAllSkills();

      for(L2Skill adminSkill : adminSkills)
      {
        activeChar.removeSkill(adminSkill);
      }

      for(L2Skill skill : skills)
      {
        activeChar.addSkill(skill, true);
      }

      activeChar.sendMessage("You now have all the skills of " + player.getName() + ".");
      activeChar.sendSkillList();

      skills = null;
    }
View Full Code Here

  }

  private void adminResetSkills(L2PcInstance activeChar)
  {
    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;

    if(target instanceof L2PcInstance)
    {
      player = (L2PcInstance) target;
    }
    else
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
      return;
    }

    if(adminSkills == null)
    {
      activeChar.sendMessage("You must get the skills of someone in order to do this.");
    }
    else
    {
      L2Skill[] skills = player.getAllSkills();

      for(L2Skill skill : skills)
      {
        player.removeSkill(skill);
      }

      for(int i = 0; i < activeChar.getAllSkills().length; i++)
      {
        player.addSkill(activeChar.getAllSkills()[i], true);
      }

      for(L2Skill skill : skills)
      {
        activeChar.removeSkill(skill);
      }

      for(L2Skill adminSkill : adminSkills)
      {
        activeChar.addSkill(adminSkill, true);
      }

      player.sendMessage("[GM]" + activeChar.getName() + " updated your skills.");
      activeChar.sendMessage("You now have all your skills back.");
      adminSkills = null;
      activeChar.sendSkillList();

      skills = null;
View Full Code Here

      con = L2DatabaseFactory.getInstance().getConnection(false);
      PreparedStatement statement;
      statement = con.prepareStatement("SELECT friend_name FROM character_friends WHERE char_id=? AND not_blocked = 1 ");
      statement.setInt(1, cha.getObjectId());
      ResultSet rset = statement.executeQuery();
      L2PcInstance friend;
      String friendName;
     
      while (rset.next())
      {
        friendName = rset.getString("friend_name");
        friend = L2World.getInstance().getPlayer(friendName);
       
        if (friend != null) // friend loggined.
        {
          friend.sendPacket(new FriendList(friend));
        }
      }
     
      rset.close();
      statement.close();
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.