Clean up formatting & Update NIO in some remaining files

This commit is contained in:
Đạt Nhân Trương
2022-08-01 14:25:32 +07:00
parent a44744c05b
commit 4496e0854f
29 changed files with 603 additions and 613 deletions

View File

@@ -33,7 +33,7 @@
<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.29</mysql-connector-java.version> <!-- MySQL JDBC driver --> <mysql-connector-java.version>8.0.30</mysql-connector-java.version> <!-- MySQL JDBC driver -->
</properties> </properties>
<dependencies> <dependencies>

View File

@@ -25,68 +25,66 @@ import provider.Data;
import provider.DataDirectoryEntry; import provider.DataDirectoryEntry;
import provider.DataProvider; import provider.DataProvider;
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.DirectoryStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class XMLWZFile implements DataProvider { public class XMLWZFile implements DataProvider {
private final Path root; private static final Logger log = LoggerFactory.getLogger(DataProvider.class);
private final WZDirectoryEntry rootForNavigation; private final Path root;
private final WZDirectoryEntry rootForNavigation;
public XMLWZFile(Path fileIn) { public XMLWZFile(Path fileIn) {
root = fileIn; root = fileIn;
rootForNavigation = new WZDirectoryEntry(fileIn.getFileName().toString(), 0, 0, null); rootForNavigation = new WZDirectoryEntry(fileIn.getFileName().toString(), 0, 0, null);
fillMapleDataEntitys(root, rootForNavigation); fillMapleDataEntitys(root, rootForNavigation);
} }
private void fillMapleDataEntitys(Path lroot, WZDirectoryEntry wzdir) { private void fillMapleDataEntitys(Path lroot, WZDirectoryEntry wzdir) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(lroot)) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(lroot)) {
for (Path path : stream) { for (Path path : stream) {
String fileName = path.getFileName().toString(); String fileName = path.getFileName().toString();
if(Files.isDirectory(path) && !fileName.endsWith(".img") ) { if (Files.isDirectory(path) && !fileName.endsWith(".img")) {
WZDirectoryEntry newDir = new WZDirectoryEntry(fileName, 0, 0, wzdir); WZDirectoryEntry newDir = new WZDirectoryEntry(fileName, 0, 0, wzdir);
wzdir.addDirectory(newDir); wzdir.addDirectory(newDir);
fillMapleDataEntitys(path, newDir); fillMapleDataEntitys(path, newDir);
} else if (fileName.endsWith(".xml")) { } else if (fileName.endsWith(".xml")) {
wzdir.addFile(new WZFileEntry(fileName.substring(0, fileName.length() - 4), 0, 0, wzdir)); wzdir.addFile(new WZFileEntry(fileName.substring(0, fileName.length() - 4), 0, 0, wzdir));
} }
} }
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block log.warn("Can not open file/directory at " + lroot);
e.printStackTrace();
} }
} }
@Override @Override
public synchronized Data getData(String path) { public synchronized Data getData(String path) {
Path dataFile = root.resolve(path + ".xml"); Path dataFile = root.resolve(path + ".xml");
//File(root, path + ".xml"); Path imageDataDir = root.resolve(path);
Path imageDataDir = root.resolve(path); if (!Files.exists(dataFile)) {
//File imageDataDir = new File(root, path); return null;// bitches
if (!Files.exists(dataFile)) { }
return null;//bitches final XMLDomMapleData domMapleData;
} try (FileInputStream fis = new FileInputStream(dataFile.toString())) {
final XMLDomMapleData domMapleData; domMapleData = new XMLDomMapleData(fis, imageDataDir.getParent());
try(FileInputStream fis = new FileInputStream(dataFile.toString()) ) { } catch (FileNotFoundException e) {
domMapleData = new XMLDomMapleData(fis, imageDataDir.getParent()); throw new RuntimeException("Datafile " + path + " does not exist in " + root.toAbsolutePath());
}catch (FileNotFoundException e) { } catch (IOException e) {
throw new RuntimeException("Datafile " + path + " does not exist in " + root.toAbsolutePath()); throw new RuntimeException(e);
}catch (IOException e) { }
throw new RuntimeException(e);
}
return domMapleData;
}
@Override return domMapleData;
public DataDirectoryEntry getRoot() { }
return rootForNavigation;
} @Override
public DataDirectoryEntry getRoot() {
return rootForNavigation;
}
} }

View File

