diff --git a/src/main/java/net/server/channel/Channel.java b/src/main/java/net/server/channel/Channel.java index 0343dc5da7..feb22becb8 100644 --- a/src/main/java/net/server/channel/Channel.java +++ b/src/main/java/net/server/channel/Channel.java @@ -50,7 +50,11 @@ import server.maps.*; import tools.PacketCreator; import tools.Pair; -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.util.*; import java.util.Map.Entry; import java.util.concurrent.ScheduledFuture; @@ -448,8 +452,14 @@ public final class Channel { private static String[] getEvents() { List events = new ArrayList<>(); - for (File file : new File("scripts/event").listFiles()) { - events.add(file.getName().substring(0, file.getName().length() - 3)); + try (DirectoryStream stream = Files.newDirectoryStream(Paths.get("scripts/event"))) { + for (Path path : stream) { + String fileName = path.getFileName().toString(); + events.add(fileName.substring(0, fileName.length() - 3)); + } + } catch (IOException e) { + log.warn("Unable to load events !"); + e.printStackTrace(); } return events.toArray(new String[0]); } diff --git a/src/main/java/provider/wz/WZFiles.java b/src/main/java/provider/wz/WZFiles.java index 3fe8dae892..783785e85e 100644 --- a/src/main/java/provider/wz/WZFiles.java +++ b/src/main/java/provider/wz/WZFiles.java @@ -28,7 +28,7 @@ public enum WZFiles { } public Path getFile() { - return Paths.get(DIRECTORY).resolve(fileName); + return Paths.get(DIRECTORY).resolve(fileName); } public String getFilePath() { @@ -36,8 +36,7 @@ public enum WZFiles { } private static String getWzDirectory() { - // Either provide a custom directory path through the "wz-path" property when launching the .jar, - // or don't provide one to use the default "wz" directory + // Either provide a custom directory path through the "wz-path" property when launching the .jar, or don't provide one to use the default "wz" directory String propertyPath = System.getProperty("wz-path"); if (propertyPath != null && new File(propertyPath).isDirectory()) { return propertyPath; diff --git a/src/main/java/provider/wz/XMLDomMapleData.java b/src/main/java/provider/wz/XMLDomMapleData.java index 4ea8461c37..da37b46880 100644 --- a/src/main/java/provider/wz/XMLDomMapleData.java +++ b/src/main/java/provider/wz/XMLDomMapleData.java @@ -80,7 +80,8 @@ public class XMLDomMapleData implements Data { boolean foundChild = false; for (int i = 0; i < childNodes.getLength(); i++) { Node childNode = childNodes.item(i); - if (childNode.getNodeType() == Node.ELEMENT_NODE && childNode.getAttributes().getNamedItem("name").getNodeValue().equals(s)) { + if (childNode.getNodeType() == Node.ELEMENT_NODE + && childNode.getAttributes().getNamedItem("name").getNodeValue().equals(s)) { myNode = childNode; foundChild = true; break; @@ -104,12 +105,12 @@ public class XMLDomMapleData implements Data { for (int i = 0; i < childNodes.getLength(); i++) { Node childNode = childNodes.item(i); if (childNode.getNodeType() == Node.ELEMENT_NODE) { - XMLDomMapleData child = new XMLDomMapleData(childNode); + XMLDomMapleData child = new XMLDomMapleData(childNode); child.imageDataDir = imageDataDir.resolve(getName().trim()); ret.add(child); } } - + return ret; } diff --git a/src/main/java/provider/wz/XMLWZFile.java b/src/main/java/provider/wz/XMLWZFile.java index 0644b95371..b493658bd4 100644 --- a/src/main/java/provider/wz/XMLWZFile.java +++ b/src/main/java/provider/wz/XMLWZFile.java @@ -38,50 +38,50 @@ 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; + private final WZDirectoryEntry rootForNavigation; - public XMLWZFile(Path fileIn) { - root = fileIn; - rootForNavigation = new WZDirectoryEntry(fileIn.getFileName().toString(), 0, 0, null); - fillMapleDataEntitys(root, rootForNavigation); - } + public XMLWZFile(Path fileIn) { + root = fileIn; + rootForNavigation = new WZDirectoryEntry(fileIn.getFileName().toString(), 0, 0, null); + fillMapleDataEntitys(root, rootForNavigation); + } - private void fillMapleDataEntitys(Path lroot, WZDirectoryEntry wzdir) { + private void fillMapleDataEntitys(Path lroot, WZDirectoryEntry wzdir) { - try (DirectoryStream stream = Files.newDirectoryStream(lroot)) { - for (Path path : stream) { - String fileName = path.getFileName().toString(); - if (Files.isDirectory(path) && !fileName.endsWith(".img")) { - WZDirectoryEntry newDir = new WZDirectoryEntry(fileName, 0, 0, wzdir); - wzdir.addDirectory(newDir); - fillMapleDataEntitys(path, newDir); - } else if (fileName.endsWith(".xml")) { - wzdir.addFile(new WZFileEntry(fileName.substring(0, fileName.length() - 4), 0, 0, wzdir)); - } - } - } catch (IOException e) { - log.warn("Can not open file/directory at " + lroot); - } - } + try (DirectoryStream stream = Files.newDirectoryStream(lroot)) { + for (Path path : stream) { + String fileName = path.getFileName().toString(); + if (Files.isDirectory(path) && !fileName.endsWith(".img")) { + WZDirectoryEntry newDir = new WZDirectoryEntry(fileName, 0, 0, wzdir); + wzdir.addDirectory(newDir); + fillMapleDataEntitys(path, newDir); + } else if (fileName.endsWith(".xml")) { + wzdir.addFile(new WZFileEntry(fileName.substring(0, fileName.length() - 4), 0, 0, wzdir)); + } + } + } catch (IOException e) { + log.warn("Can not open file/directory at " + lroot); + } + } - @Override - public synchronized Data getData(String path) { - Path dataFile = root.resolve(path + ".xml"); - Path imageDataDir = root.resolve(path); - if (!Files.exists(dataFile)) { - return null;// bitches - } - final XMLDomMapleData domMapleData; - try (FileInputStream fis = new FileInputStream(dataFile.toString())) { - domMapleData = new XMLDomMapleData(fis, imageDataDir.getParent()); - } catch (FileNotFoundException e) { - throw new RuntimeException("Datafile " + path + " does not exist in " + root.toAbsolutePath()); - } catch (IOException e) { - throw new RuntimeException(e); - } + @Override + public synchronized Data getData(String path) { + Path dataFile = root.resolve(path + ".xml"); + Path imageDataDir = root.resolve(path); + if (!Files.exists(dataFile)) { + return null;// bitches + } + final XMLDomMapleData domMapleData; + try (FileInputStream fis = new FileInputStream(dataFile.toString())) { + domMapleData = new XMLDomMapleData(fis, imageDataDir.getParent()); + } catch (FileNotFoundException e) { + throw new RuntimeException("Datafile " + path + " does not exist in " + root.toAbsolutePath()); + } catch (IOException e) { + throw new RuntimeException(e); + } - return domMapleData; - } + return domMapleData; + } @Override public DataDirectoryEntry getRoot() { diff --git a/src/main/java/server/SkillbookInformationProvider.java b/src/main/java/server/SkillbookInformationProvider.java index a28e54838d..1661f80732 100644 --- a/src/main/java/server/SkillbookInformationProvider.java +++ b/src/main/java/server/SkillbookInformationProvider.java @@ -191,24 +191,24 @@ public class SkillbookInformationProvider { return loadedSkillbooks; } - private static void listFiles(String directoryName, ArrayList files) { - Path directory = Paths.get(directoryName); + private static void listFiles(String directoryName, ArrayList files) { + Path directory = Paths.get(directoryName); - // get all the files from a directory - try (DirectoryStream stream = Files.newDirectoryStream(directory)) { - for (Path path : stream) { + // get all the files from a directory + try (DirectoryStream 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(); - } - } + 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 listFilesFromDirectoryRecursively(String directory) { ArrayList files = new ArrayList<>(); @@ -233,7 +233,7 @@ public class SkillbookInformationProvider { private static String readFileToString(Path file, String encoding) throws IOException { Scanner scanner = new Scanner(file, encoding); String text = ""; - try(scanner) { + try (scanner) { text = scanner.useDelimiter("\\A").next(); diff --git a/src/main/java/tools/mapletools/ArrowFetcher.java b/src/main/java/tools/mapletools/ArrowFetcher.java index 996f8e3bd7..d049fa0869 100644 --- a/src/main/java/tools/mapletools/ArrowFetcher.java +++ b/src/main/java/tools/mapletools/ArrowFetcher.java @@ -23,7 +23,6 @@ import server.life.MonsterStats; import tools.Pair; import java.io.PrintWriter; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.sql.Connection; import java.sql.PreparedStatement; @@ -214,7 +213,7 @@ public class ArrowFetcher { } public static void main(String[] args) { - Instant instantStarted = Instant.now(); + Instant instantStarted = Instant.now(); // load mob stats from WZ mobStats = MonsterStatFetcher.getAllMonsterStats(); diff --git a/src/main/java/tools/mapletools/BossHpBarFetcher.java b/src/main/java/tools/mapletools/BossHpBarFetcher.java index e313f39e37..e7634f09bb 100644 --- a/src/main/java/tools/mapletools/BossHpBarFetcher.java +++ b/src/main/java/tools/mapletools/BossHpBarFetcher.java @@ -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; @@ -134,19 +133,19 @@ public class BossHpBarFetcher { } private static void readBossHpBarData() throws IOException { - final Path mobDirectory = WZFiles.MOB.getFile(); - try (DirectoryStream stream = Files.newDirectoryStream(mobDirectory)) { - for (Path path : stream) { - if (Files.isRegularFile(path)) { - try (BufferedReader br = Files.newBufferedReader(path)) { - bufferedReader = br; - String line; - while ((line = bufferedReader.readLine()) != null) { - translateToken(line); - } - } - } - } + final Path mobDirectory = WZFiles.MOB.getFile(); + try (DirectoryStream stream = Files.newDirectoryStream(mobDirectory)) { + for (Path path : stream) { + if (Files.isRegularFile(path)) { + try (BufferedReader br = Files.newBufferedReader(path)) { + bufferedReader = br; + String line; + while ((line = bufferedReader.readLine()) != null) { + translateToken(line); + } + } + } + } } } @@ -170,7 +169,6 @@ public class BossHpBarFetcher { readBossHpBarData(); System.out.println("Reporting results..."); - printReportFileHeader(printWriter); printReportFileResults(printWriter); diff --git a/src/main/java/tools/mapletools/CashCosmeticsChecker.java b/src/main/java/tools/mapletools/CashCosmeticsChecker.java index 349afff565..261cf555b1 100644 --- a/src/main/java/tools/mapletools/CashCosmeticsChecker.java +++ b/src/main/java/tools/mapletools/CashCosmeticsChecker.java @@ -615,49 +615,50 @@ public class CashCosmeticsChecker { private static void reportCosmeticResults() throws IOException { System.out.println("Reporting results ..."); - - try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));) { - printWriter = pw; - printReportFileHeader(); - - if (!missingCosmeticsNpcTypes.isEmpty()) { - printWriter.println("Found " + missingCosmeticsNpcTypes.size() + " entries with missing cosmetic entries."); - - for (Pair, List> mcn : getSortedMapEntries(missingCosmeticsNpcTypes)) { - printWriter.println(" NPC " + mcn.getLeft()); - - Pair, List> genderItemids = getCosmeticReport(mcn.getRight()); - reportNpcCosmetics(genderItemids.getLeft()); - reportNpcCosmetics(genderItemids.getRight()); - printWriter.println(); - } - } - - if (!unusedCosmetics.isEmpty()) { - printWriter.println("Unused cosmetics: " + unusedCosmetics.size()); - - List 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 listString = new ArrayList<>(missingCosmeticNames); - Collections.sort(listString); - - for (String c : listString) { - printWriter.println(c); - } - - printWriter.println(); - } + + try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));) { + printWriter = pw; + printReportFileHeader(); + + if (!missingCosmeticsNpcTypes.isEmpty()) { + printWriter.println( + "Found " + missingCosmeticsNpcTypes.size() + " entries with missing cosmetic entries."); + + for (Pair, List> mcn : getSortedMapEntries(missingCosmeticsNpcTypes)) { + printWriter.println(" NPC " + mcn.getLeft()); + + Pair, List> genderItemids = getCosmeticReport(mcn.getRight()); + reportNpcCosmetics(genderItemids.getLeft()); + reportNpcCosmetics(genderItemids.getRight()); + printWriter.println(); + } + } + + if (!unusedCosmetics.isEmpty()) { + printWriter.println("Unused cosmetics: " + unusedCosmetics.size()); + + List 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 listString = new ArrayList<>(missingCosmeticNames); + Collections.sort(listString); + + for (String c : listString) { + printWriter.println(c); + } + + printWriter.println(); + } } } diff --git a/src/main/java/tools/mapletools/CashDropFetcher.java b/src/main/java/tools/mapletools/CashDropFetcher.java index f567a4fc2c..91282fa6d7 100644 --- a/src/main/java/tools/mapletools/CashDropFetcher.java +++ b/src/main/java/tools/mapletools/CashDropFetcher.java @@ -1,12 +1,9 @@ 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; @@ -182,18 +179,18 @@ public class CashDropFetcher { private static void listFiles(Path directoryName, ArrayList files) { // get all the files from a directory - try (DirectoryStream 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(); - } + try (DirectoryStream 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) { @@ -267,76 +264,75 @@ public class CashDropFetcher { } private static void reportNxDropData() { - //NEED FUTURE UPDATE - try (con; PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { - System.out.println("Reading Character.wz ..."); - ArrayList files = new ArrayList<>(); - listFiles(WZFiles.CHARACTER.getFile(), files); + try (con; PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { + System.out.println("Reading Character.wz ..."); + ArrayList files = new ArrayList<>(); + listFiles(WZFiles.CHARACTER.getFile(), files); - for (Path path : files) { - // System.out.println("Parsing " + f.getAbsolutePath()); - int itemid = getItemIdFromFilename(path.getFileName().toString()); - if (itemid < 0) { - continue; - } + for (Path path : files) { + // System.out.println("Parsing " + f.getAbsolutePath()); + int itemid = getItemIdFromFilename(path.getFileName().toString()); + if (itemid < 0) { + continue; + } - bufferedReader = Files.newBufferedReader(path); + bufferedReader = Files.newBufferedReader(path); - currentItemid = itemid; - inspectEquipWzEntry(); + currentItemid = itemid; + inspectEquipWzEntry(); - bufferedReader.close(); - } + bufferedReader.close(); + } - System.out.println("Reading Item.wz ..."); - files = new ArrayList<>(); - listFiles(WZFiles.ITEM.getFile(), files); + System.out.println("Reading Item.wz ..."); + files = new ArrayList<>(); + listFiles(WZFiles.ITEM.getFile(), files); - for (Path path : files) { - // System.out.println("Parsing " + f.getAbsolutePath()); - bufferedReader = Files.newBufferedReader(path); + for (Path path : files) { + // System.out.println("Parsing " + f.getAbsolutePath()); + bufferedReader = Files.newBufferedReader(path); - 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(path.getFileName().toString()); - if (itemid < 0) { - continue; - } + 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(path.getFileName().toString()); + if (itemid < 0) { + continue; + } - currentItemid = itemid; - inspectEquipWzEntry(); - } + currentItemid = itemid; + inspectEquipWzEntry(); + } - bufferedReader.close(); - } + bufferedReader.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. - printWriter = pw; - printReportFileHeader(); + // 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); + 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); } + */ - System.out.println("Done!"); - } catch (SQLException e) { - System.out.println("Warning: Could not establish connection to database to report quest data."); - System.out.println(e.getMessage()); - } catch (Exception e) { - e.printStackTrace(); - } - } + System.out.println("Done!"); + } catch (SQLException e) { + System.out.println("Warning: Could not establish connection to database to report quest data."); + System.out.println(e.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + } + } - public static void main(String[] args) { - reportNxDropData(); - } + public static void main(String[] args) { + reportNxDropData(); + } } diff --git a/src/main/java/tools/mapletools/CashVegaChecker.java b/src/main/java/tools/mapletools/CashVegaChecker.java index 6886be533f..1cbea1b5aa 100644 --- a/src/main/java/tools/mapletools/CashVegaChecker.java +++ b/src/main/java/tools/mapletools/CashVegaChecker.java @@ -156,7 +156,7 @@ public class CashVegaChecker { } private static void reportMissingVegaItems() { - System.out.println("Reporting results ..."); + System.out.println("Reporting results ..."); try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { printWriter = pw; diff --git a/src/main/java/tools/mapletools/CodeCouponGenerator.java b/src/main/java/tools/mapletools/CodeCouponGenerator.java index 6d0b69b791..62e35c6e09 100644 --- a/src/main/java/tools/mapletools/CodeCouponGenerator.java +++ b/src/main/java/tools/mapletools/CodeCouponGenerator.java @@ -3,7 +3,6 @@ package tools.mapletools; import tools.Pair; import java.io.*; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.sql.*; @@ -315,34 +314,34 @@ public class CodeCouponGenerator { } private static void generateCodeCoupons(Path file) throws IOException { - try (BufferedReader br = Files.newBufferedReader(file); con;) { - bufferedReader = br; - resetCouponPackage(); - status = 0; + try (BufferedReader br = Files.newBufferedReader(file); con;) { + bufferedReader = br; + resetCouponPackage(); + status = 0; - System.out.println("Reading XML coupon information..."); - 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); + } + System.out.println(); - System.out.println("Loading DB coupon codes..."); - loadUsedCouponCodes(); - System.out.println(); + System.out.println("Loading DB coupon codes..."); + loadUsedCouponCodes(); + System.out.println(); - System.out.println("Saving generated coupons..."); - currentTime = System.currentTimeMillis(); - for (CodeCouponDescriptor ccd : activeCoupons) { - commitCodeCouponDescription(ccd); - } - System.out.println(); - System.out.println("Done."); + System.out.println("Saving generated coupons..."); + currentTime = System.currentTimeMillis(); + for (CodeCouponDescriptor ccd : activeCoupons) { + commitCodeCouponDescription(ccd); + } + System.out.println(); + System.out.println("Done."); - } catch (SQLException e) { - e.printStackTrace(); - } - } + } catch (SQLException e) { + e.printStackTrace(); + } + } public static void main(String[] args) { try { diff --git a/src/main/java/tools/mapletools/CouponInstaller.java b/src/main/java/tools/mapletools/CouponInstaller.java index aba16b58dd..2532458370 100644 --- a/src/main/java/tools/mapletools/CouponInstaller.java +++ b/src/main/java/tools/mapletools/CouponInstaller.java @@ -3,7 +3,8 @@ package tools.mapletools; import provider.wz.WZFiles; import java.io.*; -import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -16,8 +17,8 @@ import java.sql.SQLException; * a SQL table that the server will make use. */ public class CouponInstaller { - private static final File COUPON_INPUT_FILE_1 = new File(WZFiles.ITEM.getFilePath(), "/Cash/0521.img.xml"); - private static final File COUPON_INPUT_FILE_2 = new File(WZFiles.ITEM.getFilePath(), "/Cash/0536.img.xml"); + private static final Path COUPON_INPUT_FILE_1 = WZFiles.ITEM.getFile().resolve("Cash/0521.img.xml"); + private static final Path COUPON_INPUT_FILE_2 = WZFiles.ITEM.getFile().resolve("Cash/0536.img.xml"); private static final Connection con = SimpleDatabaseConnection.getConnection(); private static BufferedReader bufferedReader = null; private static byte status = 0; @@ -192,20 +193,17 @@ public class CouponInstaller { } } - private static void installRateCoupons(File file) { + private static void installRateCoupons(Path file) { // This will reference one line at a time String line = null; - try { - InputStreamReader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8); - bufferedReader = new BufferedReader(fileReader); + try (BufferedReader br = Files.newBufferedReader(file)) { + bufferedReader = br; while ((line = bufferedReader.readLine()) != null) { translateToken(line); } - bufferedReader.close(); - fileReader.close(); } catch (FileNotFoundException ex) { System.out.println("Unable to open file '" + file + "'"); } catch (IOException ex) { diff --git a/src/main/java/tools/mapletools/DojoUpdate.java b/src/main/java/tools/mapletools/DojoUpdate.java index 0accbaff2d..584682cc75 100644 --- a/src/main/java/tools/mapletools/DojoUpdate.java +++ b/src/main/java/tools/mapletools/DojoUpdate.java @@ -126,8 +126,9 @@ public class DojoUpdate { if (!isDojoMapid) { return; } - try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName()))); - BufferedReader br = Files.newBufferedReader(file);) { + 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; @@ -136,7 +137,7 @@ public class DojoUpdate { while ((line = bufferedReader.readLine()) != null) { translateToken(line); } - + printFileFooter(); } } @@ -156,20 +157,20 @@ public class DojoUpdate { Path folder = OUTPUT_DIRECTORY.resolve(curPath); if (!Files.exists(folder)) { try { - Files.createDirectory(folder); - } catch (IOException e) { - // TODO Auto-generated catch block - System.out.println("Unable to create folder " + folder.toAbsolutePath() + "."); - e.printStackTrace(); - } + 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 + "'"); folder = INPUT_DIRECTORY.resolve(curPath); - try (DirectoryStream stream = Files.newDirectoryStream(folder)) { - for (Path path : stream) { - if(Files.isRegularFile(path)) { - try { + try (DirectoryStream stream = Files.newDirectoryStream(folder)) { + for (Path path : stream) { + if (Files.isRegularFile(path)) { + try { parseDojoData(path, curPath); } catch (FileNotFoundException ex) { System.out.println("Unable to open dojo file " + path.toAbsolutePath() + "."); @@ -178,24 +179,23 @@ public class DojoUpdate { } catch (Exception e) { e.printStackTrace(); } - } else { - parseDirectoryDojoData(curPath + path.getFileName() + "/"); - } - } + } else { + parseDirectoryDojoData(curPath + path.getFileName() + "/"); + } + } } catch (IOException e1) { - System.out.println("Unable to read folder " + folder.toAbsolutePath() + "."); - // TODO Auto-generated catch block - e1.printStackTrace(); - } + System.out.println("Unable to read folder " + folder.toAbsolutePath() + "."); + // TODO Auto-generated catch block + e1.printStackTrace(); + } } public static void main(String[] args) { - Instant instantStarted = Instant.now(); + Instant instantStarted = Instant.now(); 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()); - } } diff --git a/src/main/java/tools/mapletools/EmptyItemWzChecker.java b/src/main/java/tools/mapletools/EmptyItemWzChecker.java index 3ac5c7ddf0..4ac3face4f 100644 --- a/src/main/java/tools/mapletools/EmptyItemWzChecker.java +++ b/src/main/java/tools/mapletools/EmptyItemWzChecker.java @@ -409,7 +409,7 @@ public class EmptyItemWzChecker { private static void generateStringWz() throws IOException { System.out.println("Generating clean String.wz ..."); - String[][] stringWzFiles = {{"Cash", "Consume", "Ins", "Pet"}, {"Etc"}, {"Eqp"}}; + String[][] stringWzFiles = { { "Cash", "Consume", "Ins", "Pet" }, { "Etc" }, { "Eqp" } }; String stringWzPath = "/String.wz/"; File folder = new File(OUTPUT_PATH + "/String.wz/"); diff --git a/src/main/java/tools/mapletools/EquipmentOmniLeveller.java b/src/main/java/tools/mapletools/EquipmentOmniLeveller.java index 964c1f462f..71e3635b31 100644 --- a/src/main/java/tools/mapletools/EquipmentOmniLeveller.java +++ b/src/main/java/tools/mapletools/EquipmentOmniLeveller.java @@ -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; @@ -358,41 +357,40 @@ public class EquipmentOmniLeveller { } private static void copyCashItemData(Path file, String curPath) throws IOException { - try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName()))); - BufferedReader br = Files.newBufferedReader(file);) { - printWriter = pw; - bufferedReader = br; - String line; + try (PrintWriter pw = new PrintWriter( + Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName()))); + BufferedReader br = Files.newBufferedReader(file);) { + printWriter = pw; + bufferedReader = br; + String line; while ((line = bufferedReader.readLine()) != null) { printWriter.println(line); } - } + } } private static void parseEquipData(Path file, String curPath) throws IOException { - - 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; + 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; upgradeable = false; cash = false; String line; while ((line = bufferedReader.readLine()) != null) { if (translateToken(line)) { - infoTagState = status; // status: 2 + infoTagState = status; // status: 2 translateInfoTag(status); infoTagState = -1; } } printFileFooter(); - } catch (RuntimeException e) { + } catch (RuntimeException e) { copyCashItemData(file, curPath); } - - } private static void printFileFooter() { @@ -403,48 +401,48 @@ public class EquipmentOmniLeveller { } private static void parseDirectoryEquipData(String curPath) { - Path folder = OUTPUT_DIRECTORY.resolve(curPath); - if (!Files.exists(folder)) { - try { - Files.createDirectory(folder); - } catch (IOException e) { - // TODO Auto-generated catch block - System.out.println("Unable to create folder " + folder.toAbsolutePath() + "."); - e.printStackTrace(); - } - } + Path folder = OUTPUT_DIRECTORY.resolve(curPath); + if (!Files.exists(folder)) { + 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 + "'"); - folder = INPUT_DIRECTORY.resolve(curPath); - try (DirectoryStream stream = Files.newDirectoryStream(folder)) { - for (Path path : stream) { - if (Files.isRegularFile(path)) { - try { - parseEquipData(path, curPath); - } catch (FileNotFoundException ex) { - System.out.println("Unable to open dojo file " + path.toAbsolutePath() + "."); - } catch (IOException ex) { - System.out.println("Error reading dojo file " + path.toAbsolutePath() + "."); - } catch (Exception e) { - e.printStackTrace(); - } - } else { - parseDirectoryEquipData(curPath + path.getFileName() + "/"); - } - } - } catch (IOException e1) { - System.out.println("Unable to read folder " + folder.toAbsolutePath() + "."); - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } + System.out.println("Parsing directory '" + curPath + "'"); + folder = INPUT_DIRECTORY.resolve(curPath); + try (DirectoryStream stream = Files.newDirectoryStream(folder)) { + for (Path path : stream) { + if (Files.isRegularFile(path)) { + try { + parseEquipData(path, curPath); + } catch (FileNotFoundException ex) { + System.out.println("Unable to open dojo file " + path.toAbsolutePath() + "."); + } catch (IOException ex) { + System.out.println("Error reading dojo file " + path.toAbsolutePath() + "."); + } catch (Exception e) { + e.printStackTrace(); + } + } 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) { - Instant instantStarted = Instant.now(); + Instant instantStarted = Instant.now(); 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()); + System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds()); } } diff --git a/src/main/java/tools/mapletools/GachaponItemIdRetriever.java b/src/main/java/tools/mapletools/GachaponItemIdRetriever.java index cd884bc8ce..f39fb0f918 100644 --- a/src/main/java/tools/mapletools/GachaponItemIdRetriever.java +++ b/src/main/java/tools/mapletools/GachaponItemIdRetriever.java @@ -1,7 +1,6 @@ package tools.mapletools; import java.io.*; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.sql.Connection; @@ -248,73 +247,73 @@ public class GachaponItemIdRetriever { } private static void fetchDataOnMapleHandbook() throws SQLException { - String line; - try (BufferedReader bufferedReader = Files.newBufferedReader(INPUT_FILE)) { - int skip = 0; - boolean lineHeader = false; - while ((line = bufferedReader.readLine()) != null) { - if (skip > 0) { - skip--; + String line; + try (BufferedReader bufferedReader = Files.newBufferedReader(INPUT_FILE)) { + int skip = 0; + boolean lineHeader = false; + while ((line = bufferedReader.readLine()) != null) { + if (skip > 0) { + skip--; - if (lineHeader) { - if (!line.isEmpty()) { - lineHeader = false; - printWriter.println(); - printWriter.println(line + ":"); - } - } - } else if (line.isEmpty()) { - printWriter.println(""); + if (lineHeader) { + if (!line.isEmpty()) { + lineHeader = false; + printWriter.println(); + printWriter.println(line + ":"); + } + } + } else if (line.isEmpty()) { + printWriter.println(""); } else if (line.startsWith("Gachapon ")) { - String[] s = line.split("� "); - String gachaponName = s[s.length - 1]; - gachaponName = gachaponName.replace(" ", "_"); - gachaponName = gachaponName.toLowerCase(); + String[] s = line.split("� "); + String gachaponName = s[s.length - 1]; + gachaponName = gachaponName.replace(" ", "_"); + gachaponName = gachaponName.toLowerCase(); - if (printWriter != null) { - printWriter.close(); - } - Path outputFile = OUTPUT_DIRECTORY.resolve(gachaponName + ".txt"); - setupDirectories(outputFile); + if (printWriter != null) { + printWriter.close(); + } + Path outputFile = OUTPUT_DIRECTORY.resolve(gachaponName + ".txt"); + setupDirectories(outputFile); - printWriter = new PrintWriter(Files.newOutputStream(outputFile)); + printWriter = new PrintWriter(Files.newOutputStream(outputFile)); - skip = 2; - lineHeader = true; - } else if (line.startsWith(".")) { - skip = 1; - lineHeader = true; - } else { - line = line.replace("�", "'"); + skip = 2; + lineHeader = true; + } else if (line.startsWith(".")) { + skip = 1; + lineHeader = true; + } else { + line = line.replace("�", "'"); for (String item : line.split("\\s\\|\\s")) { - item = item.trim(); - if (!item.contentEquals("n/a")) { - String[] itemInfo = item.split(" - "); - fetchLineOnMapleHandbook(itemInfo[0], itemInfo.length > 1 ? itemInfo[1] : null); - } - } - } - } - } catch (IOException ex) { - System.out.println(ex.getMessage()); - ex.printStackTrace(); - } - } + item = item.trim(); + if (!item.contentEquals("n/a")) { + String[] itemInfo = item.split(" - "); + fetchLineOnMapleHandbook(itemInfo[0], itemInfo.length > 1 ? itemInfo[1] : null); + } + } + } + } + } catch (IOException ex) { + System.out.println(ex.getMessage()); + ex.printStackTrace(); + } + } private static void setupDirectories(Path file) { - if(!Files.exists(file.getParent())) { - try { - Files.createDirectories(file.getParent()); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + if (!Files.exists(file.getParent())) { + try { + Files.createDirectories(file.getParent()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } public static void main(String[] args) { - try(con) { - loadHandbookUseNames(); + try (con) { + loadHandbookUseNames(); fetchDataOnMapleHandbook(); } catch (SQLException e) { System.out.println("Error: invalid SQL syntax"); diff --git a/src/main/java/tools/mapletools/IdRetriever.java b/src/main/java/tools/mapletools/IdRetriever.java index 150d740f30..b511499f96 100644 --- a/src/main/java/tools/mapletools/IdRetriever.java +++ b/src/main/java/tools/mapletools/IdRetriever.java @@ -136,11 +136,11 @@ public class IdRetriever { } private static void fetchDataOnMapleHandbook() throws SQLException { - try (BufferedReader br = Files.newBufferedReader(INPUT_FILE); - PrintWriter printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));) { - bufferedReader = br; - String line; - while ((line = bufferedReader.readLine()) != null) { + try (BufferedReader br = Files.newBufferedReader(INPUT_FILE); + PrintWriter printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));) { + bufferedReader = br; + String line; + while ((line = bufferedReader.readLine()) != null) { if (line.isEmpty()) { printWriter.println(""); continue; @@ -164,13 +164,13 @@ public class IdRetriever { printWriter.println(str); } - } catch (IOException ex) { + } catch (IOException ex) { System.out.println(ex.getMessage()); } } public static void main(String[] args) { - Instant instantStarted = Instant.now(); + Instant instantStarted = Instant.now(); try (con) { if (INSTALL_SQLTABLE) { parseMapleHandbook(); @@ -184,7 +184,7 @@ public class IdRetriever { 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()); + System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds()); } } diff --git a/src/main/java/tools/mapletools/MapFieldLimitChecker.java b/src/main/java/tools/mapletools/MapFieldLimitChecker.java index da54249d97..92909399bc 100644 --- a/src/main/java/tools/mapletools/MapFieldLimitChecker.java +++ b/src/main/java/tools/mapletools/MapFieldLimitChecker.java @@ -3,7 +3,9 @@ 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; import java.util.ArrayList; /** @@ -72,17 +74,17 @@ public class MapFieldLimitChecker { } } - private static void listFiles(String directoryName, ArrayList files) { - File directory = new File(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); + private static void listFiles(Path directory, ArrayList files) { + try (DirectoryStream stream = Files.newDirectoryStream(directory)) { + for (Path path : stream) { + if (Files.isRegularFile(path)) { + files.add(path); + } else if (Files.isDirectory(path)) { + listFiles(path, files); + } } + } catch (IOException e) { + e.printStackTrace(); } } @@ -134,18 +136,17 @@ public class MapFieldLimitChecker { private static void loadMapWz() throws IOException { System.out.println("Reading Map.wz ..."); - ArrayList files = new ArrayList<>(); - listFiles(WZFiles.MAP.getFilePath() + "/Map", files); + ArrayList files = new ArrayList<>(); + listFiles(WZFiles.MAP.getFile().resolve("Map"), files); - for (File f : files) { - InputStreamReader fileReader = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8); - bufferedReader = new BufferedReader(fileReader); + for (Path f : files) { + try (BufferedReader br = Files.newBufferedReader(f)) { + bufferedReader = br; - mapid = getMapIdFromFilename(f.getName()); - inspectMapEntry(); + mapid = getMapIdFromFilename(f.getFileName().toString()); + inspectMapEntry(); - bufferedReader.close(); - fileReader.close(); + } } } diff --git a/src/main/java/tools/mapletools/MapInfoRetriever.java b/src/main/java/tools/mapletools/MapInfoRetriever.java index 6e884d1007..86019e8a5d 100644 --- a/src/main/java/tools/mapletools/MapInfoRetriever.java +++ b/src/main/java/tools/mapletools/MapInfoRetriever.java @@ -130,19 +130,19 @@ public class MapInfoRetriever { } } - private static void writeReport() { - try (PrintWriter printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { - if (!missingInfo.isEmpty()) { - for (Integer i : missingInfo) { - printWriter.println(i); - } - } else { - printWriter.println("All map files contain 'info' node."); - } - } catch (IOException e) { - e.printStackTrace(); - } - } + private static void writeReport() { + try (PrintWriter printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { + if (!missingInfo.isEmpty()) { + for (Integer i : missingInfo) { + printWriter.println(i); + } + } else { + printWriter.println("All map files contain 'info' node."); + } + } catch (IOException e) { + e.printStackTrace(); + } + } public static void main(String[] args) { for (int i = 0; i <= 9; i++) { diff --git a/src/main/java/tools/mapletools/MesoFetcher.java b/src/main/java/tools/mapletools/MesoFetcher.java index 908e22f929..44384fcb12 100644 --- a/src/main/java/tools/mapletools/MesoFetcher.java +++ b/src/main/java/tools/mapletools/MesoFetcher.java @@ -3,9 +3,7 @@ package tools.mapletools; import server.life.MonsterStats; import tools.Pair; -import java.io.File; import java.io.PrintWriter; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.sql.Connection; @@ -128,7 +126,7 @@ public class MesoFetcher { ResultSet rs = ps.executeQuery();) { List existingMobs = new ArrayList<>(200); - + if (rs.isBeforeFirst()) { while (rs.next()) { int mobid = rs.getInt(1); @@ -140,9 +138,9 @@ public class MesoFetcher { if (!existingMobs.isEmpty()) { try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { - printWriter = pw; - - printSqlHeader(); + printWriter = pw; + + printSqlHeader(); for (int i = 0; i < existingMobs.size() - 1; i++) { printSqlMobMesoRange(existingMobs.get(i)); @@ -159,9 +157,9 @@ public class MesoFetcher { } else { throw new Exception("ALREADY UPDATED"); } - + System.out.println("done!"); - + } catch (Exception e) { if (e.getMessage() != null && e.getMessage().equals("ALREADY UPDATED")) { System.out.println("done! The DB is already up-to-date, no file generated."); diff --git a/src/main/java/tools/mapletools/MobBookUpdate.java b/src/main/java/tools/mapletools/MobBookUpdate.java index be17c5b66e..a83af1c0e0 100644 --- a/src/main/java/tools/mapletools/MobBookUpdate.java +++ b/src/main/java/tools/mapletools/MobBookUpdate.java @@ -3,7 +3,6 @@ package tools.mapletools; import provider.wz.WZFiles; import java.io.*; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.sql.Connection; @@ -144,29 +143,29 @@ public class MobBookUpdate { } - private static void updateFromDropData() { - try (con; - PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE)); - BufferedReader br = Files.newBufferedReader(INPUT_FILE);) { - printWriter = pw; - bufferedReader = br; + private static void updateFromDropData() { + try (con; + PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE)); + BufferedReader br = Files.newBufferedReader(INPUT_FILE);) { + printWriter = pw; + bufferedReader = br; - String line = null; + String line = null; - while ((line = bufferedReader.readLine()) != null) { - translateToken(line); - } - } catch (FileNotFoundException ex) { - System.out.println("Unable to open file '" + INPUT_FILE + "'"); - } catch (IOException ex) { - System.out.println("Error reading file '" + INPUT_FILE + "'"); - } catch (SQLException e) { - System.out.println("Warning: Could not establish connection to database to change card chance rate."); - System.out.println(e.getMessage()); - } catch (Exception e) { - e.printStackTrace(); - } - } + while ((line = bufferedReader.readLine()) != null) { + translateToken(line); + } + } catch (FileNotFoundException ex) { + System.out.println("Unable to open file '" + INPUT_FILE + "'"); + } catch (IOException ex) { + System.out.println("Error reading file '" + INPUT_FILE + "'"); + } catch (SQLException e) { + System.out.println("Warning: Could not establish connection to database to change card chance rate."); + System.out.println(e.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + } + } public static void main(String[] args) { updateFromDropData(); diff --git a/src/main/java/tools/mapletools/NoItemIdFetcher.java b/src/main/java/tools/mapletools/NoItemIdFetcher.java index 83c60ad14a..7e55e11fff 100644 --- a/src/main/java/tools/mapletools/NoItemIdFetcher.java +++ b/src/main/java/tools/mapletools/NoItemIdFetcher.java @@ -199,16 +199,16 @@ public class NoItemIdFetcher { } } - public static void main(String[] args) { - try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { - printWriter = pw; - existingIds.add(0); // meso itemid - readEquipDataDirectory(WZFiles.CHARACTER.getFilePath()); - readItemDataDirectory(WZFiles.ITEM.getFilePath()); + public static void main(String[] args) { + try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { + printWriter = pw; + existingIds.add(0); // meso itemid + readEquipDataDirectory(WZFiles.CHARACTER.getFilePath()); + readItemDataDirectory(WZFiles.ITEM.getFilePath()); - evaluateDropsFromDb(); - } catch (Exception e) { - e.printStackTrace(); - } + evaluateDropsFromDb(); + } catch (Exception e) { + e.printStackTrace(); + } } } \ No newline at end of file diff --git a/src/main/java/tools/mapletools/NoItemNameFetcher.java b/src/main/java/tools/mapletools/NoItemNameFetcher.java index e3b011a9ca..c5e463b769 100644 --- a/src/main/java/tools/mapletools/NoItemNameFetcher.java +++ b/src/main/java/tools/mapletools/NoItemNameFetcher.java @@ -3,9 +3,7 @@ package tools.mapletools; import provider.*; import provider.wz.WZFiles; -import java.io.File; import java.io.PrintWriter; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.*; @@ -435,41 +433,41 @@ public class NoItemNameFetcher { } } - private static void writeMissingStringWZNames(Map> missingNames) throws Exception { - System.out.println("Writing remaining 'String.wz' names..."); - try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_XML_FILE))) { - printWriter = pw; + private static void writeMissingStringWZNames(Map> missingNames) throws Exception { + System.out.println("Writing remaining 'String.wz' names..."); + try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_XML_FILE))) { + printWriter = pw; - printOutputFileHeader(); + printOutputFileHeader(); - 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); - } + 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(); + public static void main(String[] args) { + try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { + printWriter = pw; + curType = ItemType.EQP; + readEquipWZData(); - curType = ItemType.UNDEF; - readItemWZData(); - readStringWZData(); // calculates the diff and effectively holds all items with no name property on the WZ + curType = ItemType.UNDEF; + readItemWZData(); + readStringWZData(); // calculates the diff and effectively holds all items with no name property on the WZ - System.out.println("Reporting results..."); - printReportFileHeader(); - printReportFileResults(); + System.out.println("Reporting results..."); + printReportFileHeader(); + printReportFileResults(); - Map> missingNames = filterMissingItemNames(); - writeMissingStringWZNames(missingNames); + Map> missingNames = filterMissingItemNames(); + writeMissingStringWZNames(missingNames); - System.out.println("Done!"); - } catch (Exception e) { - e.printStackTrace(); - } + System.out.println("Done!"); + } catch (Exception e) { + e.printStackTrace(); + } } } diff --git a/src/main/java/tools/mapletools/QuestItemCountFetcher.java b/src/main/java/tools/mapletools/QuestItemCountFetcher.java index 211ee211c5..1881438f48 100644 --- a/src/main/java/tools/mapletools/QuestItemCountFetcher.java +++ b/src/main/java/tools/mapletools/QuestItemCountFetcher.java @@ -240,28 +240,28 @@ public class QuestItemCountFetcher { } } - private static void reportQuestItemCountData() { - // This will reference one line at a time + private static void reportQuestItemCountData() { + // This will reference one line at a time - try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { - System.out.println("Reading WZs..."); - readQuestItemCountData(); + try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { + System.out.println("Reading WZs..."); + readQuestItemCountData(); - System.out.println("Reporting results..."); - printWriter = pw; + System.out.println("Reporting results..."); + printWriter = pw; - printReportFileHeader(); - printReportFileResults(); + printReportFileHeader(); + printReportFileResults(); - System.out.println("Done!"); - } catch (FileNotFoundException ex) { - System.out.println("Unable to open quest file."); - } catch (IOException ex) { - System.out.println("Error reading quest file."); - } catch (Exception e) { - e.printStackTrace(); - } - } + System.out.println("Done!"); + } catch (FileNotFoundException ex) { + System.out.println("Unable to open quest file."); + } catch (IOException ex) { + System.out.println("Error reading quest file."); + } catch (Exception e) { + e.printStackTrace(); + } + } public static void main(String[] args) { reportQuestItemCountData(); diff --git a/src/main/java/tools/mapletools/QuestItemFetcher.java b/src/main/java/tools/mapletools/QuestItemFetcher.java index 50570ad38e..440e96fd26 100644 --- a/src/main/java/tools/mapletools/QuestItemFetcher.java +++ b/src/main/java/tools/mapletools/QuestItemFetcher.java @@ -408,113 +408,113 @@ public class QuestItemFetcher { return (!limitedQuestids.contains(questid) ? "" : " EXPIRED"); } - private static void reportQuestItemData() { - // This will reference one line at a time - String line = null; - Path file = null; + private static void reportQuestItemData() { + // This will reference one line at a time + String line = null; + Path file = null; - try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { - System.out.println("Reading WZs..."); + try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { + System.out.println("Reading WZs..."); - file = WZFiles.QUEST.getFile().resolve("Check.img.xml"); - bufferedReader = Files.newBufferedReader(file); + file = WZFiles.QUEST.getFile().resolve("Check.img.xml"); + bufferedReader = Files.newBufferedReader(file); - while ((line = bufferedReader.readLine()) != null) { - translateCheckToken(line); // fetch expired quests through here as well - } + while ((line = bufferedReader.readLine()) != null) { + translateCheckToken(line); // fetch expired quests through here as well + } - bufferedReader.close(); + bufferedReader.close(); - file = WZFiles.QUEST.getFile().resolve("Act.img.xml"); - bufferedReader = Files.newBufferedReader(file); + file = WZFiles.QUEST.getFile().resolve("Act.img.xml"); + bufferedReader = Files.newBufferedReader(file); - while ((line = bufferedReader.readLine()) != null) { - translateActToken(line); - } + while ((line = bufferedReader.readLine()) != null) { + translateActToken(line); + } - bufferedReader.close(); + bufferedReader.close(); - System.out.println("Calculating table diffs..."); - calculateQuestItemDiff(); + System.out.println("Calculating table diffs..."); + calculateQuestItemDiff(); - System.out.println("Filtering drops on DB..."); - List> itemsWithQuest = getPairsQuestItem(); + System.out.println("Filtering drops on DB..."); + List> itemsWithQuest = getPairsQuestItem(); - filterQuestDropsOnDB(itemsWithQuest); - con.close(); + filterQuestDropsOnDB(itemsWithQuest); + con.close(); - System.out.println("Filtering drops on project files..."); - // finally, filter whether this item is mentioned on the source code or not. - filterDirectorySearchMatchingData("scripts", itemsWithQuest); - filterDirectorySearchMatchingData("sql", itemsWithQuest); - filterDirectorySearchMatchingData("src", itemsWithQuest); + System.out.println("Filtering drops on project files..."); + // finally, filter whether this item is mentioned on the source code or not. + filterDirectorySearchMatchingData("scripts", itemsWithQuest); + filterDirectorySearchMatchingData("sql", itemsWithQuest); + 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 = pw; + System.out.println("Reporting results..."); + // report suspects of missing quest drop data, as well as those drop data that + // may have incorrect questids. + printWriter = pw; - printReportFileHeader(); + printReportFileHeader(); - if (!mixedQuestidItems.isEmpty()) { - printWriter.println("INCORRECT QUESTIDS ON DB"); - for (Map.Entry emqi : getSortedMapEntries1(mixedQuestidItems)) { - int[] mqi = emqi.getValue(); - printWriter.println(mqi[0] + " : " + mqi[1] + " -> " + mqi[2] + getExpiredStringLabel(mqi[2])); - } - printWriter.println("\n\n\n\n\n"); - } + if (!mixedQuestidItems.isEmpty()) { + printWriter.println("INCORRECT QUESTIDS ON DB"); + for (Map.Entry emqi : getSortedMapEntries1(mixedQuestidItems)) { + int[] mqi = emqi.getValue(); + printWriter.println(mqi[0] + " : " + mqi[1] + " -> " + mqi[2] + getExpiredStringLabel(mqi[2])); + } + printWriter.println("\n\n\n\n\n"); + } - if (!itemsWithQuest.isEmpty()) { - Map mapIwq = new HashMap<>(itemsWithQuest.size()); - for (Pair iwq : itemsWithQuest) { - mapIwq.put(iwq.getLeft(), iwq.getRight()); - } + if (!itemsWithQuest.isEmpty()) { + Map mapIwq = new HashMap<>(itemsWithQuest.size()); + for (Pair iwq : itemsWithQuest) { + mapIwq.put(iwq.getLeft(), iwq.getRight()); + } - printWriter.println("ITEMS WITH NO QUEST DROP DATA ON DB"); - for (Map.Entry iwq : getSortedMapEntries0(mapIwq)) { - printWriter.println(iwq.getKey() + " - " + iwq.getValue() + getExpiredStringLabel(iwq.getValue())); - } - printWriter.println("\n\n\n\n\n"); - } + printWriter.println("ITEMS WITH NO QUEST DROP DATA ON DB"); + for (Map.Entry iwq : getSortedMapEntries0(mapIwq)) { + printWriter.println(iwq.getKey() + " - " + iwq.getValue() + getExpiredStringLabel(iwq.getValue())); + } + printWriter.println("\n\n\n\n\n"); + } - if (DISPLAY_EXTRA_INFO) { - if (!zeroedStartQuestItems.isEmpty()) { - printWriter.println("START QUEST ITEMS WITH ZERO QUANTITY"); - for (Pair> iwq : getSortedMapEntries2(zeroedStartQuestItems)) { - printWriter.println(iwq.getLeft() + getExpiredStringLabel(iwq.getLeft()) + ":"); - for (Integer i : iwq.getRight()) { - printWriter.println(" " + i); - } - printWriter.println(); - } - printWriter.println("\n\n\n\n\n"); - } + if (DISPLAY_EXTRA_INFO) { + if (!zeroedStartQuestItems.isEmpty()) { + printWriter.println("START QUEST ITEMS WITH ZERO QUANTITY"); + for (Pair> iwq : getSortedMapEntries2(zeroedStartQuestItems)) { + printWriter.println(iwq.getLeft() + getExpiredStringLabel(iwq.getLeft()) + ":"); + for (Integer i : iwq.getRight()) { + printWriter.println(" " + i); + } + printWriter.println(); + } + printWriter.println("\n\n\n\n\n"); + } - if (!zeroedCompleteQuestItems.isEmpty()) { - printWriter.println("COMPLETE QUEST ITEMS WITH ZERO QUANTITY"); - for (Pair> iwq : getSortedMapEntries2(zeroedCompleteQuestItems)) { - printWriter.println(iwq.getLeft() + getExpiredStringLabel(iwq.getLeft()) + ":"); - for (Integer i : iwq.getRight()) { - printWriter.println(" " + i); - } - printWriter.println(); - } - printWriter.println("\n\n\n\n\n"); - } - } + if (!zeroedCompleteQuestItems.isEmpty()) { + printWriter.println("COMPLETE QUEST ITEMS WITH ZERO QUANTITY"); + for (Pair> iwq : getSortedMapEntries2(zeroedCompleteQuestItems)) { + printWriter.println(iwq.getLeft() + getExpiredStringLabel(iwq.getLeft()) + ":"); + for (Integer i : iwq.getRight()) { + printWriter.println(" " + i); + } + printWriter.println(); + } + printWriter.println("\n\n\n\n\n"); + } + } - System.out.println("Done!"); - } catch (FileNotFoundException ex) { - System.out.println("Unable to open file '" + file + "'"); - } catch (IOException ex) { - System.out.println("Error reading file '" + file + "'"); - } catch (SQLException e) { - System.out.println("Warning: Could not establish connection to database to report quest data."); - System.out.println(e.getMessage()); - } catch (Exception e) { - e.printStackTrace(); - } + System.out.println("Done!"); + } catch (FileNotFoundException ex) { + System.out.println("Unable to open file '" + file + "'"); + } catch (IOException ex) { + System.out.println("Error reading file '" + file + "'"); + } catch (SQLException e) { + System.out.println("Warning: Could not establish connection to database to report quest data."); + System.out.println(e.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + } } public static void main(String[] args) { diff --git a/src/main/java/tools/mapletools/QuestMesoFetcher.java b/src/main/java/tools/mapletools/QuestMesoFetcher.java index 25c72149b3..c2aae9e4d5 100644 --- a/src/main/java/tools/mapletools/QuestMesoFetcher.java +++ b/src/main/java/tools/mapletools/QuestMesoFetcher.java @@ -3,7 +3,6 @@ package tools.mapletools; import provider.wz.WZFiles; import java.io.*; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.*; @@ -228,29 +227,29 @@ public class QuestMesoFetcher { } 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))) { - System.out.println("Reading WZs..."); - readQuestMesoData(); + try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { + System.out.println("Reading WZs..."); + readQuestMesoData(); - System.out.println("Reporting results..."); - // report missing meso checks on quest completes - printWriter = pw; + System.out.println("Reporting results..."); + // report missing meso checks on quest completes + printWriter = pw; - printReportFileHeader(); + printReportFileHeader(); - printReportFileResults(checkedMesoQuests, appliedMesoQuests, true); - printReportFileResults(appliedMesoQuests, checkedMesoQuests, false); + printReportFileResults(checkedMesoQuests, appliedMesoQuests, true); + printReportFileResults(appliedMesoQuests, checkedMesoQuests, false); - System.out.println("Done!"); - } catch (FileNotFoundException ex) { - System.out.println("Unable to open quest file."); - } catch (IOException ex) { - System.out.println("Error reading quest file."); - } catch (Exception e) { - e.printStackTrace(); - } + System.out.println("Done!"); + } catch (FileNotFoundException ex) { + System.out.println("Unable to open quest file."); + } catch (IOException ex) { + System.out.println("Error reading quest file."); + } catch (Exception e) { + e.printStackTrace(); + } } public static void main(String[] args) { diff --git a/src/main/java/tools/mapletools/QuestlineFetcher.java b/src/main/java/tools/mapletools/QuestlineFetcher.java index ef102506b5..25c8e256a0 100644 --- a/src/main/java/tools/mapletools/QuestlineFetcher.java +++ b/src/main/java/tools/mapletools/QuestlineFetcher.java @@ -291,33 +291,33 @@ public class QuestlineFetcher { } 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))) { - System.out.println("Reading quest scripts..."); - instantiateQuestScriptFiles(ToolConstants.SCRIPTS_PATH + "/quest"); + try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { + System.out.println("Reading quest scripts..."); + instantiateQuestScriptFiles(ToolConstants.SCRIPTS_PATH + "/quest"); - System.out.println("Reading WZs..."); - readQuestsWithSkillReward(); - readQuestsWithMissingScripts(); + System.out.println("Reading WZs..."); + readQuestsWithSkillReward(); + readQuestsWithMissingScripts(); - System.out.println("Calculating skill related quests..."); - calculateSkillRelatedMissingQuestScripts(); + System.out.println("Calculating skill related quests..."); + calculateSkillRelatedMissingQuestScripts(); - System.out.println("Reporting results..."); - printWriter = pw; + System.out.println("Reporting results..."); + printWriter = pw; - printReportFileHeader(); - printReportFileResults(); + printReportFileHeader(); + printReportFileResults(); - System.out.println("Done!"); - } catch (FileNotFoundException ex) { - System.out.println("Unable to open quest file."); - } catch (IOException ex) { - System.out.println("Error reading quest file."); - } catch (Exception e) { - e.printStackTrace(); - } + System.out.println("Done!"); + } catch (FileNotFoundException ex) { + System.out.println("Unable to open quest file."); + } catch (IOException ex) { + System.out.println("Error reading quest file."); + } catch (Exception e) { + e.printStackTrace(); + } } /* diff --git a/src/main/java/tools/mapletools/ReactorDropFetcher.java b/src/main/java/tools/mapletools/ReactorDropFetcher.java index 8999acd199..3c88abcc06 100644 --- a/src/main/java/tools/mapletools/ReactorDropFetcher.java +++ b/src/main/java/tools/mapletools/ReactorDropFetcher.java @@ -1,10 +1,11 @@ package tools.mapletools; -import java.io.File; +import java.io.IOException; import java.io.PrintWriter; -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.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -40,14 +41,14 @@ public class ReactorDropFetcher { } private static void removeScriptedReactorids(String directoryName) { - File directory = new File(directoryName); - - // get all the files from a directory - File[] fList = directory.listFiles(); - for (File file : fList) { - if (file.isFile()) { - reactors.remove(getReactorIdFromFilename(file.getName())); + try (DirectoryStream stream = Files.newDirectoryStream(Paths.get(directoryName))) { + for (Path path : stream) { + if (Files.isRegularFile(path)) { + reactors.remove(getReactorIdFromFilename(path.getFileName().toString())); + } } + } catch (IOException e) { + e.printStackTrace(); } } @@ -86,25 +87,25 @@ public class ReactorDropFetcher { } private static void reportMissingReactors() { - try (con; PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { - System.out.println("Fetching reactors from DB..."); - fetchMissingReactorDrops(); + try (con; PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { + System.out.println("Fetching reactors from DB..."); + fetchMissingReactorDrops(); - printWriter = pw; + printWriter = pw; - // 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(); + // 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(); - System.out.println("Done!"); - } catch (SQLException e) { - System.out.println("Warning: Could not establish connection to database to report quest data."); - System.out.println(e.getMessage()); - } catch (Exception e) { - e.printStackTrace(); - } + System.out.println("Done!"); + } catch (SQLException e) { + System.out.println("Warning: Could not establish connection to database to report quest data."); + System.out.println(e.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + } } public static void main(String[] args) { diff --git a/src/main/java/tools/mapletools/SkillMakerFetcher.java b/src/main/java/tools/mapletools/SkillMakerFetcher.java index dd9eee54cf..38a52ad07e 100644 --- a/src/main/java/tools/mapletools/SkillMakerFetcher.java +++ b/src/main/java/tools/mapletools/SkillMakerFetcher.java @@ -5,7 +5,6 @@ import server.ItemInformationProvider; import tools.DatabaseConnection; import java.io.*; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -303,28 +302,28 @@ public class SkillMakerFetcher { private static void writeMakerTableData() { // This will reference one line at a time - String line = null; + String line = null; - try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE)); - BufferedReader br = Files.newBufferedReader(INPUT_FILE);) { - printWriter = pw; - bufferedReader = br; + try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE)); + BufferedReader br = Files.newBufferedReader(INPUT_FILE);) { + printWriter = pw; + bufferedReader = br; - resetMakerDataFields(); + resetMakerDataFields(); - while ((line = bufferedReader.readLine()) != null) { - translateToken(line); - } + while ((line = bufferedReader.readLine()) != null) { + translateToken(line); + } - WriteMakerTableFile(); + WriteMakerTableFile(); - } catch (FileNotFoundException ex) { - System.out.println("Unable to open file '" + INPUT_FILE + "'"); - } catch (IOException ex) { - System.out.println("Error reading file '" + INPUT_FILE + "'"); - } catch (Exception e) { - e.printStackTrace(); - } + } catch (FileNotFoundException ex) { + System.out.println("Unable to open file '" + INPUT_FILE + "'"); + } catch (IOException ex) { + System.out.println("Error reading file '" + INPUT_FILE + "'"); + } catch (Exception e) { + e.printStackTrace(); + } } public static void main(String[] args) { diff --git a/src/main/java/tools/mapletools/SkillMakerReagentIndexer.java b/src/main/java/tools/mapletools/SkillMakerReagentIndexer.java index e2f1d3e0af..77708d225a 100644 --- a/src/main/java/tools/mapletools/SkillMakerReagentIndexer.java +++ b/src/main/java/tools/mapletools/SkillMakerReagentIndexer.java @@ -4,7 +4,6 @@ import provider.wz.WZFiles; import tools.Pair; import java.io.*; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -150,29 +149,29 @@ public class SkillMakerReagentIndexer { } private static void writeMakerReagentTableData() { - // This will reference one line at a time - String line = null; + // This will reference one line at a time + String line = null; - try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE)); - BufferedReader br = Files.newBufferedReader(INPUT_FILE);) { - bufferedReader = br; + try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE)); + BufferedReader br = Files.newBufferedReader(INPUT_FILE);) { + bufferedReader = br; - while ((line = bufferedReader.readLine()) != null) { - translateToken(line); - } + while ((line = bufferedReader.readLine()) != null) { + translateToken(line); + } - SortReagentList(); + SortReagentList(); - printWriter = pw; - WriteMakerReagentTableFile(); - } catch (FileNotFoundException ex) { - System.out.println("Unable to open file '" + OUTPUT_FILE + "'"); - } catch (IOException ex) { - System.out.println("Error reading file '" + OUTPUT_FILE + "'"); - } catch (Exception e) { - e.printStackTrace(); - } - } + printWriter = pw; + WriteMakerReagentTableFile(); + } catch (FileNotFoundException ex) { + System.out.println("Unable to open file '" + OUTPUT_FILE + "'"); + } catch (IOException ex) { + System.out.println("Error reading file '" + OUTPUT_FILE + "'"); + } catch (Exception e) { + e.printStackTrace(); + } + } public static void main(String[] args) { writeMakerReagentTableData(); diff --git a/src/main/java/tools/mapletools/SkillbookChanceFetcher.java b/src/main/java/tools/mapletools/SkillbookChanceFetcher.java index 7afba7ed2d..9d9d065f68 100644 --- a/src/main/java/tools/mapletools/SkillbookChanceFetcher.java +++ b/src/main/java/tools/mapletools/SkillbookChanceFetcher.java @@ -3,10 +3,8 @@ package tools.mapletools; import server.life.MonsterStats; import tools.Pair; -import java.io.File; import java.io.IOException; import java.io.PrintWriter; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.sql.Connection; @@ -103,22 +101,22 @@ public class SkillbookChanceFetcher { printWriter.println(" REPLACE INTO drop_data (`dropperid`, `itemid`, `minimum_quantity`, `maximum_quantity`, `questid`, `chance`) VALUES"); } - private static void generateSkillbookChanceUpdateFile() { - try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { - printWriter = pw; + private static void generateSkillbookChanceUpdateFile() { + try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) { + printWriter = pw; - printSkillbookChanceUpdateSqlHeader(); + printSkillbookChanceUpdateSqlHeader(); - List, Integer>> skillbookChancesList = sortedSkillbookChances(); - for (Map.Entry, Integer> e : skillbookChancesList) { - printWriter.println("(" + e.getKey().getLeft() + ", " + e.getKey().getRight() + ", 1, 1, 0, " - + e.getValue() + "),"); - } + List, Integer>> skillbookChancesList = sortedSkillbookChances(); + for (Map.Entry, Integer> e : skillbookChancesList) { + printWriter.println("(" + e.getKey().getLeft() + ", " + e.getKey().getRight() + ", 1, 1, 0, " + + e.getValue() + "),"); + } - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } public static void main(String[] args) { // load mob stats from WZ diff --git a/src/main/java/tools/mapletools/SkillbookStackUpdate.java b/src/main/java/tools/mapletools/SkillbookStackUpdate.java index 7b7cb84f43..cedd89a2b9 100644 --- a/src/main/java/tools/mapletools/SkillbookStackUpdate.java +++ b/src/main/java/tools/mapletools/SkillbookStackUpdate.java @@ -6,7 +6,6 @@ import java.io.*; 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; @@ -151,7 +150,6 @@ public class SkillbookStackUpdate { parseItemFile(path, outputDirectory.resolve(path.getFileName())); } } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } }