Exemple #1
0
 private int calculateSize() {
   int size = 0;
   for (Map.Entry<Integer, Long> entry : cooldowns.entrySet()) {
     size += DataManager.SKILL_DATA.getSkillsForCooldownId(entry.getKey()).size();
   }
   return size;
 }
Exemple #2
0
  /** {@inheritDoc} */
  @Override
  protected void writeImpl(AionConnection con) {
    writeH(calculateSize());
    long currentTime = System.currentTimeMillis();
    for (Map.Entry<Integer, Long> entry : cooldowns.entrySet()) {
      int left = Math.round((entry.getValue() - currentTime) / 1000);
      ArrayList<Integer> skillsWithCooldown =
          DataManager.SKILL_DATA.getSkillsForCooldownId(entry.getKey());

      for (int index = 0; index < skillsWithCooldown.size(); index++) {
        writeH(skillsWithCooldown.get(index));
        writeD(left > 0 ? left : 0);
      }
    }
  }
  @Override
  public void applyEffect(Effect effect) {
    super.applyEffect(effect);

    Creature effected = effect.getEffected();
    Effect placedSignet = effected.getEffectController().getAnormalEffect(signet);
    int nextSignetlvl = 1;
    if (placedSignet != null) {
      nextSignetlvl = placedSignet.getSkillId() - this.signetid + 2;
      if (nextSignetlvl > signetlvl || nextSignetlvl > 5) return;
      placedSignet.endEffect();
    }

    SkillTemplate template = DataManager.SKILL_DATA.getSkillTemplate(signetid + nextSignetlvl - 1);
    int effectsDuration = template.getEffectsDuration();
    Effect newEffect =
        new Effect(
            effect.getEffector(), effect.getEffected(), template, nextSignetlvl, effectsDuration);
    newEffect.initialize();
    newEffect.applyEffect();
  }
Exemple #4
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;
    }
  }