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 -->
<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 -->
<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>
<dependencies>

View File

@@ -25,16 +25,18 @@ import provider.Data;
import provider.DataDirectoryEntry;
import provider.DataProvider;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class XMLWZFile implements DataProvider {
private static final Logger log = LoggerFactory.getLogger(DataProvider.class);
private final Path root;
private final WZDirectoryEntry rootForNavigation;
@@ -49,7 +51,7 @@ public class XMLWZFile implements DataProvider {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(lroot)) {
for (Path path : stream) {
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);
wzdir.addDirectory(newDir);
fillMapleDataEntitys(path, newDir);
@@ -58,30 +60,26 @@ public class XMLWZFile implements DataProvider {
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
log.warn("Can not open file/directory at " + lroot);
}
}
@Override
public synchronized Data getData(String path) {
Path dataFile = root.resolve(path + ".xml");
//File(root, path + ".xml");
Path imageDataDir = root.resolve(path);
//File imageDataDir = new File(root, path);
if (!Files.exists(dataFile)) {
return null;//bitches
return null;// bitches
}
final XMLDomMapleData domMapleData;
try(FileInputStream fis = new FileInputStream(dataFile.toString()) ) {
try (FileInputStream fis = new FileInputStream(dataFile.toString())) {
domMapleData = new XMLDomMapleData(fis, imageDataDir.getParent());
}catch (FileNotFoundException e) {
} catch (FileNotFoundException e) {
throw new RuntimeException("Datafile " + path + " does not exist in " + root.toAbsolutePath());
}catch (IOException e) {
} catch (IOException e) {
throw new RuntimeException(e);
}
return domMapleData;
}

View File

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

View File

@@ -134,13 +134,11 @@ public class BossHpBarFetcher {
}
private static void readBossHpBarData() throws IOException {
final Path mobDirectory = WZFiles.MOB.getFile();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(mobDirectory)) {
for (Path path : stream) {
if(Files.isRegularFile(path)) {
try(BufferedReader br = Files.newBufferedReader(path)) {
if (Files.isRegularFile(path)) {
try (BufferedReader br = Files.newBufferedReader(path)) {
bufferedReader = br;
String line;
while ((line = bufferedReader.readLine()) != null) {
@@ -167,7 +165,7 @@ public class BossHpBarFetcher {
private static void reportBossHpBarData() {
// 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...");
readBossHpBarData();

View File

@@ -616,7 +616,7 @@ public class CashCosmeticsChecker {
private static void reportCosmeticResults() throws IOException {
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;
printReportFileHeader();

View File

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

View File

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

View File

@@ -315,7 +315,7 @@ public class CodeCouponGenerator {
}
private static void generateCodeCoupons(Path file) throws IOException {
try(BufferedReader br = Files.newBufferedReader(file); con;) {
try (BufferedReader br = Files.newBufferedReader(file); con;) {
bufferedReader = br;
resetCouponPackage();
status = 0;

View File

@@ -3,7 +3,6 @@ package tools.mapletools;
import provider.wz.WZFiles;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -22,7 +21,6 @@ import java.time.Instant;
* Estimated parse time: 10 seconds
*/
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 OUTPUT_DIRECTORY = ToolConstants.getOutputFile("dojo-maps");
private static final Path WORKING_DIRECTORY = Paths.get("").toAbsolutePath();

View File

@@ -418,7 +418,7 @@ public class EquipmentOmniLeveller {
folder = INPUT_DIRECTORY.resolve(curPath);
try (DirectoryStream<Path> stream = Files.newDirectoryStream(folder)) {
for (Path path : stream) {
if(Files.isRegularFile(path)) {
if (Files.isRegularFile(path)) {
try {
parseEquipData(path, curPath);
} catch (FileNotFoundException ex) {

View File

@@ -249,7 +249,7 @@ public class GachaponItemIdRetriever {
private static void fetchDataOnMapleHandbook() throws SQLException {
String line;
try(BufferedReader bufferedReader = Files.newBufferedReader(INPUT_FILE)) {
try (BufferedReader bufferedReader = Files.newBufferedReader(INPUT_FILE)) {
int skip = 0;
boolean lineHeader = false;
while ((line = bufferedReader.readLine()) != null) {
@@ -299,9 +299,6 @@ public class GachaponItemIdRetriever {
System.out.println(ex.getMessage());
ex.printStackTrace();
}
}
private static void setupDirectories(Path file) {

View File

@@ -136,7 +136,7 @@ public class IdRetriever {
}
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));) {
bufferedReader = br;
String line;
@@ -171,14 +171,12 @@ public class IdRetriever {
public static void main(String[] args) {
Instant instantStarted = Instant.now();
try {
try (con) {
if (INSTALL_SQLTABLE) {
parseMapleHandbook();
} else {
fetchDataOnMapleHandbook();
}
con.close();
} catch (SQLException e) {
System.out.println("Error: invalid SQL syntax");
e.printStackTrace();

View File

@@ -131,7 +131,7 @@ public class MapInfoRetriever {
}
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()) {
for (Integer i : missingInfo) {
printWriter.println(i);

View File

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

View File

@@ -126,8 +126,7 @@ public class MobBookIndexer {
private static void indexFromDropData() {
try(con;
BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
try (con; BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
bufferedReader = br;
String line = null;

View File

@@ -145,7 +145,7 @@ public class MobBookUpdate {
}
private static void updateFromDropData() {
try(con;
try (con;
PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
printWriter = pw;
@@ -166,7 +166,6 @@ public class MobBookUpdate {
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {

View File

@@ -176,7 +176,7 @@ public class NoItemIdFetcher {
}
private static void evaluateDropsFromDb() {
try {
try (con) {
System.out.println("Evaluating item data on DB...");
evaluateDropsFromTable("drop_data");
@@ -194,14 +194,13 @@ public class NoItemIdFetcher {
System.out.println("Inexistent itemid count: " + nonExistingIds.size());
System.out.println("Total itemid count: " + existingIds.size());
con.close();
} catch (Exception e) {
e.printStackTrace();
}
}
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;
existingIds.add(0); // meso itemid
readEquipDataDirectory(WZFiles.CHARACTER.getFilePath());

View File

@@ -437,12 +437,12 @@ public class NoItemNameFetcher {
private static void writeMissingStringWZNames(Map<String, List<Integer>> missingNames) throws Exception {
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;
printOutputFileHeader();
String[] nodePaths = {"Cash.img", "Consume.img", "Eqp.img", "Etc.img", "Ins.img", "Pet.img"};
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);
}
@@ -451,7 +451,7 @@ public class NoItemNameFetcher {
}
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;
curType = ItemType.EQP;
readEquipWZData();

View File

@@ -243,7 +243,7 @@ public class QuestItemCountFetcher {
private static void reportQuestItemCountData() {
// 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...");
readQuestItemCountData();

View File

@@ -413,7 +413,7 @@ public class QuestItemFetcher {
String line = null;
Path file = null;
try{
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
System.out.println("Reading WZs...");
file = WZFiles.QUEST.getFile().resolve("Check.img.xml");
@@ -450,8 +450,9 @@ public class QuestItemFetcher {
filterDirectorySearchMatchingData("src", itemsWithQuest);
System.out.println("Reporting results...");
// report suspects of missing quest drop data, as well as those drop data that may have incorrect questids.
printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
// report suspects of missing quest drop data, as well as those drop data that
// may have incorrect questids.
printWriter = pw;
printReportFileHeader();
@@ -503,7 +504,6 @@ public class QuestItemFetcher {
}
}
printWriter.close();
System.out.println("Done!");
} catch (FileNotFoundException ex) {
System.out.println("Unable to open file '" + file + "'");

View File

@@ -230,7 +230,7 @@ public class QuestMesoFetcher {
private static void reportQuestMesoData() {
// 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...");
readQuestMesoData();

View File

@@ -293,7 +293,7 @@ public class QuestlineFetcher {
private static void reportQuestlineData() {
// 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...");
instantiateQuestScriptFiles(ToolConstants.SCRIPTS_PATH + "/quest");

View File

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

View File

@@ -305,7 +305,7 @@ public class SkillMakerFetcher {
// This will reference one line at a time
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);) {
printWriter = pw;
bufferedReader = br;

View File

@@ -153,7 +153,7 @@ public class SkillMakerReagentIndexer {
// This will reference one line at a time
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;
@@ -161,7 +161,6 @@ public class SkillMakerReagentIndexer {
translateToken(line);
}
SortReagentList();
printWriter = pw;

View File

@@ -104,14 +104,15 @@ public class SkillbookChanceFetcher {
}
private static void generateSkillbookChanceUpdateFile() {
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
printWriter = pw;
printSkillbookChanceUpdateSqlHeader();
List<Map.Entry<Pair<Integer, Integer>, Integer>> skillbookChancesList = sortedSkillbookChances();
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) {

View File

@@ -118,7 +118,7 @@ public class SkillbookStackUpdate {
private static void parseItemFile(Path file, Path outputFile) {
setupDirectories(outputFile);
try(BufferedReader br = Files.newBufferedReader(file);
try (BufferedReader br = Files.newBufferedReader(file);
PrintWriter pw = new PrintWriter(Files.newOutputStream(outputFile))) {
bufferedReader = br;
printWriter = pw;
@@ -135,7 +135,7 @@ public class SkillbookStackUpdate {
}
private static void setupDirectories(Path file) {
if(!Files.exists(file.getParent())) {
if (!Files.exists(file.getParent())) {
try {
Files.createDirectories(file.getParent());
} catch (IOException e) {

View File

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