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

    if (params.length < 3) {
      PacketSendUtility.sendMessage(admin, "Incorrent number of params in //fsc command");
      return;
    }

    int id = Integer.decode(params[0]);
    String format = "";

    if (params.length > 1) format = params[1];

    SM_CUSTOM_PACKET packet = new SM_CUSTOM_PACKET(id);

    int i = 0;
    for (char c : format.toCharArray()) {
      packet.addElement(PacketElementType.getByCode(c), params[i + 2]);
      i++;
    }
    PacketSendUtility.sendPacket(admin, packet);
  }
  @Override
  public void executeCommand(Player admin, String[] params) {
    if (admin.getAccessLevel() < AdminConfig.COMMAND_BAN) {
      PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command!");
      return;
    }

    if (params == null || params.length < 1) {
      PacketSendUtility.sendMessage(admin, "Syntax: //unbanip <mask>");
      return;
    }

    LoginServer.getInstance().sendBanPacket((byte) 2, 0, params[0], -1, admin.getObjectId());
  }
Ejemplo n.º 3
0
  @Override
  public void executeCommand(Player admin, String[] params) {
    if (admin.getAccessLevel() < AdminConfig.COMMAND_RELOADSPAWNS) {
      PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
      return;
    }

    // despawn all
    World.getInstance()
        .doOnAllObjects(
            new Executor<AionObject>() {
              @Override
              public boolean run(AionObject obj) {
                if (obj instanceof Npc
                    || obj instanceof Gatherable
                    || obj instanceof StaticObject) {
                  ((VisibleObject) obj).getController().delete();
                }
                return true;
              }
            });

    // spawn all;
    SpawnEngine.getInstance().spawnAll();
  }
Ejemplo n.º 4
0
  @Override
  public void executeCommand(Player admin, String[] params) {
    int time = 0; // Default: infinity
    String targetName = "direct_type";
    String macAddress = null;
    int targetId = 0;
    if (admin.getAccessLevel() < AdminConfig.COMMAND_BANMAC) {
      PacketSendUtility.sendMessage(
          admin, LanguageHandler.translate(CustomMessageId.COMMAND_NOT_ENOUGH_RIGHTS));
      return;
    }

    VisibleObject target = admin.getTarget();
    if (target != null && target instanceof Player) {
      if (target.getObjectId() == admin.getObjectId()) {
        PacketSendUtility.sendMessage(admin, "omg, disselect yourself please.");
        return;
      }

      Player targetpl = (Player) target;
      macAddress = targetpl.getClientConnection().getMacAddress();
      targetName = targetpl.getName();
      targetId = targetpl.getObjectId();
      targetpl.getClientConnection().closeNow();
    } else {
      PacketSendUtility.sendMessage(admin, "Please select target first!!");
      return;
    }

    if (params.length > 0) {
      try {
        time = Integer.parseInt(params[0]);
      } catch (NumberFormatException e) {
        PacketSendUtility.sendMessage(admin, "Syntax: //banmac [time in minutes]");
        return;
      }
    }

    BannedMacManager.getInstance()
        .banAddress(
            macAddress,
            targetId,
            System.currentTimeMillis() + time * 60000,
            "author=" + admin.getName() + ", " + admin.getObjectId() + "; target=" + targetName);
  }
Ejemplo n.º 5
0
 private void sendSyntax(Player admin) {
   String message = "syntax: //reload <";
   for (ReloadType type : ReloadType.values()) {
     message += type.name().toLowerCase() + "|";
   }
   message = message.substring(0, message.length() - 1);
   message += ">";
   PacketSendUtility.sendMessage(admin, message);
 }
Ejemplo n.º 6
0
 @Override
 public boolean onDialogEvent(QuestEnv 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);
   if (targetId == 204650) {
     if (qs == null) {
       if (env.getDialog() == QuestDialog.START_DIALOG) return sendQuestDialog(env, 1011);
       else return sendQuestStartDialog(env);
     }
   } else if (targetId == 204655) {
     if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) {
       if (env.getDialog() == QuestDialog.USE_OBJECT) {
         PacketSendUtility.sendMessage(player, "25");
         return sendQuestDialog(env, 1352);
       } else if (env.getDialog() == QuestDialog.STEP_TO_1) {
         qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
         updateQuestStatus(env);
         PacketSendUtility.sendPacket(
             player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
         return true;
       } else return sendQuestStartDialog(env);
     }
   } else if (targetId == 204775) {
     if (qs != null) {
       if (env.getDialog() == QuestDialog.START_DIALOG && qs.getStatus() == QuestStatus.START)
         return sendQuestDialog(env, 2375);
       else if (env.getDialogId() == 1009
           && qs.getStatus() != QuestStatus.COMPLETE
           && qs.getStatus() != QuestStatus.NONE) {
         qs.setQuestVar(3);
         qs.setStatus(QuestStatus.REWARD);
         updateQuestStatus(env);
         return sendQuestEndDialog(env);
       } else return sendQuestEndDialog(env);
     }
   }
   return false;
 }
Ejemplo n.º 7
0
  @Override
  public void executeCommand(Player admin, String[] params) {
    if (admin.getAccessLevel() < AdminConfig.COMMAND_RELOAD) {
      PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
      return;
    }

    if (params == null || params.length != 1) {
      sendSyntax(admin);
      return;
    }

    ReloadType reloadType = ReloadType.UNKNOWN;
    try {
      reloadType = ReloadType.valueOf(params[0].toUpperCase());
    } catch (Exception e) {
    }

    switch (reloadType) {
      case COMMAND:
        try {
          ChatHandlers.getInstance().reloadChatHandlers();
          PacketSendUtility.sendMessage(admin, "Admin/user commands reloaded successfully!");
        } catch (GameServerError e) {
          PacketSendUtility.sendMessage(
              admin, "Admin/user commands failed to reload! Keeping last version ...");
        }
        break;
      case NPC:
        File npcXml = new File("./data/static_data/npcs/npc_templates.xml");
        List<NpcTemplate> npcTemplates = new ArrayList<NpcTemplate>();
        try {
          JAXBContext jc = JAXBContext.newInstance(StaticData.class);
          Unmarshaller un = jc.createUnmarshaller();
          un.setSchema(getSchema("./data/static_data/static_data.xsd"));

          NpcData data = (NpcData) un.unmarshal(npcXml);
          if (data != null && data.getTemplates() != null) npcTemplates.addAll(data.getTemplates());
        } catch (Exception e) {
          PacketSendUtility.sendMessage(
              admin, "NPC templates reload failed! Keeping last version ...");
          log.error(e);
          return;
        }

        if (npcTemplates.size() > 0) {
          DataManager.NPC_DATA.setTemplates(npcTemplates);

          PacketSendUtility.sendMessage(
              admin,
              "NPC templates reloaded successfuly, now updating World to reflect changes ...!");

          World.getInstance()
              .doOnAllNpcs(
                  new Executor<Npc>() {

                    @Override
                    public boolean run(Npc object) {
                      NpcTemplate newTemplate =
                          DataManager.NPC_DATA.getNpcTemplate(object.getNpcId());
                      if (newTemplate != null) {
                        object.setObjectTemplate(newTemplate);
                      }
                      return true;
                    }
                  },
                  true);

          PacketSendUtility.sendMessage(admin, "Complete !");

        } else
          PacketSendUtility.sendMessage(
              admin, "NPC templates reload failed! Keeping last version ...");

        break;
      case PORTAL:
        File portalDir = new File("./data/static_data/portals");
        List<PortalTemplate> portalTemplates = new ArrayList<PortalTemplate>();
        try {
          JAXBContext jc = JAXBContext.newInstance(StaticData.class);
          Unmarshaller un = jc.createUnmarshaller();
          un.setSchema(getSchema("./data/static_data/static_data.xsd"));

          for (File file : listFiles(portalDir, true)) {
            PortalData data = (PortalData) un.unmarshal(file);
            if (data != null && data.getPortals() != null)
              portalTemplates.addAll(data.getPortals());
          }

        } catch (Exception e) {
          PacketSendUtility.sendMessage(admin, "Portals reload failed! Keeping last version ...");
          log.error(e);
          return;
        }
        if (portalTemplates.size() > 0) {
          DataManager.PORTAL_DATA.setPortals(portalTemplates);
          PacketSendUtility.sendMessage(admin, "Portals reloaded successfuly!");
        } else
          PacketSendUtility.sendMessage(admin, "Portals reload failed! Keeping last version ...");
        break;
      case QUEST:
        File questXml = new File("./data/static_data/quest_data/quest_data.xml");
        File questDir = new File("./data/static_data/quest_script_data");

        QuestsData newQuestData;
        ArrayList<QuestScriptsData> newScriptData = new ArrayList<QuestScriptsData>();

        try {
          JAXBContext jc = JAXBContext.newInstance(StaticData.class);
          Unmarshaller un = jc.createUnmarshaller();
          un.setSchema(getSchema("./data/static_data/static_data.xsd"));
          newQuestData = (QuestsData) un.unmarshal(questXml);
          for (File file : listFiles(questDir, true)) {
            QuestScriptsData data = ((QuestScriptsData) un.unmarshal(file));
            if (data != null) if (data.getData() != null) newScriptData.add(data);
          }
        } catch (Exception e) {
          PacketSendUtility.sendMessage(admin, "Quests reload failed! Keeping last version ...");
          log.error(e);
          return;
        }

        if (newQuestData != null) {
          try {
            DataManager.QUEST_DATA.setQuestsData(newQuestData.getQuestsData());
            QuestScriptsData questScriptsData = DataManager.QUEST_SCRIPTS_DATA;
            questScriptsData.getData().clear();
            for (QuestScriptsData qsd : newScriptData) {
              questScriptsData.getData().addAll(qsd.getData());
            }
            QuestEngine.getInstance().load(true);
            PacketSendUtility.sendMessage(admin, "Quests reloaded successfuly!");
          } catch (GameServerError e) {
            PacketSendUtility.sendMessage(admin, "Quests reload failed! Keeping last version ...");
            log.error(e);
            return;
          }
        }
        break;
      case SKILL:
        File skillDir = new File("./data/static_data/skills");
        List<SkillTemplate> skillTemplates = new ArrayList<SkillTemplate>();
        try {
          JAXBContext jc = JAXBContext.newInstance(StaticData.class);
          Unmarshaller un = jc.createUnmarshaller();
          un.setSchema(getSchema("./data/static_data/static_data.xsd"));

          for (File file : listFiles(skillDir, true)) {
            SkillData data = (SkillData) un.unmarshal(file);
            if (data != null) skillTemplates.addAll(data.getSkillTemplates());
          }
        } catch (Exception e) {
          PacketSendUtility.sendMessage(admin, "Skills reload failed! Keeping last version ...");
          log.error(e);
          return;
        }

        if (skillTemplates.size() > 0) {
          DataManager.SKILL_DATA.setSkillTemplates(skillTemplates);
          PacketSendUtility.sendMessage(admin, "Skills reloaded successfuly!");
        } else
          PacketSendUtility.sendMessage(admin, "Skills reload failed! Keeping last version ...");
        break;
      case SPAWN:
        File spawnDir = new File("./data/static_data/spawns");
        List<SpawnGroup> spawnTemplates = new ArrayList<SpawnGroup>();
        try {
          JAXBContext jc = JAXBContext.newInstance(StaticData.class);
          Unmarshaller un = jc.createUnmarshaller();
          un.setSchema(getSchema("./data/static_data/static_data.xsd"));

          for (File file : listFiles(spawnDir, true)) {
            SpawnsData data = (SpawnsData) un.unmarshal(file);
            if (data != null && data.getSpawnGroups() != null)
              spawnTemplates.addAll(data.getSpawnGroups());
          }
        } catch (Exception e) {
          PacketSendUtility.sendMessage(admin, "Spawns reload failed! Keeping last version ...");
          log.error(e);
          return;
        }

        if (spawnTemplates.size() > 0) {
          DataManager.SPAWNS_DATA.setSpawns(spawnTemplates);
          PacketSendUtility.sendMessage(admin, "Spawns reloaded successfuly!");
        } else
          PacketSendUtility.sendMessage(
              admin, "Spawns reload failed with empty object! Keeping last version ...");
        break;
      default:
        sendSyntax(admin);
        return;
    }
  }
Ejemplo n.º 8
0
  @Override
  public void executeCommand(Player player, String params) {

    String[] args = params.split(" ");
    Player target = World.getInstance().findPlayer(Util.convertName(args[0]));

    if (target == null) {
      PacketSendUtility.sendMessage(
          player, "The player with this name is not on a network or do not exist.");
      return;
    }

    StringBuilder sb = new StringBuilder();

    sb.append("<poll>\n");
    sb.append("<poll_introduction>\n");
    sb.append("	<![CDATA[<font color='4CB1E5'>Player Info - Aion-Knight Dev.</font>]]>\n");
    sb.append("</poll_introduction>\n");
    sb.append("<poll_title>\n");
    sb.append("	<font color='ffc519'></font>\n");
    sb.append("</poll_title>\n");
    sb.append("<start_date></start_date>\n");
    sb.append("<end_date></end_date>\n");
    sb.append("<servers></servers>\n");
    sb.append("<order_num></order_num>\n");
    sb.append("<race></race>\n");
    sb.append("<main_class></main_class>\n");
    sb.append("<world_id></world_id>\n");
    sb.append("<item_id></item_id>\n");
    sb.append("<item_cnt></item_cnt>\n");
    sb.append("<level>1~55</level>\n");
    sb.append("<questions>\n");
    sb.append("	<question>\n");
    sb.append("		<title>\n");
    sb.append("			<![CDATA[\n");
    sb.append("<br><br>\n");
    if (target.getCommonData().getRace() == Race.ELYOS) {
      sb.append(
          "Information about the player "
              + target.getName()
              + ": <img src='http://www.aion-destination.de/_images/elyos.png'><br><hr><br><br>\n");
    } else {
      sb.append(
          "Information about the player "
              + target.getName()
              + ": <img src='http://sites.google.com/site/aioninfos/bilder/sonstiges/Asmodier-Symbol-35x40.png'><br><hr><br><br>\n");
    }

    // Falls sie die selbe Rasse haben bzw. es ein GM ist, wird der HP/MP/DP Status in % ausgegeben
    if (target.getCommonData().getRace() == player.getCommonData().getRace()
        || player.getAccessLevel() > 0) {
      int hpinPercent =
          target.getLifeStats().getCurrentHp()
              * 100
              / target.getGameStats().getCurrentStat(StatEnum.MAXHP);
      int mpinPercent =
          target.getLifeStats().getCurrentMp()
              * 100
              / target.getGameStats().getCurrentStat(StatEnum.MAXMP);
      int dpinPercent = target.getCommonData().getDp() * 100 / 4000;

      // Gesundheit grafisch darstellen
      sb.append("Gesundheit: [<font color ='00FF00'>");
      int i = 1;
      for (i = 1; i < hpinPercent / 5; i++) {
        sb.append("|");
        if (i == 10) {
          sb.append(" ");
        }
      }
      sb.append("</font><font color ='FF0000'>");
      int k = 20 - i;
      for (i = 1; i < k; i++) {
        sb.append("|");
        if (20 - k + i == 10) {
          sb.append(" ");
        }
      }
      sb.append(
          "</font>] ("
              + hpinPercent
              + "%)  ("
              + target.getLifeStats().getCurrentHp()
              + "/"
              + target.getGameStats().getCurrentStat(StatEnum.MAXHP)
              + " TP)<br>");

      if (hpinPercent
          == 0) // Falls der Spieler keine Gesundheit mehr hat also tot ist sind alle Balken rot und
      // es erscheint Tot neben dem Leben
      {
        sb.append(" <font color ='FF0000'>Tot</font>");
        sb.append("<br>Mana: [<font color='FF0000'>|||||||||| ||||||||||</font>]");
        sb.append("<br>G&ouml;ttliche Kraft: [font color='FF0000'>|||||||||| ||||||||||</font>");
      } else // ansonsten werden Mana und G�ttliche Kraft berechnet
      {
        sb.append("<br>");
        // Mana grafisch darstellen
        sb.append("Mana: [<font color ='00FFFF'>");
        for (i = 1; i < mpinPercent / 5; i++) // gr�ne Gesundheitsbalken
        {
          sb.append("|");
          if (i == 10) {
            sb.append(" ");
          }
        }
        sb.append("</font><font color ='FF0000'>");
        k = 20 - i;
        for (i = 1; i < k; i++) // Rote Gesundheitsbalken
        {
          sb.append("|");
          if (20 - k + i == 10) {
            sb.append(" ");
          }
        }
        sb.append(
            "</font>] ("
                + mpinPercent
                + "%)  ("
                + target.getLifeStats().getCurrentMp()
                + "/"
                + target.getGameStats().getCurrentStat(StatEnum.MAXMP)
                + " MP)<br>");

        // G�ttliche Kraft grafisch darstellen
        sb.append("G&ouml;ttliche Kraft: [<font color='FFCC00'>");
        for (i = 1; i < dpinPercent / 5; i++) {
          sb.append("|");
          if (i == 10) {
            sb.append(" ");
          }
        }
        sb.append("</font><font color ='FF0000'>");
        k = 20 - i;
        for (i = 1; i < k; i++) {
          sb.append("|");
          if (20 - k + i == 10) {
            sb.append(" ");
          }
        }
        sb.append(
            "</font>] ("
                + dpinPercent
                + "%)  ("
                + target.getCommonData().getDp()
                + "/4000 GK)<br>");
      }
    }

    sb.append("Level: " + target.getLevel() + "<br>\n");
    // sb.append("Online: " + (System.currentTimeMillis() -
    // target.getCommonData().getLastOnline().getTime()) / 60000 + " Minuten<br>\n");

    if (target.getCommonData().getRace() == player.getCommonData().getRace()
        || player.getAccessLevel() > 0) {
      // PacketSendUtility.broadcastPacket(((Player) player), new SM_MESSAGE(((Player)
      // player),"Position von [Pos:" + target.getName() + ";" + target.getPosition().getMapId() + "
      // " + target.getPosition().getX() + " " + target.getPosition().getY() + " 0.0 -1]" ,
      // ChatType.NORMAL), true);
      // TODO Post des Ortes via Chat... Umwandlung in Ortsbezogene Markierung??
    }

    sb.append("Klasse: ");
    int targetclass = target.getPlayerClass().getClassId();
    if (targetclass == 0) {
      sb.append("Krieger");
    } else if (targetclass == 1) {
      sb.append("Gladiator");
    } else if (targetclass == 2) {
      sb.append("Templer");
    } else if (targetclass == 3) {
      sb.append("Sp&auml;her");
    } else if (targetclass == 4) {
      sb.append("Assassine");
    } else if (targetclass == 5) {
      sb.append("J&auml;ger");
    } else if (targetclass == 6) {
      sb.append("Magier");
    } else if (targetclass == 7) {
      sb.append("Zauberer");
    } else if (targetclass == 8) {
      sb.append("Beschw&ouml;rer");
    } else if (targetclass == 9) {
      sb.append("Priester");
    } else if (targetclass == 10) {
      sb.append("Kleriker");
    } else if (targetclass == 11) {
      sb.append("Kantor");
    }

    sb.append("<br>");

    if (target.getCommonData().getRace() == Race.ELYOS) {
      sb.append("Rasse: Elyos<br>\n");
    } else {
      sb.append("Rasse: Asmodier<br>\n");
    }

    StringBuilder strbld = new StringBuilder("Gruppe: <br>--Leitung: \n");

    PlayerGroup group = target.getPlayerGroup();
    if (group == null) sb.append("Gruppe: keine<br>\n");
    else {
      Iterator<Player> it = group.getMembers().iterator();

      strbld.append(group.getGroupLeader().getName() + "<br>--Mitglieder:<br>\n");
      while (it.hasNext()) {
        Player act = (Player) it.next();
        strbld.append("----" + act.getName() + "<br>\n");
      }
      sb.append(strbld.toString());
    }

    Legion legion = target.getLegion();
    if (legion == null) {
      sb.append("Legion: keine<br>\n");
    } else {
      sb.append("Legion: " + legion.getLegionName() + "<br>\n");
    }

    if (player.getAccessLevel() > 0) {
      sb.append("<hr>");
      sb.append("Zus&auml;tzliche Informationen f&uuml;r Teammitglieder:<br><br>");
      sb.append("Account Name: " + target.getClientConnection().getAccount().getName() + "<br>\n");
      // sb.append("IP: " + target.getClientConnection.getIP() + "<br>\n");

      try {
        if (args[1].equals("+items")) {
          sb.append("<br><hr><br>Item Informationen:<br><br>");
          StringBuilder itstrbld = new StringBuilder("-- Inventar:<br>");

          List<Item> items = target.getInventory().getAllItems();
          Iterator<Item> it = items.iterator();

          if (items.isEmpty()) itstrbld.append("---- Keine");
          else {
            while (it.hasNext()) {

              Item act = (Item) it.next();
              itstrbld.append(
                  "---- "
                      + act.getItemCount()
                      + "mal "
                      + "[item:"
                      + act.getItemTemplate().getTemplateId()
                      + "]<br>");
            }
          }
          items.clear();
          items = target.getEquipment().getEquippedItems();
          it = items.iterator();
          itstrbld.append("<br>-- Ausger&uuml;stet:<br>");
          if (items.isEmpty()) itstrbld.append("---- Keine");
          else {
            while (it.hasNext()) {
              Item act = (Item) it.next();
              itstrbld.append(
                  "---- "
                      + act.getItemCount()
                      + "mal "
                      + "[item:"
                      + act.getItemTemplate().getTemplateId()
                      + "]<br>");
            }
          }

          items.clear();
          items = target.getWarehouse().getAllItems();
          it = items.iterator();
          itstrbld.append("<br>-- Lagerhaus:<br>");
          if (items.isEmpty()) itstrbld.append("---- Keine");
          else {
            while (it.hasNext()) {
              Item act = (Item) it.next();
              itstrbld.append(
                  "---- "
                      + act.getItemCount()
                      + "mal "
                      + "[item:"
                      + act.getItemTemplate().getTemplateId()
                      + "]"
                      + "<br>");
            }
          }
          sb.append(itstrbld.toString());
        }
      } catch (Exception e) {
      }
    } else if (player.getAccessLevel() == 0 && args[1].equals("+items")) {
      sb.append("<br><hr><br>Du hast nicht genug Rechte, um Item Informationen abzurufen.<br><br>");
    }
    sb.append("<br><br><br>\n");
    sb.append("			]]>\n");
    sb.append("		</title>\n");
    sb.append("		<select>\n");
    sb.append("<input type='radio'>");
    sb.append("Danke f&uuml;r die Info!");
    sb.append("</input>\n");
    sb.append("		</select>\n");
    sb.append("	</question>\n");
    sb.append("</questions>\n");
    sb.append("</poll>\n");

    String html = sb.toString();
    final int messageId = IDFactory.getInstance().nextId();
    byte packet_count = (byte) Math.ceil(html.length() / (Short.MAX_VALUE - 8) + 1);
    if (packet_count < 256) {
      for (byte i = 0; i < packet_count; i++) {
        try {
          int from = i * (Short.MAX_VALUE - 8), to = (i + 1) * (Short.MAX_VALUE - 8);
          if (from < 0) from = 0;
          if (to > html.length()) to = html.length();
          String sub = html.substring(from, to);
          player
              .getClientConnection()
              .sendPacket(new SM_QUESTIONNAIRE(messageId, i, packet_count, sub));
        } catch (Exception e) {

        }
      }
    }
  }
