Merge pull request #1 from truongdatnhan/eclipse

Upgrade to to File NIO
This commit is contained in:
truongdatnhan
2022-07-30 16:18:57 +07:00
committed by GitHub
37 changed files with 565 additions and 506 deletions

10
.gitignore vendored
View File

@@ -1,4 +1,4 @@
/logs/** /logs/**
.idea/ .idea/
*.iml *.iml
/target /target
@@ -7,6 +7,12 @@
/build/ /build/
/dist/ /dist/
/nbproject/ /nbproject/
/.settings
/out /out
*.onetoc2 *.onetoc2
# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath

View File

@@ -1,4 +1,4 @@
2000000 - Red Potion - A potion made out of red herbs.\nRecovers 50 HP. 2000000 - Red Potion - A potion made out of red herbs.\nRecovers 50 HP.
2000001 - Orange Potion - A concentrated potion made out of red herbs.\nRecovers 150 HP. 2000001 - Orange Potion - A concentrated potion made out of red herbs.\nRecovers 150 HP.
2000002 - White Potion - A highly-concentrated potion made out of red herbs.\nRecovers 300 HP. 2000002 - White Potion - A highly-concentrated potion made out of red herbs.\nRecovers 300 HP.
2000003 - Blue Potion - A potion made out of blue herbs.\nRecovers 100 MP. 2000003 - Blue Potion - A potion made out of blue herbs.\nRecovers 100 MP.

View File

@@ -25,15 +25,15 @@
<!-- Dependencies --> <!-- Dependencies -->
<slf4j-api.version>1.7.36</slf4j-api.version> <!-- Logging facade --> <slf4j-api.version>1.7.36</slf4j-api.version> <!-- Logging facade -->
<log4j.version>2.17.1</log4j.version> <!-- Slf4j implementation --> <log4j.version>2.18.0</log4j.version> <!-- Slf4j implementation -->
<graalvm.version>21.1.0</graalvm.version> <!-- ScriptEngine implementation --> <graalvm.version>22.2.0</graalvm.version> <!-- ScriptEngine implementation -->
<netty.version>4.1.74.Final</netty.version> <!-- Networking --> <netty.version>4.1.79.Final</netty.version> <!-- Networking -->
<junit.version>5.8.2</junit.version> <!-- Unit test --> <junit.version>5.8.2</junit.version> <!-- Unit test -->
<yamlbeans.version>1.15</yamlbeans.version> <!-- Config file --> <yamlbeans.version>1.15</yamlbeans.version> <!-- Config file -->
<jcip-annotations.version>1.0</jcip-annotations.version> <!-- Annotations for concurrency documentation --> <jcip-annotations.version>1.0</jcip-annotations.version> <!-- Annotations for concurrency documentation -->
<commons-io.version>2.11.0</commons-io.version> <!-- Util library used by some of our tools --> <commons-io.version>2.11.0</commons-io.version> <!-- Util library used by some of our tools -->
<HikariCP.version>5.0.1</HikariCP.version> <!-- Database connection pool --> <HikariCP.version>5.0.1</HikariCP.version> <!-- Database connection pool -->
<mysql-connector-java.version>8.0.28</mysql-connector-java.version> <!-- MySQL JDBC driver --> <mysql-connector-java.version>8.0.29</mysql-connector-java.version> <!-- MySQL JDBC driver -->
</properties> </properties>
<dependencies> <dependencies>

View File

@@ -76,44 +76,10 @@ public enum Stat {
} }
public static Stat getByString(String type) { public static Stat getByString(String type) {
if (type.equals("SKIN")) { for (Stat stat : Stat.values()) {
return SKIN; if (stat.name().equals(type)) {
} else if (type.equals("FACE")) { return stat;
return FACE; }
} else if (type.equals("HAIR")) {
return HAIR;
} else if (type.equals("LEVEL")) {
return LEVEL;
} else if (type.equals("JOB")) {
return JOB;
} else if (type.equals("STR")) {
return STR;
} else if (type.equals("DEX")) {
return DEX;
} else if (type.equals("INT")) {
return INT;
} else if (type.equals("LUK")) {
return LUK;
} else if (type.equals("HP")) {
return HP;
} else if (type.equals("MAXHP")) {
return MAXHP;
} else if (type.equals("MP")) {
return MP;
} else if (type.equals("MAXMP")) {
return MAXMP;
} else if (type.equals("AVAILABLEAP")) {
return AVAILABLEAP;
} else if (type.equals("AVAILABLESP")) {
return AVAILABLESP;
} else if (type.equals("EXP")) {
return EXP;
} else if (type.equals("FAME")) {
return FAME;
} else if (type.equals("MESO")) {
return MESO;
} else if (type.equals("PET")) {
return PET;
} }
return null; return null;
} }

View File

@@ -25,9 +25,10 @@ import provider.wz.WZFiles;
import provider.wz.XMLWZFile; import provider.wz.XMLWZFile;
import java.io.File; import java.io.File;
import java.nio.file.Path;
public class DataProviderFactory { public class DataProviderFactory {
private static DataProvider getWZ(File in) { private static DataProvider getWZ(Path in) {
return new XMLWZFile(in); return new XMLWZFile(in);
} }

View File

@@ -1,6 +1,8 @@
package provider.wz; package provider.wz;
import java.io.File; import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
public enum WZFiles { public enum WZFiles {
QUEST("Quest"), QUEST("Quest"),
@@ -25,12 +27,12 @@ public enum WZFiles {
this.fileName = name + ".wz"; this.fileName = name + ".wz";
} }
public File getFile() { public Path getFile() {
return new File(DIRECTORY, fileName); return Paths.get(DIRECTORY).resolve(fileName);
} }
public String getFilePath() { public String getFilePath() {
return getFile().getPath(); return getFile().toString();
} }
private static String getWzDirectory() { private static String getWzDirectory() {

View File

@@ -37,15 +37,16 @@ import java.awt.*;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
public class XMLDomMapleData implements Data { public class XMLDomMapleData implements Data {
private final Node node; private final Node node;
private File imageDataDir; private Path imageDataDir;
public XMLDomMapleData(FileInputStream fis, File imageDataDir) { public XMLDomMapleData(FileInputStream fis, Path imageDataDir) {
try { try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
@@ -91,7 +92,7 @@ public class XMLDomMapleData implements Data {
} }
XMLDomMapleData ret = new XMLDomMapleData(myNode); XMLDomMapleData ret = new XMLDomMapleData(myNode);
ret.imageDataDir = new File(imageDataDir, getName() + "/" + path).getParentFile(); ret.imageDataDir = imageDataDir.resolve(getName().trim()).resolve(path).getParent();
return ret; return ret;
} }
@@ -103,12 +104,12 @@ public class XMLDomMapleData implements Data {
for (int i = 0; i < childNodes.getLength(); i++) { for (int i = 0; i < childNodes.getLength(); i++) {
Node childNode = childNodes.item(i); Node childNode = childNodes.item(i);
if (childNode.getNodeType() == Node.ELEMENT_NODE) { if (childNode.getNodeType() == Node.ELEMENT_NODE) {
XMLDomMapleData child = new XMLDomMapleData(childNode); XMLDomMapleData child = new XMLDomMapleData(childNode);
child.imageDataDir = new File(imageDataDir, getName()); child.imageDataDir = imageDataDir.resolve(getName().trim());
ret.add(child); ret.add(child);
} }
} }
return ret; return ret;
} }
@@ -193,7 +194,7 @@ public class XMLDomMapleData implements Data {
return null; return null;
} }
XMLDomMapleData parentData = new XMLDomMapleData(parentNode); XMLDomMapleData parentData = new XMLDomMapleData(parentNode);
parentData.imageDataDir = imageDataDir.getParentFile(); parentData.imageDataDir = imageDataDir.getParent();
return parentData; return parentData;
} }

View File

@@ -29,53 +29,59 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class XMLWZFile implements DataProvider { public class XMLWZFile implements DataProvider {
private final File root; private final Path root;
private final WZDirectoryEntry rootForNavigation; private final WZDirectoryEntry rootForNavigation;
public XMLWZFile(File fileIn) { public XMLWZFile(Path fileIn) {
root = fileIn; root = fileIn;
rootForNavigation = new WZDirectoryEntry(fileIn.getName(), 0, 0, null); rootForNavigation = new WZDirectoryEntry(fileIn.getFileName().toString(), 0, 0, null);
fillMapleDataEntitys(root, rootForNavigation); fillMapleDataEntitys(root, rootForNavigation);
} }
private void fillMapleDataEntitys(File lroot, WZDirectoryEntry wzdir) { private void fillMapleDataEntitys(Path lroot, WZDirectoryEntry wzdir) {
for (File file : lroot.listFiles()) {
String fileName = file.getName(); try (DirectoryStream<Path> stream = Files.newDirectoryStream(lroot)) {
if (file.isDirectory() && !fileName.endsWith(".img")) { for (Path path : stream) {
WZDirectoryEntry newDir = new WZDirectoryEntry(fileName, 0, 0, wzdir); String fileName = path.getFileName().toString();
wzdir.addDirectory(newDir); if(Files.isDirectory(path) && !fileName.endsWith(".img") ) {
fillMapleDataEntitys(file, newDir); WZDirectoryEntry newDir = new WZDirectoryEntry(fileName, 0, 0, wzdir);
} else if (fileName.endsWith(".xml")) { wzdir.addDirectory(newDir);
wzdir.addFile(new WZFileEntry(fileName.substring(0, fileName.length() - 4), 0, 0, wzdir)); fillMapleDataEntitys(path, newDir);
} else if (fileName.endsWith(".xml")) {
wzdir.addFile(new WZFileEntry(fileName.substring(0, fileName.length() - 4), 0, 0, wzdir));
}
} }
} } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
@Override @Override
public synchronized Data getData(String path) { public synchronized Data getData(String path) {
File dataFile = new File(root, path + ".xml"); Path dataFile = root.resolve(path + ".xml");
File imageDataDir = new File(root, path); //File(root, path + ".xml");
if (!dataFile.exists()) { Path imageDataDir = root.resolve(path);
//File imageDataDir = new File(root, path);
if (!Files.exists(dataFile)) {
return null;//bitches return null;//bitches
} }
FileInputStream fis;
try {
fis = new FileInputStream(dataFile);
} catch (FileNotFoundException e) {
throw new RuntimeException("Datafile " + path + " does not exist in " + root.getAbsolutePath());
}
final XMLDomMapleData domMapleData; final XMLDomMapleData domMapleData;
try { try(FileInputStream fis = new FileInputStream(dataFile.toString()) ) {
domMapleData = new XMLDomMapleData(fis, imageDataDir.getParentFile()); domMapleData = new XMLDomMapleData(fis, imageDataDir.getParent());
} finally { }catch (FileNotFoundException e) {
try { throw new RuntimeException("Datafile " + path + " does not exist in " + root.toAbsolutePath());
fis.close(); }catch (IOException e) {
} catch (IOException e) { throw new RuntimeException(e);
throw new RuntimeException(e);
}
} }
return domMapleData; return domMapleData;
} }
@@ -83,4 +89,4 @@ public class XMLWZFile implements DataProvider {
public DataDirectoryEntry getRoot() { public DataDirectoryEntry getRoot() {
return rootForNavigation; return rootForNavigation;
} }
} }

View File

@@ -24,9 +24,12 @@ import tools.Pair;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -171,7 +174,7 @@ public class ArrowFetcher {
if (!existingEntries.isEmpty()) { if (!existingEntries.isEmpty()) {
List<int[]> entryValues = getArrowEntryValues(existingEntries); List<int[]> entryValues = getArrowEntryValues(existingEntries);
printWriter = new PrintWriter(ToolConstants.getOutputFile(OUTPUT_FILE_NAME), StandardCharsets.UTF_8); printWriter = new PrintWriter(Files.newOutputStream(ToolConstants.getOutputFile(OUTPUT_FILE_NAME)));
printSqlHeader(); printSqlHeader();
for (int[] arrowEntry : entryValues) { for (int[] arrowEntry : entryValues) {
@@ -211,10 +214,15 @@ public class ArrowFetcher {
} }
public static void main(String[] args) { public static void main(String[] args) {
Instant instantStarted = Instant.now();
// load mob stats from WZ // load mob stats from WZ
mobStats = MonsterStatFetcher.getAllMonsterStats(); mobStats = MonsterStatFetcher.getAllMonsterStats();
calcAllMobsArrowRange(); calcAllMobsArrowRange();
updateMobsArrowRange(); updateMobsArrowRange();
Instant instantStopped = Instant.now();
Duration durationBetween = Duration.between(instantStarted, instantStopped);
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
} }
} }

View File

@@ -4,6 +4,11 @@ import provider.wz.WZFiles;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -129,21 +134,21 @@ public class BossHpBarFetcher {
} }
private static void readBossHpBarData() throws IOException { private static void readBossHpBarData() throws IOException {
String line;
final File mobDirectory = WZFiles.MOB.getFile(); final Path mobDirectory = WZFiles.MOB.getFile();
for (File file : mobDirectory.listFiles()) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(mobDirectory)) {
if (file.isFile()) { for (Path path : stream) {
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8); if(Files.isRegularFile(path)) {
bufferedReader = new BufferedReader(fileReader); try(BufferedReader br = Files.newBufferedReader(path)) {
bufferedReader = br;
while ((line = bufferedReader.readLine()) != null) { String line;
translateToken(line); while ((line = bufferedReader.readLine()) != null) {
} translateToken(line);
}
bufferedReader.close(); }
fileReader.close(); }
} }
} }
} }
@@ -162,17 +167,16 @@ public class BossHpBarFetcher {
private static void reportBossHpBarData() { private static void reportBossHpBarData() {
// This will reference one line at a time // This will reference one line at a time
try { try(final PrintWriter printWriter = new PrintWriter(Files.newOutputStream(ToolConstants.getOutputFile(OUTPUT_FILE_NAME)))) {
System.out.println("Reading WZs..."); System.out.println("Reading WZs...");
readBossHpBarData(); readBossHpBarData();
System.out.println("Reporting results..."); System.out.println("Reporting results...");
final PrintWriter printWriter = new PrintWriter(ToolConstants.getOutputFile(OUTPUT_FILE_NAME), StandardCharsets.UTF_8);
printReportFileHeader(printWriter); printReportFileHeader(printWriter);
printReportFileResults(printWriter); printReportFileResults(printWriter);
printWriter.close();
System.out.println("Done!"); System.out.println("Done!");
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
System.out.println("Unable to open mob file."); System.out.println("Unable to open mob file.");
@@ -184,7 +188,12 @@ public class BossHpBarFetcher {
} }
public static void main(String[] args) { public static void main(String[] args) {
Instant instantStarted = Instant.now();
reportBossHpBarData(); reportBossHpBarData();
Instant instantStopped = Instant.now();
Duration durationBetween = Duration.between(instantStarted, instantStopped);
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
} }
} }

View File

@@ -5,6 +5,8 @@ import tools.Pair;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*; import java.util.*;
/** /**
@@ -21,8 +23,8 @@ import java.util.*;
* Estimated parse time: 1 minute * Estimated parse time: 1 minute
*/ */
public class CashCosmeticsChecker { public class CashCosmeticsChecker {
private static final String INPUT_DIRECTORY_PATH = ToolConstants.getInputFile("care").getPath(); private static final String INPUT_DIRECTORY_PATH = ToolConstants.getInputFile("care").toString();
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("cash_cosmetics_result.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("cash_cosmetics_result.txt");
private static final boolean IGNORE_CURRENT_SCRIPT_COSMETICS = false; // Toggle to preference private static final boolean IGNORE_CURRENT_SCRIPT_COSMETICS = false; // Toggle to preference
private static final int INITIAL_STRING_LENGTH = 50; private static final int INITIAL_STRING_LENGTH = 50;
@@ -613,51 +615,50 @@ public class CashCosmeticsChecker {
private static void reportCosmeticResults() throws IOException { private static void reportCosmeticResults() throws IOException {
System.out.println("Reporting results ..."); System.out.println("Reporting results ...");
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));) {
printWriter = pw;
printReportFileHeader(); printReportFileHeader();
if (!missingCosmeticsNpcTypes.isEmpty()) { if (!missingCosmeticsNpcTypes.isEmpty()) {
printWriter.println("Found " + missingCosmeticsNpcTypes.size() + " entries with missing cosmetic entries."); printWriter.println("Found " + missingCosmeticsNpcTypes.size() + " entries with missing cosmetic entries.");
for (Pair<Pair<Integer, String>, List<Integer>> mcn : getSortedMapEntries(missingCosmeticsNpcTypes)) { for (Pair<Pair<Integer, String>, List<Integer>> mcn : getSortedMapEntries(missingCosmeticsNpcTypes)) {
printWriter.println(" NPC " + mcn.getLeft()); printWriter.println(" NPC " + mcn.getLeft());
Pair<List<Integer>, List<Integer>> genderItemids = getCosmeticReport(mcn.getRight()); Pair<List<Integer>, List<Integer>> genderItemids = getCosmeticReport(mcn.getRight());
reportNpcCosmetics(genderItemids.getLeft()); reportNpcCosmetics(genderItemids.getLeft());
reportNpcCosmetics(genderItemids.getRight()); reportNpcCosmetics(genderItemids.getRight());
printWriter.println(); printWriter.println();
} }
}
if (!unusedCosmetics.isEmpty()) {
printWriter.println("Unused cosmetics: " + unusedCosmetics.size());
List<Integer> list = new ArrayList<>(unusedCosmetics);
Collections.sort(list);
for (Integer i : list) {
printWriter.println(i + " " + cosmeticIdNames.get(i));
}
printWriter.println();
}
if (!missingCosmeticNames.isEmpty()) {
printWriter.println("Missing cosmetic itemids: " + missingCosmeticNames.size());
List<String> listString = new ArrayList<>(missingCosmeticNames);
Collections.sort(listString);
for (String c : listString) {
printWriter.println(c);
}
printWriter.println();
}
} }
if (!unusedCosmetics.isEmpty()) {
printWriter.println("Unused cosmetics: " + unusedCosmetics.size());
List<Integer> list = new ArrayList<>(unusedCosmetics);
Collections.sort(list);
for (Integer i : list) {
printWriter.println(i + " " + cosmeticIdNames.get(i));
}
printWriter.println();
}
if (!missingCosmeticNames.isEmpty()) {
printWriter.println("Missing cosmetic itemids: " + missingCosmeticNames.size());
List<String> listString = new ArrayList<>(missingCosmeticNames);
Collections.sort(listString);
for (String c : listString) {
printWriter.println(c);
}
printWriter.println();
}
printWriter.close();
} }
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -5,6 +5,8 @@ import tools.Pair;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -20,7 +22,7 @@ import java.util.*;
* Estimated parse time: 2 minutes * Estimated parse time: 2 minutes
*/ */
public class CashDropFetcher { public class CashDropFetcher {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("cash_drop_report.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("cash_drop_report.txt");
private static final Connection con = SimpleDatabaseConnection.getConnection(); private static final Connection con = SimpleDatabaseConnection.getConnection();
private static final int INITIAL_STRING_LENGTH = 50; private static final int INITIAL_STRING_LENGTH = 50;
private static final int ITEM_FILE_NAME_SIZE = 13; private static final int ITEM_FILE_NAME_SIZE = 13;
@@ -260,7 +262,8 @@ public class CashDropFetcher {
} }
private static void reportNxDropData() { private static void reportNxDropData() {
try { //NEED FUTURE UPDATE
try {
System.out.println("Reading Character.wz ..."); System.out.println("Reading Character.wz ...");
ArrayList<File> files = new ArrayList<>(); ArrayList<File> files = new ArrayList<>();
listFiles(WZFiles.CHARACTER.getFilePath(), files); listFiles(WZFiles.CHARACTER.getFilePath(), files);
@@ -311,7 +314,7 @@ public class CashDropFetcher {
System.out.println("Reporting results..."); System.out.println("Reporting results...");
// report suspects of missing quest drop data, as well as those drop data that may have incorrect questids. // report suspects of missing quest drop data, as well as those drop data that may have incorrect questids.
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
printReportFileHeader(); printReportFileHeader();
reportNxDropResults(true); reportNxDropResults(true);

View File

@@ -4,6 +4,8 @@ import provider.wz.WZFiles;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@@ -16,7 +18,7 @@ import java.util.Set;
* Estimated parse time: 10 seconds * Estimated parse time: 10 seconds
*/ */
public class CashVegaChecker { public class CashVegaChecker {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("vega_checker_report.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("vega_checker_report.txt");
private static final int INITIAL_STRING_LENGTH = 1000; private static final int INITIAL_STRING_LENGTH = 1000;
private static final Set<Integer> vegaItems = new HashSet<>(); private static final Set<Integer> vegaItems = new HashSet<>();
@@ -154,11 +156,11 @@ public class CashVegaChecker {
} }
private static void reportMissingVegaItems() { private static void reportMissingVegaItems() {
System.out.println("Reporting results ..."); //NEED FUTURE UPDATE
System.out.println("Reporting results ...");
try { try {
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
printReportFileHeader(); printReportFileHeader();
for (Integer itemid : vegaItems) { for (Integer itemid : vegaItems) {

View File

@@ -4,6 +4,8 @@ import tools.Pair;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.*; import java.sql.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
@@ -22,7 +24,7 @@ import static java.util.concurrent.TimeUnit.HOURS;
* Estimated parse time: 2 minutes (for 100 code entries) * Estimated parse time: 2 minutes (for 100 code entries)
*/ */
public class CodeCouponGenerator { public class CodeCouponGenerator {
private static final File INPUT_FILE = ToolConstants.getInputFile("CouponCodes.img.xml"); private static final Path INPUT_FILE = ToolConstants.getInputFile("CouponCodes.img.xml");
private static final int INITIAL_STRING_LENGTH = 250; private static final int INITIAL_STRING_LENGTH = 250;
private static final Connection con = SimpleDatabaseConnection.getConnection(); private static final Connection con = SimpleDatabaseConnection.getConnection();
@@ -312,24 +314,19 @@ public class CodeCouponGenerator {
ps.close(); ps.close();
} }
private static void generateCodeCoupons(File file) throws IOException { private static void generateCodeCoupons(Path file) throws IOException {
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8); try(BufferedReader br = Files.newBufferedReader(file); con;) {
bufferedReader = new BufferedReader(fileReader); bufferedReader = br;
resetCouponPackage();
status = 0;
resetCouponPackage(); System.out.println("Reading XML coupon information...");
status = 0; String line;
while ((line = bufferedReader.readLine()) != null) {
translateToken(line);
}
System.out.println();
System.out.println("Reading XML coupon information...");
String line;
while ((line = bufferedReader.readLine()) != null) {
translateToken(line);
}
bufferedReader.close();
fileReader.close();
System.out.println();
try {
System.out.println("Loading DB coupon codes..."); System.out.println("Loading DB coupon codes...");
loadUsedCouponCodes(); loadUsedCouponCodes();
System.out.println(); System.out.println();
@@ -340,10 +337,9 @@ public class CodeCouponGenerator {
commitCodeCouponDescription(ccd); commitCodeCouponDescription(ccd);
} }
System.out.println(); System.out.println();
con.close();
System.out.println("Done."); System.out.println("Done.");
} catch (SQLException e) {
} catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@@ -352,7 +348,7 @@ public class CodeCouponGenerator {
try { try {
generateCodeCoupons(INPUT_FILE); generateCodeCoupons(INPUT_FILE);
} catch (IOException ex) { } catch (IOException ex) {
System.out.println("Error reading file '" + INPUT_FILE.getAbsolutePath() + "'"); System.out.println("Error reading file '" + INPUT_FILE.toAbsolutePath() + "'");
} }
} }
} }

View File

@@ -4,6 +4,12 @@ import provider.wz.WZFiles;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.time.Instant;
/** /**
* @author RonanLana * @author RonanLana
@@ -16,8 +22,10 @@ import java.nio.charset.StandardCharsets;
* Estimated parse time: 10 seconds * Estimated parse time: 10 seconds
*/ */
public class DojoUpdate { public class DojoUpdate {
private static final File INPUT_DIRECTORY = new File(WZFiles.MAP.getFile(), "/Map/Map9"); //private static final Path INPUT_DIRECTORY = WZFiles.MAP.getFile().resolve("/Map/Map9");
private static final File OUTPUT_DIRECTORY = ToolConstants.getOutputFile("dojo-maps"); private static final Path INPUT_DIRECTORY = WZFiles.MAP.getFile().resolve("Map").resolve("Map9");
private static final Path OUTPUT_DIRECTORY = ToolConstants.getOutputFile("dojo-maps");
private static final Path WORKING_DIRECTORY = Paths.get("").toAbsolutePath();
private static final int DOJO_MIN_MAP_ID = 925_020_100; private static final int DOJO_MIN_MAP_ID = 925_020_100;
private static final int DOJO_MAX_MAP_ID = 925_033_804; private static final int DOJO_MAX_MAP_ID = 925_033_804;
private static final int INITIAL_STRING_LENGTH = 250; private static final int INITIAL_STRING_LENGTH = 250;
@@ -114,30 +122,25 @@ public class DojoUpdate {
return Integer.parseInt(fileName.substring(0, 9)); return Integer.parseInt(fileName.substring(0, 9));
} }
private static void parseDojoData(File file, String curPath) throws IOException { private static void parseDojoData(Path file, String curPath) throws IOException {
int mapId = getMapId(file.getName()); int mapId = getMapId(file.getFileName().toString());
isDojoMapid = isDojoMapId(mapId); isDojoMapid = isDojoMapId(mapId);
if (!isDojoMapid) { if (!isDojoMapid) {
return; return;
} }
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName())));
BufferedReader br = Files.newBufferedReader(file);) {
printWriter = pw;
bufferedReader = br;
status = 0;
printWriter = new PrintWriter(OUTPUT_DIRECTORY.getPath() + "/" + curPath + file.getName(), StandardCharsets.UTF_8); String line;
while ((line = bufferedReader.readLine()) != null) {
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8); translateToken(line);
bufferedReader = new BufferedReader(fileReader); }
status = 0; printFileFooter();
String line;
while ((line = bufferedReader.readLine()) != null) {
translateToken(line);
} }
bufferedReader.close();
fileReader.close();
printFileFooter();
printWriter.close();
} }
private static boolean isDojoMapId(int mapId) { private static boolean isDojoMapId(int mapId) {
@@ -152,31 +155,49 @@ public class DojoUpdate {
} }
private static void parseDirectoryDojoData(String curPath) { private static void parseDirectoryDojoData(String curPath) {
File folder = new File(OUTPUT_DIRECTORY, curPath); Path folder = OUTPUT_DIRECTORY.resolve(curPath);
if (!folder.exists()) { if (!Files.exists(folder)) {
folder.mkdir(); try {
Files.createDirectory(folder);
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Unable to create folder " + folder.toAbsolutePath() + ".");
e.printStackTrace();
}
} }
System.out.println("Parsing directory '" + curPath + "'"); System.out.println("Parsing directory '" + curPath + "'");
folder = new File(INPUT_DIRECTORY, curPath); folder = INPUT_DIRECTORY.resolve(curPath);
for (File file : folder.listFiles()) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(folder)) {
if (file.isFile()) { for (Path path : stream) {
try { if(Files.isRegularFile(path)) {
parseDojoData(file, curPath); try {
} catch (FileNotFoundException ex) { parseDojoData(path, curPath);
System.out.println("Unable to open dojo file " + file.getAbsolutePath() + "."); } catch (FileNotFoundException ex) {
} catch (IOException ex) { System.out.println("Unable to open dojo file " + path.toAbsolutePath() + ".");
System.out.println("Error reading dojo file " + file.getAbsolutePath() + "."); } catch (IOException ex) {
} catch (Exception e) { System.out.println("Error reading dojo file " + path.toAbsolutePath() + ".");
e.printStackTrace(); } catch (Exception e) {
} e.printStackTrace();
} else { }
parseDirectoryDojoData(curPath + file.getName() + "/"); } else {
} parseDirectoryDojoData(curPath + path.getFileName() + "/");
} }
}
} catch (IOException e1) {
System.out.println("Unable to read folder " + folder.toAbsolutePath() + ".");
// TODO Auto-generated catch block
e1.printStackTrace();
}
} }
public static void main(String[] args) { public static void main(String[] args) {
Instant instantStarted = Instant.now();
parseDirectoryDojoData(""); parseDirectoryDojoData("");
Instant instantStopped = Instant.now();
Duration durationBetween = Duration.between(instantStarted, instantStopped);
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
} }
} }

View File

@@ -4,6 +4,8 @@ import provider.wz.WZFiles;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*; import java.util.*;
/** /**
@@ -14,8 +16,8 @@ import java.util.*;
* And it removes from the String.wz XMLs all entries which misses properties on Item.wz. * And it removes from the String.wz XMLs all entries which misses properties on Item.wz.
*/ */
public class EmptyItemWzChecker { public class EmptyItemWzChecker {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("empty_item_wz_report.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("empty_item_wz_report.txt");
private static final String OUTPUT_PATH = ToolConstants.OUTPUT_DIRECTORY.getPath(); private static final String OUTPUT_PATH = ToolConstants.OUTPUT_DIRECTORY.toString();
private static final int INITIAL_STRING_LENGTH = 50; private static final int INITIAL_STRING_LENGTH = 50;
private static final int ITEM_FILE_NAME_SIZE = 13; private static final int ITEM_FILE_NAME_SIZE = 13;
@@ -338,12 +340,11 @@ public class EmptyItemWzChecker {
private static void reportItemNameDiff(Set<Integer> emptyItemNames, Set<Integer> emptyNameItems) throws IOException { private static void reportItemNameDiff(Set<Integer> emptyItemNames, Set<Integer> emptyNameItems) throws IOException {
System.out.println("Reporting results..."); System.out.println("Reporting results...");
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
printWriter = pw;
printReportFileHeader(); printReportFileHeader();
printReportFileResults(emptyItemNames, emptyNameItems); printReportFileResults(emptyItemNames, emptyNameItems);
}
printWriter.close();
} }
private static void locateItemStringWzDiff() throws IOException { private static void locateItemStringWzDiff() throws IOException {

View File

@@ -4,6 +4,11 @@ import provider.wz.WZFiles;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.time.Instant;
/** /**
* @author RonanLana * @author RonanLana
@@ -16,14 +21,13 @@ import java.nio.charset.StandardCharsets;
* Estimated parse time: 7 minutes * Estimated parse time: 7 minutes
*/ */
public class EquipmentOmniLeveller { public class EquipmentOmniLeveller {
private static final File INPUT_DIRECTORY = WZFiles.CHARACTER.getFile(); private static final Path INPUT_DIRECTORY = WZFiles.CHARACTER.getFile();
private static final File OUTPUT_DIRECTORY = ToolConstants.getOutputFile("equips-with-levels"); private static final Path OUTPUT_DIRECTORY = ToolConstants.getOutputFile("equips-with-levels");
private static final int INITIAL_STRING_LENGTH = 250; private static final int INITIAL_STRING_LENGTH = 250;
private static final int FIXED_EXP = 10000; private static final int FIXED_EXP = 10000;
private static final int MAX_EQP_LEVEL = 30; private static final int MAX_EQP_LEVEL = 30;
private static PrintWriter printWriter = null; private static PrintWriter printWriter = null;
private static InputStreamReader fileReader = null;
private static BufferedReader bufferedReader = null; private static BufferedReader bufferedReader = null;
private static int infoTagState = -1; private static int infoTagState = -1;
@@ -353,31 +357,25 @@ public class EquipmentOmniLeveller {
return accessInfoTag; return accessInfoTag;
} }
private static void copyCashItemData(File file, String curPath) throws IOException { private static void copyCashItemData(Path file, String curPath) throws IOException {
printWriter = new PrintWriter(new File(OUTPUT_DIRECTORY, curPath + file.getName()), StandardCharsets.UTF_8); try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName())));
BufferedReader br = Files.newBufferedReader(file);) {
fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8); printWriter = pw;
bufferedReader = new BufferedReader(fileReader); bufferedReader = br;
String line;
String line; while ((line = bufferedReader.readLine()) != null) {
while ((line = bufferedReader.readLine()) != null) { printWriter.println(line);
printWriter.println(line); }
} }
bufferedReader.close();
fileReader.close();
printWriter.close();
} }
private static void parseEquipData(File file, String curPath) throws IOException { private static void parseEquipData(Path file, String curPath) throws IOException {
printWriter = new PrintWriter(new File(OUTPUT_DIRECTORY, curPath + file.getName()), StandardCharsets.UTF_8);
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName())));
fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8); BufferedReader br = Files.newBufferedReader(file);) {
bufferedReader = new BufferedReader(fileReader); printWriter = pw;
bufferedReader = br;
try { status = 0;
status = 0;
upgradeable = false; upgradeable = false;
cash = false; cash = false;
@@ -389,20 +387,12 @@ public class EquipmentOmniLeveller {
infoTagState = -1; infoTagState = -1;
} }
} }
bufferedReader.close();
fileReader.close();
printFileFooter(); printFileFooter();
printWriter.close(); } catch (RuntimeException e) {
} catch (RuntimeException e) {
bufferedReader.close();
fileReader.close();
printWriter.close();
copyCashItemData(file, curPath); copyCashItemData(file, curPath);
} }
} }
private static void printFileFooter() { private static void printFileFooter() {
@@ -413,31 +403,48 @@ public class EquipmentOmniLeveller {
} }
private static void parseDirectoryEquipData(String curPath) { private static void parseDirectoryEquipData(String curPath) {
File folder = new File(OUTPUT_DIRECTORY, curPath); Path folder = OUTPUT_DIRECTORY.resolve(curPath);
if (!folder.exists()) { if (!Files.exists(folder)) {
folder.mkdir(); try {
Files.createDirectory(folder);
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Unable to create folder " + folder.toAbsolutePath() + ".");
e.printStackTrace();
}
} }
System.out.println("Parsing directory '" + curPath + "'"); System.out.println("Parsing directory '" + curPath + "'");
folder = new File(INPUT_DIRECTORY, curPath); folder = INPUT_DIRECTORY.resolve(curPath);
for (File file : folder.listFiles()) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(folder)) {
if (file.isFile()) { for (Path path : stream) {
try { if(Files.isRegularFile(path)) {
parseEquipData(file, curPath); try {
} catch (FileNotFoundException ex) { parseEquipData(path, curPath);
System.out.println("Unable to open equip file " + file.getAbsolutePath() + "."); } catch (FileNotFoundException ex) {
} catch (IOException ex) { System.out.println("Unable to open dojo file " + path.toAbsolutePath() + ".");
System.out.println("Error reading equip file " + file.getAbsolutePath() + "."); } catch (IOException ex) {
} catch (Exception e) { System.out.println("Error reading dojo file " + path.toAbsolutePath() + ".");
e.printStackTrace(); } catch (Exception e) {
} e.printStackTrace();
} else { }
parseDirectoryEquipData(curPath + file.getName() + "/"); } else {
} parseDirectoryEquipData(curPath + path.getFileName() + "/");
} }
}
} catch (IOException e1) {
System.out.println("Unable to read folder " + folder.toAbsolutePath() + ".");
// TODO Auto-generated catch block
e1.printStackTrace();
}
} }
public static void main(String[] args) { public static void main(String[] args) {
Instant instantStarted = Instant.now();
parseDirectoryEquipData(""); parseDirectoryEquipData("");
Instant instantStopped = Instant.now();
Duration durationBetween = Duration.between(instantStarted, instantStopped);
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
} }
} }

