Esempio n. 1
0
  @Override
  public void executeCommand(Player admin, String[] params) {
    if (admin.getAccessLevel() < AdminConfig.COMMAND_APPLY_PRESET) {
      PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
      return;
    }

    if (params.length == 0 || params.length > 1) {
      PacketSendUtility.sendMessage(admin, "syntax //preset <name>");
      return;
    }

    VisibleObject target = admin.getTarget();
    Player player = null;

    if (target == null) player = admin;
    else if (!(target instanceof Player)) {
      PacketSendUtility.sendMessage(admin, "Presets can be applied only on players!");
      return;
    } else {
      player = (Player) target;
    }

    String presetName = params[0];

    PresetTemplate template = DataManager.CUSTOM_PRESET_DATA.getPresetTemplate(presetName);
    if (template == null) {
      PacketSendUtility.sendMessage(admin, "No such preset!");
      return;
    }
    if (template.getGender().ordinal() != player.getCommonData().getGender().ordinal()
        || template.getRace().ordinal() != player.getCommonData().getRace().ordinal()) {
      PacketSendUtility.sendMessage(admin, "Preset can not be applied on current gender or race!");
      return;
    }

    PlayerAppearance.loadDetails(player.getPlayerAppearance(), template.getDetail());
    if (template.getFaceType() > 0) player.getPlayerAppearance().setFace(template.getFaceType());
    if (template.getHairType() > 0) player.getPlayerAppearance().setHair(template.getHairType());
    if (template.getHairRGB() != null)
      player.getPlayerAppearance().setHairRGB(getDyeColor(template.getHairRGB()));
    if (template.getLipsRGB() != null)
      player.getPlayerAppearance().setLipRGB(getDyeColor(template.getLipsRGB()));
    if (template.getSkinRGB() != null)
      player.getPlayerAppearance().setSkinRGB(getDyeColor(template.getSkinRGB()));
    if (template.getHeight() > 0) player.getPlayerAppearance().setHeight(template.getHeight());

    DAOManager.getDAO(PlayerAppearanceDAO.class).store(player);

    player.clearKnownlist();
    PacketSendUtility.sendPacket(player, new SM_PLAYER_INFO(player, false));
    player.updateKnownlist();
  }
 @Override
 public boolean onDialogEvent(QuestCookie env) {
   final Player player = env.getPlayer();
   int targetId = 0;
   if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
   final QuestState qs = player.getQuestStateList().getQuestState(questId);
   QuestTemplate template = questsData.getQuestById(questId);
   if (targetId == 278639) {
     if (qs == null || qs.getStatus() == QuestStatus.NONE) {
       if (env.getDialogId() == 2) {
         PlayerClass playerClass = player.getCommonData().getPlayerClass();
         PlayerClass startPC = null;
         try {
           startPC = PlayerClass.getStartingClassFor(playerClass);
         } catch (IllegalArgumentException e) {
           startPC = playerClass; // already a start class
         }
         if (startPC == PlayerClass.MAGE || startPC == PlayerClass.PRIEST) {
           QuestService.startQuest(env, QuestStatus.START);
           return sendQuestDialog(env, 1011);
         } else {
           return sendQuestDialog(env, 3739);
         }
       }
     } else if (qs != null && qs.getStatus() == QuestStatus.START) {
       if (env.getDialogId() == 2) {
         return sendQuestDialog(env, 1011);
       } else if (env.getDialogId() == 1011) {
         if (player.getInventory().getItemCountByItemId(186000003) >= 16) {
           qs.setQuestVarById(0, 0);
           qs.setStatus(QuestStatus.REWARD);
           updateQuestStatus(env);
           return sendQuestDialog(env, 5);
         } else {
           return sendQuestDialog(env, 1009);
         }
       } else if (env.getDialogId() == 1352) {
         if (player.getInventory().getItemCountByItemId(186000003) >= 32) {
           qs.setQuestVarById(0, 1);
           qs.setStatus(QuestStatus.REWARD);
           updateQuestStatus(env);
           return sendQuestDialog(env, 6);
         } else {
           return sendQuestDialog(env, 1009);
         }
       }
     } else if (qs.getStatus() == QuestStatus.COMPLETE) {
       if (env.getDialogId() == 2) {
         if ((qs.getCompleteCount() <= template.getMaxRepeatCount())) {
           QuestService.startQuest(env, QuestStatus.START);
           return sendQuestDialog(env, 1011);
         } else return sendQuestDialog(env, 1008);
       }
     } else if (qs != null && qs.getStatus() == QuestStatus.REWARD) {
       return defaultQuestEndDialog(env, qs.getQuestVarById(0));
     }
   }
   return false;
 }
 @Override
 public boolean onLvlUpEvent(QuestCookie env) {
   Player player = env.getPlayer();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   boolean lvlCheck =
       QuestService.checkLevelRequirement(questId, player.getCommonData().getLevel());
   if (qs != null || !lvlCheck) return false;
   QuestService.startQuest(env, QuestStatus.START);
   return true;
 }
Esempio n. 4
0
  private void writeImplTitleList(ByteBuffer buf) {
    Player player = titleList.getOwner();
    TitleService.removeExpiredTitles(player);

    if (GSConfig.SERVER_VERSION.startsWith("2.")) writeH(buf, 0); // unk
    else writeC(buf, 0); // unk

    writeH(buf, titleList.size());

    for (final Title title : titleList.getTitles()) {
      writeD(buf, title.getTitleId());
      writeD(buf, (int) title.getTitleTimeLeft());
    }

    if (player.getCommonData().getTitleId() > 0) {
      if (titleList.canAddTitle(player.getCommonData().getTitleId())) {
        player.getCommonData().setTitleId(0);
        PacketSendUtility.sendMessage(player, "The usage time of title has expired.");
      }
    }
  }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    int removeItem = 0;
    Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    int var = 0;

    if (qs != null) var = qs.getQuestVarById(0);

    if (qs == null
        || qs.getStatus() == QuestStatus.NONE
        || qs.getStatus() == QuestStatus.COMPLETE) {
      if (env.getTargetId() == 278645) {
        switch (env.getDialogId()) {
          case 26:
            if (QuestService.checkLevelRequirement(questId, player.getCommonData().getLevel()))
              return sendQuestDialog(env, 1011);
            else return sendQuestDialog(env, 3398);
          case 1011:
          case 1352:
          case 1693:
          case 2034:
            int i = 0;
            for (int id : Items[0]) {
              if (id == env.getDialogId()) break;
              i++;
            }
            removeItem = Items[1][i];
            var = i;

            if (player.getInventory().getItemCountByItemId(removeItem) > 0) {
              if (qs == null) {
                qs = new QuestState(questId, QuestStatus.REWARD, 0, 0);
                player.getQuestStateList().addQuest(questId, qs);
              } else qs.setStatus(QuestStatus.REWARD);
              qs.setQuestVar(var);
              defaultQuestRemoveItem(env, removeItem, 1);
              return sendQuestDialog(env, var + 5);
            } else return sendQuestDialog(env, 1009);
        }
      }
    }

    if (qs == null) return false;

    return defaultQuestRewardDialog(env, 278645, 0, var);
  }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    final Player player = env.getPlayer();
    if (player.getLevel() <= 46) return false;
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    QuestTemplate template = questsData.getQuestById(questId);

    if (targetId == 798174) {
      if (qs == null || qs.getStatus() == QuestStatus.NONE) {
        if (env.getDialogId() == 2) {
          PlayerClass playerClass = player.getCommonData().getPlayerClass();
          if (playerClass == PlayerClass.MAGE
              || playerClass == PlayerClass.SORCERER
              || playerClass == PlayerClass.SPIRIT_MASTER) {
            QuestService.startQuest(env, QuestStatus.START);
            return sendQuestDialog(env, 1011);
          } else {
            return sendQuestDialog(env, 3739);
          }
        }
      } else if (qs != null && qs.getStatus() == QuestStatus.START) {
        if (env.getDialogId() == 2) {
          return sendQuestDialog(env, 1011);
        } else if (env.getDialogId() == 10000) {
          if (player.getInventory().getItemCountByItemId(186000005) >= 2000) {
            qs.setQuestVarById(1, 0);
            player.getInventory().removeFromBagByItemId(186000005, 2000);
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            return sendQuestDialog(env, 5);
          } else {
            return sendQuestDialog(env, 1009);
          }
        } else if (env.getDialogId() == 10001) {
          if (player.getInventory().getItemCountByItemId(186000005) >= 400) {
            qs.setQuestVarById(1, 1);
            player.getInventory().removeFromBagByItemId(186000005, 400);
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            return sendQuestDialog(env, 6);
          } else {
            return sendQuestDialog(env, 1009);
          }
        } else if (env.getDialogId() == 10002) {
          if (player.getInventory().getItemCountByItemId(186000005) >= 1000) {
            qs.setQuestVarById(1, 2);
            player.getInventory().removeFromBagByItemId(186000005, 1000);
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            return sendQuestDialog(env, 7);
          } else {
            return sendQuestDialog(env, 1009);
          }
        } else if (env.getDialogId() == 10003) {
          if (player.getInventory().getItemCountByItemId(186000005) >= 200) {
            qs.setQuestVarById(1, 3);
            player.getInventory().removeFromBagByItemId(186000005, 200);
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            return sendQuestDialog(env, 8);
          } else {
            return sendQuestDialog(env, 1009);
          }
        }
      } else if (qs.getStatus() == QuestStatus.COMPLETE) {
        if (env.getDialogId() == 2) {
          if ((qs.getCompleteCount() <= template.getMaxRepeatCount())) {
            QuestService.startQuest(env, QuestStatus.START);
            return sendQuestDialog(env, 1011);
          } else return sendQuestDialog(env, 1008);
        }
      } else if (qs != null && qs.getStatus() == QuestStatus.REWARD) {
        return defaultQuestEndDialog(env, qs.getQuestVarById(1));
      }
    }
    return false;
  }
 @Override
 public boolean onDialogEvent(QuestCookie env) {
   final Player player = env.getPlayer();
   final QuestState qs = player.getQuestStateList().getQuestState(questId);
   int targetId = 0;
   if (player.getCommonData().getLevel() < 21) return false;
   if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
   if (targetId == 798125) {
     if (qs == null || qs.getStatus() == QuestStatus.NONE) {
       if (env.getDialogId() == 26) return sendQuestDialog(env, 1011);
       else return defaultQuestStartDialog(env);
     } else if (qs.getStatus() == QuestStatus.START) {
       long itemCount;
       long itemCount1;
       long itemCount2;
       if (env.getDialogId() == 26 && qs.getQuestVarById(0) == 0) {
         return sendQuestDialog(env, 2375);
       } else if (env.getDialogId() == 34 && qs.getQuestVarById(0) == 0) {
         itemCount = player.getInventory().getItemCountByItemId(182204227);
         itemCount1 = player.getInventory().getItemCountByItemId(182204228);
         itemCount2 = player.getInventory().getItemCountByItemId(182204229);
         if (itemCount > 4 && itemCount1 > 4 && itemCount2 > 4) {
           player.getInventory().removeFromBagByItemId(182204227, 5);
           player.getInventory().removeFromBagByItemId(182204228, 5);
           player.getInventory().removeFromBagByItemId(182204229, 5);
           qs.setStatus(QuestStatus.REWARD);
           updateQuestStatus(env);
           return sendQuestDialog(env, 5);
         } else {
           return sendQuestDialog(env, 2716);
         }
       } else return defaultQuestEndDialog(env);
     } else if (qs.getStatus() == QuestStatus.REWARD) {
       if (env.getDialogId() == 26 && qs.getQuestVarById(0) == 5) {
         return sendQuestDialog(env, 5);
       } else if (env.getDialogId() == 26 && qs.getQuestVarById(0) == 6) {
         return sendQuestDialog(env, 6);
       } else if (env.getDialogId() == 26 && qs.getQuestVarById(0) == 7) {
         return sendQuestDialog(env, 7);
       } else {
         return defaultQuestEndDialog(env);
       }
     } else {
       return defaultQuestEndDialog(env);
     }
   } else if (targetId == 700317) {
     long itemCount;
     itemCount = player.getInventory().getItemCountByItemId(182204227);
     if (qs != null
         && qs.getStatus() == QuestStatus.START
         && qs.getQuestVarById(0) == 0
         && itemCount < 5) {
       final int targetObjectId = env.getVisibleObject().getObjectId();
       PacketSendUtility.broadcastPacket(
           player, new SM_EMOTION(player, EmotionType.NEUTRALMODE2, 0, targetObjectId), true);
       ThreadPoolManager.getInstance()
           .schedule(
               new Runnable() {
                 @Override
                 public void run() {
                   PacketSendUtility.broadcastPacket(
                       player,
                       new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId),
                       true);
                 }
               },
               3000);
       return true;
     } else {
       return defaultQuestEndDialog(env);
     }
   } else if (targetId == 700318) {
     long itemCount1;
     itemCount1 = player.getInventory().getItemCountByItemId(182204228);
     if (qs != null
         && qs.getStatus() == QuestStatus.START
         && qs.getQuestVarById(0) == 0
         && itemCount1 < 5) {
       final int targetObjectId = env.getVisibleObject().getObjectId();
       PacketSendUtility.broadcastPacket(
           player, new SM_EMOTION(player, EmotionType.NEUTRALMODE2, 0, targetObjectId), true);
       ThreadPoolManager.getInstance()
           .schedule(
               new Runnable() {
                 @Override
                 public void run() {
                   PacketSendUtility.broadcastPacket(
                       player,
                       new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId),
                       true);
                 }
               },
               3000);
       return true;
     } else {
       return defaultQuestEndDialog(env);
     }
   } else if (targetId == 700319) {
     long itemCount2;
     itemCount2 = player.getInventory().getItemCountByItemId(182204229);
     if (qs != null
         && qs.getStatus() == QuestStatus.START
         && qs.getQuestVarById(0) == 0
         && itemCount2 < 5) {
       final int targetObjectId = env.getVisibleObject().getObjectId();
       PacketSendUtility.broadcastPacket(
           player, new SM_EMOTION(player, EmotionType.NEUTRALMODE2, 0, targetObjectId), true);
       ThreadPoolManager.getInstance()
           .schedule(
               new Runnable() {
                 @Override
                 public void run() {
                   PacketSendUtility.broadcastPacket(
                       player,
                       new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId),
                       true);
                 }
               },
               3000);
       return true;
     } else {
       return defaultQuestEndDialog(env);
     }
   } else {
     return defaultQuestEndDialog(env);
   }
 }