Ejemplo n.º 9
0
 @Override
 public void executeCommand(Player admin, String[] params) {
   if (admin.getAccessLevel() < 2) {
     PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
     return;
   }
   if (params.length < 1) {
     PacketSendUtility.sendMessage(admin, "syntax: //pvp <open|close|reset|ap>");
     return;
   }
   if ("open".equalsIgnoreCase(params[0])) {
     if (!PvPZoneService.Spawn(250148, 250148, 730207))
       PacketSendUtility.sendMessage(admin, "PvP Event ist already started.");
     else PacketSendUtility.sendMessage(admin, "PvP Event will be started.");
   } else if ("close".equalsIgnoreCase(params[0])) {
     if (!PvPZoneService.Delete())
       PacketSendUtility.sendMessage(admin, "PvP Event has bin not started.");
   } else if ("ap".equalsIgnoreCase(params[0])) {
     if (params.length == 1) {
       PacketSendUtility.sendMessage(admin, "syntax: //pvp ap <on|off>");
     } else if ("on".equalsIgnoreCase(params[1])) {
       if (PvpService.getPvpZoneReward())
         PacketSendUtility.sendMessage(admin, "PvP Event Reward was already set.");
       else {
         PvpService.setPvpZoneReward(true);
         PacketSendUtility.sendMessage(admin, "PvP Event Reward was already turn on");
       }
     } else if ("off".equalsIgnoreCase(params[1])) {
       if (!PvpService.getPvpZoneReward())
         PacketSendUtility.sendMessage(admin, "PvP Event Reward was turned off.");
       else {
         PvpService.setPvpZoneReward(true);
         PacketSendUtility.sendMessage(admin, "PvP Event Reward was set off.");
       }
     } else {
       PacketSendUtility.sendMessage(admin, "syntax: //pvp ap <on|off>");
     }
   } else if ("reset".equalsIgnoreCase(params[0])) {
     PvPZoneService.AdminReset();
     PacketSendUtility.sendMessage(admin, "PvP Event has bin resetet.");
   } else {
     PacketSendUtility.sendMessage(admin, "Syntax: //pvp <open|close|reset|ap>");
   }
 }
Ejemplo n.º 10
0
  private static void analyzePortation(final Player player, PortalTemplate portalTemplate) {

    boolean instanceTitleReq = false;
    boolean instanceLevelReq = false;
    boolean instanceRaceReq = false;
    boolean instanceQuestReq = false;
    boolean instanceGroupReq = false;
    int instanceCooldownRate = 0;

    ExitPoint exit = TeleportService.getExitPointByRace(portalTemplate, player.getRace());
    if (exit == null) {
      return;
    }
    int mapId = exit.getMapId();

    if (player.getAccessLevel() < AdminConfig.INSTANCE_REQ) {
      instanceTitleReq = !player.havePermission(MembershipConfig.INSTANCES_TITLE_REQ);
      instanceLevelReq = !player.havePermission(MembershipConfig.INSTANCES_LEVEL_REQ);
      instanceRaceReq = !player.havePermission(MembershipConfig.INSTANCES_RACE_REQ);
      instanceQuestReq = !player.havePermission(MembershipConfig.INSTANCES_QUEST_REQ);
      instanceGroupReq = !player.havePermission(MembershipConfig.INSTANCES_GROUP_REQ);
      instanceCooldownRate = InstanceService.getInstanceRate(player, mapId);
    }

    if (portalTemplate.getKinahCount() != 0) {
      if (player.getInventory().getKinah() >= portalTemplate.getKinahCount())
        player.getInventory().decreaseKinah(portalTemplate.getKinahCount());
      else {
        PacketSendUtility.sendPacket(
            player, SM_SYSTEM_MESSAGE.STR_CANNOT_REGISTER_RESURRECT_POINT_NOT_ENOUGH_FEE);
        return;
      }
    }
    if (portalTemplate.getInstanceSiegeId() != 0) {
      int LocationId = portalTemplate.getInstanceSiegeId();
      FortressLocation loc = SiegeService.getInstance().getFortress(LocationId);
      if (loc != null)
        if (loc.getRace().getRaceId() != player.getRace().getRaceId() && instanceRaceReq) {
          PacketSendUtility.sendPacket(
              player, SM_SYSTEM_MESSAGE.STR_MOVE_PORTAL_ERROR_INVALID_RACE);
          return;
        }
    }

    if (portalTemplate.getIdTitle() != 0
        && player.getCommonData().getTitleId() != portalTemplate.getIdTitle()
        && instanceTitleReq) return;

    if (!portalTemplate.existsExitForRace(player.getRace()) && instanceRaceReq) {
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MOVE_PORTAL_ERROR_INVALID_RACE);
      return;
    }

    if (!(portalTemplate.isInstance()
        && DataManager.INSTANCE_COOLTIME_DATA.getInstanceCooltimeByWorldId(mapId) != null
        && DataManager.INSTANCE_COOLTIME_DATA
            .getInstanceCooltimeByWorldId(mapId)
            .getCanEnterMentor()
        && player.isMentor())) {
      if (((portalTemplate.getMaxLevel() != 0 && player.getLevel() > portalTemplate.getMaxLevel())
              || player.getLevel() < portalTemplate.getMinLevel())
          && instanceLevelReq) {
        PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MSG_CANT_INSTANCE_ENTER_LEVEL);
        return;
      }
    }

    PlayerGroup group = player.getPlayerGroup2();
    PlayerAlliance allianceGroup = player.getPlayerAlliance2();
    switch (portalTemplate.getPlayerSize()) {
      case 12:
      case 24:
      case 48:
        if (allianceGroup == null && instanceGroupReq) {
          // to do sniff
          PacketSendUtility.sendMessage(player, "You must be in Alliance.");
          return;
        }
        break;
      case 6:
        if (group == null && instanceGroupReq) {
          PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MSG_ENTER_ONLY_PARTY_DON);
          return;
        }
        break;
    }

    if (instanceQuestReq && portalTemplate.needQuest()) {
      int[][] quests = portalTemplate.getQuests();
      boolean present = false;
      for (int i = 0; i < quests.length; i++) {
        // TEMP: please remove when Quest 1044 get fixed
        if (quests[i][0] == 1044) {
          present = true;
          break;
        }

        final QuestState qs = player.getQuestStateList().getQuestState(quests[i][0]);
        if (qs != null) {
          if ((quests[i][1] == 0 && qs.getStatus() == QuestStatus.COMPLETE)
              || (quests[i][1] != 0
                  && (qs.getStatus() == QuestStatus.COMPLETE
                      || qs.getQuestVarById(0) >= quests[i][1]))) {
            present = true;
            break;
          }
        }
      }

      if (!present) {
        PacketSendUtility.sendMessage(player, "You must complete the entrance quest.");
        return;
      }
    }

    if (CustomConfig.INSTANCE_KEYCHECK) {
      if (portalTemplate.getPortalItem() != null && !portalTemplate.getPortalItem().isEmpty()) {
        for (PortalItem pi : portalTemplate.getPortalItem()) {
          if (!player.getInventory().decreaseByItemId(pi.getItemid(), pi.getQuantity())) {
            // TODO: find correct message
            PacketSendUtility.sendPacket(
                player, SM_SYSTEM_MESSAGE.STR_CANNOT_OPEN_DOOR_NEED_KEY_ITEM);
            return;
          }
        }
      }
    }

    boolean reenter = false;
    int useDelay = 0;
    int instanceCooldown = DataManager.INSTANCE_COOLTIME_DATA.getInstanceEntranceCooltime(mapId);
    if (instanceCooldownRate > 0) {
      useDelay = instanceCooldown / instanceCooldownRate;
    }
    WorldMapInstance instance = null;
    if (player.getPortalCooldownList().isPortalUseDisabled(mapId) && useDelay > 0) {

      switch (portalTemplate.getPlayerSize()) {
        case 6: // group
          if (player.getPlayerGroup2() != null) {
            instance =
                InstanceService.getRegisteredInstance(mapId, player.getPlayerGroup2().getTeamId());
          }
          break;
        case 12: // alliance
        case 24:
        case 48:
          if (player.isInAlliance2()) {
            instance =
                InstanceService.getRegisteredInstance(
                    mapId, player.getPlayerAlliance2().getTeamId());
          }
          break;
        default: // solo
          instance = InstanceService.getRegisteredInstance(mapId, player.getObjectId());
          break;
      }

      if (instance == null) {
        PacketSendUtility.sendPacket(
            player, SM_SYSTEM_MESSAGE.STR_MSG_CANNOT_MAKE_INSTANCE_COOL_TIME);
        return;
      } else {
        if (!instance.isRegistered(player.getObjectId())) {
          PacketSendUtility.sendPacket(
              player, SM_SYSTEM_MESSAGE.STR_MSG_CANNOT_MAKE_INSTANCE_COOL_TIME);
          return;
        } else {
          reenter = true;
          log.debug(player.getName() + "has been in intance and also have cd, can reenter.");
        }
      }
    } else {
      log.debug(
          player.getName()
              + "doesn't have cd of this instance, can enter and will be registed to this intance");
    }

    switch (portalTemplate.getPlayerSize()) {
      case 6:
        if (group != null || !instanceGroupReq) {
          // If there is a group (whatever group requirement exists or not)...
          if (group != null) {
            instance = InstanceService.getRegisteredInstance(mapId, group.getTeamId());
          }
          // But if there is no group (and solo is enabled, of course)
          else {
            instance = InstanceService.getRegisteredInstance(mapId, player.getObjectId());
          }

          // No instance (for group), group on and default requirement off
          if (instance == null && group != null && !instanceGroupReq) {
            // For each player from group
            for (Player member : group.getMembers()) {
              // Get his instance
              instance = InstanceService.getRegisteredInstance(mapId, member.getObjectId());

              // If some player is soloing and I found no one else yet, I get his instance
              if (instance != null) {
                break;
              }
            }

            // No solo instance found
            if (instance == null) instance = registerGroup(group, mapId);
          }

          // No instance and default requirement on = Group on
          else if (instance == null && instanceGroupReq) {
            instance = registerGroup(group, mapId);
          }
          // No instance, default requirement off, no group = Register new instance with player ID
          else if (instance == null && !instanceGroupReq && group == null) {
            instance = InstanceService.getNextAvailableInstance(mapId);
          }

          transfer(player, portalTemplate, instance, reenter);
        }
        break;
      case 12:
      case 24:
      case 48:
        if (allianceGroup != null || !instanceGroupReq) {
          if (allianceGroup != null) {
            instance = InstanceService.getRegisteredInstance(mapId, allianceGroup.getObjectId());
          } else {
            instance = InstanceService.getRegisteredInstance(mapId, player.getObjectId());
          }

          if (instance == null && allianceGroup != null && !instanceGroupReq) {
            for (Player member : allianceGroup.getMembers()) {
              instance = InstanceService.getRegisteredInstance(mapId, member.getObjectId());
              if (instance != null) {
                break;
              }
            }
            if (instance == null) {
              instance = registerAlliance(allianceGroup, mapId);
            }
          } else if (instance == null && instanceGroupReq) {
            instance = registerAlliance(allianceGroup, mapId);
          } else if (instance == null && !instanceGroupReq && allianceGroup == null) {
            instance = InstanceService.getNextAvailableInstance(mapId);
          }
          if (instance.getPlayersInside().size() < portalTemplate.getPlayerSize()) {
            transfer(player, portalTemplate, instance, reenter);
          }
        }
        break;
      default:
        // If there is a group (whatever group requirement exists or not)...
        if (group != null && !instanceGroupReq) {
          instance = InstanceService.getRegisteredInstance(mapId, group.getTeamId());
        }
        // But if there is no group, go to solo
        else {
          instance = InstanceService.getRegisteredInstance(mapId, player.getObjectId());
        }

        // No group instance, group on and default requirement off
        if (instance == null && group != null && !instanceGroupReq) {
          // For each player from group
          for (Player member : group.getMembers()) {
            // Get his instance
            instance = InstanceService.getRegisteredInstance(mapId, member.getObjectId());

            // If some player is soloing and I found no one else yet, I get his instance
            if (instance != null) {
              break;
            }
          }

          // No solo instance found
          if (instance == null && portalTemplate.isInstance())
            instance = registerGroup(group, mapId);
        }

        // if already registered - just teleport
        if (instance != null) {
          reenter = true;
          transfer(player, portalTemplate, instance, reenter);
          return;
        }
        port(player, portalTemplate, reenter);
        break;
    }
  }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    // Instanceof
    final Player player = env.getPlayer();
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    // ------------------------------------------------------------
    // NPC Quest :
    // 0 - Start to Kvasir
    if (qs == null || qs.getStatus() == QuestStatus.NONE) {
      if (targetId == 204053) {
        // Get HACTION_QUEST_SELECT in the eddit-HyperLinks.xml
        if (env.getDialogId() == 25)
          // Send select_none to eddit-HtmlPages.xml
          return sendQuestDialog(env, 4762);
        else return defaultQuestStartDialog(env);
      }
    }

    if (qs == null) return false;

    int var = qs.getQuestVarById(0);

    if (qs.getStatus() == QuestStatus.START) {

      switch (targetId) {
          // 1 - Talk with Latatusk
        case 204096:
          if (var == 0) {
            switch (env.getDialogId()) {
                // Get HACTION_QUEST_SELECT in the eddit-HyperLinks.xml
              case 25:
                // Send select1 to eddit-HtmlPages.xml
                return sendQuestDialog(env, 1011);
                // Get HACTION_SETPRO1 in the eddit-HyperLinks.xml
              case 10000:
                qs.setQuestVarById(0, var + 1);
                updateQuestStatus(env);
                PacketSendUtility.sendPacket(
                    player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
                return true;
            }
          }
          // 3 - Collect the Light of Luck and take it to Latatusk
          if (var == 2) {
            switch (env.getDialogId()) {
                // Get HACTION_QUEST_SELECT in the eddit-HyperLinks.xml
              case 25:
                // Send select3 to eddit-HtmlPages.xml
                return sendQuestDialog(env, 1693);
                // Get HACTION_CHECK_USER_HAS_QUEST_ITEM in the eddit-HyperLinks.xml
              case 33:
                if (player.getInventory().getItemCountByItemId(182207124) >= 20) {
                  player.getInventory().removeFromBagByItemId(182207124, 20);
                  qs.setQuestVarById(0, var + 1);
                  updateQuestStatus(env);
                  // Send check_user_item_ok to eddit-HtmlPages.xml
                  return sendQuestDialog(env, 10000);
                } else
                  // Send check_user_item_fail to eddit-HtmlPages.xml
                  return sendQuestDialog(env, 10001);
            }
          }
          break;
          // 2 - Talk with Relir.
        case 204097:
          if (var == 1) {
            log.info("Received dialog id :" + env.getDialogId());
            switch (env.getDialogId()) {
                // Get HACTION_QUEST_SELECT in the eddit-HyperLinks.xml
              case 25:
                // Send select2 to eddit-HtmlPages.xml
                return sendQuestDialog(env, 1352);
                // Get HACTION_SETPRO2 in the eddit-HyperLinks.xml
              case 1354:
                PacketSendUtility.sendMessage(
                    player, String.valueOf(player.getInventory().getKinahItem().getItemCount()));
                if (player.getInventory().getKinahItem().getItemCount() >= 3400000) {
                  player.getInventory().decreaseKinah(3400000);
                  PacketSendUtility.sendPacket(
                      player, new SM_UPDATE_ITEM(player.getInventory().getKinahItem()));

                  if (player.getInventory().getItemCountByItemId(182207123) == 0) {
                    if (!ItemService.addItems(
                        player, Collections.singletonList(new QuestItems(182207123, 1))))
                      return true;
                  }

                  qs.setQuestVarById(0, var + 1);
                  updateQuestStatus(env);
                  PacketSendUtility.sendPacket(
                      player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
                  return true;
                } else {
                  return sendQuestDialog(env, 1438);
                }
            }
          }
          break;
          // 4 - Better purify yourself! Take Glossy Holy Water and visit High Priest Balder
        case 204075:
          if (var == 3) {
            switch (env.getDialogId()) {
                // Get HACTION_QUEST_SELECT in the eddit-HyperLinks.xml
              case 25:
                if (player.getInventory().getItemCountByItemId(186000084) >= 1)
                  // Send select5 to eddit-HtmlPages.xml
                  return sendQuestDialog(env, 2034);
                else
                  // Send select5_2 to eddit-HtmlPages.xml
                  return sendQuestDialog(env, 2120);
                // Get HACTION_SET_SUCCEED in the eddit-HyperLinks.xml
              case 10255:
                // Send select_success to eddit-HtmlPages.xml
                return sendQuestDialog(env, 10002);
                // Get HACTION_SELECT_QUEST_REWARD in the eddit-HyperLinks.xml
              case 1009:
                player.getInventory().removeFromBagByItemId(186000084, 1);
                qs.setStatus(QuestStatus.REWARD);
                updateQuestStatus(env);
                // Send select_quest_reward1 to eddit-HtmlPages.xml
                return sendQuestDialog(env, 5);
            }
          }
          break;
          // No match
        default:
          return defaultQuestStartDialog(env);
      }
    } else if (qs.getStatus() == QuestStatus.REWARD) {
      // 5 - Talk with Kvasir
      if (targetId == 204053) return defaultQuestEndDialog(env);
    }
    return false;
  }
Ejemplo n.º 12
0
  @Override
  public void executeCommand(Player admin, String[] params) {
    String usage = "syntax; //ring <add (c|p1|p2)>|<save>|<next>";

    if (admin.getAccessLevel() < AdminConfig.COMMAND_RING) {
      PacketSendUtility.sendMessage(admin, "<You don't have the right to execute this command>");
    }

    if (params.length == 0) {
      PacketSendUtility.sendMessage(admin, usage);
      return;
    }

    if (params[0].equalsIgnoreCase("add")) {
      if (params.length < 2) {
        PacketSendUtility.sendMessage(admin, usage);
        return;
      }

      if (params[1].equalsIgnoreCase("c")) {
        if (params.length == 3 && params[2].equalsIgnoreCase("new")) {
          String newZoneName = admin.getZoneInstance().getTemplate().getName().name();
          if (zoneName != null && !zoneName.equalsIgnoreCase(newZoneName)) {
            zoneName = newZoneName;
          }
        }

        if (zoneName == null) {
          zoneName = admin.getZoneInstance().getTemplate().getName().name();
        }

        center = new Point3D(admin.getX(), admin.getY(), admin.getZ());
        ringId = nextIdForRegion(zoneName);
        ringName = zoneName + "_" + ringId;
        PacketSendUtility.sendMessage(admin, "Center for " + ringName + " added");
      }

      if (params[1].equalsIgnoreCase("p1")) {
        p1 = new Point3D(admin.getX(), admin.getY(), admin.getZ());
        PacketSendUtility.sendMessage(admin, "Point p1 for " + ringName + " added");
      }

      if (params[1].equalsIgnoreCase("p2")) {
        p2 = new Point3D(admin.getX(), admin.getY(), admin.getZ());
        PacketSendUtility.sendMessage(admin, "Point p2 for " + ringName + " added");
      }

      if (center != null && p1 != null && p2 != null) {
        rings
            .get(zoneName)
            .put(ringId, new FlyRingTemplate(ringName, admin.getWorldId(), center, p1, p2));
        center = null;
        p1 = null;
        p2 = null;
        PacketSendUtility.sendMessage(admin, "Added fly ring " + ringName + " !");
      }
      return;
    }

    if (params[0].equalsIgnoreCase("save")) {
      Schema schema = null;
      SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
      Logger log = Logger.getLogger(Ring.class);

      try {
        schema = sf.newSchema(new File("./data/static_data/fly_rings/fly_rings.xsd"));
      } catch (SAXException e1) {
        log.error("Error while saving data: " + e1.getMessage(), e1.getCause());
        PacketSendUtility.sendMessage(admin, "Unexpected error occured during saving");
        return;
      }

      File xml = new File("./data/static_data/fly_rings/generated_fly_rings.xml");
      JAXBContext jc;
      Marshaller marshaller;
      FlyRingData data = new FlyRingData();
      for (Map<Integer, FlyRingTemplate> e : rings.values()) {
        data.addAll(e.values());
      }
      try {
        jc = JAXBContext.newInstance(FlyRingData.class);
        marshaller = jc.createMarshaller();
        marshaller.setSchema(schema);
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.marshal(data, xml);
      } catch (JAXBException e) {
        log.error("Error while saving data: " + e.getMessage(), e.getCause());
        PacketSendUtility.sendMessage(admin, "Unexpected error occured during saving");
        return;
      }

      PacketSendUtility.sendMessage(admin, "Saved successfully new fly_rings !");
    }

    if (params[0].equalsIgnoreCase("next")) {
      float x = (float) ringPositions[i].x;
      float y = (float) ringPositions[i].y;
      float z = (float) ringPositions[i].z;

      TeleportService.teleportTo(admin, admin.getWorldId(), x, y, z, 0);
      PacketSendUtility.sendMessage(
          admin, "Teleported to ring " + (i + 1) + "/" + ringPositions.length);

      i = (i + 1) % ringPositions.length;
    }
  }