@@ -26,11 +26,17 @@ import provider.Data;
import provider.DataProvider; import provider.DataProvider;
import provider.DataProviderFactory; import provider.DataProviderFactory;
import provider.DataTool; import provider.DataTool;
import provider.wz.WZDirectoryEntry;
import provider.wz.WZFileEntry;
import provider.wz.WZFiles; import provider.wz.WZFiles;
import tools.DatabaseConnection; import tools.DatabaseConnection;
import java.io.File; import java.io.File;
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;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -185,26 +191,31 @@ public class SkillbookInformationProvider {
return loadedSkillbooks; return loadedSkillbooks;
} }
private static void listFiles(String directoryName, ArrayList<File> files) { private static void listFiles(String directoryName, ArrayList<Path> files) {
File directory = new File(directoryName); Path directory = Paths.get(directoryName);
// get all the files from a directory // get all the files from a directory
File[] fList = directory.listFiles(); try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory)) {
for (File file : fList) { for (Path path : stream) {
if (file.isFile()) {
files.add(file);
} else if (file.isDirectory()) {
listFiles(file.getAbsolutePath(), files);
}
}
}
private static List<File> listFilesFromDirectoryRecursively(String directory) { if (Files.isRegularFile(path)) {
ArrayList<File> files = new ArrayList<>(); files.add(path);
listFiles(directory, files); } else if (Files.isDirectory(path)) {
listFiles(path.toAbsolutePath().toString(), files);
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return files; private static List<Path> listFilesFromDirectoryRecursively(String directory) {
} ArrayList<Path> files = new ArrayList<>();
listFiles(directory, files);
return files;
}
private static Set<Integer> findMatchingSkillbookIdsOnFile(String fileContent) { private static Set<Integer> findMatchingSkillbookIdsOnFile(String fileContent) {
Set<Integer> skillbookIds = new HashSet<>(4); Set<Integer> skillbookIds = new HashSet<>(4);
@@ -219,22 +230,20 @@ public class SkillbookInformationProvider {
return skillbookIds; return skillbookIds;
} }
private static String readFileToString(File file, String encoding) throws IOException { private static String readFileToString(Path file, String encoding) throws IOException {
Scanner scanner = new Scanner(file, encoding); Scanner scanner = new Scanner(file, encoding);
String text = ""; String text = "";
try { try(scanner) {
try {
text = scanner.useDelimiter("\\A").next(); text = scanner.useDelimiter("\\A").next();
} finally {
scanner.close();
}
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
} }
return text; return text;
} }
private static Map<Integer, SkillBookEntry> fileSearchMatchingData(File file) { private static Map<Integer, SkillBookEntry> fileSearchMatchingData(Path file) {
Map<Integer, SkillBookEntry> scriptFileSkillbooks = new HashMap<>(); Map<Integer, SkillBookEntry> scriptFileSkillbooks = new HashMap<>();
try { try {
@@ -245,7 +254,7 @@ public class SkillbookInformationProvider {
scriptFileSkillbooks.put(skillbookId, SkillBookEntry.SCRIPT); scriptFileSkillbooks.put(skillbookId, SkillBookEntry.SCRIPT);
} }
} catch (IOException ioe) { } catch (IOException ioe) {
log.error("Failed to read file:{}", file.getName(), ioe); log.error("Failed to read file:{}", file.getFileName(), ioe);
} }
return scriptFileSkillbooks; return scriptFileSkillbooks;
@@ -254,8 +263,8 @@ public class SkillbookInformationProvider {
private static Map<Integer, SkillBookEntry> fetchSkillbooksFromScripts() { private static Map<Integer, SkillBookEntry> fetchSkillbooksFromScripts() {
Map<Integer, SkillBookEntry> scriptSkillbooks = new HashMap<>(); Map<Integer, SkillBookEntry> scriptSkillbooks = new HashMap<>();
for (File file : listFilesFromDirectoryRecursively("./scripts")) { for (Path file : listFilesFromDirectoryRecursively("./scripts")) {
if (file.getName().endsWith(".js")) { if (file.getFileName().endsWith(".js")) {
scriptSkillbooks.putAll(fileSearchMatchingData(file)); scriptSkillbooks.putAll(fileSearchMatchingData(file));
} }
} }

View File

@@ -134,18 +134,16 @@ public class BossHpBarFetcher {
} }
private static void readBossHpBarData() throws IOException { private static void readBossHpBarData() throws IOException {
final Path mobDirectory = WZFiles.MOB.getFile();
final Path mobDirectory = WZFiles.MOB.getFile();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(mobDirectory)) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(mobDirectory)) {
for (Path path : stream) { for (Path path : stream) {
if(Files.isRegularFile(path)) { if (Files.isRegularFile(path)) {
try(BufferedReader br = Files.newBufferedReader(path)) { try (BufferedReader br = Files.newBufferedReader(path)) {
bufferedReader = br; bufferedReader = br;
String line; String line;
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateToken(line); translateToken(line);
} }
} }
} }
} }
@@ -167,7 +165,7 @@ 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(final PrintWriter printWriter = new PrintWriter(Files.newOutputStream(ToolConstants.getOutputFile(OUTPUT_FILE_NAME)))) { try (PrintWriter printWriter = new PrintWriter(Files.newOutputStream(ToolConstants.getOutputFile(OUTPUT_FILE_NAME)))) {
System.out.println("Reading WZs..."); System.out.println("Reading WZs...");
readBossHpBarData(); readBossHpBarData();

View File

@@ -616,9 +616,9 @@ 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 ...");
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));) { try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));) {
printWriter = pw; 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.");

View File

@@ -1,10 +1,13 @@
package tools.mapletools; package tools.mapletools;
import provider.wz.WZDirectoryEntry;
import provider.wz.WZFileEntry;
import provider.wz.WZFiles; import provider.wz.WZFiles;
import tools.Pair; import tools.Pair;
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.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
@@ -177,18 +180,20 @@ public class CashDropFetcher {
printWriter.println(); printWriter.println();
} }
private static void listFiles(String directoryName, ArrayList<File> files) { private static void listFiles(Path directoryName, ArrayList<Path> files) {
File directory = new File(directoryName);
// get all the files from a directory // get all the files from a directory
File[] fList = directory.listFiles(); try (DirectoryStream<Path> stream = Files.newDirectoryStream(directoryName)) {
for (File file : fList) { for (Path path : stream) {
if (file.isFile()) { if (Files.isRegularFile(path)) {
files.add(file); files.add(path);
} else if (file.isDirectory()) { } else if (Files.isDirectory(path)) {
listFiles(file.getAbsolutePath(), files); listFiles(path, files);
} }
} }
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
private static int getItemIdFromFilename(String name) { private static int getItemIdFromFilename(String name) {
@@ -263,82 +268,75 @@ public class CashDropFetcher {
private static void reportNxDropData() { private static void reportNxDropData() {
//NEED FUTURE UPDATE //NEED FUTURE UPDATE
try { try (con; PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
System.out.println("Reading Character.wz ..."); System.out.println("Reading Character.wz ...");
ArrayList<File> files = new ArrayList<>(); ArrayList<Path> files = new ArrayList<>();
listFiles(WZFiles.CHARACTER.getFilePath(), files); listFiles(WZFiles.CHARACTER.getFile(), files);
InputStreamReader fileReader = null; for (Path path : files) {
for (File f : files) { // System.out.println("Parsing " + f.getAbsolutePath());
//System.out.println("Parsing " + f.getAbsolutePath()); int itemid = getItemIdFromFilename(path.getFileName().toString());
int itemid = getItemIdFromFilename(f.getName()); if (itemid < 0) {
if (itemid < 0) { continue;
continue; }
}
fileReader = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8); bufferedReader = Files.newBufferedReader(path);
bufferedReader = new BufferedReader(fileReader);
currentItemid = itemid; currentItemid = itemid;
inspectEquipWzEntry(); inspectEquipWzEntry();
bufferedReader.close(); bufferedReader.close();
fileReader.close(); }
}
System.out.println("Reading Item.wz ..."); System.out.println("Reading Item.wz ...");
files = new ArrayList<>(); files = new ArrayList<>();
listFiles(WZFiles.ITEM.getFilePath(), files); listFiles(WZFiles.ITEM.getFile(), files);
for (File f : files) { for (Path path : files) {
//System.out.println("Parsing " + f.getAbsolutePath()); // System.out.println("Parsing " + f.getAbsolutePath());
fileReader = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8); bufferedReader = Files.newBufferedReader(path);
bufferedReader = new BufferedReader(fileReader);
if (f.getName().length() <= ITEM_FILE_NAME_SIZE) { if (path.getFileName().toString().length() <= ITEM_FILE_NAME_SIZE) {
inspectItemWzEntry(); inspectItemWzEntry();
} else { // pet file structure is similar to equips, maybe there are other item-types following this behaviour? } else { // pet file structure is similar to equips, maybe there are other item-types
int itemid = getItemIdFromFilename(f.getName()); // following this behaviour?
if (itemid < 0) { int itemid = getItemIdFromFilename(path.getFileName().toString());
continue; if (itemid < 0) {
} continue;
}
currentItemid = itemid; currentItemid = itemid;
inspectEquipWzEntry(); inspectEquipWzEntry();
} }
bufferedReader.close(); bufferedReader.close();
fileReader.close(); }
}
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
printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE)); // may have incorrect questids.
printReportFileHeader(); printWriter = pw;
printReportFileHeader();
reportNxDropResults(true); reportNxDropResults(true);
reportNxDropResults(false); reportNxDropResults(false);
/* /*
printWriter.println("NX LIST"); // list of all cash items found * printWriter.println("NX LIST"); // list of all cash items found for(Integer
for(Integer nx : nxItems) { * nx : nxItems) { printWriter.println(nx); }
printWriter.println(nx); */
}
*/
con.close(); System.out.println("Done!");
printWriter.close(); } catch (SQLException e) {
System.out.println("Done!"); System.out.println("Warning: Could not establish connection to database to report quest data.");
} catch (SQLException e) { System.out.println(e.getMessage());
System.out.println("Warning: Could not establish connection to database to report quest data."); } catch (Exception e) {
System.out.println(e.getMessage()); e.printStackTrace();
} catch (Exception e) { }
e.printStackTrace(); }
}
}
public static void main(String[] args) { public static void main(String[] args) {
reportNxDropData(); reportNxDropData();
} }
} }

View File

@@ -156,18 +156,16 @@ public class CashVegaChecker {
} }
private static void reportMissingVegaItems() { private static void reportMissingVegaItems() {
//NEED FUTURE UPDATE
System.out.println("Reporting results ..."); System.out.println("Reporting results ...");
try { try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE)); printWriter = pw;
printReportFileHeader(); printReportFileHeader();
for (Integer itemid : vegaItems) { for (Integer itemid : vegaItems) {
printWriter.println(" " + itemid); printWriter.println(" " + itemid);
} }
printWriter.close();
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
} }

View File

@@ -315,34 +315,34 @@ public class CodeCouponGenerator {
} }
private static void generateCodeCoupons(Path file) throws IOException { private static void generateCodeCoupons(Path file) throws IOException {
try(BufferedReader br = Files.newBufferedReader(file); con;) { try (BufferedReader br = Files.newBufferedReader(file); con;) {
bufferedReader = br; bufferedReader = br;
resetCouponPackage(); resetCouponPackage();
status = 0; status = 0;
System.out.println("Reading XML coupon information..."); System.out.println("Reading XML coupon information...");
String line; String line;
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateToken(line); translateToken(line);
} }
System.out.println(); System.out.println();
System.out.println("Loading DB coupon codes..."); System.out.println("Loading DB coupon codes...");
loadUsedCouponCodes(); loadUsedCouponCodes();
System.out.println(); System.out.println();
System.out.println("Saving generated coupons..."); System.out.println("Saving generated coupons...");
currentTime = System.currentTimeMillis(); currentTime = System.currentTimeMillis();
for (CodeCouponDescriptor ccd : activeCoupons) { for (CodeCouponDescriptor ccd : activeCoupons) {
commitCodeCouponDescription(ccd); commitCodeCouponDescription(ccd);
} }
System.out.println(); System.out.println();
System.out.println("Done."); System.out.println("Done.");
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
try { try {

View File

@@ -3,7 +3,6 @@ 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.DirectoryStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@@ -22,7 +21,6 @@ import java.time.Instant;
* Estimated parse time: 10 seconds * Estimated parse time: 10 seconds
*/ */
public class DojoUpdate { public class DojoUpdate {
//private static final Path INPUT_DIRECTORY = WZFiles.MAP.getFile().resolve("/Map/Map9");
private static final Path INPUT_DIRECTORY = WZFiles.MAP.getFile().resolve("Map").resolve("Map9"); 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 OUTPUT_DIRECTORY = ToolConstants.getOutputFile("dojo-maps");
private static final Path WORKING_DIRECTORY = Paths.get("").toAbsolutePath(); private static final Path WORKING_DIRECTORY = Paths.get("").toAbsolutePath();

View File

@@ -403,41 +403,41 @@ public class EquipmentOmniLeveller {
} }
private static void parseDirectoryEquipData(String curPath) { private static void parseDirectoryEquipData(String curPath) {
Path folder = OUTPUT_DIRECTORY.resolve(curPath); Path folder = OUTPUT_DIRECTORY.resolve(curPath);
if (!Files.exists(folder)) { if (!Files.exists(folder)) {
try { try {
Files.createDirectory(folder); Files.createDirectory(folder);
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
System.out.println("Unable to create folder " + folder.toAbsolutePath() + "."); System.out.println("Unable to create folder " + folder.toAbsolutePath() + ".");
e.printStackTrace(); e.printStackTrace();
} }
} }
System.out.println("Parsing directory '" + curPath + "'"); System.out.println("Parsing directory '" + curPath + "'");
folder = INPUT_DIRECTORY.resolve(curPath); folder = INPUT_DIRECTORY.resolve(curPath);
try (DirectoryStream<Path> stream = Files.newDirectoryStream(folder)) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(folder)) {
for (Path path : stream) { for (Path path : stream) {
if(Files.isRegularFile(path)) { if (Files.isRegularFile(path)) {
try { try {
parseEquipData(path, curPath); parseEquipData(path, curPath);
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
System.out.println("Unable to open dojo file " + path.toAbsolutePath() + "."); System.out.println("Unable to open dojo file " + path.toAbsolutePath() + ".");
} catch (IOException ex) { } catch (IOException ex) {
System.out.println("Error reading dojo file " + path.toAbsolutePath() + "."); System.out.println("Error reading dojo file " + path.toAbsolutePath() + ".");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {
parseDirectoryEquipData(curPath + path.getFileName() + "/"); parseDirectoryEquipData(curPath + path.getFileName() + "/");
} }
} }
} catch (IOException e1) { } catch (IOException e1) {
System.out.println("Unable to read folder " + folder.toAbsolutePath() + "."); System.out.println("Unable to read folder " + folder.toAbsolutePath() + ".");
// TODO Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
Instant instantStarted = Instant.now(); Instant instantStarted = Instant.now();

View File

@@ -248,61 +248,58 @@ 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 (BufferedReader bufferedReader = Files.newBufferedReader(INPUT_FILE)) {
int skip = 0; 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) {
skip--; skip--;
if (lineHeader) { if (lineHeader) {
if (!line.isEmpty()) { if (!line.isEmpty()) {
lineHeader = false; lineHeader = false;
printWriter.println(); printWriter.println();
printWriter.println(line + ":"); printWriter.println(line + ":");
} }
} }
} else if (line.isEmpty()) { } else if (line.isEmpty()) {
printWriter.println(""); printWriter.println("");
} else if (line.startsWith("Gachapon ")) { } else if (line.startsWith("Gachapon ")) {
String[] s = line.split("<EFBFBD> "); String[] s = line.split("<EFBFBD> ");
String gachaponName = s[s.length - 1]; String gachaponName = s[s.length - 1];
gachaponName = gachaponName.replace(" ", "_"); gachaponName = gachaponName.replace(" ", "_");
gachaponName = gachaponName.toLowerCase(); gachaponName = gachaponName.toLowerCase();
if (printWriter != null) { if (printWriter != null) {
printWriter.close(); printWriter.close();
} }
Path outputFile = OUTPUT_DIRECTORY.resolve(gachaponName + ".txt"); Path outputFile = OUTPUT_DIRECTORY.resolve(gachaponName + ".txt");
setupDirectories(outputFile); setupDirectories(outputFile);
printWriter = new PrintWriter(Files.newOutputStream(outputFile)); printWriter = new PrintWriter(Files.newOutputStream(outputFile));
skip = 2; skip = 2;
lineHeader = true; lineHeader = true;
} else if (line.startsWith(".")) { } else if (line.startsWith(".")) {
skip = 1; skip = 1;
lineHeader = true; lineHeader = true;
} else { } else {
line = line.replace("<EFBFBD>", "'"); line = line.replace("<EFBFBD>", "'");
for (String item : line.split("\\s\\|\\s")) { for (String item : line.split("\\s\\|\\s")) {
item = item.trim(); item = item.trim();
if (!item.contentEquals("n/a")) { if (!item.contentEquals("n/a")) {
String[] itemInfo = item.split(" - "); String[] itemInfo = item.split(" - ");
fetchLineOnMapleHandbook(itemInfo[0], itemInfo.length > 1 ? itemInfo[1] : null); fetchLineOnMapleHandbook(itemInfo[0], itemInfo.length > 1 ? itemInfo[1] : null);
} }
} }
} }
} }
} catch (IOException ex) { } catch (IOException ex) {
System.out.println(ex.getMessage()); System.out.println(ex.getMessage());
ex.printStackTrace(); ex.printStackTrace();
} }
}
}
private static void setupDirectories(Path file) { private static void setupDirectories(Path file) {
if(!Files.exists(file.getParent())) { if(!Files.exists(file.getParent())) {

View File

@@ -136,10 +136,10 @@ public class IdRetriever {
} }
private static void fetchDataOnMapleHandbook() throws SQLException { private static void fetchDataOnMapleHandbook() throws SQLException {
try(BufferedReader br = Files.newBufferedReader(INPUT_FILE); try (BufferedReader br = Files.newBufferedReader(INPUT_FILE);
PrintWriter printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));) { PrintWriter printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));) {
bufferedReader = br; bufferedReader = br;
String line; String line;
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
if (line.isEmpty()) { if (line.isEmpty()) {
printWriter.println(""); printWriter.println("");
@@ -171,14 +171,12 @@ public class IdRetriever {
public static void main(String[] args) { public static void main(String[] args) {
Instant instantStarted = Instant.now(); Instant instantStarted = Instant.now();
try { try (con) {
if (INSTALL_SQLTABLE) { if (INSTALL_SQLTABLE) {
parseMapleHandbook(); parseMapleHandbook();
} else { } else {
fetchDataOnMapleHandbook(); fetchDataOnMapleHandbook();
} }
con.close();
} catch (SQLException e) { } catch (SQLException e) {
System.out.println("Error: invalid SQL syntax"); System.out.println("Error: invalid SQL syntax");
e.printStackTrace(); e.printStackTrace();

View File

@@ -130,19 +130,19 @@ public class MapInfoRetriever {
} }
} }
private static void writeReport() { private static void writeReport() {
try(PrintWriter printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { try (PrintWriter printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
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.");
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
for (int i = 0; i <= 9; i++) { for (int i = 0; i <= 9; i++) {

View File

@@ -123,7 +123,7 @@ public class MesoFetcher {
private static void generateMissingMobsMesoRange() { private static void generateMissingMobsMesoRange() {
System.out.print("Generating missing ranges... "); System.out.print("Generating missing ranges... ");
try(Connection con = SimpleDatabaseConnection.getConnection(); try (Connection con = SimpleDatabaseConnection.getConnection();
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 + ";"); 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();) { ResultSet rs = ps.executeQuery();) {
@@ -139,7 +139,7 @@ public class MesoFetcher {
} }
if (!existingMobs.isEmpty()) { if (!existingMobs.isEmpty()) {
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
printWriter = pw; printWriter = pw;
printSqlHeader(); printSqlHeader();
@@ -169,7 +169,6 @@ public class MesoFetcher {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -125,14 +125,13 @@ public class MobBookIndexer {
} }
private static void indexFromDropData() { private static void indexFromDropData() {
try(con; try (con; BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
BufferedReader br = Files.newBufferedReader(INPUT_FILE);) { bufferedReader = br;
bufferedReader = br; String line = null;
String line = null;
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` ("
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT," + "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
@@ -142,20 +141,20 @@ public class MobBookIndexer {
+ ");"); + ");");
ps.execute(); ps.execute();
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateToken(line); translateToken(line);
} }
} 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) {
System.out.println("Error reading file '" + INPUT_FILE + "'"); System.out.println("Error reading file '" + INPUT_FILE + "'");
} catch (SQLException e) { } catch (SQLException e) {
System.out.println("Warning: Could not establish connection to database to change card chance rate."); System.out.println("Warning: Could not establish connection to database to change card chance rate.");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
e.printStackTrace(); e.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -144,30 +144,29 @@ public class MobBookUpdate {
} }
private static void updateFromDropData() { private static void updateFromDropData() {
try(con; try (con;
PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE)); PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
BufferedReader br = Files.newBufferedReader(INPUT_FILE);) { BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
printWriter = pw; printWriter = pw;
bufferedReader = br; bufferedReader = br;
String line = null; String line = null;
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateToken(line); translateToken(line);
} }
} 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) {
System.out.println("Error reading file '" + INPUT_FILE + "'"); System.out.println("Error reading file '" + INPUT_FILE + "'");
} catch (SQLException e) { } catch (SQLException e) {
System.out.println("Warning: Could not establish connection to database to change card chance rate."); System.out.println("Warning: Could not establish connection to database to change card chance rate.");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}
}
public static void main(String[] args) { public static void main(String[] args) {
updateFromDropData(); updateFromDropData();

View File

@@ -145,7 +145,7 @@ public class MonsterStatFetcher {
public static void main(String[] args) { public static void main(String[] args) {
Instant instantStarted = Instant.now(); Instant instantStarted = Instant.now();
// load mob stats from WZ // load mob stats from WZ
Map<Integer, MonsterStats> mobStats = MonsterStatFetcher.getAllMonsterStats(); Map<Integer, MonsterStats> mobStats = MonsterStatFetcher.getAllMonsterStats();
Instant instantStopped = Instant.now(); Instant instantStopped = Instant.now();
Duration durationBetween = Duration.between(instantStarted, instantStopped); Duration durationBetween = Duration.between(instantStarted, instantStopped);
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis()); System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());

View File

@@ -176,7 +176,7 @@ public class NoItemIdFetcher {
} }
private static void evaluateDropsFromDb() { private static void evaluateDropsFromDb() {
try { try (con) {
System.out.println("Evaluating item data on DB..."); System.out.println("Evaluating item data on DB...");
evaluateDropsFromTable("drop_data"); evaluateDropsFromTable("drop_data");
@@ -194,22 +194,21 @@ public class NoItemIdFetcher {
System.out.println("Inexistent itemid count: " + nonExistingIds.size()); System.out.println("Inexistent itemid count: " + nonExistingIds.size());
System.out.println("Total itemid count: " + existingIds.size()); System.out.println("Total itemid count: " + existingIds.size());
con.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
printWriter = pw; 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();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

View File

@@ -435,41 +435,41 @@ 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))) { try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_XML_FILE))) {
printWriter = pw; printWriter = pw;
printOutputFileHeader();
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);
}
public static void main(String[] args) { }
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { }
printWriter = pw;
curType = ItemType.EQP;
readEquipWZData();
curType = ItemType.UNDEF; public static void main(String[] args) {
readItemWZData(); try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
readStringWZData(); // calculates the diff and effectively holds all items with no name property on the WZ printWriter = pw;
curType = ItemType.EQP;
readEquipWZData();
System.out.println("Reporting results..."); curType = ItemType.UNDEF;
printReportFileHeader(); readItemWZData();
printReportFileResults(); readStringWZData(); // calculates the diff and effectively holds all items with no name property on the WZ
Map<String, List<Integer>> missingNames = filterMissingItemNames(); System.out.println("Reporting results...");
writeMissingStringWZNames(missingNames); printReportFileHeader();
printReportFileResults();
System.out.println("Done!"); Map<String, List<Integer>> missingNames = filterMissingItemNames();
} catch (Exception e) { writeMissingStringWZNames(missingNames);
e.printStackTrace();
} System.out.println("Done!");
} catch (Exception e) {
e.printStackTrace();
}
} }
} }

View File

@@ -240,28 +240,28 @@ 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(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { 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 = pw; printWriter = pw;
printReportFileHeader(); printReportFileHeader();
printReportFileResults(); printReportFileResults();
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.");
} catch (IOException ex) { } catch (IOException ex) {
System.out.println("Error reading quest file."); System.out.println("Error reading quest file.");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
reportQuestItemCountData(); reportQuestItemCountData();

View File

@@ -408,113 +408,113 @@ public class QuestItemFetcher {
return (!limitedQuestids.contains(questid) ? "" : " EXPIRED"); return (!limitedQuestids.contains(questid) ? "" : " EXPIRED");
} }
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;
Path file = null; Path file = null;
try{ try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
System.out.println("Reading WZs..."); System.out.println("Reading WZs...");
file = WZFiles.QUEST.getFile().resolve("Check.img.xml"); file = WZFiles.QUEST.getFile().resolve("Check.img.xml");
bufferedReader = Files.newBufferedReader(file); bufferedReader = Files.newBufferedReader(file);
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();
file = WZFiles.QUEST.getFile().resolve("Act.img.xml"); file = WZFiles.QUEST.getFile().resolve("Act.img.xml");
bufferedReader = Files.newBufferedReader(file); bufferedReader = Files.newBufferedReader(file);
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateActToken(line); translateActToken(line);
} }
bufferedReader.close(); bufferedReader.close();
System.out.println("Calculating table diffs..."); System.out.println("Calculating table diffs...");
calculateQuestItemDiff(); calculateQuestItemDiff();
System.out.println("Filtering drops on DB..."); System.out.println("Filtering drops on DB...");
List<Pair<Integer, Integer>> itemsWithQuest = getPairsQuestItem(); List<Pair<Integer, Integer>> itemsWithQuest = getPairsQuestItem();
filterQuestDropsOnDB(itemsWithQuest); filterQuestDropsOnDB(itemsWithQuest);
con.close(); con.close();
System.out.println("Filtering drops on project files..."); System.out.println("Filtering drops on project files...");
// finally, filter whether this item is mentioned on the source code or not. // finally, filter whether this item is mentioned on the source code or not.
filterDirectorySearchMatchingData("scripts", itemsWithQuest); filterDirectorySearchMatchingData("scripts", itemsWithQuest);
filterDirectorySearchMatchingData("sql", itemsWithQuest); filterDirectorySearchMatchingData("sql", itemsWithQuest);
filterDirectorySearchMatchingData("src", itemsWithQuest); filterDirectorySearchMatchingData("src", itemsWithQuest);
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
printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE)); // may have incorrect questids.
printWriter = pw;
printReportFileHeader(); printReportFileHeader();
if (!mixedQuestidItems.isEmpty()) { if (!mixedQuestidItems.isEmpty()) {
printWriter.println("INCORRECT QUESTIDS ON DB"); printWriter.println("INCORRECT QUESTIDS ON DB");
for (Map.Entry<Integer, int[]> emqi : getSortedMapEntries1(mixedQuestidItems)) { for (Map.Entry<Integer, int[]> emqi : getSortedMapEntries1(mixedQuestidItems)) {
int[] mqi = emqi.getValue(); int[] mqi = emqi.getValue();
printWriter.println(mqi[0] + " : " + mqi[1] + " -> " + mqi[2] + getExpiredStringLabel(mqi[2])); printWriter.println(mqi[0] + " : " + mqi[1] + " -> " + mqi[2] + getExpiredStringLabel(mqi[2]));
} }
printWriter.println("\n\n\n\n\n"); printWriter.println("\n\n\n\n\n");
} }
if (!itemsWithQuest.isEmpty()) { if (!itemsWithQuest.isEmpty()) {
Map<Integer, Integer> mapIwq = new HashMap<>(itemsWithQuest.size()); Map<Integer, Integer> mapIwq = new HashMap<>(itemsWithQuest.size());
for (Pair<Integer, Integer> iwq : itemsWithQuest) { for (Pair<Integer, Integer> iwq : itemsWithQuest) {
mapIwq.put(iwq.getLeft(), iwq.getRight()); mapIwq.put(iwq.getLeft(), iwq.getRight());
} }
printWriter.println("ITEMS WITH NO QUEST DROP DATA ON DB"); printWriter.println("ITEMS WITH NO QUEST DROP DATA ON DB");
for (Map.Entry<Integer, Integer> iwq : getSortedMapEntries0(mapIwq)) { for (Map.Entry<Integer, Integer> iwq : getSortedMapEntries0(mapIwq)) {
printWriter.println(iwq.getKey() + " - " + iwq.getValue() + getExpiredStringLabel(iwq.getValue())); printWriter.println(iwq.getKey() + " - " + iwq.getValue() + getExpiredStringLabel(iwq.getValue()));
} }
printWriter.println("\n\n\n\n\n"); printWriter.println("\n\n\n\n\n");
} }
if (DISPLAY_EXTRA_INFO) { if (DISPLAY_EXTRA_INFO) {
if (!zeroedStartQuestItems.isEmpty()) { if (!zeroedStartQuestItems.isEmpty()) {
printWriter.println("START QUEST ITEMS WITH ZERO QUANTITY"); printWriter.println("START QUEST ITEMS WITH ZERO QUANTITY");
for (Pair<Integer, List<Integer>> iwq : getSortedMapEntries2(zeroedStartQuestItems)) { for (Pair<Integer, List<Integer>> iwq : getSortedMapEntries2(zeroedStartQuestItems)) {
printWriter.println(iwq.getLeft() + getExpiredStringLabel(iwq.getLeft()) + ":"); printWriter.println(iwq.getLeft() + getExpiredStringLabel(iwq.getLeft()) + ":");
for (Integer i : iwq.getRight()) { for (Integer i : iwq.getRight()) {
printWriter.println(" " + i); printWriter.println(" " + i);
} }
printWriter.println(); printWriter.println();
} }
printWriter.println("\n\n\n\n\n"); printWriter.println("\n\n\n\n\n");
} }
if (!zeroedCompleteQuestItems.isEmpty()) { if (!zeroedCompleteQuestItems.isEmpty()) {
printWriter.println("COMPLETE QUEST ITEMS WITH ZERO QUANTITY"); printWriter.println("COMPLETE QUEST ITEMS WITH ZERO QUANTITY");
for (Pair<Integer, List<Integer>> iwq : getSortedMapEntries2(zeroedCompleteQuestItems)) { for (Pair<Integer, List<Integer>> iwq : getSortedMapEntries2(zeroedCompleteQuestItems)) {
printWriter.println(iwq.getLeft() + getExpiredStringLabel(iwq.getLeft()) + ":"); printWriter.println(iwq.getLeft() + getExpiredStringLabel(iwq.getLeft()) + ":");
for (Integer i : iwq.getRight()) { for (Integer i : iwq.getRight()) {
printWriter.println(" " + i); printWriter.println(" " + i);
} }
printWriter.println(); printWriter.println();
} }
printWriter.println("\n\n\n\n\n"); printWriter.println("\n\n\n\n\n");
} }
} }
printWriter.close(); System.out.println("Done!");
System.out.println("Done!"); } catch (FileNotFoundException ex) {
} catch (FileNotFoundException ex) { System.out.println("Unable to open file '" + file + "'");
System.out.println("Unable to open file '" + file + "'"); } catch (IOException ex) {
} catch (IOException ex) { System.out.println("Error reading file '" + file + "'");
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()); } catch (Exception e) {
} catch (Exception e) { e.printStackTrace();
e.printStackTrace(); }
}
} }
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -228,29 +228,29 @@ 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(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { 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 = pw; printWriter = pw;
printReportFileHeader(); printReportFileHeader();
printReportFileResults(checkedMesoQuests, appliedMesoQuests, true); printReportFileResults(checkedMesoQuests, appliedMesoQuests, true);
printReportFileResults(appliedMesoQuests, checkedMesoQuests, false); printReportFileResults(appliedMesoQuests, checkedMesoQuests, false);
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.");
} catch (IOException ex) { } catch (IOException ex) {
System.out.println("Error reading quest file."); System.out.println("Error reading quest file.");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -291,33 +291,33 @@ 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(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { 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");
System.out.println("Reading WZs..."); System.out.println("Reading WZs...");
readQuestsWithSkillReward(); readQuestsWithSkillReward();
readQuestsWithMissingScripts(); readQuestsWithMissingScripts();
System.out.println("Calculating skill related quests..."); System.out.println("Calculating skill related quests...");
calculateSkillRelatedMissingQuestScripts(); calculateSkillRelatedMissingQuestScripts();
System.out.println("Reporting results..."); System.out.println("Reporting results...");
printWriter = pw; printWriter = pw;
printReportFileHeader(); printReportFileHeader();
printReportFileResults(); printReportFileResults();
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.");
} catch (IOException ex) { } catch (IOException ex) {
System.out.println("Error reading quest file."); System.out.println("Error reading quest file.");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
/* /*

View File

@@ -86,25 +86,25 @@ public class ReactorDropFetcher {
} }
private static void reportMissingReactors() { private static void reportMissingReactors() {
try(con; try (con; PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { System.out.println("Fetching reactors from DB...");
System.out.println("Fetching reactors from DB..."); fetchMissingReactorDrops();
fetchMissingReactorDrops();
printWriter = pw; printWriter = pw;
// 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
System.out.println("Reporting results..."); // may have incorrect questids.
printReportFileHeader(); System.out.println("Reporting results...");
reportMissingReactorDrops(); printReportFileHeader();
reportMissingReactorDrops();
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.");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -301,31 +301,31 @@ public class SkillMakerFetcher {
printWriter.println(sb_reward); printWriter.println(sb_reward);
} }
private static void writeMakerTableData() { private static void writeMakerTableData() {
// This will reference one line at a time // This will reference one line at a time
String line = null; String line = null;
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE)); try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
BufferedReader br = Files.newBufferedReader(INPUT_FILE);) { BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
printWriter = pw; printWriter = pw;
bufferedReader = br; bufferedReader = br;
resetMakerDataFields(); resetMakerDataFields();
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateToken(line); translateToken(line);
} }
WriteMakerTableFile(); WriteMakerTableFile();
} 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) {
System.out.println("Error reading file '" + INPUT_FILE + "'"); System.out.println("Error reading file '" + INPUT_FILE + "'");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
DatabaseConnection.initializeConnectionPool(); // Using ItemInformationProvider which loads som unrelated things from the db DatabaseConnection.initializeConnectionPool(); // Using ItemInformationProvider which loads som unrelated things from the db

View File

@@ -149,31 +149,30 @@ public class SkillMakerReagentIndexer {
printWriter.println(sb); printWriter.println(sb);
} }
private static void writeMakerReagentTableData() { private static void writeMakerReagentTableData() {
// This will reference one line at a time // This will reference one line at a time
String line = null; String line = null;
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE)); try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
BufferedReader br = Files.newBufferedReader(INPUT_FILE);) { BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
bufferedReader = br; bufferedReader = br;
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateToken(line); translateToken(line);
} }
SortReagentList();
SortReagentList(); printWriter = pw;
WriteMakerReagentTableFile();
printWriter = pw; } catch (FileNotFoundException ex) {
WriteMakerReagentTableFile(); System.out.println("Unable to open file '" + OUTPUT_FILE + "'");
} catch (FileNotFoundException ex) { } catch (IOException ex) {
System.out.println("Unable to open file '" + OUTPUT_FILE + "'"); System.out.println("Error reading file '" + OUTPUT_FILE + "'");
} catch (IOException ex) { } catch (Exception e) {
System.out.println("Error reading file '" + OUTPUT_FILE + "'"); e.printStackTrace();
} catch (Exception e) { }
e.printStackTrace(); }
}
}
public static void main(String[] args) { public static void main(String[] args) {
writeMakerReagentTableData(); writeMakerReagentTableData();

View File

@@ -103,21 +103,22 @@ public class SkillbookChanceFetcher {
printWriter.println(" REPLACE INTO drop_data (`dropperid`, `itemid`, `minimum_quantity`, `maximum_quantity`, `questid`, `chance`) VALUES"); printWriter.println(" REPLACE INTO drop_data (`dropperid`, `itemid`, `minimum_quantity`, `maximum_quantity`, `questid`, `chance`) VALUES");
} }
private static void generateSkillbookChanceUpdateFile() { private static void generateSkillbookChanceUpdateFile() {
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
printWriter = pw; printWriter = pw;
printSkillbookChanceUpdateSqlHeader(); printSkillbookChanceUpdateSqlHeader();
List<Map.Entry<Pair<Integer, Integer>, Integer>> skillbookChancesList = sortedSkillbookChances(); List<Map.Entry<Pair<Integer, Integer>, Integer>> skillbookChancesList = sortedSkillbookChances();
for (Map.Entry<Pair<Integer, Integer>, Integer> e : skillbookChancesList) { for (Map.Entry<Pair<Integer, Integer>, Integer> e : skillbookChancesList) {
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() + "),");
}
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
// load mob stats from WZ // load mob stats from WZ

View File

@@ -116,26 +116,26 @@ public class SkillbookStackUpdate {
} }
private static void parseItemFile(Path file, Path outputFile) { private static void parseItemFile(Path file, Path outputFile) {
setupDirectories(outputFile); setupDirectories(outputFile);
try(BufferedReader br = Files.newBufferedReader(file); try (BufferedReader br = Files.newBufferedReader(file);
PrintWriter pw = new PrintWriter(Files.newOutputStream(outputFile))) { PrintWriter pw = new PrintWriter(Files.newOutputStream(outputFile))) {
bufferedReader = br; bufferedReader = br;
printWriter = pw; printWriter = pw;
String line; String line;
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
translateItemToken(line); translateItemToken(line);
} }
} catch (IOException ex) { } catch (IOException ex) {
System.out.println("Error reading file '" + file.getFileName() + "'"); 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(Path file) { private static void setupDirectories(Path file) {
if(!Files.exists(file.getParent())) { if (!Files.exists(file.getParent())) {
try { try {
Files.createDirectories(file.getParent()); Files.createDirectories(file.getParent());
} catch (IOException e) { } catch (IOException e) {

View File

@@ -188,7 +188,7 @@ public class WorldmapChecker {
} }
private static void verifyWorldmapTreeMapids() { private static void verifyWorldmapTreeMapids() {
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
printWriter = pw; printWriter = pw;
printReportFileHeader(); printReportFileHeader();