@Override public void execute(Player player, String... params) { if ((params.length < 0) || (params.length < 1)) { onFail(player, null); return; } int itemId = 0; long itemCount = 1; Player receiver; try { String item = params[0]; // Some item links have space before Id if (item.equals("[item:")) { item = params[1]; Pattern id = Pattern.compile("(\\d{9})"); Matcher result = id.matcher(item); if (result.find()) itemId = Integer.parseInt(result.group(1)); if (params.length == 3) itemCount = Long.parseLong(params[2]); } else { Pattern id = Pattern.compile("\\[item:(\\d{9})"); Matcher result = id.matcher(item); if (result.find()) itemId = Integer.parseInt(result.group(1)); else itemId = Integer.parseInt(params[0]); if (params.length == 2) itemCount = Long.parseLong(params[1]); } receiver = player; } catch (NumberFormatException e) { receiver = World.getInstance().findPlayer(Util.convertName(params[0])); if (receiver == null) { PacketSendUtility.sendMessage(player, "Could not find a player by that name."); return; } try { String item = params[1]; // Some item links have space before Id if (item.equals("[item:")) { item = params[2]; Pattern id = Pattern.compile("(\\d{9})"); Matcher result = id.matcher(item); if (result.find()) itemId = Integer.parseInt(result.group(1)); if (params.length == 4) itemCount = Long.parseLong(params[3]); } else { Pattern id = Pattern.compile("\\[item:(\\d{9})"); Matcher result = id.matcher(item); if (result.find()) itemId = Integer.parseInt(result.group(1)); else itemId = Integer.parseInt(params[1]); if (params.length == 3) itemCount = Long.parseLong(params[2]); } } catch (NumberFormatException ex) { PacketSendUtility.sendMessage(player, "You must give number to itemid."); return; } catch (Exception ex2) { PacketSendUtility.sendMessage(player, "Occurs an error."); return; } } if (DataManager.ITEM_DATA.getItemTemplate(itemId) == null) { PacketSendUtility.sendMessage(player, "Item id is incorrect: " + itemId); return; } if (!AdminService.getInstance().canOperate(player, receiver, itemId, "command //add")) return; long count = ItemService.addItem(receiver, itemId, itemCount); if (count == 0) { if (player != receiver) { PacketSendUtility.sendMessage( player, "You successfully gave " + itemCount + " x [item:" + itemId + "] to " + receiver.getName() + "."); PacketSendUtility.sendMessage( receiver, "You successfully received " + itemCount + " x [item:" + itemId + "] from " + player.getName() + "."); } else PacketSendUtility.sendMessage( player, "You successfully received " + itemCount + " x [item:" + itemId + "]"); } else { PacketSendUtility.sendMessage(player, "Item couldn't be added"); } }
@Override public boolean onDialogEvent(QuestEnv env) { Player player = env.getPlayer(); QuestState qs = player.getQuestStateList().getQuestState(questId); if (qs == null) { return false; } int var = qs.getQuestVars().getQuestVars(); int targetId = env.getTargetId(); DialogAction dialog = env.getDialog(); if (qs.getStatus() == QuestStatus.START) { switch (targetId) { case 204182: { // Heimdall switch (dialog) { case QUEST_SELECT: { if (var == 0) { return sendQuestDialog(env, 1011); } } case SETPRO1: { return defaultCloseDialog(env, 0, 1); // 1 } } break; } case 203550: { // Munin switch (dialog) { case QUEST_SELECT: { if (var == 1) { return sendQuestDialog(env, 1352); } else if (var == 10) { return sendQuestDialog(env, 4080); } } case SETPRO2: { return defaultCloseDialog(env, 1, 2); // 2 } case SETPRO10: { return defaultCloseDialog(env, 10, 10, true, false); // reward } } break; } case 790003: { // Urd switch (dialog) { case QUEST_SELECT: { if (var == 2) { return sendQuestDialog(env, 1693); } } case SETPRO3: { return defaultCloseDialog(env, 2, 3); // 3 } } break; } case 790002: { // Verdandi switch (dialog) { case QUEST_SELECT: { if (var == 3) { return sendQuestDialog(env, 2034); } } case SETPRO4: { return defaultCloseDialog(env, 3, 4); // 4 } } break; } case 203546: { // Skuld switch (dialog) { case QUEST_SELECT: { if (var == 4) { return sendQuestDialog(env, 2375); } else if (var == 9) { return sendQuestDialog(env, 3739); } } case SETPRO5: { if (var == 4) { changeQuestStep(env, 4, 95, false); // 95 WorldMapInstance newInstance = InstanceService.getNextAvailableInstance(320070000); InstanceService.registerPlayerWithInstance(newInstance, player); TeleportService2.teleportTo( player, 320070000, newInstance.getInstanceId(), 268.47397f, 251.80275f, 125.8369f); return closeDialogWindow(env); } } case SETPRO9: { changeQuestStep(env, 9, 10, false); // 10 TeleportService2.teleportTo(player, 220010000, 1, 383.0f, 1896.0f, 327.625f); return closeDialogWindow(env); } } break; } case 204264: { // Skuld 2 switch (dialog) { case USE_OBJECT: { if (var == 99 && !isStigmaEquipped(env)) { return sendQuestDialog(env, 3057); } } case QUEST_SELECT: { if (var == 95) { return sendQuestDialog(env, 2716); } else if (var == 96) { return sendQuestDialog(env, 3057); } else if (var == 97) { return sendQuestDialog(env, 3398); } } case SETPRO6: { if (var == 95) { playQuestMovie(env, 156); return closeDialogWindow(env); } } case SELECT_ACTION_3058: { if (var == 96) { if (giveQuestItem(env, getStoneId(player), 1) && !isStigmaEquipped(env)) { long existendStigmaShards = player.getInventory().getItemCountByItemId(141000001); if (existendStigmaShards < 60) { if (!player.getInventory().isFull()) { ItemService.addItem(player, 141000001, 60 - existendStigmaShards); changeQuestStep(env, 96, 99, false); // 99 return sendQuestDialog(env, 3058); } else { return closeDialogWindow(env); } } else { changeQuestStep(env, 96, 99, false); // 99 return sendQuestDialog(env, 3058); } } else { return closeDialogWindow(env); } } else if (var == 99) { return sendQuestDialog(env, 3058); } } case SETPRO7: { if (var == 99) { PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 1)); return true; } } case SETPRO8: { if (var == 97) { changeQuestStep(env, 97, 98, false); // 98 QuestService.addNewSpawn( 320070000, player.getInstanceId(), 204263, 257.5f, 245f, 125f, (byte) 0); return closeDialogWindow(env); } } } break; } } } else if (qs.getStatus() == QuestStatus.REWARD) { if (targetId == 204061) { // Aud return sendQuestEndDialog(env); } } return false; }