Пример #1
0
 public void createInformation(Element inf, Quest quest) {
   if (inf != null) {
     quest.setName(inf.getChildText("Name"));
     quest.setDescription(inf.getChildText("Description"));
     quest.setObjective(inf.getChildText("Objective"));
   }
 }
Пример #2
0
 @Override
 public Quest read(JsonReader in) throws IOException {
   int ID_OFFSET = Quest.size();
   QUEST = new Quest(ID_OFFSET, "", "", 0, 0, false);
   List<Integer> requirement = new ArrayList<>(), options = new ArrayList<>();
   in.beginObject();
   while (in.hasNext()) {
     switch (in.nextName()) {
       case NAME:
         QUEST.setName(in.nextString());
         break;
       case DESCRIPTION:
         QUEST.setDescription(in.nextString());
         break;
       case X:
         ReflectionHelper.setPrivateValue(Quest.class, QUEST, in.nextInt(), X);
         break;
       case Y:
         ReflectionHelper.setPrivateValue(Quest.class, QUEST, in.nextInt(), Y);
         break;
       case TRIGGER_TASKS:
         QUEST.setTriggerTasks(in.nextInt());
         break;
       case PARENT_REQUIREMENT:
         QUEST.setParentRequirementCount(in.nextInt());
         break;
       case BIG_ICON:
         QUEST.setBigIcon(in.nextBoolean());
         break;
       case ICON:
         QUEST.setIcon(MinecraftAdapter.ITEM_STACK.read(in));
         break;
       case REQUIREMENTS:
         in.beginArray();
         while (in.hasNext()) {
           requirement.add(in.nextInt() + QUEST_ID);
         }
         in.endArray();
         break;
       case OPTIONS:
         in.beginArray();
         while (in.hasNext()) {
           options.add(in.nextInt() + QUEST_ID);
         }
         in.endArray();
         break;
       case REPEAT:
         QUEST.setRepeatInfo(REPEAT_INFO_ADAPTER.read(in));
         break;
       case TRIGGER:
         QUEST.setTriggerType(TriggerType.valueOf(in.nextString()));
         break;
       case TASKS:
         in.beginArray();
         while (in.hasNext()) {
           QuestTask task = TASK_ADAPTER.read(in);
           if (task != null) {
             QUEST.getTasks().add(task);
           }
         }
         in.endArray();
         break;
       case REWARDS:
         ReflectionHelper.setPrivateValue(
             Quest.class, QUEST, readItemStackArray(in), REWARDS);
         break;
       case REWARDS_CHOICE:
         ReflectionHelper.setPrivateValue(
             Quest.class, QUEST, readItemStackArray(in), REWARDS_CHOICE);
         break;
       case REWARDS_REPUTATION:
         in.beginArray();
         List<Quest.ReputationReward> reputationRewards = new ArrayList<>();
         while (in.hasNext()) {
           Quest.ReputationReward reward = REPUTATION_REWARD_ADAPTER.read(in);
           if (reward != null) reputationRewards.add(reward);
         }
         QUEST.setReputationRewards(reputationRewards);
         in.endArray();
         break;
     }
   }
   in.endObject();
   if (!QUEST.getName().isEmpty()) {
     requirementMapping.put(QUEST, requirement);
     optionMapping.put(QUEST, options);
     return QUEST;
   }
   QuestLine.getActiveQuestLine().quests.remove(QUEST.getId());
   return null;
 }