diff --git a/tools/MapleQuestlineFetcher/src/maplequestlinefetcher/MapleQuestlineFetcher.java b/src/main/java/tools/mapletools/QuestlineFetcher.java similarity index 54% rename from tools/MapleQuestlineFetcher/src/maplequestlinefetcher/MapleQuestlineFetcher.java rename to src/main/java/tools/mapletools/QuestlineFetcher.java index 7e360efc0a..cd40f6c83b 100644 --- a/tools/MapleQuestlineFetcher/src/maplequestlinefetcher/MapleQuestlineFetcher.java +++ b/src/main/java/tools/mapletools/QuestlineFetcher.java @@ -1,89 +1,47 @@ -/* - This file is part of the HeavenMS MapleStory Server - Copyleft (L) 2016 - 2019 RonanLana +package tools.mapletools; - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation version 3 as published by - the Free Software Foundation. You may not use, modify or distribute - this program under any other version of the GNU Affero General Public - License. +import provider.wz.WZFiles; - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ -package maplequestlinefetcher; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.sql.Connection; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedList; -import java.util.List; -import java.util.HashMap; -import java.util.Map; -import java.util.HashSet; -import java.util.Set; -import java.util.Stack; +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.*; /** - * * @author RonanLana - - This application parses the Quest.wz file inputted and generates a report showing - all cases where quest script files have not been found for quests that requires a - script file. - As an extension, it highlights missing script files for questlines that hand over - skills as rewards. - - Running it should generate a report file under "lib" folder with the search results. - + *

+ * This application parses the Quest.wz file inputted and generates a report showing + * all cases where quest script files have not been found for quests that requires a + * script file. + * As an extension, it highlights missing script files for questlines that hand over + * skills as rewards. + *

+ * Running it should generate a report file under "output" folder with the search results. */ -public class MapleQuestlineFetcher { - static String actName = "../../wz/Quest.wz/Act.img.xml"; - static String checkName = "../../wz/Quest.wz/Check.img.xml"; - static String directoryName = "../.."; - static String newFile = "lib/QuestReport.txt"; +public class QuestlineFetcher { + private static final File OUTPUT_FILE = ToolConstants.getOutputFile("questline_report.txt"); + private static final String ACT_NAME = WZFiles.QUEST.getFilePath() + "/Act.img.xml"; + private static final String CHECK_NAME = WZFiles.QUEST.getFilePath() + "/Check.img.xml"; + private static final int INITIAL_STRING_LENGTH = 50; + + private static final Stack skillObtainableQuests = new Stack<>(); + private static final Set scriptedQuestFiles = new HashSet<>(); + private static final Set expiredQuests = new HashSet<>(); + private static final Map> questDependencies = new HashMap<>(); + private static final Set nonScriptedQuests = new HashSet<>(); + private static final Set skillObtainableNonScriptedQuests = new HashSet<>(); + + private static PrintWriter printWriter = null; + private static InputStreamReader fileReader = null; + private static BufferedReader bufferedReader = null; + private static byte status = 0; + private static int questId = -1; + private static int isCompleteState = 0; + private static boolean isScriptedQuest; + private static boolean isExpiredQuest; + private static List questDependencyList; + private static int curQuestId; + private static int curQuestState; - static Connection con = null; - static PrintWriter printWriter = null; - static InputStreamReader fileReader = null; - static BufferedReader bufferedReader = null; - - static int initialLength = 200; - static int initialStringLength = 50; - - static byte status = 0; - static int questId = -1; - static int isCompleteState = 0; - static boolean isScriptedQuest; - static boolean isExpiredQuest; - static List questDependencyList; - - static int curQuestId; - static int curQuestState; - - static Stack skillObtainableQuests = new Stack<>(); - static Set scriptedQuestFiles = new HashSet<>(); - static Set expiredQuests = new HashSet<>(); - - static Map> questDependencies = new HashMap<>(); - - static Set nonScriptedQuests = new HashSet<>(); - static Set skillObtainableNonScriptedQuests = new HashSet<>(); - private static String getName(String token) { int i, j; char[] dest; @@ -93,13 +51,13 @@ public class MapleQuestlineFetcher { i = token.indexOf("\"", i) + 1; //lower bound of the string j = token.indexOf("\"", i); //upper bound - dest = new char[initialStringLength]; + dest = new char[INITIAL_STRING_LENGTH]; token.getChars(i, j, dest, 0); d = new String(dest); - return(d.trim()); + return (d.trim()); } - + private static String getValue(String token) { int i, j; char[] dest; @@ -109,108 +67,97 @@ public class MapleQuestlineFetcher { i = token.indexOf("\"", i) + 1; //lower bound of the string j = token.indexOf("\"", i); //upper bound - dest = new char[initialStringLength]; + dest = new char[INITIAL_STRING_LENGTH]; token.getChars(i, j, dest, 0); d = new String(dest); - return(d.trim()); + return (d.trim()); } - + private static void forwardCursor(int st) { String line = null; try { - while(status >= st && (line = bufferedReader.readLine()) != null) { + while (status >= st && (line = bufferedReader.readLine()) != null) { simpleToken(line); } - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); } } private static void simpleToken(String token) { - if(token.contains("/imgdir")) { + if (token.contains("/imgdir")) { status -= 1; - } - else if(token.contains("imgdir")) { + } else if (token.contains("imgdir")) { status += 1; } } - + private static void translateTokenCheck(String token) { String d; - - if(token.contains("/imgdir")) { + + if (token.contains("/imgdir")) { status -= 1; - - if(status == 1) { + + if (status == 1) { evaluateCurrentQuest(); - } - else if(status == 4) { + } else if (status == 4) { evaluateCurrentQuestDependency(); } - } - else if(token.contains("imgdir")) { - if(status == 1) { //getting QuestId + } else if (token.contains("imgdir")) { + if (status == 1) { //getting QuestId d = getName(token); questId = Integer.parseInt(d); - + isScriptedQuest = false; isExpiredQuest = false; questDependencyList = new LinkedList<>(); - } - else if(status == 2) { //start/complete + } else if (status == 2) { //start/complete d = getName(token); isCompleteState = Integer.parseInt(d); - } - else if(status == 3) { - if(isCompleteState == 1 || !token.contains("quest")) { + } else if (status == 3) { + if (isCompleteState == 1 || !token.contains("quest")) { forwardCursor(status); } } - + status += 1; - } - else { - if(status == 3) { + } else { + if (status == 3) { d = getName(token); - - if(d.contains("script")) { + + if (d.contains("script")) { isScriptedQuest = true; - } else if(d.contains("end")) { + } else if (d.contains("end")) { isExpiredQuest = true; } - } - else if(status == 5) { + } else if (status == 5) { readQuestLabel(token); } } } - + private static void translateTokenAct(String token) { String d; - - if(token.contains("/imgdir")) { + + if (token.contains("/imgdir")) { status -= 1; - } - else if(token.contains("imgdir")) { - if(status == 1) { //getting QuestId + } else if (token.contains("imgdir")) { + if (status == 1) { //getting QuestId d = getName(token); questId = Integer.parseInt(d); - } - else if(status == 2) { //start/complete + } else if (status == 2) { //start/complete d = getName(token); isCompleteState = Integer.parseInt(d); - } - else if(status == 3) { - if(isCompleteState == 1 && token.contains("skill")) { + } else if (status == 3) { + if (isCompleteState == 1 && token.contains("skill")) { skillObtainableQuests.add(questId); } - + forwardCursor(status); } - + status += 1; } } @@ -219,34 +166,29 @@ public class MapleQuestlineFetcher { String name = getName(token); String value = getValue(token); - switch(name) { - case "id": - curQuestId = Integer.parseInt(value); - break; - - case "state": - curQuestState = Integer.parseInt(value); - break; + switch (name) { + case "id" -> curQuestId = Integer.parseInt(value); + case "state" -> curQuestState = Integer.parseInt(value); } } - + private static void evaluateCurrentQuestDependency() { - if(curQuestState == 2) { + if (curQuestState == 2) { questDependencyList.add(curQuestId); } } - + private static void evaluateCurrentQuest() { - if(isScriptedQuest && !scriptedQuestFiles.contains(questId)) { + if (isScriptedQuest && !scriptedQuestFiles.contains(questId)) { nonScriptedQuests.add(questId); } - if(isExpiredQuest) { + if (isExpiredQuest) { expiredQuests.add(questId); } - + questDependencies.put(questId, questDependencyList); } - + private static void instantiateQuestScriptFiles(String directoryName) { File directory = new File(directoryName); @@ -255,130 +197,126 @@ public class MapleQuestlineFetcher { for (File file : fList) { if (file.isFile()) { String fname = file.getName(); - + try { Integer questid = Integer.parseInt(fname.substring(0, fname.indexOf('.'))); scriptedQuestFiles.add(questid); - } catch(NumberFormatException nfe) {} + } catch (NumberFormatException nfe) { + } } } } - + private static void readQuestsWithMissingScripts() throws IOException { String line; - - fileReader = new InputStreamReader(new FileInputStream(checkName), "UTF-8"); + + fileReader = new InputStreamReader(new FileInputStream(CHECK_NAME), StandardCharsets.UTF_8); bufferedReader = new BufferedReader(fileReader); - while((line = bufferedReader.readLine()) != null) { + while ((line = bufferedReader.readLine()) != null) { translateTokenCheck(line); } bufferedReader.close(); fileReader.close(); } - + private static void readQuestsWithSkillReward() throws IOException { String line; - - fileReader = new InputStreamReader(new FileInputStream(actName), "UTF-8"); + + fileReader = new InputStreamReader(new FileInputStream(ACT_NAME), StandardCharsets.UTF_8); bufferedReader = new BufferedReader(fileReader); - while((line = bufferedReader.readLine()) != null) { + while ((line = bufferedReader.readLine()) != null) { translateTokenAct(line); } bufferedReader.close(); fileReader.close(); } - + private static void calculateSkillRelatedMissingQuestScripts() { Stack frontierQuests = skillObtainableQuests; Set solvedQuests = new HashSet<>(); - - while(!frontierQuests.isEmpty()) { + + while (!frontierQuests.isEmpty()) { Integer questid = frontierQuests.pop(); solvedQuests.add(questid); - - if(nonScriptedQuests.contains(questid)) { + + if (nonScriptedQuests.contains(questid)) { skillObtainableNonScriptedQuests.add(questid); nonScriptedQuests.remove(questid); } - + List questDependency = questDependencies.get(questid); - for(Integer i : questDependency) { - if(!solvedQuests.contains(i)) { + for (Integer i : questDependency) { + if (!solvedQuests.contains(i)) { frontierQuests.add(i); } } } } - + private static void printReportFileHeader() { printWriter.println(" # Report File autogenerated from the MapleQuestlineFetcher feature by Ronan Lana."); printWriter.println(" # Generated data takes into account several data info from the server-side WZ.xmls."); printWriter.println(); } - + private static List getSortedListEntries(Set set) { List list = new ArrayList<>(set); Collections.sort(list); - + return list; } - + private static void printReportFileResults() { - if(!skillObtainableNonScriptedQuests.isEmpty()) { + if (!skillObtainableNonScriptedQuests.isEmpty()) { printWriter.println("SKILL-RELATED NON-SCRIPTED QUESTS"); - for(Integer nsq : getSortedListEntries(skillObtainableNonScriptedQuests)) { + for (Integer nsq : getSortedListEntries(skillObtainableNonScriptedQuests)) { printWriter.println(" " + nsq + (expiredQuests.contains(nsq) ? " EXPIRED" : "")); } - + printWriter.println(); } - + printWriter.println("\nCOMMON NON-SCRIPTED QUESTS"); - for(Integer nsq : getSortedListEntries(nonScriptedQuests)) { + for (Integer nsq : getSortedListEntries(nonScriptedQuests)) { printWriter.println(" " + nsq + (expiredQuests.contains(nsq) ? " EXPIRED" : "")); } } - - private static void ReportQuestlineData() { + + private static void reportQuestlineData() { // This will reference one line at a time - + try { System.out.println("Reading quest scripts..."); - instantiateQuestScriptFiles(directoryName + "/scripts/quest"); - + instantiateQuestScriptFiles(ToolConstants.SCRIPTS_PATH + "/quest"); + System.out.println("Reading WZs..."); readQuestsWithSkillReward(); readQuestsWithMissingScripts(); - + System.out.println("Calculating skill related quests..."); calculateSkillRelatedMissingQuestScripts(); - + System.out.println("Reporting results..."); - printWriter = new PrintWriter(newFile, "UTF-8"); - + printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); + printReportFileHeader(); printReportFileResults(); - + printWriter.close(); System.out.println("Done!"); - } - - catch(FileNotFoundException ex) { + } catch (FileNotFoundException ex) { System.out.println("Unable to open quest file."); - } - catch(IOException ex) { + } catch (IOException ex) { System.out.println("Error reading quest file."); - } - - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); } } - + /* private static List>> getSortedMapEntries(Map> map) { List>> list = new ArrayList<>(map.size()); @@ -387,27 +325,27 @@ public class MapleQuestlineFetcher { for(Integer i : e.getValue()) { il.add(i); } - + Collections.sort(il, new Comparator() { @Override public int compare(Integer o1, Integer o2) { return o1 - o2; } }); - + list.add(new Pair<>(e.getKey(), il)); } - + Collections.sort(list, new Comparator>>() { @Override public int compare(Pair> o1, Pair> o2) { return o1.getLeft() - o2.getLeft(); } }); - + return list; } - + private static void DumpQuestlineData() { for(Pair> questDependency : getSortedMapEntries(questDependencies)) { if(!questDependency.right.isEmpty()) { @@ -416,9 +354,9 @@ public class MapleQuestlineFetcher { } } */ - + public static void main(String[] args) { - ReportQuestlineData(); + reportQuestlineData(); } - } + diff --git a/tools/MapleQuestlineFetcher/lib/QuestReport.txt b/tools/MapleQuestlineFetcher/lib/QuestReport.txt deleted file mode 100644 index c4ef7db9fb..0000000000 --- a/tools/MapleQuestlineFetcher/lib/QuestReport.txt +++ /dev/null @@ -1,373 +0,0 @@ - # Report File autogenerated from the MapleQuestlineFetcher feature by Ronan Lana. - # Generated data takes into account several data info from the server-side WZ.xmls. - -SKILL-RELATED NON-SCRIPTED QUESTS - 20500 EXPIRED - 20502 EXPIRED - - -COMMON NON-SCRIPTED QUESTS - 1028 - 1048 EXPIRED - 1049 EXPIRED - 1050 EXPIRED - 1051 EXPIRED - 1052 EXPIRED - 1053 EXPIRED - 1054 EXPIRED - 2147 EXPIRED - 2228 - 2232 - 2233 - 2234 - 2238 - 2245 - 2257 - 2258 - 2259 - 2260 - 2291 - 2338 - 3305 EXPIRED - 3306 EXPIRED - 3529 - 3714 - 4482 EXPIRED - 4483 EXPIRED - 4490 EXPIRED - 4676 EXPIRED - 6700 EXPIRED - 8247 EXPIRED - 9432 EXPIRED - 9633 EXPIRED - 9680 EXPIRED - 9682 EXPIRED - 9683 EXPIRED - 9684 EXPIRED - 9685 EXPIRED - 9690 EXPIRED - 9691 EXPIRED - 9692 EXPIRED - 9693 EXPIRED - 9694 EXPIRED - 9695 EXPIRED - 9696 EXPIRED - 9697 EXPIRED - 9698 EXPIRED - 9699 EXPIRED - 9700 EXPIRED - 9701 EXPIRED - 9702 EXPIRED - 9703 EXPIRED - 9730 EXPIRED - 9731 EXPIRED - 9732 EXPIRED - 9733 EXPIRED - 9734 EXPIRED - 9735 EXPIRED - 9745 EXPIRED - 9746 EXPIRED - 9747 EXPIRED - 9840 EXPIRED - 9841 EXPIRED - 9842 EXPIRED - 9844 EXPIRED - 9845 EXPIRED - 9846 EXPIRED - 9847 EXPIRED - 9849 EXPIRED - 9850 EXPIRED - 9851 EXPIRED - 9860 EXPIRED - 9875 EXPIRED - 9878 EXPIRED - 9880 EXPIRED - 9881 EXPIRED - 9882 EXPIRED - 9883 EXPIRED - 9884 EXPIRED - 9885 EXPIRED - 9887 EXPIRED - 9890 EXPIRED - 9891 EXPIRED - 9892 EXPIRED - 9893 EXPIRED - 9900 EXPIRED - 9901 EXPIRED - 9902 EXPIRED - 9903 EXPIRED - 9904 EXPIRED - 9905 EXPIRED - 9906 EXPIRED - 9907 EXPIRED - 9908 EXPIRED - 9909 EXPIRED - 9920 EXPIRED - 9922 EXPIRED - 9924 EXPIRED - 9925 EXPIRED - 9926 EXPIRED - 9927 EXPIRED - 9928 EXPIRED - 9929 EXPIRED - 9930 EXPIRED - 9931 EXPIRED - 9932 EXPIRED - 9933 EXPIRED - 9934 EXPIRED - 9935 EXPIRED - 9936 EXPIRED - 9937 EXPIRED - 9938 EXPIRED - 9939 EXPIRED - 9943 EXPIRED - 9947 EXPIRED - 9950 EXPIRED - 9951 EXPIRED - 9961 EXPIRED - 9965 EXPIRED - 9970 EXPIRED - 9980 EXPIRED - 9981 EXPIRED - 9982 EXPIRED - 9983 EXPIRED - 9984 EXPIRED - 9985 EXPIRED - 9990 EXPIRED - 9991 EXPIRED - 9997 EXPIRED - 10002 EXPIRED - 10008 EXPIRED - 10010 EXPIRED - 10011 EXPIRED - 10012 EXPIRED - 10014 EXPIRED - 10034 EXPIRED - 10036 EXPIRED - 10037 EXPIRED - 10039 EXPIRED - 10043 EXPIRED - 10046 EXPIRED - 10050 EXPIRED - 10052 EXPIRED - 10059 EXPIRED - 10066 EXPIRED - 10069 EXPIRED - 10074 EXPIRED - 10075 EXPIRED - 10076 EXPIRED - 10077 EXPIRED - 10078 EXPIRED - 10079 EXPIRED - 10082 EXPIRED - 10083 EXPIRED - 10084 EXPIRED - 10085 EXPIRED - 10086 EXPIRED - 10087 EXPIRED - 10088 EXPIRED - 10089 EXPIRED - 10090 EXPIRED - 10091 EXPIRED - 10092 EXPIRED - 10093 EXPIRED - 10094 EXPIRED - 10095 EXPIRED - 10096 EXPIRED - 10097 EXPIRED - 10098 EXPIRED - 10099 EXPIRED - 10100 EXPIRED - 10101 EXPIRED - 10102 EXPIRED - 10103 EXPIRED - 10104 EXPIRED - 10105 EXPIRED - 10106 EXPIRED - 10108 EXPIRED - 10110 EXPIRED - 10206 EXPIRED - 10207 EXPIRED - 10208 EXPIRED - 10209 EXPIRED - 10210 EXPIRED - 10211 EXPIRED - 10212 EXPIRED - 10213 EXPIRED - 10214 EXPIRED - 10215 EXPIRED - 10216 EXPIRED - 10217 EXPIRED - 10218 EXPIRED - 10219 EXPIRED - 10220 EXPIRED - 10222 EXPIRED - 10224 EXPIRED - 10231 EXPIRED - 10240 EXPIRED - 10241 EXPIRED - 10242 EXPIRED - 10243 EXPIRED - 10244 EXPIRED - 10245 EXPIRED - 10246 EXPIRED - 10247 EXPIRED - 10248 EXPIRED - 10249 EXPIRED - 10250 EXPIRED - 10251 EXPIRED - 10252 EXPIRED - 10253 EXPIRED - 10254 EXPIRED - 10255 EXPIRED - 10256 EXPIRED - 10260 EXPIRED - 10261 EXPIRED - 10262 EXPIRED - 10263 EXPIRED - 10264 EXPIRED - 10265 EXPIRED - 10266 EXPIRED - 10267 EXPIRED - 10268 EXPIRED - 10270 EXPIRED - 10271 EXPIRED - 10272 EXPIRED - 10274 EXPIRED - 10275 EXPIRED - 10276 EXPIRED - 10277 EXPIRED - 10278 EXPIRED - 10279 EXPIRED - 10280 EXPIRED - 10281 EXPIRED - 10282 EXPIRED - 10283 EXPIRED - 10284 EXPIRED - 10287 EXPIRED - 10300 EXPIRED - 10301 EXPIRED - 10302 EXPIRED - 10311 EXPIRED - 10312 EXPIRED - 10313 EXPIRED - 10314 EXPIRED - 10315 EXPIRED - 10316 EXPIRED - 10317 EXPIRED - 10318 EXPIRED - 10319 EXPIRED - 10320 EXPIRED - 10321 EXPIRED - 10324 EXPIRED - 10325 EXPIRED - 10326 EXPIRED - 10327 EXPIRED - 10329 EXPIRED - 10330 EXPIRED - 10331 EXPIRED - 10332 EXPIRED - 10333 EXPIRED - 10340 EXPIRED - 10341 EXPIRED - 10342 EXPIRED - 10344 EXPIRED - 10345 EXPIRED - 10346 EXPIRED - 10347 EXPIRED - 10348 EXPIRED - 10349 EXPIRED - 10350 EXPIRED - 10351 EXPIRED - 10352 EXPIRED - 10353 EXPIRED - 10354 EXPIRED - 10355 EXPIRED - 10356 EXPIRED - 10360 EXPIRED - 10370 EXPIRED - 10380 EXPIRED - 10394 EXPIRED - 10395 EXPIRED - 10396 EXPIRED - 10397 EXPIRED - 10398 EXPIRED - 10400 EXPIRED - 10401 EXPIRED - 10415 EXPIRED - 10417 EXPIRED - 10418 EXPIRED - 10419 EXPIRED - 10420 EXPIRED - 10450 EXPIRED - 10451 EXPIRED - 10452 EXPIRED - 10453 EXPIRED - 10454 EXPIRED - 10455 EXPIRED - 10456 EXPIRED - 10457 EXPIRED - 10470 EXPIRED - 19000 - 19001 - 19002 - 19005 EXPIRED - 19006 EXPIRED - 20015 - 20020 - 20400 - 20401 - 20405 - 20406 - 20408 - 20506 EXPIRED - 20507 EXPIRED - 20509 EXPIRED - 21303 - 28004 EXPIRED - 28117 EXPIRED - 28118 EXPIRED - 28131 EXPIRED - 28137 EXPIRED - 28138 EXPIRED - 28139 EXPIRED - 28140 EXPIRED - 28141 EXPIRED - 28142 EXPIRED - 28143 EXPIRED - 28144 EXPIRED - 28145 EXPIRED - 28146 EXPIRED - 28147 EXPIRED - 28148 EXPIRED - 28149 EXPIRED - 28150 EXPIRED - 28151 EXPIRED - 28152 EXPIRED - 28153 EXPIRED - 28154 EXPIRED - 28155 EXPIRED - 28156 EXPIRED - 28157 EXPIRED - 28158 EXPIRED - 28159 EXPIRED - 28160 EXPIRED - 28161 EXPIRED - 28284 EXPIRED - 28285 EXPIRED - 28286 EXPIRED - 28304 EXPIRED - 28311 EXPIRED - 28318 EXPIRED - 28326 EXPIRED - 28327 EXPIRED - 28328 EXPIRED - 28333 EXPIRED - 28337 EXPIRED - 29500 - 29501 - 29502 - 29503 - 29505 - 29506 - 29508 diff --git a/tools/MapleQuestlineFetcher/src/maplequestlinefetcher/Pair.java b/tools/MapleQuestlineFetcher/src/maplequestlinefetcher/Pair.java deleted file mode 100644 index ae652848a9..0000000000 --- a/tools/MapleQuestlineFetcher/src/maplequestlinefetcher/Pair.java +++ /dev/null @@ -1,121 +0,0 @@ -/* -This file is part of the OdinMS Maple Story Server -Copyright (C) 2008 ~ 2010 Patrick Huy -Matthias Butz -Jan Christian Meyer - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License version 3 -as published by the Free Software Foundation. You may not use, modify -or distribute this program under any other version of the -GNU Affero General Public License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . - */ -package maplequestlinefetcher; - -/** - * Represents a pair of values. - * - * @author Frz - * @since Revision 333 - * @version 1.0 - * - * @param The type of the left value. - * @param The type of the right value. - */ -public class Pair { - - public E left; - public F right; - - /** - * Class constructor - pairs two objects together. - * - * @param left The left object. - * @param right The right object. - */ - public Pair(E left, F right) { - this.left = left; - this.right = right; - } - - /** - * Gets the left value. - * - * @return The left value. - */ - public E getLeft() { - return left; - } - - /** - * Gets the right value. - * - * @return The right value. - */ - public F getRight() { - return right; - } - - /** - * Turns the pair into a string. - * - * @return Each value of the pair as a string joined with a colon. - */ - @Override - public String toString() { - return left.toString() + ":" + right.toString(); - } - - /** - * Gets the hash code of this pair. - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((left == null) ? 0 : left.hashCode()); - result = prime * result + ((right == null) ? 0 : right.hashCode()); - return result; - } - - /** - * Checks to see if two pairs are equal. - */ - @SuppressWarnings("unchecked") - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final Pair other = (Pair) obj; - if (left == null) { - if (other.left != null) { - return false; - } - } else if (!left.equals(other.left)) { - return false; - } - if (right == null) { - if (other.right != null) { - return false; - } - } else if (!right.equals(other.right)) { - return false; - } - return true; - } -} \ No newline at end of file