Package lineage2.gameserver.model

Examples of lineage2.gameserver.model.GameObject


    Commands command = (Commands) comm;
    if (!activeChar.getPlayerAccess().CanEditChar)
    {
      return false;
    }
    GameObject target = activeChar.getTarget();
    if ((target == null) || !(target.isPlayer() || target.isPet()))
    {
      activeChar.sendPacket(Msg.INVALID_TARGET);
      return false;
    }
    int level;
View Full Code Here


      {
        activeChar.sendMessage(new CustomMessage("common.TradeBanned", activeChar).addString(Util.formatTime((int) ((Long.parseLong(tradeBan) / 1000L) - (System.currentTimeMillis() / 1000L)))));
      }
      return;
    }
    GameObject target = activeChar.getVisibleObject(_objectId);
    if ((target == null) || !target.isPlayer() || (target == activeChar))
    {
      activeChar.sendPacket(SystemMsg.THAT_IS_AN_INCORRECT_TARGET);
      return;
    }
    if (!activeChar.isInRangeZ(target, Creature.INTERACTION_DISTANCE))
View Full Code Here

      return false;
    }
    try
    {
      String targetName = wordList[1];
      GameObject obj = World.getPlayer(targetName);
      if ((obj != null) && obj.isPlayer())
      {
        obj.onActionSelect(activeChar, false);
      }
      else
      {
        activeChar.sendMessage("Player " + targetName + " not found");
      }
View Full Code Here

   * @param activeChar Player
   * @param player String
   */
  private void handleRes(Player activeChar, String player)
  {
    GameObject obj = activeChar.getTarget();
    if (player != null)
    {
      Player plyr = World.getPlayer(player);
      if (plyr != null)
      {
View Full Code Here

    Commands command = (Commands) comm;
    if (!activeChar.getPlayerAccess().Door)
    {
      return false;
    }
    GameObject target;
    switch (command)
    {
      case admin_open:
        if (wordList.length > 1)
        {
          target = World.getAroundObjectById(activeChar, Integer.parseInt(wordList[1]));
        }
        else
        {
          target = activeChar.getTarget();
        }
        if ((target != null) && target.isDoor())
        {
          ((DoorInstance) target).openMe();
        }
        else
        {
          activeChar.sendPacket(Msg.INVALID_TARGET);
        }
        break;
      case admin_close:
        if (wordList.length > 1)
        {
          target = World.getAroundObjectById(activeChar, Integer.parseInt(wordList[1]));
        }
        else
        {
          target = activeChar.getTarget();
        }
        if ((target != null) && target.isDoor())
        {
          ((DoorInstance) target).closeMe();
        }
        else
        {
View Full Code Here

      if (fullString.startsWith("admin_settitle"))
      {
        try
        {
          String val = fullString.substring(15);
          GameObject target = activeChar.getTarget();
          Player player = null;
          if (target == null)
          {
            return false;
          }
          if (target.isPlayer())
          {
            player = (Player) target;
            player.setTitle(val);
            player.sendMessage("Your title has been changed by a GM");
            player.sendChanges();
          }
          else if (target.isNpc())
          {
            ((NpcInstance) target).setTitle(val);
            target.decayMe();
            target.spawnMe();
          }
          return true;
        }
        catch (StringIndexOutOfBoundsException e)
        {
          activeChar.sendMessage("You need to specify the new title.");
          return false;
        }
      }
      else if (fullString.startsWith("admin_setclass"))
      {
        try
        {
          String val = fullString.substring(15);
          int id = Integer.parseInt(val.trim());
          GameObject target = activeChar.getTarget();
          if ((target == null) || !target.isPlayer())
          {
            target = activeChar;
          }
          if (id > (ClassId.VALUES.length - 1))
          {
            activeChar.sendMessage("There are no classes over " + String.valueOf(ClassId.VALUES.length - 1) + "  id.");
            return false;
          }
          Player player = target.getPlayer();
          player.setClassId(id, true, false);
          player.sendMessage("Your class has been changed by a GM");
          player.broadcastCharInfo();
          return true;
        }
        catch (StringIndexOutOfBoundsException e)
        {
          activeChar.sendMessage("You need to specify the new class id.");
          return false;
        }
      }
      else if (fullString.startsWith("admin_setname"))
      {
        try
        {
          String val = fullString.substring(14);
          GameObject target = activeChar.getTarget();
          Player player;
          if ((target != null) && target.isPlayer())
          {
            player = (Player) target;
          }
          else
          {
            return false;
          }
          if (mysql.simple_get_int("count(*)", "characters", "`char_name` like '" + val + "'") > 0)
          {
            activeChar.sendMessage("Name already exist.");
            return false;
          }
          Log.add("Character " + player.getName() + " renamed to " + val + " by GM " + activeChar.getName(), "renames");
          player.reName(val);
          player.sendMessage("Your name has been changed by a GM");
          return true;
        }
        catch (StringIndexOutOfBoundsException e)
        {
          activeChar.sendMessage("You need to specify the new name.");
          return false;
        }
      }
    }
    if (!activeChar.getPlayerAccess().CanEditChar && !activeChar.getPlayerAccess().CanViewChar)
    {
      return false;
    }
    if (fullString.equals("admin_current_player"))
    {
      showCharacterList(activeChar, null);
    }
    else if (fullString.startsWith("admin_character_list"))
    {
      try
      {
        String val = fullString.substring(21);
        Player target = GameObjectsStorage.getPlayer(val);
        showCharacterList(activeChar, target);
      }
      catch (StringIndexOutOfBoundsException e)
      {
      }
    }
    else if (fullString.startsWith("admin_show_characters"))
    {
      try
      {
        String val = fullString.substring(22);
        int page = Integer.parseInt(val);
        listCharacters(activeChar, page);
      }
      catch (StringIndexOutOfBoundsException e)
      {
      }
    }
    else if (fullString.startsWith("admin_find_character"))
    {
      try
      {
        String val = fullString.substring(21);
        findCharacter(activeChar, val);
      }
      catch (StringIndexOutOfBoundsException e)
      {
        activeChar.sendMessage("You didnt enter a character name to find.");
        listCharacters(activeChar, 0);
      }
    }
    else if (!activeChar.getPlayerAccess().CanEditChar)
    {
      return false;
    }
    else if (fullString.equals("admin_edit_character"))
    {
      editCharacter(activeChar);
    }
    else if (fullString.equals("admin_character_actions"))
    {
      showCharacterActions(activeChar);
    }
    else if (fullString.equals("admin_nokarma"))
    {
      setTargetKarma(activeChar, 0);
    }
    else if (fullString.startsWith("admin_setkarma"))
    {
      try
      {
        String val = fullString.substring(15);
        int karma = Integer.parseInt(val);
        setTargetKarma(activeChar, karma);
      }
      catch (StringIndexOutOfBoundsException e)
      {
        activeChar.sendMessage("Please specify new karma value.");
      }
    }
    else if (fullString.startsWith("admin_save_modifications"))
    {
      try
      {
        String val = fullString.substring(24);
        adminModifyCharacter(activeChar, val);
      }
      catch (StringIndexOutOfBoundsException e)
      {
        activeChar.sendMessage("Error while modifying character.");
        listCharacters(activeChar, 0);
      }
    }
    else if (fullString.equals("admin_rec"))
    {
      GameObject target = activeChar.getTarget();
      Player player = null;
      if ((target != null) && target.isPlayer())
      {
        player = (Player) target;
      }
      else
      {
        return false;
      }
      player.setRecomHave(player.getRecomHave() + 1);
      player.sendMessage("You have been recommended by a GM");
      player.broadcastCharInfo();
    }
    else if (fullString.startsWith("admin_rec"))
    {
      try
      {
        String val = fullString.substring(10);
        int recVal = Integer.parseInt(val);
        GameObject target = activeChar.getTarget();
        Player player = null;
        if ((target != null) && target.isPlayer())
        {
          player = (Player) target;
        }
        else
        {
          return false;
        }
        player.setRecomHave(player.getRecomHave() + recVal);
        player.sendMessage("You have been recommended by a GM");
        player.broadcastCharInfo();
      }
      catch (NumberFormatException e)
      {
        activeChar.sendMessage("Command format is //rec <number>");
      }
    }
    else if (fullString.startsWith("admin_sethero"))
    {
      GameObject target = activeChar.getTarget();
      Player player;
      if ((wordList.length > 1) && (wordList[1] != null))
      {
        player = GameObjectsStorage.getPlayer(wordList[1]);
        if (player == null)
        {
          activeChar.sendMessage("Character " + wordList[1] + " not found in game.");
          return false;
        }
      }
      else if ((target != null) && target.isPlayer())
      {
        player = (Player) target;
      }
      else
      {
        activeChar.sendMessage("You must specify the name or target character.");
        return false;
      }
      if (player.isHero())
      {
        player.setHero(false);
        player.updatePledgeClass();
        player.removeSkill(SkillTable.getInstance().getInfo(395, 1));
        player.removeSkill(SkillTable.getInstance().getInfo(396, 1));
        player.removeSkill(SkillTable.getInstance().getInfo(1374, 1));
        player.removeSkill(SkillTable.getInstance().getInfo(1375, 1));
        player.removeSkill(SkillTable.getInstance().getInfo(1376, 1));
      }
      else
      {
        player.setHero(true);
        player.updatePledgeClass();
        player.addSkill(SkillTable.getInstance().getInfo(395, 1));
        player.addSkill(SkillTable.getInstance().getInfo(396, 1));
        player.addSkill(SkillTable.getInstance().getInfo(1374, 1));
        player.addSkill(SkillTable.getInstance().getInfo(1375, 1));
        player.addSkill(SkillTable.getInstance().getInfo(1376, 1));
      }
      player.sendSkillList();
      player.sendMessage("Admin has changed your hero status.");
      player.broadcastUserInfo();
    }
    else if (fullString.startsWith("admin_setnoble"))
    {
      GameObject target = activeChar.getTarget();
      Player player;
      if ((wordList.length > 1) && (wordList[1] != null))
      {
        player = GameObjectsStorage.getPlayer(wordList[1]);
        if (player == null)
        {
          activeChar.sendMessage("Character " + wordList[1] + " not found in game.");
          return false;
        }
      }
      else if ((target != null) && target.isPlayer())
      {
        player = (Player) target;
      }
      else
      {
        activeChar.sendMessage("You must specify the name or target character.");
        return false;
      }
      if (player.isNoble())
      {
        Olympiad.removeNoble(player);
        player.setNoble(false);
        player.sendMessage("Admin changed your noble status, now you are not nobless.");
      }
      else
      {
        Olympiad.addNoble(player);
        player.setNoble(true);
        player.sendMessage("Admin changed your noble status, now you are Nobless.");
      }
      player.updatePledgeClass();
      player.updateNobleSkills();
      player.sendSkillList();
      player.broadcastUserInfo();
    }
    else if (fullString.startsWith("admin_setsex"))
    {
      GameObject target = activeChar.getTarget();
      Player player = null;
      if ((target != null) && target.isPlayer())
      {
        player = (Player) target;
      }
      else
      {
        return false;
      }
      player.changeSex();
      player.sendMessage("Your gender has been changed by a GM");
      player.broadcastUserInfo();
    }
    else if (fullString.startsWith("admin_setcolor"))
    {
      try
      {
        String val = fullString.substring(15);
        GameObject target = activeChar.getTarget();
        Player player = null;
        if ((target != null) && target.isPlayer())
        {
          player = (Player) target;
        }
        else
        {
          return false;
        }
        player.setNameColor(Integer.decode("0x" + val));
        player.sendMessage("Your name color has been changed by a GM");
        player.broadcastUserInfo();
      }
      catch (StringIndexOutOfBoundsException e)
      {
        activeChar.sendMessage("You need to specify the new color.");
      }
    }
    else if (fullString.startsWith("admin_add_exp_sp_to_character"))
    {
      addExpSp(activeChar);
    }
    else if (fullString.startsWith("admin_add_exp_sp"))
    {
      try
      {
        final String val = fullString.substring(16).trim();
        String[] vals = val.split(" ");
        long exp = NumberUtils.toLong(vals[0], 0L);
        int sp = vals.length > 1 ? NumberUtils.toInt(vals[1], 0) : 0;
        adminAddExpSp(activeChar, exp, sp);
      }
      catch (Exception e)
      {
        activeChar.sendMessage("Usage: //add_exp_sp <exp> <sp>");
      }
    }
    else if (fullString.startsWith("admin_trans"))
    {
      StringTokenizer st = new StringTokenizer(fullString);
      if (st.countTokens() > 1)
      {
        st.nextToken();
        int transformId = 0;
        try
        {
          transformId = Integer.parseInt(st.nextToken());
        }
        catch (Exception e)
        {
          activeChar.sendMessage("Specify a valid integer value.");
          return false;
        }
        if ((transformId != 0) && (activeChar.getTransformation() != 0))
        {
          activeChar.sendPacket(Msg.YOU_ALREADY_POLYMORPHED_AND_CANNOT_POLYMORPH_AGAIN);
          return false;
        }
        activeChar.setTransformation(transformId);
        activeChar.sendMessage("Transforming...");
      }
      else
      {
        activeChar.sendMessage("Usage: //trans <ID>");
      }
    }
    else if (fullString.startsWith("admin_setsubclass"))
    {
      final GameObject target = activeChar.getTarget();
      if ((target == null) || !target.isPlayer())
      {
        activeChar.sendPacket(Msg.SELECT_TARGET);
        return false;
      }
      final Player player = (Player) target;
      StringTokenizer st = new StringTokenizer(fullString);
      if (st.countTokens() > 1)
      {
        st.nextToken();
        int classId = Short.parseShort(st.nextToken());
        if (!player.addSubClass(classId, true, 0, 0, false, 0))
        {
          activeChar.sendMessage(new CustomMessage("lineage2.gameserver.model.instances.L2VillageMasterInstance.SubclassCouldNotBeAdded", activeChar));
          return false;
        }
        player.sendPacket(Msg.CONGRATULATIONS_YOU_HAVE_TRANSFERRED_TO_A_NEW_CLASS);
      }
      else
      {
        setSubclass(activeChar, player);
      }
    }
    else if (fullString.startsWith("admin_setfame"))
    {
      try
      {
        String val = fullString.substring(14);
        int fame = Integer.parseInt(val);
        setTargetFame(activeChar, fame);
      }
      catch (StringIndexOutOfBoundsException e)
      {
        activeChar.sendMessage("Please specify new fame value.");
      }
    }
    else if (fullString.startsWith("admin_setbday"))
    {
      String msgUsage = "Usage: //setbday YYYY-MM-DD";
      String date = fullString.substring(14);
      if ((date.length() != 10) || !Util.isMatchingRegexp(date, "[0-9]{4}-[0-9]{2}-[0-9]{2}"))
      {
        activeChar.sendMessage(msgUsage);
        return false;
      }
      SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
      try
      {
        dateFormat.parse(date);
      }
      catch (ParseException e)
      {
        activeChar.sendMessage(msgUsage);
      }
      if ((activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer())
      {
        activeChar.sendMessage("Please select a character.");
        return false;
      }
      if (!mysql.set("update characters set createtime = UNIX_TIMESTAMP('" + date + "') where obj_Id = " + activeChar.getTarget().getObjectId()))
      {
        activeChar.sendMessage(msgUsage);
        return false;
      }
      activeChar.sendMessage("New Birthday for " + activeChar.getTarget().getName() + ": " + date);
      activeChar.getTarget().getPlayer().sendMessage("Admin changed your birthday to: " + date);
    }
    else if (fullString.startsWith("admin_give_item"))
    {
      if (wordList.length < 3)
      {
        activeChar.sendMessage("Usage: //give_item id count <target>");
        return false;
      }
      int id = Integer.parseInt(wordList[1]);
      int count = Integer.parseInt(wordList[2]);
      if ((id < 1) || (count < 1) || (activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer())
      {
        activeChar.sendMessage("Usage: //give_item id count <target>");
        return false;
      }
      ItemFunctions.addItem(activeChar.getTarget().getPlayer(), id, count, true);
    }
    else if (fullString.startsWith("admin_add_bang"))
    {
      if (!Config.ALT_PCBANG_POINTS_ENABLED)
      {
        activeChar.sendMessage("Error! Pc Bang Points service disabled!");
        return true;
      }
      if (wordList.length < 1)
      {
        activeChar.sendMessage("Usage: //add_bang count <target>");
        return false;
      }
      int count = Integer.parseInt(wordList[1]);
      if ((count < 1) || (activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer())
      {
        activeChar.sendMessage("Usage: //add_bang count <target>");
        return false;
      }
      Player target = activeChar.getTarget().getPlayer();
      target.addPcBangPoints(count, false);
      activeChar.sendMessage("You have added " + count + " Pc Bang Points to " + target.getName());
    }
    else if (fullString.startsWith("admin_set_bang"))
    {
      if (!Config.ALT_PCBANG_POINTS_ENABLED)
      {
        activeChar.sendMessage("Error! Pc Bang Points service disabled!");
        return true;
      }
      if (wordList.length < 1)
      {
        activeChar.sendMessage("Usage: //set_bang count <target>");
        return false;
      }
      int count = Integer.parseInt(wordList[1]);
      if ((count < 1) || (activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer())
      {
        activeChar.sendMessage("Usage: //set_bang count <target>");
        return false;
      }
      Player target = activeChar.getTarget().getPlayer();
      target.setPcBangPoints(count);
      target.sendMessage("Your Pc Bang Points count is now " + count);
      target.sendPacket(new ExPCCafePointInfo(target, count, 1, 2, 12));
      activeChar.sendMessage("You have set " + target.getName() + "'s Pc Bang Points to " + count);
    }
    else if (fullString.startsWith("admin_reset_mentor_penalty"))
    {
      if (activeChar.getTarget().getPlayer() == null)
      {
View Full Code Here

   * @return boolean
   */
  @Override
  protected boolean useItemImpl(Player player, ItemInstance item, boolean ctrl)
  {
    final GameObject target = player.getTarget();
    if ((target == null) || !(target instanceof HellboundRemnantInstance))
    {
      player.sendPacket(SystemMsg.THAT_IS_AN_INCORRECT_TARGET);
      return false;
    }
View Full Code Here

   */
  public static void showCharacterList(Player activeChar, Player player)
  {
    if (player == null)
    {
      GameObject target = activeChar.getTarget();
      if ((target != null) && target.isPlayer())
      {
        player = (Player) target;
      }
      else
      {
View Full Code Here

   * @param activeChar Player
   * @param newKarma int
   */
  private void setTargetKarma(Player activeChar, int newKarma)
  {
    GameObject target = activeChar.getTarget();
    if (target == null)
    {
      activeChar.sendPacket(Msg.INVALID_TARGET);
      return;
    }
    Player player;
    if (target.isPlayer())
    {
      player = (Player) target;
    }
    else
    {
View Full Code Here

   * @param activeChar Player
   * @param newFame int
   */
  private void setTargetFame(Player activeChar, int newFame)
  {
    GameObject target = activeChar.getTarget();
    if (target == null)
    {
      activeChar.sendPacket(Msg.INVALID_TARGET);
      return;
    }
    Player player;
    if (target.isPlayer())
    {
      player = (Player) target;
    }
    else
    {
View Full Code Here

TOP

Related Classes of lineage2.gameserver.model.GameObject

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.