View File

@@ -2,6 +2,8 @@ package tools.mapletools;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -22,8 +24,8 @@ import java.util.regex.Pattern;
* Estimated parse time: 1 minute * Estimated parse time: 1 minute
*/ */
public class GachaponItemIdRetriever { public class GachaponItemIdRetriever {
private static final File INPUT_FILE = ToolConstants.getInputFile("gachapon_items.txt"); private static final Path INPUT_FILE = ToolConstants.getInputFile("gachapon_items.txt");
private static final File OUTPUT_DIRECTORY = ToolConstants.getOutputFile("gachapons"); private static final Path OUTPUT_DIRECTORY = ToolConstants.getOutputFile("gachapons");
private static final Connection con = SimpleDatabaseConnection.getConnection(); private static final Connection con = SimpleDatabaseConnection.getConnection();
private static final Pattern pattern = Pattern.compile("(\\d*)%"); private static final Pattern pattern = Pattern.compile("(\\d*)%");
private static final int[] scrollsChances = new int[]{10, 15, 30, 60, 65, 70, 100}; private static final int[] scrollsChances = new int[]{10, 15, 30, 60, 65, 70, 100};
@@ -247,12 +249,8 @@ public class GachaponItemIdRetriever {
private static void fetchDataOnMapleHandbook() throws SQLException { private static void fetchDataOnMapleHandbook() throws SQLException {
String line; String line;
try(BufferedReader bufferedReader = Files.newBufferedReader(INPUT_FILE)) {
try { int skip = 0;
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(INPUT_FILE), StandardCharsets.UTF_8);
BufferedReader bufferedReader = new BufferedReader(fileReader);
int skip = 0;
boolean lineHeader = false; boolean lineHeader = false;
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
if (skip > 0) { if (skip > 0) {
@@ -276,10 +274,10 @@ public class GachaponItemIdRetriever {
if (printWriter != null) { if (printWriter != null) {
printWriter.close(); printWriter.close();
} }
File outputFile = new File(OUTPUT_DIRECTORY, gachaponName + ".txt"); Path outputFile = OUTPUT_DIRECTORY.resolve(gachaponName + ".txt");
setupDirectories(outputFile); setupDirectories(outputFile);
printWriter = new PrintWriter(outputFile, StandardCharsets.UTF_8); printWriter = new PrintWriter(Files.newOutputStream(outputFile));
skip = 2; skip = 2;
lineHeader = true; lineHeader = true;
@@ -297,30 +295,30 @@ public class GachaponItemIdRetriever {
} }
} }
} }
if (printWriter != null) {
printWriter.close();
}
bufferedReader.close();
fileReader.close();
} catch (IOException ex) { } catch (IOException ex) {
System.out.println(ex.getMessage()); System.out.println(ex.getMessage());
ex.printStackTrace(); ex.printStackTrace();
} }
} }
private static void setupDirectories(File file) { private static void setupDirectories(Path file) {
if (!file.getParentFile().exists()) { if(!Files.exists(file.getParent())) {
file.getParentFile().mkdirs(); try {
} Files.createDirectories(file.getParent());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} }
public static void main(String[] args) { public static void main(String[] args) {
try { try(con) {
loadHandbookUseNames(); loadHandbookUseNames();
fetchDataOnMapleHandbook(); fetchDataOnMapleHandbook();
con.close();
} catch (SQLException e) { } catch (SQLException e) {
System.out.println("Error: invalid SQL syntax"); System.out.println("Error: invalid SQL syntax");
System.out.println(e.getMessage()); System.out.println(e.getMessage());

View File

@@ -2,10 +2,14 @@ package tools.mapletools;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
@@ -26,8 +30,8 @@ import java.util.ArrayList;
*/ */
public class IdRetriever { public class IdRetriever {
private static final boolean INSTALL_SQLTABLE = true; private static final boolean INSTALL_SQLTABLE = true;
private static final File INPUT_FILE = ToolConstants.getInputFile("fetch_ids.txt"); private static final Path INPUT_FILE = ToolConstants.getInputFile("fetch_ids.txt");
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("fetched_ids.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("fetched_ids.txt");
private static final Connection con = SimpleDatabaseConnection.getConnection(); private static final Connection con = SimpleDatabaseConnection.getConnection();
private static InputStreamReader fileReader = null; private static InputStreamReader fileReader = null;
@@ -132,15 +136,11 @@ public class IdRetriever {
} }
private static void fetchDataOnMapleHandbook() throws SQLException { private static void fetchDataOnMapleHandbook() throws SQLException {
String line; try(BufferedReader br = Files.newBufferedReader(INPUT_FILE);
PrintWriter printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));) {
try { bufferedReader = br;
fileReader = new InputStreamReader(new FileInputStream(INPUT_FILE), StandardCharsets.UTF_8); String line;
bufferedReader = new BufferedReader(fileReader); while ((line = bufferedReader.readLine()) != null) {
PrintWriter printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
while ((line = bufferedReader.readLine()) != null) {
if (line.isEmpty()) { if (line.isEmpty()) {
printWriter.println(""); printWriter.println("");
continue; continue;
@@ -164,17 +164,13 @@ public class IdRetriever {
printWriter.println(str); printWriter.println(str);
} }
} catch (IOException ex) {
printWriter.close();
bufferedReader.close();
fileReader.close();
} catch (IOException ex) {
System.out.println(ex.getMessage()); System.out.println(ex.getMessage());
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
Instant instantStarted = Instant.now();
try { try {
if (INSTALL_SQLTABLE) { if (INSTALL_SQLTABLE) {
parseMapleHandbook(); parseMapleHandbook();
@@ -187,6 +183,10 @@ public class IdRetriever {
System.out.println("Error: invalid SQL syntax"); System.out.println("Error: invalid SQL syntax");
e.printStackTrace(); e.printStackTrace();
} }
Instant instantStopped = Instant.now();
Duration durationBetween = Duration.between(instantStarted, instantStopped);
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
} }
} }

View File

@@ -5,6 +5,8 @@ import provider.wz.WZFiles;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@@ -16,7 +18,7 @@ import java.util.List;
* the "info" node in their WZ node tree. * the "info" node in their WZ node tree.
*/ */
public class MapInfoRetriever { public class MapInfoRetriever {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("map_info_report.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("map_info_report.txt");
private static final List<Integer> missingInfo = new ArrayList<>(); private static final List<Integer> missingInfo = new ArrayList<>();
private static BufferedReader bufferedReader = null; private static BufferedReader bufferedReader = null;
@@ -129,18 +131,14 @@ public class MapInfoRetriever {
} }
private static void writeReport() { private static void writeReport() {
try { try(PrintWriter printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
PrintWriter printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); if (!missingInfo.isEmpty()) {
if (!missingInfo.isEmpty()) {
for (Integer i : missingInfo) { for (Integer i : missingInfo) {
printWriter.println(i); printWriter.println(i);
} }
} else { } else {
printWriter.println("All map files contain 'info' node."); printWriter.println("All map files contain 'info' node.");
} }
printWriter.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -6,9 +6,13 @@ import tools.Pair;
import java.io.File; import java.io.File;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -27,7 +31,7 @@ import java.util.Map;
*/ */
public class MesoFetcher { public class MesoFetcher {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("meso_drop_data.sql"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("meso_drop_data.sql");
private static final boolean PERMIT_MESOS_ON_DOJO_BOSSES = false; private static final boolean PERMIT_MESOS_ON_DOJO_BOSSES = false;
private static final int MESO_ID = 0; private static final int MESO_ID = 0;
private static final int MIN_ITEMS = 4; private static final int MIN_ITEMS = 4;
@@ -119,14 +123,12 @@ public class MesoFetcher {
private static void generateMissingMobsMesoRange() { private static void generateMissingMobsMesoRange() {
System.out.print("Generating missing ranges... "); System.out.print("Generating missing ranges... ");
Connection con = SimpleDatabaseConnection.getConnection(); try(Connection con = SimpleDatabaseConnection.getConnection();
List<Integer> existingMobs = new ArrayList<>(200); PreparedStatement ps = con.prepareStatement("SELECT dropperid FROM drop_data WHERE dropperid NOT IN (SELECT DISTINCT dropperid FROM drop_data WHERE itemid = 0) GROUP BY dropperid HAVING count(*) >= " + MIN_ITEMS + ";");
ResultSet rs = ps.executeQuery();) {
try {
// select all mobs which doesn't drop mesos and have a fair amount of items dropping (meaning they are not an event mob) List<Integer> existingMobs = new ArrayList<>(200);
PreparedStatement ps = con.prepareStatement("SELECT dropperid FROM drop_data WHERE dropperid NOT IN (SELECT DISTINCT dropperid FROM drop_data WHERE itemid = 0) GROUP BY dropperid HAVING count(*) >= " + MIN_ITEMS + ";");
ResultSet rs = ps.executeQuery();
if (rs.isBeforeFirst()) { if (rs.isBeforeFirst()) {
while (rs.next()) { while (rs.next()) {
int mobid = rs.getInt(1); int mobid = rs.getInt(1);
@@ -137,18 +139,19 @@ public class MesoFetcher {
} }
if (!existingMobs.isEmpty()) { if (!existingMobs.isEmpty()) {
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
printSqlHeader(); printWriter = pw;
printSqlHeader();
for (int i = 0; i < existingMobs.size() - 1; i++) { for (int i = 0; i < existingMobs.size() - 1; i++) {
printSqlMobMesoRange(existingMobs.get(i)); printSqlMobMesoRange(existingMobs.get(i));
}
printSqlMobMesoRangeFinal(existingMobs.get(existingMobs.size() - 1));
printSqlExceptions();
} }
printSqlMobMesoRangeFinal(existingMobs.get(existingMobs.size() - 1));
printSqlExceptions();
printWriter.close();
} else { } else {
throw new Exception("ALREADY UPDATED"); throw new Exception("ALREADY UPDATED");
} }
@@ -156,13 +159,9 @@ public class MesoFetcher {
} else { } else {
throw new Exception("ALREADY UPDATED"); throw new Exception("ALREADY UPDATED");
} }
rs.close();
ps.close();
con.close();
System.out.println("done!"); System.out.println("done!");
} catch (Exception e) { } catch (Exception e) {
if (e.getMessage() != null && e.getMessage().equals("ALREADY UPDATED")) { if (e.getMessage() != null && e.getMessage().equals("ALREADY UPDATED")) {
System.out.println("done! The DB is already up-to-date, no file generated."); System.out.println("done! The DB is already up-to-date, no file generated.");
@@ -170,14 +169,21 @@ public class MesoFetcher {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
// load mob stats from WZ Instant instantStarted = Instant.now();
// load mob stats from WZ
mobStats = MonsterStatFetcher.getAllMonsterStats(); mobStats = MonsterStatFetcher.getAllMonsterStats();
calcAllMobsMesoRange(); calcAllMobsMesoRange();
generateMissingMobsMesoRange(); generateMissingMobsMesoRange();
Instant instantStopped = Instant.now();
Duration durationBetween = Duration.between(instantStarted, instantStopped);
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
} }
} }

View File

@@ -4,6 +4,8 @@ import provider.wz.WZFiles;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -16,7 +18,7 @@ import java.sql.SQLException;
* puts them on a SQL table with the correspondent mob cardid. * puts them on a SQL table with the correspondent mob cardid.
*/ */
public class MobBookIndexer { public class MobBookIndexer {
private static final File INPUT_FILE = new File(WZFiles.STRING.getFile(), "MonsterBook.img.xml"); private static final Path INPUT_FILE = WZFiles.STRING.getFile().resolve("MonsterBook.img.xml");
private static final Connection con = SimpleDatabaseConnection.getConnection(); private static final Connection con = SimpleDatabaseConnection.getConnection();
private static BufferedReader bufferedReader = null; private static BufferedReader bufferedReader = null;
@@ -123,14 +125,13 @@ public class MobBookIndexer {
} }
private static void indexFromDropData() { private static void indexFromDropData() {
// This will reference one line at a time
String line = null; try(con;
BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
try { bufferedReader = br;
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(INPUT_FILE), StandardCharsets.UTF_8); String line = null;
bufferedReader = new BufferedReader(fileReader);
PreparedStatement ps = con.prepareStatement("DROP TABLE IF EXISTS monstercardwz;");
PreparedStatement ps = con.prepareStatement("DROP TABLE IF EXISTS monstercardwz;");
ps.execute(); ps.execute();
ps = con.prepareStatement("CREATE TABLE `monstercardwz` (" ps = con.prepareStatement("CREATE TABLE `monstercardwz` ("
@@ -144,12 +145,7 @@ public class MobBookIndexer {
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateToken(line); translateToken(line);
} }
} catch (FileNotFoundException ex) {
bufferedReader.close();
fileReader.close();
con.close();
} catch (FileNotFoundException ex) {
System.out.println("Unable to open file '" + INPUT_FILE + "'"); System.out.println("Unable to open file '" + INPUT_FILE + "'");
} catch (IOException ex) { } catch (IOException ex) {
System.out.println("Error reading file '" + INPUT_FILE + "'"); System.out.println("Error reading file '" + INPUT_FILE + "'");

View File

@@ -4,6 +4,8 @@ import provider.wz.WZFiles;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -26,8 +28,8 @@ import java.sql.SQLException;
* remove the property 'MonsterBook.img' inside 'string.wz' and choose to import the xml generated with this software. * remove the property 'MonsterBook.img' inside 'string.wz' and choose to import the xml generated with this software.
*/ */
public class MobBookUpdate { public class MobBookUpdate {
private static final File INPUT_FILE = new File(WZFiles.STRING.getFile(), "MonsterBook.img.xml"); private static final Path INPUT_FILE = WZFiles.STRING.getFile().resolve("MonsterBook.img.xml");
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("MonsterBook_updated.img.xml"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("MonsterBook_updated.img.xml");
private static final Connection con = SimpleDatabaseConnection.getConnection(); private static final Connection con = SimpleDatabaseConnection.getConnection();
private static PrintWriter printWriter = null; private static PrintWriter printWriter = null;
@@ -143,23 +145,17 @@ public class MobBookUpdate {
} }
private static void updateFromDropData() { private static void updateFromDropData() {
// This will reference one line at a time try(con;
String line = null; PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
try { printWriter = pw;
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); bufferedReader = br;
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(INPUT_FILE), StandardCharsets.UTF_8);
bufferedReader = new BufferedReader(fileReader); String line = null;
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateToken(line); translateToken(line);
} }
printWriter.close();
bufferedReader.close();
fileReader.close();
con.close();
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
System.out.println("Unable to open file '" + INPUT_FILE + "'"); System.out.println("Unable to open file '" + INPUT_FILE + "'");
} catch (IOException ex) { } catch (IOException ex) {
@@ -170,6 +166,7 @@ public class MobBookUpdate {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -11,6 +11,8 @@ import server.life.LifeFactory.selfDestruction;
import server.life.MonsterStats; import server.life.MonsterStats;
import tools.Pair; import tools.Pair;
import java.time.Duration;
import java.time.Instant;
import java.util.*; import java.util.*;
public class MonsterStatFetcher { public class MonsterStatFetcher {
@@ -140,4 +142,15 @@ public class MonsterStatFetcher {
} }
} }
public static void main(String[] args) {
Instant instantStarted = Instant.now();
// load mob stats from WZ
Map<Integer, MonsterStats> mobStats = MonsterStatFetcher.getAllMonsterStats();
Instant instantStopped = Instant.now();
Duration durationBetween = Duration.between(instantStarted, instantStopped);
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
}
} }

View File

@@ -4,6 +4,8 @@ import provider.wz.WZFiles;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -20,7 +22,7 @@ import java.util.*;
* A file is generated listing all the inexistent ids. * A file is generated listing all the inexistent ids.
*/ */
public class NoItemIdFetcher { public class NoItemIdFetcher {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("no_item_id_report.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("no_item_id_report.txt");
private static final Connection con = SimpleDatabaseConnection.getConnection(); private static final Connection con = SimpleDatabaseConnection.getConnection();
private static final Set<Integer> existingIds = new HashSet<>(); private static final Set<Integer> existingIds = new HashSet<>();
@@ -199,16 +201,13 @@ public class NoItemIdFetcher {
} }
public static void main(String[] args) { public static void main(String[] args) {
try { try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); printWriter = pw;
existingIds.add(0); // meso itemid
existingIds.add(0); // meso itemid
readEquipDataDirectory(WZFiles.CHARACTER.getFilePath()); readEquipDataDirectory(WZFiles.CHARACTER.getFilePath());
readItemDataDirectory(WZFiles.ITEM.getFilePath()); readItemDataDirectory(WZFiles.ITEM.getFilePath());
evaluateDropsFromDb(); evaluateDropsFromDb();
printWriter.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -6,6 +6,8 @@ import provider.wz.WZFiles;
import java.io.File; import java.io.File;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*; import java.util.*;
/** /**
@@ -19,8 +21,8 @@ import java.util.*;
* Estimated parse time: 2 minutes * Estimated parse time: 2 minutes
*/ */
public class NoItemNameFetcher { public class NoItemNameFetcher {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("no_item_name_result.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("no_item_name_result.txt");
private static final File OUTPUT_XML_FILE = ToolConstants.getOutputFile("no_item_name_xml.txt"); private static final Path OUTPUT_XML_FILE = ToolConstants.getOutputFile("no_item_name_xml.txt");
private static final Map<Integer, String> itemsWzPath = new HashMap<>(); private static final Map<Integer, String> itemsWzPath = new HashMap<>();
private static final Map<Integer, EquipType> equipTypes = new HashMap<>(); private static final Map<Integer, EquipType> equipTypes = new HashMap<>();
@@ -435,20 +437,22 @@ public class NoItemNameFetcher {
private static void writeMissingStringWZNames(Map<String, List<Integer>> missingNames) throws Exception { private static void writeMissingStringWZNames(Map<String, List<Integer>> missingNames) throws Exception {
System.out.println("Writing remaining 'String.wz' names..."); System.out.println("Writing remaining 'String.wz' names...");
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_XML_FILE))) {
printWriter = pw;
printOutputFileHeader();
printWriter = new PrintWriter(OUTPUT_XML_FILE, StandardCharsets.UTF_8); String[] nodePaths = {"Cash.img", "Consume.img", "Eqp.img", "Etc.img", "Ins.img", "Pet.img"};
printOutputFileHeader(); for (int i = 0; i < nodePaths.length; i++) {
writeMissingStringWZNode(nodePaths[i], missingNames.get(nodePaths[i]), i == 2);
}
String[] nodePaths = {"Cash.img", "Consume.img", "Eqp.img", "Etc.img", "Ins.img", "Pet.img"};
for (int i = 0; i < nodePaths.length; i++) {
writeMissingStringWZNode(nodePaths[i], missingNames.get(nodePaths[i]), i == 2);
} }
printWriter.close();
} }
public static void main(String[] args) { public static void main(String[] args) {
try { try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
printWriter = pw;
curType = ItemType.EQP; curType = ItemType.EQP;
readEquipWZData(); readEquipWZData();
@@ -457,10 +461,8 @@ public class NoItemNameFetcher {
readStringWZData(); // calculates the diff and effectively holds all items with no name property on the WZ readStringWZData(); // calculates the diff and effectively holds all items with no name property on the WZ
System.out.println("Reporting results..."); System.out.println("Reporting results...");
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
printReportFileHeader(); printReportFileHeader();
printReportFileResults(); printReportFileResults();
printWriter.close();
Map<String, List<Integer>> missingNames = filterMissingItemNames(); Map<String, List<Integer>> missingNames = filterMissingItemNames();
writeMissingStringWZNames(missingNames); writeMissingStringWZNames(missingNames);

View File

@@ -5,6 +5,8 @@ import tools.Pair;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*; import java.util.*;
/** /**
@@ -17,7 +19,7 @@ import java.util.*;
* Running it should generate a report file under "output" folder with the search results. * Running it should generate a report file under "output" folder with the search results.
*/ */
public class QuestItemCountFetcher { public class QuestItemCountFetcher {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("quest_item_count_report.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("quest_item_count_report.txt");
private static final String ACT_NAME = WZFiles.QUEST.getFilePath() + "/Act.img.xml"; 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 String CHECK_NAME = WZFiles.QUEST.getFilePath() + "/Check.img.xml";
private static final int INITIAL_STRING_LENGTH = 50; private static final int INITIAL_STRING_LENGTH = 50;
@@ -241,17 +243,16 @@ public class QuestItemCountFetcher {
private static void reportQuestItemCountData() { private static void reportQuestItemCountData() {
// This will reference one line at a time // This will reference one line at a time
try { try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
System.out.println("Reading WZs..."); System.out.println("Reading WZs...");
readQuestItemCountData(); readQuestItemCountData();
System.out.println("Reporting results..."); System.out.println("Reporting results...");
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); printWriter = pw;
printReportFileHeader(); printReportFileHeader();
printReportFileResults(); printReportFileResults();
printWriter.close();
System.out.println("Done!"); System.out.println("Done!");
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
System.out.println("Unable to open quest file."); System.out.println("Unable to open quest file.");

View File

@@ -8,6 +8,8 @@ import tools.Pair;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -25,7 +27,7 @@ import java.util.*;
* Estimated parse time: 1 minute * Estimated parse time: 1 minute
*/ */
public class QuestItemFetcher { public class QuestItemFetcher {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("quest_report.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("quest_report.txt");
private static final int INITIAL_STRING_LENGTH = 50; private static final int INITIAL_STRING_LENGTH = 50;
private static final int INITIAL_LENGTH = 200; private static final int INITIAL_LENGTH = 200;
private static final boolean DISPLAY_EXTRA_INFO = true; // display items with zero quantity over the quest act WZ private static final boolean DISPLAY_EXTRA_INFO = true; // display items with zero quantity over the quest act WZ
@@ -409,32 +411,28 @@ public class QuestItemFetcher {
private static void reportQuestItemData() { private static void reportQuestItemData() {
// This will reference one line at a time // This will reference one line at a time
String line = null; String line = null;
String fileName = null; Path file = null;
try { try{
System.out.println("Reading WZs..."); System.out.println("Reading WZs...");
fileName = WZFiles.QUEST.getFilePath() + "/Check.img.xml"; file = WZFiles.QUEST.getFile().resolve("Check.img.xml");
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(fileName), StandardCharsets.UTF_8); bufferedReader = Files.newBufferedReader(file);
bufferedReader = new BufferedReader(fileReader);
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateCheckToken(line); // fetch expired quests through here as well translateCheckToken(line); // fetch expired quests through here as well
} }
bufferedReader.close(); bufferedReader.close();
fileReader.close();
fileName = WZFiles.QUEST.getFilePath() + "/Act.img.xml"; file = WZFiles.QUEST.getFile().resolve("Act.img.xml");
fileReader = new InputStreamReader(new FileInputStream(fileName), StandardCharsets.UTF_8); bufferedReader = Files.newBufferedReader(file);
bufferedReader = new BufferedReader(fileReader);
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateActToken(line); translateActToken(line);
} }
bufferedReader.close(); bufferedReader.close();
fileReader.close();
System.out.println("Calculating table diffs..."); System.out.println("Calculating table diffs...");
calculateQuestItemDiff(); calculateQuestItemDiff();
@@ -453,7 +451,7 @@ public class QuestItemFetcher {
System.out.println("Reporting results..."); System.out.println("Reporting results...");
// report suspects of missing quest drop data, as well as those drop data that may have incorrect questids. // report suspects of missing quest drop data, as well as those drop data that may have incorrect questids.
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
printReportFileHeader(); printReportFileHeader();
@@ -508,9 +506,9 @@ public class QuestItemFetcher {
printWriter.close(); printWriter.close();
System.out.println("Done!"); System.out.println("Done!");
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
System.out.println("Unable to open file '" + fileName + "'"); System.out.println("Unable to open file '" + file + "'");
} catch (IOException ex) { } catch (IOException ex) {
System.out.println("Error reading file '" + fileName + "'"); System.out.println("Error reading file '" + file + "'");
} catch (SQLException e) { } catch (SQLException e) {
System.out.println("Warning: Could not establish connection to database to report quest data."); System.out.println("Warning: Could not establish connection to database to report quest data.");
System.out.println(e.getMessage()); System.out.println(e.getMessage());

View File

@@ -4,6 +4,8 @@ import provider.wz.WZFiles;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*; import java.util.*;
/** /**
@@ -16,7 +18,7 @@ import java.util.*;
* Running it should generate a report file under "output" folder with the search results. * Running it should generate a report file under "output" folder with the search results.
*/ */
public class QuestMesoFetcher { public class QuestMesoFetcher {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("quest_meso_report.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("quest_meso_report.txt");
private static final boolean PRINT_FEES = true; // print missing values as additional info report private static final boolean PRINT_FEES = true; // print missing values as additional info report
private static final int INITIAL_STRING_LENGTH = 50; private static final int INITIAL_STRING_LENGTH = 50;
@@ -147,25 +149,21 @@ public class QuestMesoFetcher {
private static void readQuestMesoData() throws IOException { private static void readQuestMesoData() throws IOException {
String line; String line;
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(WZFiles.QUEST.getFilePath() + "/Act.img.xml"), StandardCharsets.UTF_8); bufferedReader = Files.newBufferedReader(WZFiles.QUEST.getFile().resolve("Act.img.xml"));
bufferedReader = new BufferedReader(fileReader);
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateTokenAct(line); translateTokenAct(line);
} }
bufferedReader.close(); bufferedReader.close();
fileReader.close();
fileReader = new InputStreamReader(new FileInputStream(WZFiles.QUEST.getFilePath() + "/Check.img.xml"), StandardCharsets.UTF_8); bufferedReader = Files.newBufferedReader(WZFiles.QUEST.getFile().resolve("Check.img.xml"));
bufferedReader = new BufferedReader(fileReader);
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateTokenCheck(line); translateTokenCheck(line);
} }
bufferedReader.close(); bufferedReader.close();
fileReader.close();
} }
private static void printReportFileHeader() { private static void printReportFileHeader() {
@@ -232,20 +230,19 @@ public class QuestMesoFetcher {
private static void reportQuestMesoData() { private static void reportQuestMesoData() {
// This will reference one line at a time // This will reference one line at a time
try { try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
System.out.println("Reading WZs..."); System.out.println("Reading WZs...");
readQuestMesoData(); readQuestMesoData();
System.out.println("Reporting results..."); System.out.println("Reporting results...");
// report missing meso checks on quest completes // report missing meso checks on quest completes
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); printWriter = pw;
printReportFileHeader(); printReportFileHeader();
printReportFileResults(checkedMesoQuests, appliedMesoQuests, true); printReportFileResults(checkedMesoQuests, appliedMesoQuests, true);
printReportFileResults(appliedMesoQuests, checkedMesoQuests, false); printReportFileResults(appliedMesoQuests, checkedMesoQuests, false);
printWriter.close();
System.out.println("Done!"); System.out.println("Done!");
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
System.out.println("Unable to open quest file."); System.out.println("Unable to open quest file.");

View File

@@ -4,6 +4,10 @@ import provider.wz.WZFiles;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.time.Instant;
import java.util.*; import java.util.*;
/** /**
@@ -18,7 +22,7 @@ import java.util.*;
* Running it should generate a report file under "output" folder with the search results. * Running it should generate a report file under "output" folder with the search results.
*/ */
public class QuestlineFetcher { public class QuestlineFetcher {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("questline_report.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("questline_report.txt");
private static final String ACT_NAME = WZFiles.QUEST.getFilePath() + "/Act.img.xml"; 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 String CHECK_NAME = WZFiles.QUEST.getFilePath() + "/Check.img.xml";
private static final int INITIAL_STRING_LENGTH = 50; private static final int INITIAL_STRING_LENGTH = 50;
@@ -289,7 +293,7 @@ public class QuestlineFetcher {
private static void reportQuestlineData() { private static void reportQuestlineData() {
// This will reference one line at a time // This will reference one line at a time
try { try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
System.out.println("Reading quest scripts..."); System.out.println("Reading quest scripts...");
instantiateQuestScriptFiles(ToolConstants.SCRIPTS_PATH + "/quest"); instantiateQuestScriptFiles(ToolConstants.SCRIPTS_PATH + "/quest");
@@ -301,12 +305,11 @@ public class QuestlineFetcher {
calculateSkillRelatedMissingQuestScripts(); calculateSkillRelatedMissingQuestScripts();
System.out.println("Reporting results..."); System.out.println("Reporting results...");
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); printWriter = pw;
printReportFileHeader(); printReportFileHeader();
printReportFileResults(); printReportFileResults();
printWriter.close();
System.out.println("Done!"); System.out.println("Done!");
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
System.out.println("Unable to open quest file."); System.out.println("Unable to open quest file.");
@@ -356,7 +359,13 @@ public class QuestlineFetcher {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
Instant instantStarted = Instant.now();
reportQuestlineData(); reportQuestlineData();
Instant instantStopped = Instant.now();
Duration durationBetween = Duration.between(instantStarted, instantStopped);
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
} }
} }

View File

@@ -3,6 +3,8 @@ package tools.mapletools;
import java.io.File; import java.io.File;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -16,7 +18,7 @@ import java.util.*;
* not yet coded. * not yet coded.
*/ */
public class ReactorDropFetcher { public class ReactorDropFetcher {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("reactor_drop_report.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("reactor_drop_report.txt");
private static final String REACTOR_SCRIPT_PATH = ToolConstants.SCRIPTS_PATH + "/reactor"; private static final String REACTOR_SCRIPT_PATH = ToolConstants.SCRIPTS_PATH + "/reactor";
private static final Connection con = SimpleDatabaseConnection.getConnection(); private static final Connection con = SimpleDatabaseConnection.getConnection();
@@ -84,19 +86,18 @@ public class ReactorDropFetcher {
} }
private static void reportMissingReactors() { private static void reportMissingReactors() {
try { try(con;
PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
System.out.println("Fetching reactors from DB..."); System.out.println("Fetching reactors from DB...");
fetchMissingReactorDrops(); fetchMissingReactorDrops();
con.close(); printWriter = pw;
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
// report suspects of missing quest drop data, as well as those drop data that may have incorrect questids. // report suspects of missing quest drop data, as well as those drop data that may have incorrect questids.
System.out.println("Reporting results..."); System.out.println("Reporting results...");
printReportFileHeader(); printReportFileHeader();
reportMissingReactorDrops(); reportMissingReactorDrops();
printWriter.close();
System.out.println("Done!"); System.out.println("Done!");
} catch (SQLException e) { } catch (SQLException e) {
System.out.println("Warning: Could not establish connection to database to report quest data."); System.out.println("Warning: Could not establish connection to database to report quest data.");

View File

@@ -6,6 +6,8 @@ import tools.DatabaseConnection;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@@ -20,8 +22,8 @@ import java.util.Map;
*/ */
public class SkillMakerFetcher { public class SkillMakerFetcher {
private static final File INPUT_FILE = new File(WZFiles.ETC.getFile(), "ItemMake.img.xml"); private static final Path INPUT_FILE = WZFiles.ETC.getFile().resolve("ItemMake.img.xml");
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("maker-data.sql"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("maker-data.sql");
private static final int INITIAL_STRING_LENGTH = 50; private static final int INITIAL_STRING_LENGTH = 50;
private static PrintWriter printWriter = null; private static PrintWriter printWriter = null;
@@ -303,10 +305,10 @@ public class SkillMakerFetcher {
// This will reference one line at a time // This will reference one line at a time
String line = null; String line = null;
try { try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(INPUT_FILE), StandardCharsets.UTF_8); printWriter = pw;
bufferedReader = new BufferedReader(fileReader); bufferedReader = br;
resetMakerDataFields(); resetMakerDataFields();
@@ -316,9 +318,6 @@ public class SkillMakerFetcher {
WriteMakerTableFile(); WriteMakerTableFile();
printWriter.close();
bufferedReader.close();
fileReader.close();
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
System.out.println("Unable to open file '" + INPUT_FILE + "'"); System.out.println("Unable to open file '" + INPUT_FILE + "'");
} catch (IOException ex) { } catch (IOException ex) {

View File

@@ -5,6 +5,8 @@ import tools.Pair;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -16,8 +18,8 @@ import java.util.List;
* by the server source. * by the server source.
*/ */
public class SkillMakerReagentIndexer { public class SkillMakerReagentIndexer {
private static final File INPUT_FILE = new File(WZFiles.ITEM.getFile(), "Etc/0425.img.xml"); private static final Path INPUT_FILE = WZFiles.ITEM.getFile().resolve("Etc/0425.img.xml");
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("maker-reagent-data.sql"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("maker-reagent-data.sql");
private static final int INITIAL_STRING_LENGTH = 50; private static final int INITIAL_STRING_LENGTH = 50;
private static final List<Pair<Integer, Pair<String, Integer>>> reagentList = new ArrayList<>(); private static final List<Pair<Integer, Pair<String, Integer>>> reagentList = new ArrayList<>();
@@ -151,22 +153,19 @@ public class SkillMakerReagentIndexer {
// This will reference one line at a time // This will reference one line at a time
String line = null; String line = null;
try { try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(INPUT_FILE), StandardCharsets.UTF_8); BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
bufferedReader = new BufferedReader(fileReader); bufferedReader = br;
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateToken(line); translateToken(line);
} }
bufferedReader.close();
fileReader.close();
SortReagentList(); SortReagentList();
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); printWriter = pw;
WriteMakerReagentTableFile(); WriteMakerReagentTableFile();
printWriter.close();
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
System.out.println("Unable to open file '" + OUTPUT_FILE + "'"); System.out.println("Unable to open file '" + OUTPUT_FILE + "'");
} catch (IOException ex) { } catch (IOException ex) {

View File

@@ -7,6 +7,8 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -27,7 +29,7 @@ import java.util.Map;
* drops. * drops.
*/ */
public class SkillbookChanceFetcher { public class SkillbookChanceFetcher {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("skillbook_drop_data.sql"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("skillbook_drop_data.sql");
private static final Map<Pair<Integer, Integer>, Integer> skillbookChances = new HashMap<>(); private static final Map<Pair<Integer, Integer>, Integer> skillbookChances = new HashMap<>();
private static PrintWriter printWriter; private static PrintWriter printWriter;
@@ -102,8 +104,8 @@ public class SkillbookChanceFetcher {
} }
private static void generateSkillbookChanceUpdateFile() { private static void generateSkillbookChanceUpdateFile() {
try { try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); printWriter = pw;
printSkillbookChanceUpdateSqlHeader(); printSkillbookChanceUpdateSqlHeader();
@@ -112,7 +114,6 @@ public class SkillbookChanceFetcher {
printWriter.println("(" + e.getKey().getLeft() + ", " + e.getKey().getRight() + ", 1, 1, 0, " + e.getValue() + "),"); printWriter.println("(" + e.getKey().getLeft() + ", " + e.getKey().getRight() + ", 1, 1, 0, " + e.getValue() + "),");
} }
printWriter.close();
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
} }

View File

@@ -3,7 +3,12 @@ package tools.mapletools;
import provider.wz.WZFiles; import provider.wz.WZFiles;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.time.Duration;
import java.time.Instant;
/** /**
* @author RonanLana * @author RonanLana
@@ -15,8 +20,8 @@ import java.nio.charset.StandardCharsets;
* Estimated parse time: 10 seconds * Estimated parse time: 10 seconds
*/ */
public class SkillbookStackUpdate { public class SkillbookStackUpdate {
private static final File INPUT_DIRECTORY = new File(WZFiles.ITEM.getFile(), "Consume"); private static final Path INPUT_DIRECTORY = WZFiles.ITEM.getFile().resolve("Consume");
private static final File OUTPUT_DIRECTORY = ToolConstants.getOutputFile("skillbook-update"); private static final Path OUTPUT_DIRECTORY = ToolConstants.getOutputFile("skillbook-update");
private static final int INITIAL_STRING_LENGTH = 50; private static final int INITIAL_STRING_LENGTH = 50;
private static PrintWriter printWriter = null; private static PrintWriter printWriter = null;
@@ -65,7 +70,6 @@ public class SkillbookStackUpdate {
private static void forwardCursor(int st) { private static void forwardCursor(int st) {
String line = null; String line = null;
try { try {
while (status >= st && (line = bufferedReader.readLine()) != null) { while (status >= st && (line = bufferedReader.readLine()) != null) {
simpleToken(line); simpleToken(line);
@@ -111,47 +115,56 @@ public class SkillbookStackUpdate {
printWriter.println(token); printWriter.println(token);
} }
private static void parseItemFile(File file, File outputFile) { private static void parseItemFile(Path file, Path outputFile) {
setupDirectories(outputFile); setupDirectories(outputFile);
// This will reference one line at a time
String line = null; try(BufferedReader br = Files.newBufferedReader(file);
PrintWriter pw = new PrintWriter(Files.newOutputStream(outputFile))) {
try { bufferedReader = br;
printWriter = new PrintWriter(outputFile); printWriter = pw;
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8); String line;
bufferedReader = new BufferedReader(fileReader); while ((line = bufferedReader.readLine()) != null) {
translateItemToken(line);
while ((line = bufferedReader.readLine()) != null) { }
translateItemToken(line);
}
bufferedReader.close();
fileReader.close();
printWriter.close();
} catch (IOException ex) { } catch (IOException ex) {
System.out.println("Error reading file '" + file.getName() + "'"); System.out.println("Error reading file '" + file.getFileName() + "'");
ex.printStackTrace(); ex.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private static void setupDirectories(File file) { private static void setupDirectories(Path file) {
if (!file.getParentFile().exists()) { if(!Files.exists(file.getParent())) {
file.getParentFile().mkdirs(); try {
} Files.createDirectories(file.getParent());
} catch (IOException e) {
System.out.println("Error creating folder '" + file.getParent() + "'");
e.printStackTrace();
}
}
} }
private static void parseItemDirectory(File inputDirectory, File outputDirectory) { private static void parseItemDirectory(Path inputDirectory, Path outputDirectory) {
for (File f : inputDirectory.listFiles()) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(inputDirectory)) {
parseItemFile(f, new File(outputDirectory, f.getName())); for (Path path : stream) {
} parseItemFile(path, outputDirectory.resolve(path.getFileName()));
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
public static void main(String[] args) { public static void main(String[] args) {
Instant instantStarted = Instant.now();
System.out.println("Reading item files..."); System.out.println("Reading item files...");
parseItemDirectory(INPUT_DIRECTORY, OUTPUT_DIRECTORY); parseItemDirectory(INPUT_DIRECTORY, OUTPUT_DIRECTORY);
System.out.println("Done!"); System.out.println("Done!");
Instant instantStopped = Instant.now();
Duration durationBetween = Duration.between(instantStarted, instantStopped);
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
} }
} }

View File

@@ -1,18 +1,19 @@
package tools.mapletools; package tools.mapletools;
import java.io.File; import java.nio.file.Path;
import java.nio.file.Paths;
class ToolConstants { class ToolConstants {
static final File INPUT_DIRECTORY = new File("tools/input"); static final Path INPUT_DIRECTORY = Paths.get("tools/input");
static final File OUTPUT_DIRECTORY = new File("tools/output"); static final Path OUTPUT_DIRECTORY = Paths.get("tools/output");
static final String SCRIPTS_PATH = "scripts"; static final String SCRIPTS_PATH = "scripts";
static final String HANDBOOK_PATH = "handbook"; static final String HANDBOOK_PATH = "handbook";
static File getInputFile(String fileName) { static Path getInputFile(String fileName) {
return new File(INPUT_DIRECTORY, fileName); return INPUT_DIRECTORY.resolve(fileName);
} }
static File getOutputFile(String fileName) { static Path getOutputFile(String fileName) {
return new File(OUTPUT_DIRECTORY, fileName); return OUTPUT_DIRECTORY.resolve(fileName);
} }
} }

View File

@@ -5,6 +5,8 @@ import tools.Pair;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*; import java.util.*;
/** /**
@@ -14,7 +16,7 @@ import java.util.*;
* throughout the map tree (area map -> continent map -> world map) but are currently missing. * throughout the map tree (area map -> continent map -> world map) but are currently missing.
*/ */
public class WorldmapChecker { public class WorldmapChecker {
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("worldmap_report.txt"); private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("worldmap_report.txt");
private static final int INITIAL_STRING_LENGTH = 50; private static final int INITIAL_STRING_LENGTH = 50;
private static final Map<String, Set<Integer>> worldMapids = new HashMap<>(); private static final Map<String, Set<Integer>> worldMapids = new HashMap<>();
private static final Map<String, String> parentWorldmaps = new HashMap<>(); private static final Map<String, String> parentWorldmaps = new HashMap<>();
@@ -186,8 +188,8 @@ public class WorldmapChecker {
} }
private static void verifyWorldmapTreeMapids() { private static void verifyWorldmapTreeMapids() {
try { try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8); printWriter = pw;
printReportFileHeader(); printReportFileHeader();
if (rootWorldmaps.size() > 1) { if (rootWorldmaps.size() > 1) {
@@ -242,7 +244,6 @@ public class WorldmapChecker {
printReportFileResults(unreferencedEntries); printReportFileResults(unreferencedEntries);
} }
printWriter.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }