diff --git a/tools/MapleCashVegaChecker/src/maplecashvegachecker/MapleCashVegaChecker.java b/src/main/java/tools/mapletools/CashVegaChecker.java similarity index 65% rename from tools/MapleCashVegaChecker/src/maplecashvegachecker/MapleCashVegaChecker.java rename to src/main/java/tools/mapletools/CashVegaChecker.java index 220a1fdd24..ffdebc41d6 100644 --- a/tools/MapleCashVegaChecker/src/maplecashvegachecker/MapleCashVegaChecker.java +++ b/src/main/java/tools/mapletools/CashVegaChecker.java @@ -1,57 +1,32 @@ -/* - 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 maplecashvegachecker; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintWriter; +import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.HashSet; import java.util.Set; /** * * @author RonanLana - * - This application main objective is to read Vega-related information from - the item's description report back missing nodes for these items. - - Estimated parse time: 10 seconds + * +This application main objective is to read Vega-related information from +the item's description report back missing nodes for these items. + +Estimated parse time: 10 seconds */ -public class MapleCashVegaChecker { - - private static String wzPath = "../../wz"; - - static PrintWriter printWriter = null; - static InputStreamReader fileReader = null; - static BufferedReader bufferedReader = null; - - static int initialStringLength = 1000; - static int currentItem; - - static byte status = 0; - - static Set vegaItems = new HashSet<>(); - +public class CashVegaChecker { + private static final File OUTPUT_FILE = ToolConstants.getOutputFile("vega_checker_report.txt"); + private static final int INITIAL_STRING_LENGTH = 1000; + private static final Set vegaItems = new HashSet<>(); + + private static PrintWriter printWriter = null; + private static InputStreamReader fileReader = null; + private static BufferedReader bufferedReader = null; + private static int currentItem; + private static byte status = 0; + private static String getName(String token) { int i, j; char[] dest; @@ -61,13 +36,13 @@ public class MapleCashVegaChecker { 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()); } - + private static String getValue(String token) { int i, j; char[] dest; @@ -77,13 +52,13 @@ public class MapleCashVegaChecker { 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()); } - + private static void forwardCursor(int st) { String line = null; @@ -105,16 +80,16 @@ public class MapleCashVegaChecker { status += 1; } } - + private static void translateItemToken(String token) { if(token.contains("/imgdir")) { status -= 1; } else if(token.contains("imgdir")) { status += 1; - + if (status == 2) { - currentItem = Integer.valueOf(getName(token)); + currentItem = Integer.parseInt(getName(token)); } } else { if (status == 2) { @@ -124,7 +99,7 @@ public class MapleCashVegaChecker { } } } - + private static void translateVegaToken(String token) { if(token.contains("/imgdir")) { status -= 1; @@ -139,11 +114,11 @@ public class MapleCashVegaChecker { } } } - + private static void readItemDescriptionFile(File f) { System.out.print("Reading String.wz... "); try { - fileReader = new InputStreamReader(new FileInputStream(f), "UTF-8"); + fileReader = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8); bufferedReader = new BufferedReader(fileReader); String line; @@ -158,11 +133,11 @@ public class MapleCashVegaChecker { } System.out.println(vegaItems.size() + " Vega Scroll items found"); } - + private static void readVegaDescriptionFile(File f) { System.out.println("Reading Etc.wz..."); try { - fileReader = new InputStreamReader(new FileInputStream(f), "UTF-8"); + fileReader = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8); bufferedReader = new BufferedReader(fileReader); String line; @@ -176,38 +151,38 @@ public class MapleCashVegaChecker { ioe.printStackTrace(); } } - + private static void printReportFileHeader() { printWriter.println(" # Report File autogenerated from the MapleCashVegaChecker feature by Ronan Lana."); printWriter.println(" # Generated data takes into account several data info from the server-side WZ.xmls."); printWriter.println(); } - + private static void reportMissingVegaItems() { System.out.println("Reporting results ..."); - + try { - printWriter = new PrintWriter("lib/result.txt", "UTF-8"); - + printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); + printReportFileHeader(); for (Integer itemid : vegaItems) { printWriter.println(" " + itemid); } - + printWriter.close(); } catch (IOException ioe) { ioe.printStackTrace(); } - + } - + public static void main(String[] args) { - - readItemDescriptionFile(new File(wzPath + "/String.wz/Consume.img.xml")); - readVegaDescriptionFile(new File(wzPath + "/Etc.wz/VegaSpell.img.xml")); - + + readItemDescriptionFile(new File(WZFiles.STRING.getFilePath() + "/Consume.img.xml")); + readVegaDescriptionFile(new File(WZFiles.ETC.getFilePath() + "/VegaSpell.img.xml")); + reportMissingVegaItems(); } - + } diff --git a/tools/MapleCashVegaChecker/lib/result.txt b/tools/MapleCashVegaChecker/lib/result.txt deleted file mode 100644 index a1e80b03cf..0000000000 --- a/tools/MapleCashVegaChecker/lib/result.txt +++ /dev/null @@ -1,5 +0,0 @@ - # Report File autogenerated from the MapleCashVegaChecker feature by Ronan Lana. - # Generated data takes into account several data info from the server-side WZ.xmls. - - 2040759 - 2040760