Merge pull request #78 from truongdatnhan/master
Upgrade to to File NIO
This commit is contained in:
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1,4 +1,4 @@
|
|||||||
/logs/**
|
/logs/**
|
||||||
.idea/
|
.idea/
|
||||||
*.iml
|
*.iml
|
||||||
/target
|
/target
|
||||||
@@ -7,6 +7,12 @@
|
|||||||
/build/
|
/build/
|
||||||
/dist/
|
/dist/
|
||||||
/nbproject/
|
/nbproject/
|
||||||
|
/.settings
|
||||||
/out
|
/out
|
||||||
*.onetoc2
|
*.onetoc2
|
||||||
|
|
||||||
|
# Eclipse m2e generated files
|
||||||
|
# Eclipse Core
|
||||||
|
.project
|
||||||
|
# JDT-specific (Eclipse Java Development Tools)
|
||||||
|
.classpath
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
2000000 - Red Potion - A potion made out of red herbs.\nRecovers 50 HP.
|
2000000 - Red Potion - A potion made out of red herbs.\nRecovers 50 HP.
|
||||||
2000001 - Orange Potion - A concentrated potion made out of red herbs.\nRecovers 150 HP.
|
2000001 - Orange Potion - A concentrated potion made out of red herbs.\nRecovers 150 HP.
|
||||||
2000002 - White Potion - A highly-concentrated potion made out of red herbs.\nRecovers 300 HP.
|
2000002 - White Potion - A highly-concentrated potion made out of red herbs.\nRecovers 300 HP.
|
||||||
2000003 - Blue Potion - A potion made out of blue herbs.\nRecovers 100 MP.
|
2000003 - Blue Potion - A potion made out of blue herbs.\nRecovers 100 MP.
|
||||||
|
|||||||
8
pom.xml
8
pom.xml
@@ -25,15 +25,15 @@
|
|||||||
|
|
||||||
<!-- Dependencies -->
|
<!-- Dependencies -->
|
||||||
<slf4j-api.version>1.7.36</slf4j-api.version> <!-- Logging facade -->
|
<slf4j-api.version>1.7.36</slf4j-api.version> <!-- Logging facade -->
|
||||||
<log4j.version>2.17.1</log4j.version> <!-- Slf4j implementation -->
|
<log4j.version>2.18.0</log4j.version> <!-- Slf4j implementation -->
|
||||||
<graalvm.version>21.1.0</graalvm.version> <!-- ScriptEngine implementation -->
|
<graalvm.version>22.2.0</graalvm.version> <!-- ScriptEngine implementation -->
|
||||||
<netty.version>4.1.74.Final</netty.version> <!-- Networking -->
|
<netty.version>4.1.79.Final</netty.version> <!-- Networking -->
|
||||||
<junit.version>5.8.2</junit.version> <!-- Unit test -->
|
<junit.version>5.8.2</junit.version> <!-- Unit test -->
|
||||||
<yamlbeans.version>1.15</yamlbeans.version> <!-- Config file -->
|
<yamlbeans.version>1.15</yamlbeans.version> <!-- Config file -->
|
||||||
<jcip-annotations.version>1.0</jcip-annotations.version> <!-- Annotations for concurrency documentation -->
|
<jcip-annotations.version>1.0</jcip-annotations.version> <!-- Annotations for concurrency documentation -->
|
||||||
<commons-io.version>2.11.0</commons-io.version> <!-- Util library used by some of our tools -->
|
<commons-io.version>2.11.0</commons-io.version> <!-- Util library used by some of our tools -->
|
||||||
<HikariCP.version>5.0.1</HikariCP.version> <!-- Database connection pool -->
|
<HikariCP.version>5.0.1</HikariCP.version> <!-- Database connection pool -->
|
||||||
<mysql-connector-java.version>8.0.28</mysql-connector-java.version> <!-- MySQL JDBC driver -->
|
<mysql-connector-java.version>8.0.30</mysql-connector-java.version> <!-- MySQL JDBC driver -->
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -76,44 +76,10 @@ public enum Stat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Stat getByString(String type) {
|
public static Stat getByString(String type) {
|
||||||
if (type.equals("SKIN")) {
|
for (Stat stat : Stat.values()) {
|
||||||
return SKIN;
|
if (stat.name().equals(type)) {
|
||||||
} else if (type.equals("FACE")) {
|
return stat;
|
||||||
return FACE;
|
}
|
||||||
} else if (type.equals("HAIR")) {
|
|
||||||
return HAIR;
|
|
||||||
} else if (type.equals("LEVEL")) {
|
|
||||||
return LEVEL;
|
|
||||||
} else if (type.equals("JOB")) {
|
|
||||||
return JOB;
|
|
||||||
} else if (type.equals("STR")) {
|
|
||||||
return STR;
|
|
||||||
} else if (type.equals("DEX")) {
|
|
||||||
return DEX;
|
|
||||||
} else if (type.equals("INT")) {
|
|
||||||
return INT;
|
|
||||||
} else if (type.equals("LUK")) {
|
|
||||||
return LUK;
|
|
||||||
} else if (type.equals("HP")) {
|
|
||||||
return HP;
|
|
||||||
} else if (type.equals("MAXHP")) {
|
|
||||||
return MAXHP;
|
|
||||||
} else if (type.equals("MP")) {
|
|
||||||
return MP;
|
|
||||||
} else if (type.equals("MAXMP")) {
|
|
||||||
return MAXMP;
|
|
||||||
} else if (type.equals("AVAILABLEAP")) {
|
|
||||||
return AVAILABLEAP;
|
|
||||||
} else if (type.equals("AVAILABLESP")) {
|
|
||||||
return AVAILABLESP;
|
|
||||||
} else if (type.equals("EXP")) {
|
|
||||||
return EXP;
|
|
||||||
} else if (type.equals("FAME")) {
|
|
||||||
return FAME;
|
|
||||||
} else if (type.equals("MESO")) {
|
|
||||||
return MESO;
|
|
||||||
} else if (type.equals("PET")) {
|
|
||||||
return PET;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,11 @@ import server.maps.*;
|
|||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
import tools.Pair;
|
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.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
@@ -448,8 +452,14 @@ public final class Channel {
|
|||||||
|
|
||||||
private static String[] getEvents() {
|
private static String[] getEvents() {
|
||||||
List<String> events = new ArrayList<>();
|
List<String> events = new ArrayList<>();
|
||||||
for (File file : new File("scripts/event").listFiles()) {
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get("scripts/event"))) {
|
||||||
events.add(file.getName().substring(0, file.getName().length() - 3));
|
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]);
|
return events.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,10 @@ import provider.wz.WZFiles;
|
|||||||
import provider.wz.XMLWZFile;
|
import provider.wz.XMLWZFile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class DataProviderFactory {
|
public class DataProviderFactory {
|
||||||
private static DataProvider getWZ(File in) {
|
private static DataProvider getWZ(Path in) {
|
||||||
return new XMLWZFile(in);
|
return new XMLWZFile(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package provider.wz;
|
package provider.wz;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
public enum WZFiles {
|
public enum WZFiles {
|
||||||
QUEST("Quest"),
|
QUEST("Quest"),
|
||||||
@@ -25,17 +27,16 @@ public enum WZFiles {
|
|||||||
this.fileName = name + ".wz";
|
this.fileName = name + ".wz";
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getFile() {
|
public Path getFile() {
|
||||||
return new File(DIRECTORY, fileName);
|
return Paths.get(DIRECTORY).resolve(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFilePath() {
|
public String getFilePath() {
|
||||||
return getFile().getPath();
|
return getFile().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getWzDirectory() {
|
private static String getWzDirectory() {
|
||||||
// Either provide a custom directory path through the "wz-path" property when launching the .jar,
|
// 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
|
||||||
// or don't provide one to use the default "wz" directory
|
|
||||||
String propertyPath = System.getProperty("wz-path");
|
String propertyPath = System.getProperty("wz-path");
|
||||||
if (propertyPath != null && new File(propertyPath).isDirectory()) {
|
if (propertyPath != null && new File(propertyPath).isDirectory()) {
|
||||||
return propertyPath;
|
return propertyPath;
|
||||||
|
|||||||
@@ -37,15 +37,16 @@ import java.awt.*;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class XMLDomMapleData implements Data {
|
public class XMLDomMapleData implements Data {
|
||||||
private final Node node;
|
private final Node node;
|
||||||
private File imageDataDir;
|
private Path imageDataDir;
|
||||||
|
|
||||||
public XMLDomMapleData(FileInputStream fis, File imageDataDir) {
|
public XMLDomMapleData(FileInputStream fis, Path imageDataDir) {
|
||||||
try {
|
try {
|
||||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||||
@@ -79,7 +80,8 @@ public class XMLDomMapleData implements Data {
|
|||||||
boolean foundChild = false;
|
boolean foundChild = false;
|
||||||
for (int i = 0; i < childNodes.getLength(); i++) {
|
for (int i = 0; i < childNodes.getLength(); i++) {
|
||||||
Node childNode = childNodes.item(i);
|
Node childNode = childNodes.item(i);
|
||||||
if (childNode.getNodeType() == Node.ELEMENT_NODE && childNode.getAttributes().getNamedItem("name").getNodeValue().equals(s)) {
|
if (childNode.getNodeType() == Node.ELEMENT_NODE
|
||||||
|
&& childNode.getAttributes().getNamedItem("name").getNodeValue().equals(s)) {
|
||||||
myNode = childNode;
|
myNode = childNode;
|
||||||
foundChild = true;
|
foundChild = true;
|
||||||
break;
|
break;
|
||||||
@@ -91,7 +93,7 @@ public class XMLDomMapleData implements Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
XMLDomMapleData ret = new XMLDomMapleData(myNode);
|
XMLDomMapleData ret = new XMLDomMapleData(myNode);
|
||||||
ret.imageDataDir = new File(imageDataDir, getName() + "/" + path).getParentFile();
|
ret.imageDataDir = imageDataDir.resolve(getName().trim()).resolve(path).getParent();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +106,7 @@ public class XMLDomMapleData implements Data {
|
|||||||
Node childNode = childNodes.item(i);
|
Node childNode = childNodes.item(i);
|
||||||
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
|
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
XMLDomMapleData child = new XMLDomMapleData(childNode);
|
XMLDomMapleData child = new XMLDomMapleData(childNode);
|
||||||
child.imageDataDir = new File(imageDataDir, getName());
|
child.imageDataDir = imageDataDir.resolve(getName().trim());
|
||||||
ret.add(child);
|
ret.add(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,7 +195,7 @@ public class XMLDomMapleData implements Data {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
XMLDomMapleData parentData = new XMLDomMapleData(parentNode);
|
XMLDomMapleData parentData = new XMLDomMapleData(parentNode);
|
||||||
parentData.imageDataDir = imageDataDir.getParentFile();
|
parentData.imageDataDir = imageDataDir.getParent();
|
||||||
return parentData;
|
return parentData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,62 +25,66 @@ import provider.Data;
|
|||||||
import provider.DataDirectoryEntry;
|
import provider.DataDirectoryEntry;
|
||||||
import provider.DataProvider;
|
import provider.DataProvider;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.DirectoryStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class XMLWZFile implements DataProvider {
|
public class XMLWZFile implements DataProvider {
|
||||||
private final File root;
|
private static final Logger log = LoggerFactory.getLogger(DataProvider.class);
|
||||||
|
private final Path root;
|
||||||
private final WZDirectoryEntry rootForNavigation;
|
private final WZDirectoryEntry rootForNavigation;
|
||||||
|
|
||||||
public XMLWZFile(File fileIn) {
|
public XMLWZFile(Path fileIn) {
|
||||||
root = fileIn;
|
root = fileIn;
|
||||||
rootForNavigation = new WZDirectoryEntry(fileIn.getName(), 0, 0, null);
|
rootForNavigation = new WZDirectoryEntry(fileIn.getFileName().toString(), 0, 0, null);
|
||||||
fillMapleDataEntitys(root, rootForNavigation);
|
fillMapleDataEntitys(root, rootForNavigation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillMapleDataEntitys(File lroot, WZDirectoryEntry wzdir) {
|
private void fillMapleDataEntitys(Path lroot, WZDirectoryEntry wzdir) {
|
||||||
for (File file : lroot.listFiles()) {
|
|
||||||
String fileName = file.getName();
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(lroot)) {
|
||||||
if (file.isDirectory() && !fileName.endsWith(".img")) {
|
for (Path path : stream) {
|
||||||
WZDirectoryEntry newDir = new WZDirectoryEntry(fileName, 0, 0, wzdir);
|
String fileName = path.getFileName().toString();
|
||||||
wzdir.addDirectory(newDir);
|
if (Files.isDirectory(path) && !fileName.endsWith(".img")) {
|
||||||
fillMapleDataEntitys(file, newDir);
|
WZDirectoryEntry newDir = new WZDirectoryEntry(fileName, 0, 0, wzdir);
|
||||||
} else if (fileName.endsWith(".xml")) {
|
wzdir.addDirectory(newDir);
|
||||||
wzdir.addFile(new WZFileEntry(fileName.substring(0, fileName.length() - 4), 0, 0, wzdir));
|
fillMapleDataEntitys(path, newDir);
|
||||||
|
} else if (fileName.endsWith(".xml")) {
|
||||||
|
wzdir.addFile(new WZFileEntry(fileName.substring(0, fileName.length() - 4), 0, 0, wzdir));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.warn("Can not open file/directory at " + lroot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized Data getData(String path) {
|
public synchronized Data getData(String path) {
|
||||||
File dataFile = new File(root, path + ".xml");
|
Path dataFile = root.resolve(path + ".xml");
|
||||||
File imageDataDir = new File(root, path);
|
Path imageDataDir = root.resolve(path);
|
||||||
if (!dataFile.exists()) {
|
if (!Files.exists(dataFile)) {
|
||||||
return null;//bitches
|
return null;// bitches
|
||||||
}
|
|
||||||
FileInputStream fis;
|
|
||||||
try {
|
|
||||||
fis = new FileInputStream(dataFile);
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
throw new RuntimeException("Datafile " + path + " does not exist in " + root.getAbsolutePath());
|
|
||||||
}
|
}
|
||||||
final XMLDomMapleData domMapleData;
|
final XMLDomMapleData domMapleData;
|
||||||
try {
|
try (FileInputStream fis = new FileInputStream(dataFile.toString())) {
|
||||||
domMapleData = new XMLDomMapleData(fis, imageDataDir.getParentFile());
|
domMapleData = new XMLDomMapleData(fis, imageDataDir.getParent());
|
||||||
} finally {
|
} catch (FileNotFoundException e) {
|
||||||
try {
|
throw new RuntimeException("Datafile " + path + " does not exist in " + root.toAbsolutePath());
|
||||||
fis.close();
|
} catch (IOException e) {
|
||||||
} catch (IOException e) {
|
throw new RuntimeException(e);
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return domMapleData;
|
return domMapleData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataDirectoryEntry getRoot() {
|
public DataDirectoryEntry getRoot() {
|
||||||
return rootForNavigation;
|
return rootForNavigation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,11 +26,17 @@ import provider.Data;
|
|||||||
import provider.DataProvider;
|
import provider.DataProvider;
|
||||||
import provider.DataProviderFactory;
|
import provider.DataProviderFactory;
|
||||||
import provider.DataTool;
|
import provider.DataTool;
|
||||||
|
import provider.wz.WZDirectoryEntry;
|
||||||
|
import provider.wz.WZFileEntry;
|
||||||
import provider.wz.WZFiles;
|
import provider.wz.WZFiles;
|
||||||
import tools.DatabaseConnection;
|
import tools.DatabaseConnection;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.DirectoryStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -185,26 +191,31 @@ public class SkillbookInformationProvider {
|
|||||||
return loadedSkillbooks;
|
return loadedSkillbooks;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void listFiles(String directoryName, ArrayList<File> files) {
|
private static void listFiles(String directoryName, ArrayList<Path> files) {
|
||||||
File directory = new File(directoryName);
|
Path directory = Paths.get(directoryName);
|
||||||
|
|
||||||
// get all the files from a directory
|
// get all the files from a directory
|
||||||
File[] fList = directory.listFiles();
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory)) {
|
||||||
for (File file : fList) {
|
for (Path path : stream) {
|
||||||
if (file.isFile()) {
|
|
||||||
files.add(file);
|
if (Files.isRegularFile(path)) {
|
||||||
} else if (file.isDirectory()) {
|
files.add(path);
|
||||||
listFiles(file.getAbsolutePath(), files);
|
} 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) {
|
private static List<Path> listFilesFromDirectoryRecursively(String directory) {
|
||||||
ArrayList<File> files = new ArrayList<>();
|
ArrayList<Path> files = new ArrayList<>();
|
||||||
listFiles(directory, files);
|
listFiles(directory, files);
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<Integer> findMatchingSkillbookIdsOnFile(String fileContent) {
|
private static Set<Integer> findMatchingSkillbookIdsOnFile(String fileContent) {
|
||||||
Set<Integer> skillbookIds = new HashSet<>(4);
|
Set<Integer> skillbookIds = new HashSet<>(4);
|
||||||
@@ -219,22 +230,20 @@ public class SkillbookInformationProvider {
|
|||||||
return skillbookIds;
|
return skillbookIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String readFileToString(File file, String encoding) throws IOException {
|
private static String readFileToString(Path file, String encoding) throws IOException {
|
||||||
Scanner scanner = new Scanner(file, encoding);
|
Scanner scanner = new Scanner(file, encoding);
|
||||||
String text = "";
|
String text = "";
|
||||||
try {
|
try (scanner) {
|
||||||
try {
|
|
||||||
text = scanner.useDelimiter("\\A").next();
|
text = scanner.useDelimiter("\\A").next();
|
||||||
} finally {
|
|
||||||
scanner.close();
|
|
||||||
}
|
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<Integer, SkillBookEntry> fileSearchMatchingData(File file) {
|
private static Map<Integer, SkillBookEntry> fileSearchMatchingData(Path file) {
|
||||||
Map<Integer, SkillBookEntry> scriptFileSkillbooks = new HashMap<>();
|
Map<Integer, SkillBookEntry> scriptFileSkillbooks = new HashMap<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -245,7 +254,7 @@ public class SkillbookInformationProvider {
|
|||||||
scriptFileSkillbooks.put(skillbookId, SkillBookEntry.SCRIPT);
|
scriptFileSkillbooks.put(skillbookId, SkillBookEntry.SCRIPT);
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
log.error("Failed to read file:{}", file.getName(), ioe);
|
log.error("Failed to read file:{}", file.getFileName(), ioe);
|
||||||
}
|
}
|
||||||
|
|
||||||
return scriptFileSkillbooks;
|
return scriptFileSkillbooks;
|
||||||
@@ -254,8 +263,8 @@ public class SkillbookInformationProvider {
|
|||||||
private static Map<Integer, SkillBookEntry> fetchSkillbooksFromScripts() {
|
private static Map<Integer, SkillBookEntry> fetchSkillbooksFromScripts() {
|
||||||
Map<Integer, SkillBookEntry> scriptSkillbooks = new HashMap<>();
|
Map<Integer, SkillBookEntry> scriptSkillbooks = new HashMap<>();
|
||||||
|
|
||||||
for (File file : listFilesFromDirectoryRecursively("./scripts")) {
|
for (Path file : listFilesFromDirectoryRecursively("./scripts")) {
|
||||||
if (file.getName().endsWith(".js")) {
|
if (file.getFileName().endsWith(".js")) {
|
||||||
scriptSkillbooks.putAll(fileSearchMatchingData(file));
|
scriptSkillbooks.putAll(fileSearchMatchingData(file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ import server.life.MonsterStats;
|
|||||||
import tools.Pair;
|
import tools.Pair;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.Files;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -171,7 +173,7 @@ public class ArrowFetcher {
|
|||||||
if (!existingEntries.isEmpty()) {
|
if (!existingEntries.isEmpty()) {
|
||||||
List<int[]> entryValues = getArrowEntryValues(existingEntries);
|
List<int[]> entryValues = getArrowEntryValues(existingEntries);
|
||||||
|
|
||||||
printWriter = new PrintWriter(ToolConstants.getOutputFile(OUTPUT_FILE_NAME), StandardCharsets.UTF_8);
|
printWriter = new PrintWriter(Files.newOutputStream(ToolConstants.getOutputFile(OUTPUT_FILE_NAME)));
|
||||||
printSqlHeader();
|
printSqlHeader();
|
||||||
|
|
||||||
for (int[] arrowEntry : entryValues) {
|
for (int[] arrowEntry : entryValues) {
|
||||||
@@ -211,10 +213,15 @@ public class ArrowFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Instant instantStarted = Instant.now();
|
||||||
// load mob stats from WZ
|
// load mob stats from WZ
|
||||||
mobStats = MonsterStatFetcher.getAllMonsterStats();
|
mobStats = MonsterStatFetcher.getAllMonsterStats();
|
||||||
|
|
||||||
calcAllMobsArrowRange();
|
calcAllMobsArrowRange();
|
||||||
updateMobsArrowRange();
|
updateMobsArrowRange();
|
||||||
|
Instant instantStopped = Instant.now();
|
||||||
|
Duration durationBetween = Duration.between(instantStarted, instantStopped);
|
||||||
|
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
|
||||||
|
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ package tools.mapletools;
|
|||||||
import provider.wz.WZFiles;
|
import provider.wz.WZFiles;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.DirectoryStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -129,20 +133,18 @@ public class BossHpBarFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void readBossHpBarData() throws IOException {
|
private static void readBossHpBarData() throws IOException {
|
||||||
String line;
|
final Path mobDirectory = WZFiles.MOB.getFile();
|
||||||
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(mobDirectory)) {
|
||||||
final File mobDirectory = WZFiles.MOB.getFile();
|
for (Path path : stream) {
|
||||||
for (File file : mobDirectory.listFiles()) {
|
if (Files.isRegularFile(path)) {
|
||||||
if (file.isFile()) {
|
try (BufferedReader br = Files.newBufferedReader(path)) {
|
||||||
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
bufferedReader = br;
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
String line;
|
||||||
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
translateToken(line);
|
||||||
translateToken(line);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferedReader.close();
|
|
||||||
fileReader.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,17 +164,15 @@ public class BossHpBarFetcher {
|
|||||||
private static void reportBossHpBarData() {
|
private static void reportBossHpBarData() {
|
||||||
// This will reference one line at a time
|
// This will reference one line at a time
|
||||||
|
|
||||||
try {
|
try (PrintWriter printWriter = new PrintWriter(Files.newOutputStream(ToolConstants.getOutputFile(OUTPUT_FILE_NAME)))) {
|
||||||
System.out.println("Reading WZs...");
|
System.out.println("Reading WZs...");
|
||||||
readBossHpBarData();
|
readBossHpBarData();
|
||||||
|
|
||||||
System.out.println("Reporting results...");
|
System.out.println("Reporting results...");
|
||||||
final PrintWriter printWriter = new PrintWriter(ToolConstants.getOutputFile(OUTPUT_FILE_NAME), StandardCharsets.UTF_8);
|
|
||||||
|
|
||||||
printReportFileHeader(printWriter);
|
printReportFileHeader(printWriter);
|
||||||
printReportFileResults(printWriter);
|
printReportFileResults(printWriter);
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
System.out.println("Done!");
|
System.out.println("Done!");
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
System.out.println("Unable to open mob file.");
|
System.out.println("Unable to open mob file.");
|
||||||
@@ -184,7 +184,12 @@ public class BossHpBarFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Instant instantStarted = Instant.now();
|
||||||
reportBossHpBarData();
|
reportBossHpBarData();
|
||||||
|
Instant instantStopped = Instant.now();
|
||||||
|
Duration durationBetween = Duration.between(instantStarted, instantStopped);
|
||||||
|
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
|
||||||
|
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import tools.Pair;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,8 +23,8 @@ import java.util.*;
|
|||||||
* Estimated parse time: 1 minute
|
* Estimated parse time: 1 minute
|
||||||
*/
|
*/
|
||||||
public class CashCosmeticsChecker {
|
public class CashCosmeticsChecker {
|
||||||
private static final String INPUT_DIRECTORY_PATH = ToolConstants.getInputFile("care").getPath();
|
private static final String INPUT_DIRECTORY_PATH = ToolConstants.getInputFile("care").toString();
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("cash_cosmetics_result.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("cash_cosmetics_result.txt");
|
||||||
private static final boolean IGNORE_CURRENT_SCRIPT_COSMETICS = false; // Toggle to preference
|
private static final boolean IGNORE_CURRENT_SCRIPT_COSMETICS = false; // Toggle to preference
|
||||||
private static final int INITIAL_STRING_LENGTH = 50;
|
private static final int INITIAL_STRING_LENGTH = 50;
|
||||||
|
|
||||||
@@ -614,50 +616,50 @@ public class CashCosmeticsChecker {
|
|||||||
private static void reportCosmeticResults() throws IOException {
|
private static void reportCosmeticResults() throws IOException {
|
||||||
System.out.println("Reporting results ...");
|
System.out.println("Reporting results ...");
|
||||||
|
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));) {
|
||||||
|
printWriter = pw;
|
||||||
|
printReportFileHeader();
|
||||||
|
|
||||||
printReportFileHeader();
|
if (!missingCosmeticsNpcTypes.isEmpty()) {
|
||||||
|
printWriter.println(
|
||||||
|
"Found " + missingCosmeticsNpcTypes.size() + " entries with missing cosmetic entries.");
|
||||||
|
|
||||||
if (!missingCosmeticsNpcTypes.isEmpty()) {
|
for (Pair<Pair<Integer, String>, List<Integer>> mcn : getSortedMapEntries(missingCosmeticsNpcTypes)) {
|
||||||
printWriter.println("Found " + missingCosmeticsNpcTypes.size() + " entries with missing cosmetic entries.");
|
printWriter.println(" NPC " + mcn.getLeft());
|
||||||
|
|
||||||
for (Pair<Pair<Integer, String>, List<Integer>> mcn : getSortedMapEntries(missingCosmeticsNpcTypes)) {
|
Pair<List<Integer>, List<Integer>> genderItemids = getCosmeticReport(mcn.getRight());
|
||||||
printWriter.println(" NPC " + mcn.getLeft());
|
reportNpcCosmetics(genderItemids.getLeft());
|
||||||
|
reportNpcCosmetics(genderItemids.getRight());
|
||||||
|
printWriter.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!unusedCosmetics.isEmpty()) {
|
||||||
|
printWriter.println("Unused cosmetics: " + unusedCosmetics.size());
|
||||||
|
|
||||||
|
List<Integer> list = new ArrayList<>(unusedCosmetics);
|
||||||
|
Collections.sort(list);
|
||||||
|
|
||||||
|
for (Integer i : list) {
|
||||||
|
printWriter.println(i + " " + cosmeticIdNames.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
printWriter.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!missingCosmeticNames.isEmpty()) {
|
||||||
|
printWriter.println("Missing cosmetic itemids: " + missingCosmeticNames.size());
|
||||||
|
|
||||||
|
List<String> listString = new ArrayList<>(missingCosmeticNames);
|
||||||
|
Collections.sort(listString);
|
||||||
|
|
||||||
|
for (String c : listString) {
|
||||||
|
printWriter.println(c);
|
||||||
|
}
|
||||||
|
|
||||||
Pair<List<Integer>, List<Integer>> genderItemids = getCosmeticReport(mcn.getRight());
|
|
||||||
reportNpcCosmetics(genderItemids.getLeft());
|
|
||||||
reportNpcCosmetics(genderItemids.getRight());
|
|
||||||
printWriter.println();
|
printWriter.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!unusedCosmetics.isEmpty()) {
|
|
||||||
printWriter.println("Unused cosmetics: " + unusedCosmetics.size());
|
|
||||||
|
|
||||||
List<Integer> list = new ArrayList<>(unusedCosmetics);
|
|
||||||
Collections.sort(list);
|
|
||||||
|
|
||||||
for (Integer i : list) {
|
|
||||||
printWriter.println(i + " " + cosmeticIdNames.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
printWriter.println();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!missingCosmeticNames.isEmpty()) {
|
|
||||||
printWriter.println("Missing cosmetic itemids: " + missingCosmeticNames.size());
|
|
||||||
|
|
||||||
List<String> listString = new ArrayList<>(missingCosmeticNames);
|
|
||||||
Collections.sort(listString);
|
|
||||||
|
|
||||||
for (String c : listString) {
|
|
||||||
printWriter.println(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
printWriter.println();
|
|
||||||
}
|
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import provider.wz.WZFiles;
|
|||||||
import tools.Pair;
|
import tools.Pair;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.DirectoryStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -20,7 +22,7 @@ import java.util.*;
|
|||||||
* Estimated parse time: 2 minutes
|
* Estimated parse time: 2 minutes
|
||||||
*/
|
*/
|
||||||
public class CashDropFetcher {
|
public class CashDropFetcher {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("cash_drop_report.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("cash_drop_report.txt");
|
||||||
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
||||||
private static final int INITIAL_STRING_LENGTH = 50;
|
private static final int INITIAL_STRING_LENGTH = 50;
|
||||||
private static final int ITEM_FILE_NAME_SIZE = 13;
|
private static final int ITEM_FILE_NAME_SIZE = 13;
|
||||||
@@ -175,17 +177,19 @@ public class CashDropFetcher {
|
|||||||
printWriter.println();
|
printWriter.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void listFiles(String directoryName, ArrayList<File> files) {
|
private static void listFiles(Path directoryName, ArrayList<Path> files) {
|
||||||
File directory = new File(directoryName);
|
|
||||||
|
|
||||||
// get all the files from a directory
|
// get all the files from a directory
|
||||||
File[] fList = directory.listFiles();
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(directoryName)) {
|
||||||
for (File file : fList) {
|
for (Path path : stream) {
|
||||||
if (file.isFile()) {
|
if (Files.isRegularFile(path)) {
|
||||||
files.add(file);
|
files.add(path);
|
||||||
} else if (file.isDirectory()) {
|
} else if (Files.isDirectory(path)) {
|
||||||
listFiles(file.getAbsolutePath(), files);
|
listFiles(path, files);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,42 +264,39 @@ public class CashDropFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void reportNxDropData() {
|
private static void reportNxDropData() {
|
||||||
try {
|
try (con; PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
System.out.println("Reading Character.wz ...");
|
System.out.println("Reading Character.wz ...");
|
||||||
ArrayList<File> files = new ArrayList<>();
|
ArrayList<Path> files = new ArrayList<>();
|
||||||
listFiles(WZFiles.CHARACTER.getFilePath(), files);
|
listFiles(WZFiles.CHARACTER.getFile(), files);
|
||||||
|
|
||||||
InputStreamReader fileReader = null;
|
for (Path path : files) {
|
||||||
for (File f : files) {
|
// System.out.println("Parsing " + f.getAbsolutePath());
|
||||||
//System.out.println("Parsing " + f.getAbsolutePath());
|
int itemid = getItemIdFromFilename(path.getFileName().toString());
|
||||||
int itemid = getItemIdFromFilename(f.getName());
|
|
||||||
if (itemid < 0) {
|
if (itemid < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileReader = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8);
|
bufferedReader = Files.newBufferedReader(path);
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
|
||||||
|
|
||||||
currentItemid = itemid;
|
currentItemid = itemid;
|
||||||
inspectEquipWzEntry();
|
inspectEquipWzEntry();
|
||||||
|
|
||||||
bufferedReader.close();
|
bufferedReader.close();
|
||||||
fileReader.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Reading Item.wz ...");
|
System.out.println("Reading Item.wz ...");
|
||||||
files = new ArrayList<>();
|
files = new ArrayList<>();
|
||||||
listFiles(WZFiles.ITEM.getFilePath(), files);
|
listFiles(WZFiles.ITEM.getFile(), files);
|
||||||
|
|
||||||
for (File f : files) {
|
for (Path path : files) {
|
||||||
//System.out.println("Parsing " + f.getAbsolutePath());
|
// System.out.println("Parsing " + f.getAbsolutePath());
|
||||||
fileReader = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8);
|
bufferedReader = Files.newBufferedReader(path);
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
|
||||||
|
|
||||||
if (f.getName().length() <= ITEM_FILE_NAME_SIZE) {
|
if (path.getFileName().toString().length() <= ITEM_FILE_NAME_SIZE) {
|
||||||
inspectItemWzEntry();
|
inspectItemWzEntry();
|
||||||
} else { // pet file structure is similar to equips, maybe there are other item-types following this behaviour?
|
} else { // pet file structure is similar to equips, maybe there are other item-types
|
||||||
int itemid = getItemIdFromFilename(f.getName());
|
// following this behaviour?
|
||||||
|
int itemid = getItemIdFromFilename(path.getFileName().toString());
|
||||||
if (itemid < 0) {
|
if (itemid < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -305,27 +306,23 @@ public class CashDropFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bufferedReader.close();
|
bufferedReader.close();
|
||||||
fileReader.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Reporting results...");
|
System.out.println("Reporting results...");
|
||||||
|
|
||||||
// report suspects of missing quest drop data, as well as those drop data that may have incorrect questids.
|
// report suspects of missing quest drop data, as well as those drop data that
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
// may have incorrect questids.
|
||||||
|
printWriter = pw;
|
||||||
printReportFileHeader();
|
printReportFileHeader();
|
||||||
|
|
||||||
reportNxDropResults(true);
|
reportNxDropResults(true);
|
||||||
reportNxDropResults(false);
|
reportNxDropResults(false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
printWriter.println("NX LIST"); // list of all cash items found
|
* printWriter.println("NX LIST"); // list of all cash items found for(Integer
|
||||||
for(Integer nx : nxItems) {
|
* nx : nxItems) { printWriter.println(nx); }
|
||||||
printWriter.println(nx);
|
*/
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
con.close();
|
|
||||||
printWriter.close();
|
|
||||||
System.out.println("Done!");
|
System.out.println("Done!");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println("Warning: Could not establish connection to database to report quest data.");
|
System.out.println("Warning: Could not establish connection to database to report quest data.");
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import provider.wz.WZFiles;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -16,7 +18,7 @@ import java.util.Set;
|
|||||||
* Estimated parse time: 10 seconds
|
* Estimated parse time: 10 seconds
|
||||||
*/
|
*/
|
||||||
public class CashVegaChecker {
|
public class CashVegaChecker {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("vega_checker_report.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("vega_checker_report.txt");
|
||||||
private static final int INITIAL_STRING_LENGTH = 1000;
|
private static final int INITIAL_STRING_LENGTH = 1000;
|
||||||
private static final Set<Integer> vegaItems = new HashSet<>();
|
private static final Set<Integer> vegaItems = new HashSet<>();
|
||||||
|
|
||||||
@@ -156,16 +158,14 @@ public class CashVegaChecker {
|
|||||||
private static void reportMissingVegaItems() {
|
private static void reportMissingVegaItems() {
|
||||||
System.out.println("Reporting results ...");
|
System.out.println("Reporting results ...");
|
||||||
|
|
||||||
try {
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
printWriter = pw;
|
||||||
|
|
||||||
printReportFileHeader();
|
printReportFileHeader();
|
||||||
|
|
||||||
for (Integer itemid : vegaItems) {
|
for (Integer itemid : vegaItems) {
|
||||||
printWriter.println(" " + itemid);
|
printWriter.println(" " + itemid);
|
||||||
}
|
}
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
ioe.printStackTrace();
|
ioe.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ package tools.mapletools;
|
|||||||
import tools.Pair;
|
import tools.Pair;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -22,7 +23,7 @@ import static java.util.concurrent.TimeUnit.HOURS;
|
|||||||
* Estimated parse time: 2 minutes (for 100 code entries)
|
* Estimated parse time: 2 minutes (for 100 code entries)
|
||||||
*/
|
*/
|
||||||
public class CodeCouponGenerator {
|
public class CodeCouponGenerator {
|
||||||
private static final File INPUT_FILE = ToolConstants.getInputFile("CouponCodes.img.xml");
|
private static final Path INPUT_FILE = ToolConstants.getInputFile("CouponCodes.img.xml");
|
||||||
private static final int INITIAL_STRING_LENGTH = 250;
|
private static final int INITIAL_STRING_LENGTH = 250;
|
||||||
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
||||||
|
|
||||||
@@ -312,24 +313,19 @@ public class CodeCouponGenerator {
|
|||||||
ps.close();
|
ps.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void generateCodeCoupons(File file) throws IOException {
|
private static void generateCodeCoupons(Path file) throws IOException {
|
||||||
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
try (BufferedReader br = Files.newBufferedReader(file); con;) {
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
bufferedReader = br;
|
||||||
|
resetCouponPackage();
|
||||||
|
status = 0;
|
||||||
|
|
||||||
resetCouponPackage();
|
System.out.println("Reading XML coupon information...");
|
||||||
status = 0;
|
String line;
|
||||||
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
|
translateToken(line);
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
System.out.println("Reading XML coupon information...");
|
|
||||||
String line;
|
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
|
||||||
translateToken(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
bufferedReader.close();
|
|
||||||
fileReader.close();
|
|
||||||
System.out.println();
|
|
||||||
|
|
||||||
try {
|
|
||||||
System.out.println("Loading DB coupon codes...");
|
System.out.println("Loading DB coupon codes...");
|
||||||
loadUsedCouponCodes();
|
loadUsedCouponCodes();
|
||||||
System.out.println();
|
System.out.println();
|
||||||
@@ -340,9 +336,8 @@ public class CodeCouponGenerator {
|
|||||||
commitCodeCouponDescription(ccd);
|
commitCodeCouponDescription(ccd);
|
||||||
}
|
}
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
con.close();
|
|
||||||
System.out.println("Done.");
|
System.out.println("Done.");
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -352,7 +347,7 @@ public class CodeCouponGenerator {
|
|||||||
try {
|
try {
|
||||||
generateCodeCoupons(INPUT_FILE);
|
generateCodeCoupons(INPUT_FILE);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
System.out.println("Error reading file '" + INPUT_FILE.getAbsolutePath() + "'");
|
System.out.println("Error reading file '" + INPUT_FILE.toAbsolutePath() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ package tools.mapletools;
|
|||||||
import provider.wz.WZFiles;
|
import provider.wz.WZFiles;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -16,8 +17,8 @@ import java.sql.SQLException;
|
|||||||
* a SQL table that the server will make use.
|
* a SQL table that the server will make use.
|
||||||
*/
|
*/
|
||||||
public class CouponInstaller {
|
public class CouponInstaller {
|
||||||
private static final File COUPON_INPUT_FILE_1 = new File(WZFiles.ITEM.getFilePath(), "/Cash/0521.img.xml");
|
private static final Path COUPON_INPUT_FILE_1 = WZFiles.ITEM.getFile().resolve("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_2 = WZFiles.ITEM.getFile().resolve("Cash/0536.img.xml");
|
||||||
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
||||||
private static BufferedReader bufferedReader = null;
|
private static BufferedReader bufferedReader = null;
|
||||||
private static byte status = 0;
|
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
|
// This will reference one line at a time
|
||||||
String line = null;
|
String line = null;
|
||||||
|
|
||||||
try {
|
try (BufferedReader br = Files.newBufferedReader(file)) {
|
||||||
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
bufferedReader = br;
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
|
||||||
|
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
translateToken(line);
|
translateToken(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferedReader.close();
|
|
||||||
fileReader.close();
|
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
System.out.println("Unable to open file '" + file + "'");
|
System.out.println("Unable to open file '" + file + "'");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ package tools.mapletools;
|
|||||||
import provider.wz.WZFiles;
|
import provider.wz.WZFiles;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.DirectoryStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author RonanLana
|
* @author RonanLana
|
||||||
@@ -16,8 +21,9 @@ import java.nio.charset.StandardCharsets;
|
|||||||
* Estimated parse time: 10 seconds
|
* Estimated parse time: 10 seconds
|
||||||
*/
|
*/
|
||||||
public class DojoUpdate {
|
public class DojoUpdate {
|
||||||
private static final File INPUT_DIRECTORY = new File(WZFiles.MAP.getFile(), "/Map/Map9");
|
private static final Path INPUT_DIRECTORY = WZFiles.MAP.getFile().resolve("Map").resolve("Map9");
|
||||||
private static final File OUTPUT_DIRECTORY = ToolConstants.getOutputFile("dojo-maps");
|
private static final Path OUTPUT_DIRECTORY = ToolConstants.getOutputFile("dojo-maps");
|
||||||
|
private static final Path WORKING_DIRECTORY = Paths.get("").toAbsolutePath();
|
||||||
private static final int DOJO_MIN_MAP_ID = 925_020_100;
|
private static final int DOJO_MIN_MAP_ID = 925_020_100;
|
||||||
private static final int DOJO_MAX_MAP_ID = 925_033_804;
|
private static final int DOJO_MAX_MAP_ID = 925_033_804;
|
||||||
private static final int INITIAL_STRING_LENGTH = 250;
|
private static final int INITIAL_STRING_LENGTH = 250;
|
||||||
@@ -114,30 +120,26 @@ public class DojoUpdate {
|
|||||||
return Integer.parseInt(fileName.substring(0, 9));
|
return Integer.parseInt(fileName.substring(0, 9));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void parseDojoData(File file, String curPath) throws IOException {
|
private static void parseDojoData(Path file, String curPath) throws IOException {
|
||||||
int mapId = getMapId(file.getName());
|
int mapId = getMapId(file.getFileName().toString());
|
||||||
isDojoMapid = isDojoMapId(mapId);
|
isDojoMapid = isDojoMapId(mapId);
|
||||||
if (!isDojoMapid) {
|
if (!isDojoMapid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try (PrintWriter pw = new PrintWriter(
|
||||||
|
Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName())));
|
||||||
|
BufferedReader br = Files.newBufferedReader(file);) {
|
||||||
|
printWriter = pw;
|
||||||
|
bufferedReader = br;
|
||||||
|
status = 0;
|
||||||
|
|
||||||
printWriter = new PrintWriter(OUTPUT_DIRECTORY.getPath() + "/" + curPath + file.getName(), StandardCharsets.UTF_8);
|
String line;
|
||||||
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
|
translateToken(line);
|
||||||
|
}
|
||||||
|
|
||||||
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
printFileFooter();
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
|
||||||
|
|
||||||
status = 0;
|
|
||||||
|
|
||||||
String line;
|
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
|
||||||
translateToken(line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferedReader.close();
|
|
||||||
fileReader.close();
|
|
||||||
|
|
||||||
printFileFooter();
|
|
||||||
printWriter.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isDojoMapId(int mapId) {
|
private static boolean isDojoMapId(int mapId) {
|
||||||
@@ -152,31 +154,48 @@ public class DojoUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void parseDirectoryDojoData(String curPath) {
|
private static void parseDirectoryDojoData(String curPath) {
|
||||||
File folder = new File(OUTPUT_DIRECTORY, curPath);
|
Path folder = OUTPUT_DIRECTORY.resolve(curPath);
|
||||||
if (!folder.exists()) {
|
if (!Files.exists(folder)) {
|
||||||
folder.mkdir();
|
try {
|
||||||
|
Files.createDirectory(folder);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
System.out.println("Unable to create folder " + folder.toAbsolutePath() + ".");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Parsing directory '" + curPath + "'");
|
System.out.println("Parsing directory '" + curPath + "'");
|
||||||
folder = new File(INPUT_DIRECTORY, curPath);
|
folder = INPUT_DIRECTORY.resolve(curPath);
|
||||||
for (File file : folder.listFiles()) {
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(folder)) {
|
||||||
if (file.isFile()) {
|
for (Path path : stream) {
|
||||||
try {
|
if (Files.isRegularFile(path)) {
|
||||||
parseDojoData(file, curPath);
|
try {
|
||||||
} catch (FileNotFoundException ex) {
|
parseDojoData(path, curPath);
|
||||||
System.out.println("Unable to open dojo file " + file.getAbsolutePath() + ".");
|
} catch (FileNotFoundException ex) {
|
||||||
} catch (IOException ex) {
|
System.out.println("Unable to open dojo file " + path.toAbsolutePath() + ".");
|
||||||
System.out.println("Error reading dojo file " + file.getAbsolutePath() + ".");
|
} catch (IOException ex) {
|
||||||
} catch (Exception e) {
|
System.out.println("Error reading dojo file " + path.toAbsolutePath() + ".");
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
parseDirectoryDojoData(curPath + path.getFileName() + "/");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
parseDirectoryDojoData(curPath + file.getName() + "/");
|
|
||||||
}
|
}
|
||||||
|
} catch (IOException e1) {
|
||||||
|
System.out.println("Unable to read folder " + folder.toAbsolutePath() + ".");
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Instant instantStarted = Instant.now();
|
||||||
parseDirectoryDojoData("");
|
parseDirectoryDojoData("");
|
||||||
|
Instant instantStopped = Instant.now();
|
||||||
|
Duration durationBetween = Duration.between(instantStarted, instantStopped);
|
||||||
|
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
|
||||||
|
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import provider.wz.WZFiles;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,8 +16,8 @@ import java.util.*;
|
|||||||
* And it removes from the String.wz XMLs all entries which misses properties on Item.wz.
|
* And it removes from the String.wz XMLs all entries which misses properties on Item.wz.
|
||||||
*/
|
*/
|
||||||
public class EmptyItemWzChecker {
|
public class EmptyItemWzChecker {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("empty_item_wz_report.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("empty_item_wz_report.txt");
|
||||||
private static final String OUTPUT_PATH = ToolConstants.OUTPUT_DIRECTORY.getPath();
|
private static final String OUTPUT_PATH = ToolConstants.OUTPUT_DIRECTORY.toString();
|
||||||
private static final int INITIAL_STRING_LENGTH = 50;
|
private static final int INITIAL_STRING_LENGTH = 50;
|
||||||
private static final int ITEM_FILE_NAME_SIZE = 13;
|
private static final int ITEM_FILE_NAME_SIZE = 13;
|
||||||
|
|
||||||
@@ -338,12 +340,11 @@ public class EmptyItemWzChecker {
|
|||||||
|
|
||||||
private static void reportItemNameDiff(Set<Integer> emptyItemNames, Set<Integer> emptyNameItems) throws IOException {
|
private static void reportItemNameDiff(Set<Integer> emptyItemNames, Set<Integer> emptyNameItems) throws IOException {
|
||||||
System.out.println("Reporting results...");
|
System.out.println("Reporting results...");
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
|
printWriter = pw;
|
||||||
printReportFileHeader();
|
printReportFileHeader();
|
||||||
printReportFileResults(emptyItemNames, emptyNameItems);
|
printReportFileResults(emptyItemNames, emptyNameItems);
|
||||||
|
}
|
||||||
printWriter.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void locateItemStringWzDiff() throws IOException {
|
private static void locateItemStringWzDiff() throws IOException {
|
||||||
@@ -408,7 +409,7 @@ public class EmptyItemWzChecker {
|
|||||||
|
|
||||||
private static void generateStringWz() throws IOException {
|
private static void generateStringWz() throws IOException {
|
||||||
System.out.println("Generating clean String.wz ...");
|
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/";
|
String stringWzPath = "/String.wz/";
|
||||||
|
|
||||||
File folder = new File(OUTPUT_PATH + "/String.wz/");
|
File folder = new File(OUTPUT_PATH + "/String.wz/");
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ package tools.mapletools;
|
|||||||
import provider.wz.WZFiles;
|
import provider.wz.WZFiles;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.DirectoryStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author RonanLana
|
* @author RonanLana
|
||||||
@@ -16,14 +20,13 @@ import java.nio.charset.StandardCharsets;
|
|||||||
* Estimated parse time: 7 minutes
|
* Estimated parse time: 7 minutes
|
||||||
*/
|
*/
|
||||||
public class EquipmentOmniLeveller {
|
public class EquipmentOmniLeveller {
|
||||||
private static final File INPUT_DIRECTORY = WZFiles.CHARACTER.getFile();
|
private static final Path INPUT_DIRECTORY = WZFiles.CHARACTER.getFile();
|
||||||
private static final File OUTPUT_DIRECTORY = ToolConstants.getOutputFile("equips-with-levels");
|
private static final Path OUTPUT_DIRECTORY = ToolConstants.getOutputFile("equips-with-levels");
|
||||||
private static final int INITIAL_STRING_LENGTH = 250;
|
private static final int INITIAL_STRING_LENGTH = 250;
|
||||||
private static final int FIXED_EXP = 10000;
|
private static final int FIXED_EXP = 10000;
|
||||||
private static final int MAX_EQP_LEVEL = 30;
|
private static final int MAX_EQP_LEVEL = 30;
|
||||||
|
|
||||||
private static PrintWriter printWriter = null;
|
private static PrintWriter printWriter = null;
|
||||||
private static InputStreamReader fileReader = null;
|
|
||||||
private static BufferedReader bufferedReader = null;
|
private static BufferedReader bufferedReader = null;
|
||||||
|
|
||||||
private static int infoTagState = -1;
|
private static int infoTagState = -1;
|
||||||
@@ -353,30 +356,25 @@ public class EquipmentOmniLeveller {
|
|||||||
return accessInfoTag;
|
return accessInfoTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyCashItemData(File file, String curPath) throws IOException {
|
private static void copyCashItemData(Path file, String curPath) throws IOException {
|
||||||
printWriter = new PrintWriter(new File(OUTPUT_DIRECTORY, curPath + file.getName()), StandardCharsets.UTF_8);
|
try (PrintWriter pw = new PrintWriter(
|
||||||
|
Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName())));
|
||||||
fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
BufferedReader br = Files.newBufferedReader(file);) {
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
printWriter = pw;
|
||||||
|
bufferedReader = br;
|
||||||
String line;
|
String line;
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
printWriter.println(line);
|
printWriter.println(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferedReader.close();
|
|
||||||
fileReader.close();
|
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void parseEquipData(File file, String curPath) throws IOException {
|
private static void parseEquipData(Path file, String curPath) throws IOException {
|
||||||
printWriter = new PrintWriter(new File(OUTPUT_DIRECTORY, curPath + file.getName()), StandardCharsets.UTF_8);
|
try (PrintWriter pw = new PrintWriter(
|
||||||
|
Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName())));
|
||||||
fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
BufferedReader br = Files.newBufferedReader(file);) {
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
printWriter = pw;
|
||||||
|
bufferedReader = br;
|
||||||
try {
|
|
||||||
status = 0;
|
status = 0;
|
||||||
upgradeable = false;
|
upgradeable = false;
|
||||||
cash = false;
|
cash = false;
|
||||||
@@ -384,23 +382,13 @@ public class EquipmentOmniLeveller {
|
|||||||
String line;
|
String line;
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
if (translateToken(line)) {
|
if (translateToken(line)) {
|
||||||
infoTagState = status; // status: 2
|
infoTagState = status; // status: 2
|
||||||
translateInfoTag(status);
|
translateInfoTag(status);
|
||||||
infoTagState = -1;
|
infoTagState = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferedReader.close();
|
|
||||||
fileReader.close();
|
|
||||||
|
|
||||||
printFileFooter();
|
printFileFooter();
|
||||||
printWriter.close();
|
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
bufferedReader.close();
|
|
||||||
fileReader.close();
|
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
|
|
||||||
copyCashItemData(file, curPath);
|
copyCashItemData(file, curPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -413,31 +401,48 @@ public class EquipmentOmniLeveller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void parseDirectoryEquipData(String curPath) {
|
private static void parseDirectoryEquipData(String curPath) {
|
||||||
File folder = new File(OUTPUT_DIRECTORY, curPath);
|
Path folder = OUTPUT_DIRECTORY.resolve(curPath);
|
||||||
if (!folder.exists()) {
|
if (!Files.exists(folder)) {
|
||||||
folder.mkdir();
|
try {
|
||||||
|
Files.createDirectory(folder);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
System.out.println("Unable to create folder " + folder.toAbsolutePath() + ".");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Parsing directory '" + curPath + "'");
|
System.out.println("Parsing directory '" + curPath + "'");
|
||||||
folder = new File(INPUT_DIRECTORY, curPath);
|
folder = INPUT_DIRECTORY.resolve(curPath);
|
||||||
for (File file : folder.listFiles()) {
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(folder)) {
|
||||||
if (file.isFile()) {
|
for (Path path : stream) {
|
||||||
try {
|
if (Files.isRegularFile(path)) {
|
||||||
parseEquipData(file, curPath);
|
try {
|
||||||
} catch (FileNotFoundException ex) {
|
parseEquipData(path, curPath);
|
||||||
System.out.println("Unable to open equip file " + file.getAbsolutePath() + ".");
|
} catch (FileNotFoundException ex) {
|
||||||
} catch (IOException ex) {
|
System.out.println("Unable to open dojo file " + path.toAbsolutePath() + ".");
|
||||||
System.out.println("Error reading equip file " + file.getAbsolutePath() + ".");
|
} catch (IOException ex) {
|
||||||
} catch (Exception e) {
|
System.out.println("Error reading dojo file " + path.toAbsolutePath() + ".");
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
parseDirectoryEquipData(curPath + path.getFileName() + "/");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
parseDirectoryEquipData(curPath + file.getName() + "/");
|
|
||||||
}
|
}
|
||||||
|
} catch (IOException e1) {
|
||||||
|
System.out.println("Unable to read folder " + folder.toAbsolutePath() + ".");
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Instant instantStarted = Instant.now();
|
||||||
parseDirectoryEquipData("");
|
parseDirectoryEquipData("");
|
||||||
|
Instant instantStopped = Instant.now();
|
||||||
|
Duration durationBetween = Duration.between(instantStarted, instantStopped);
|
||||||
|
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
|
||||||
|
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package tools.mapletools;
|
package tools.mapletools;
|
||||||
|
|
||||||
import java.io.*;
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -22,8 +23,8 @@ import java.util.regex.Pattern;
|
|||||||
* Estimated parse time: 1 minute
|
* Estimated parse time: 1 minute
|
||||||
*/
|
*/
|
||||||
public class GachaponItemIdRetriever {
|
public class GachaponItemIdRetriever {
|
||||||
private static final File INPUT_FILE = ToolConstants.getInputFile("gachapon_items.txt");
|
private static final Path INPUT_FILE = ToolConstants.getInputFile("gachapon_items.txt");
|
||||||
private static final File OUTPUT_DIRECTORY = ToolConstants.getOutputFile("gachapons");
|
private static final Path OUTPUT_DIRECTORY = ToolConstants.getOutputFile("gachapons");
|
||||||
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
||||||
private static final Pattern pattern = Pattern.compile("(\\d*)%");
|
private static final Pattern pattern = Pattern.compile("(\\d*)%");
|
||||||
private static final int[] scrollsChances = new int[]{10, 15, 30, 60, 65, 70, 100};
|
private static final int[] scrollsChances = new int[]{10, 15, 30, 60, 65, 70, 100};
|
||||||
@@ -247,11 +248,7 @@ public class GachaponItemIdRetriever {
|
|||||||
|
|
||||||
private static void fetchDataOnMapleHandbook() throws SQLException {
|
private static void fetchDataOnMapleHandbook() throws SQLException {
|
||||||
String line;
|
String line;
|
||||||
|
try (BufferedReader bufferedReader = Files.newBufferedReader(INPUT_FILE)) {
|
||||||
try {
|
|
||||||
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(INPUT_FILE), StandardCharsets.UTF_8);
|
|
||||||
BufferedReader bufferedReader = new BufferedReader(fileReader);
|
|
||||||
|
|
||||||
int skip = 0;
|
int skip = 0;
|
||||||
boolean lineHeader = false;
|
boolean lineHeader = false;
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
@@ -276,10 +273,10 @@ public class GachaponItemIdRetriever {
|
|||||||
if (printWriter != null) {
|
if (printWriter != null) {
|
||||||
printWriter.close();
|
printWriter.close();
|
||||||
}
|
}
|
||||||
File outputFile = new File(OUTPUT_DIRECTORY, gachaponName + ".txt");
|
Path outputFile = OUTPUT_DIRECTORY.resolve(gachaponName + ".txt");
|
||||||
setupDirectories(outputFile);
|
setupDirectories(outputFile);
|
||||||
|
|
||||||
printWriter = new PrintWriter(outputFile, StandardCharsets.UTF_8);
|
printWriter = new PrintWriter(Files.newOutputStream(outputFile));
|
||||||
|
|
||||||
skip = 2;
|
skip = 2;
|
||||||
lineHeader = true;
|
lineHeader = true;
|
||||||
@@ -297,30 +294,27 @@ public class GachaponItemIdRetriever {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (printWriter != null) {
|
|
||||||
printWriter.close();
|
|
||||||
}
|
|
||||||
bufferedReader.close();
|
|
||||||
fileReader.close();
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
System.out.println(ex.getMessage());
|
System.out.println(ex.getMessage());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setupDirectories(File file) {
|
private static void setupDirectories(Path file) {
|
||||||
if (!file.getParentFile().exists()) {
|
if (!Files.exists(file.getParent())) {
|
||||||
file.getParentFile().mkdirs();
|
try {
|
||||||
|
Files.createDirectories(file.getParent());
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try {
|
try (con) {
|
||||||
loadHandbookUseNames();
|
loadHandbookUseNames();
|
||||||
fetchDataOnMapleHandbook();
|
fetchDataOnMapleHandbook();
|
||||||
|
|
||||||
con.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println("Error: invalid SQL syntax");
|
System.out.println("Error: invalid SQL syntax");
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ package tools.mapletools;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,8 +30,8 @@ import java.util.ArrayList;
|
|||||||
*/
|
*/
|
||||||
public class IdRetriever {
|
public class IdRetriever {
|
||||||
private static final boolean INSTALL_SQLTABLE = true;
|
private static final boolean INSTALL_SQLTABLE = true;
|
||||||
private static final File INPUT_FILE = ToolConstants.getInputFile("fetch_ids.txt");
|
private static final Path INPUT_FILE = ToolConstants.getInputFile("fetch_ids.txt");
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("fetched_ids.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("fetched_ids.txt");
|
||||||
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
||||||
|
|
||||||
private static InputStreamReader fileReader = null;
|
private static InputStreamReader fileReader = null;
|
||||||
@@ -132,14 +136,10 @@ public class IdRetriever {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void fetchDataOnMapleHandbook() throws SQLException {
|
private static void fetchDataOnMapleHandbook() throws SQLException {
|
||||||
String line;
|
try (BufferedReader br = Files.newBufferedReader(INPUT_FILE);
|
||||||
|
PrintWriter printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));) {
|
||||||
try {
|
bufferedReader = br;
|
||||||
fileReader = new InputStreamReader(new FileInputStream(INPUT_FILE), StandardCharsets.UTF_8);
|
String line;
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
|
||||||
|
|
||||||
PrintWriter printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
|
||||||
|
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
if (line.isEmpty()) {
|
if (line.isEmpty()) {
|
||||||
printWriter.println("");
|
printWriter.println("");
|
||||||
@@ -164,29 +164,27 @@ public class IdRetriever {
|
|||||||
|
|
||||||
printWriter.println(str);
|
printWriter.println(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
bufferedReader.close();
|
|
||||||
fileReader.close();
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
System.out.println(ex.getMessage());
|
System.out.println(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Instant instantStarted = Instant.now();
|
||||||
try {
|
try (con) {
|
||||||
if (INSTALL_SQLTABLE) {
|
if (INSTALL_SQLTABLE) {
|
||||||
parseMapleHandbook();
|
parseMapleHandbook();
|
||||||
} else {
|
} else {
|
||||||
fetchDataOnMapleHandbook();
|
fetchDataOnMapleHandbook();
|
||||||
}
|
}
|
||||||
|
|
||||||
con.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println("Error: invalid SQL syntax");
|
System.out.println("Error: invalid SQL syntax");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package tools.mapletools;
|
|||||||
import provider.wz.WZFiles;
|
import provider.wz.WZFiles;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.DirectoryStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,17 +74,17 @@ public class MapFieldLimitChecker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void listFiles(String directoryName, ArrayList<File> files) {
|
private static void listFiles(Path directory, ArrayList<Path> files) {
|
||||||
File directory = new File(directoryName);
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory)) {
|
||||||
|
for (Path path : stream) {
|
||||||
// get all the files from a directory
|
if (Files.isRegularFile(path)) {
|
||||||
File[] fList = directory.listFiles();
|
files.add(path);
|
||||||
for (File file : fList) {
|
} else if (Files.isDirectory(path)) {
|
||||||
if (file.isFile()) {
|
listFiles(path, files);
|
||||||
files.add(file);
|
}
|
||||||
} else if (file.isDirectory()) {
|
|
||||||
listFiles(file.getAbsolutePath(), files);
|
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,18 +136,17 @@ public class MapFieldLimitChecker {
|
|||||||
|
|
||||||
private static void loadMapWz() throws IOException {
|
private static void loadMapWz() throws IOException {
|
||||||
System.out.println("Reading Map.wz ...");
|
System.out.println("Reading Map.wz ...");
|
||||||
ArrayList<File> files = new ArrayList<>();
|
ArrayList<Path> files = new ArrayList<>();
|
||||||
listFiles(WZFiles.MAP.getFilePath() + "/Map", files);
|
listFiles(WZFiles.MAP.getFile().resolve("Map"), files);
|
||||||
|
|
||||||
for (File f : files) {
|
for (Path f : files) {
|
||||||
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8);
|
try (BufferedReader br = Files.newBufferedReader(f)) {
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
bufferedReader = br;
|
||||||
|
|
||||||
mapid = getMapIdFromFilename(f.getName());
|
mapid = getMapIdFromFilename(f.getFileName().toString());
|
||||||
inspectMapEntry();
|
inspectMapEntry();
|
||||||
|
|
||||||
bufferedReader.close();
|
}
|
||||||
fileReader.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import provider.wz.WZFiles;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -16,7 +18,7 @@ import java.util.List;
|
|||||||
* the "info" node in their WZ node tree.
|
* the "info" node in their WZ node tree.
|
||||||
*/
|
*/
|
||||||
public class MapInfoRetriever {
|
public class MapInfoRetriever {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("map_info_report.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("map_info_report.txt");
|
||||||
private static final List<Integer> missingInfo = new ArrayList<>();
|
private static final List<Integer> missingInfo = new ArrayList<>();
|
||||||
|
|
||||||
private static BufferedReader bufferedReader = null;
|
private static BufferedReader bufferedReader = null;
|
||||||
@@ -129,9 +131,7 @@ public class MapInfoRetriever {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void writeReport() {
|
private static void writeReport() {
|
||||||
try {
|
try (PrintWriter printWriter = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
PrintWriter printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
|
||||||
|
|
||||||
if (!missingInfo.isEmpty()) {
|
if (!missingInfo.isEmpty()) {
|
||||||
for (Integer i : missingInfo) {
|
for (Integer i : missingInfo) {
|
||||||
printWriter.println(i);
|
printWriter.println(i);
|
||||||
@@ -139,8 +139,6 @@ public class MapInfoRetriever {
|
|||||||
} else {
|
} else {
|
||||||
printWriter.println("All map files contain 'info' node.");
|
printWriter.println("All map files contain 'info' node.");
|
||||||
}
|
}
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ package tools.mapletools;
|
|||||||
import server.life.MonsterStats;
|
import server.life.MonsterStats;
|
||||||
import tools.Pair;
|
import tools.Pair;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -27,7 +29,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class MesoFetcher {
|
public class MesoFetcher {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("meso_drop_data.sql");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("meso_drop_data.sql");
|
||||||
private static final boolean PERMIT_MESOS_ON_DOJO_BOSSES = false;
|
private static final boolean PERMIT_MESOS_ON_DOJO_BOSSES = false;
|
||||||
private static final int MESO_ID = 0;
|
private static final int MESO_ID = 0;
|
||||||
private static final int MIN_ITEMS = 4;
|
private static final int MIN_ITEMS = 4;
|
||||||
@@ -119,13 +121,11 @@ public class MesoFetcher {
|
|||||||
|
|
||||||
private static void generateMissingMobsMesoRange() {
|
private static void generateMissingMobsMesoRange() {
|
||||||
System.out.print("Generating missing ranges... ");
|
System.out.print("Generating missing ranges... ");
|
||||||
Connection con = SimpleDatabaseConnection.getConnection();
|
try (Connection con = SimpleDatabaseConnection.getConnection();
|
||||||
List<Integer> existingMobs = new ArrayList<>(200);
|
PreparedStatement ps = con.prepareStatement("SELECT dropperid FROM drop_data WHERE dropperid NOT IN (SELECT DISTINCT dropperid FROM drop_data WHERE itemid = 0) GROUP BY dropperid HAVING count(*) >= " + MIN_ITEMS + ";");
|
||||||
|
ResultSet rs = ps.executeQuery();) {
|
||||||
try {
|
|
||||||
// select all mobs which doesn't drop mesos and have a fair amount of items dropping (meaning they are not an event mob)
|
List<Integer> existingMobs = new ArrayList<>(200);
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT dropperid FROM drop_data WHERE dropperid NOT IN (SELECT DISTINCT dropperid FROM drop_data WHERE itemid = 0) GROUP BY dropperid HAVING count(*) >= " + MIN_ITEMS + ";");
|
|
||||||
ResultSet rs = ps.executeQuery();
|
|
||||||
|
|
||||||
if (rs.isBeforeFirst()) {
|
if (rs.isBeforeFirst()) {
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@@ -137,18 +137,19 @@ public class MesoFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!existingMobs.isEmpty()) {
|
if (!existingMobs.isEmpty()) {
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
printSqlHeader();
|
printWriter = pw;
|
||||||
|
|
||||||
for (int i = 0; i < existingMobs.size() - 1; i++) {
|
printSqlHeader();
|
||||||
printSqlMobMesoRange(existingMobs.get(i));
|
|
||||||
|
for (int i = 0; i < existingMobs.size() - 1; i++) {
|
||||||
|
printSqlMobMesoRange(existingMobs.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
printSqlMobMesoRangeFinal(existingMobs.get(existingMobs.size() - 1));
|
||||||
|
|
||||||
|
printSqlExceptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
printSqlMobMesoRangeFinal(existingMobs.get(existingMobs.size() - 1));
|
|
||||||
|
|
||||||
printSqlExceptions();
|
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("ALREADY UPDATED");
|
throw new Exception("ALREADY UPDATED");
|
||||||
}
|
}
|
||||||
@@ -157,10 +158,6 @@ public class MesoFetcher {
|
|||||||
throw new Exception("ALREADY UPDATED");
|
throw new Exception("ALREADY UPDATED");
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
|
||||||
ps.close();
|
|
||||||
con.close();
|
|
||||||
|
|
||||||
System.out.println("done!");
|
System.out.println("done!");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -173,11 +170,17 @@ public class MesoFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// load mob stats from WZ
|
Instant instantStarted = Instant.now();
|
||||||
|
// load mob stats from WZ
|
||||||
mobStats = MonsterStatFetcher.getAllMonsterStats();
|
mobStats = MonsterStatFetcher.getAllMonsterStats();
|
||||||
|
|
||||||
calcAllMobsMesoRange();
|
calcAllMobsMesoRange();
|
||||||
generateMissingMobsMesoRange();
|
generateMissingMobsMesoRange();
|
||||||
|
Instant instantStopped = Instant.now();
|
||||||
|
Duration durationBetween = Duration.between(instantStarted, instantStopped);
|
||||||
|
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
|
||||||
|
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import provider.wz.WZFiles;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -16,7 +18,7 @@ import java.sql.SQLException;
|
|||||||
* puts them on a SQL table with the correspondent mob cardid.
|
* puts them on a SQL table with the correspondent mob cardid.
|
||||||
*/
|
*/
|
||||||
public class MobBookIndexer {
|
public class MobBookIndexer {
|
||||||
private static final File INPUT_FILE = new File(WZFiles.STRING.getFile(), "MonsterBook.img.xml");
|
private static final Path INPUT_FILE = WZFiles.STRING.getFile().resolve("MonsterBook.img.xml");
|
||||||
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
||||||
|
|
||||||
private static BufferedReader bufferedReader = null;
|
private static BufferedReader bufferedReader = null;
|
||||||
@@ -123,15 +125,13 @@ public class MobBookIndexer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void indexFromDropData() {
|
private static void indexFromDropData() {
|
||||||
// This will reference one line at a time
|
|
||||||
String line = null;
|
|
||||||
|
|
||||||
try {
|
try (con; BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
|
||||||
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(INPUT_FILE), StandardCharsets.UTF_8);
|
bufferedReader = br;
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
String line = null;
|
||||||
|
|
||||||
PreparedStatement ps = con.prepareStatement("DROP TABLE IF EXISTS monstercardwz;");
|
PreparedStatement ps = con.prepareStatement("DROP TABLE IF EXISTS monstercardwz;");
|
||||||
ps.execute();
|
ps.execute();
|
||||||
|
|
||||||
ps = con.prepareStatement("CREATE TABLE `monstercardwz` ("
|
ps = con.prepareStatement("CREATE TABLE `monstercardwz` ("
|
||||||
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
||||||
@@ -141,25 +141,20 @@ public class MobBookIndexer {
|
|||||||
+ ");");
|
+ ");");
|
||||||
ps.execute();
|
ps.execute();
|
||||||
|
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
translateToken(line);
|
translateToken(line);
|
||||||
}
|
}
|
||||||
|
} catch (FileNotFoundException ex) {
|
||||||
bufferedReader.close();
|
System.out.println("Unable to open file '" + INPUT_FILE + "'");
|
||||||
fileReader.close();
|
} catch (IOException ex) {
|
||||||
|
System.out.println("Error reading file '" + INPUT_FILE + "'");
|
||||||
con.close();
|
} catch (SQLException e) {
|
||||||
} catch (FileNotFoundException ex) {
|
System.out.println("Warning: Could not establish connection to database to change card chance rate.");
|
||||||
System.out.println("Unable to open file '" + INPUT_FILE + "'");
|
System.out.println(e.getMessage());
|
||||||
} catch (IOException ex) {
|
e.printStackTrace();
|
||||||
System.out.println("Error reading file '" + INPUT_FILE + "'");
|
} catch (Exception e) {
|
||||||
} catch (SQLException e) {
|
e.printStackTrace();
|
||||||
System.out.println("Warning: Could not establish connection to database to change card chance rate.");
|
}
|
||||||
System.out.println(e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ package tools.mapletools;
|
|||||||
import provider.wz.WZFiles;
|
import provider.wz.WZFiles;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -26,8 +27,8 @@ import java.sql.SQLException;
|
|||||||
* remove the property 'MonsterBook.img' inside 'string.wz' and choose to import the xml generated with this software.
|
* remove the property 'MonsterBook.img' inside 'string.wz' and choose to import the xml generated with this software.
|
||||||
*/
|
*/
|
||||||
public class MobBookUpdate {
|
public class MobBookUpdate {
|
||||||
private static final File INPUT_FILE = new File(WZFiles.STRING.getFile(), "MonsterBook.img.xml");
|
private static final Path INPUT_FILE = WZFiles.STRING.getFile().resolve("MonsterBook.img.xml");
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("MonsterBook_updated.img.xml");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("MonsterBook_updated.img.xml");
|
||||||
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
||||||
|
|
||||||
private static PrintWriter printWriter = null;
|
private static PrintWriter printWriter = null;
|
||||||
@@ -143,23 +144,17 @@ public class MobBookUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void updateFromDropData() {
|
private static void updateFromDropData() {
|
||||||
// This will reference one line at a time
|
try (con;
|
||||||
String line = null;
|
PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
|
||||||
|
BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
|
||||||
|
printWriter = pw;
|
||||||
|
bufferedReader = br;
|
||||||
|
|
||||||
try {
|
String line = null;
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
|
||||||
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(INPUT_FILE), StandardCharsets.UTF_8);
|
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
|
||||||
|
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
translateToken(line);
|
translateToken(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
bufferedReader.close();
|
|
||||||
fileReader.close();
|
|
||||||
|
|
||||||
con.close();
|
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
System.out.println("Unable to open file '" + INPUT_FILE + "'");
|
System.out.println("Unable to open file '" + INPUT_FILE + "'");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import server.life.LifeFactory.selfDestruction;
|
|||||||
import server.life.MonsterStats;
|
import server.life.MonsterStats;
|
||||||
import tools.Pair;
|
import tools.Pair;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class MonsterStatFetcher {
|
public class MonsterStatFetcher {
|
||||||
@@ -140,4 +142,15 @@ public class MonsterStatFetcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Instant instantStarted = Instant.now();
|
||||||
|
// load mob stats from WZ
|
||||||
|
Map<Integer, MonsterStats> mobStats = MonsterStatFetcher.getAllMonsterStats();
|
||||||
|
Instant instantStopped = Instant.now();
|
||||||
|
Duration durationBetween = Duration.between(instantStarted, instantStopped);
|
||||||
|
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
|
||||||
|
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import provider.wz.WZFiles;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -20,7 +22,7 @@ import java.util.*;
|
|||||||
* A file is generated listing all the inexistent ids.
|
* A file is generated listing all the inexistent ids.
|
||||||
*/
|
*/
|
||||||
public class NoItemIdFetcher {
|
public class NoItemIdFetcher {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("no_item_id_report.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("no_item_id_report.txt");
|
||||||
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
||||||
|
|
||||||
private static final Set<Integer> existingIds = new HashSet<>();
|
private static final Set<Integer> existingIds = new HashSet<>();
|
||||||
@@ -174,7 +176,7 @@ public class NoItemIdFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void evaluateDropsFromDb() {
|
private static void evaluateDropsFromDb() {
|
||||||
try {
|
try (con) {
|
||||||
System.out.println("Evaluating item data on DB...");
|
System.out.println("Evaluating item data on DB...");
|
||||||
|
|
||||||
evaluateDropsFromTable("drop_data");
|
evaluateDropsFromTable("drop_data");
|
||||||
@@ -192,23 +194,19 @@ public class NoItemIdFetcher {
|
|||||||
System.out.println("Inexistent itemid count: " + nonExistingIds.size());
|
System.out.println("Inexistent itemid count: " + nonExistingIds.size());
|
||||||
System.out.println("Total itemid count: " + existingIds.size());
|
System.out.println("Total itemid count: " + existingIds.size());
|
||||||
|
|
||||||
con.close();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try {
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
printWriter = pw;
|
||||||
|
|
||||||
existingIds.add(0); // meso itemid
|
existingIds.add(0); // meso itemid
|
||||||
readEquipDataDirectory(WZFiles.CHARACTER.getFilePath());
|
readEquipDataDirectory(WZFiles.CHARACTER.getFilePath());
|
||||||
readItemDataDirectory(WZFiles.ITEM.getFilePath());
|
readItemDataDirectory(WZFiles.ITEM.getFilePath());
|
||||||
|
|
||||||
evaluateDropsFromDb();
|
evaluateDropsFromDb();
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package tools.mapletools;
|
|||||||
import provider.*;
|
import provider.*;
|
||||||
import provider.wz.WZFiles;
|
import provider.wz.WZFiles;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,8 +19,8 @@ import java.util.*;
|
|||||||
* Estimated parse time: 2 minutes
|
* Estimated parse time: 2 minutes
|
||||||
*/
|
*/
|
||||||
public class NoItemNameFetcher {
|
public class NoItemNameFetcher {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("no_item_name_result.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("no_item_name_result.txt");
|
||||||
private static final File OUTPUT_XML_FILE = ToolConstants.getOutputFile("no_item_name_xml.txt");
|
private static final Path OUTPUT_XML_FILE = ToolConstants.getOutputFile("no_item_name_xml.txt");
|
||||||
|
|
||||||
private static final Map<Integer, String> itemsWzPath = new HashMap<>();
|
private static final Map<Integer, String> itemsWzPath = new HashMap<>();
|
||||||
private static final Map<Integer, EquipType> equipTypes = new HashMap<>();
|
private static final Map<Integer, EquipType> equipTypes = new HashMap<>();
|
||||||
@@ -435,32 +435,32 @@ public class NoItemNameFetcher {
|
|||||||
|
|
||||||
private static void writeMissingStringWZNames(Map<String, List<Integer>> missingNames) throws Exception {
|
private static void writeMissingStringWZNames(Map<String, List<Integer>> missingNames) throws Exception {
|
||||||
System.out.println("Writing remaining 'String.wz' names...");
|
System.out.println("Writing remaining 'String.wz' names...");
|
||||||
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_XML_FILE))) {
|
||||||
|
printWriter = pw;
|
||||||
|
|
||||||
printWriter = new PrintWriter(OUTPUT_XML_FILE, StandardCharsets.UTF_8);
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try {
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
|
printWriter = pw;
|
||||||
curType = ItemType.EQP;
|
curType = ItemType.EQP;
|
||||||
readEquipWZData();
|
readEquipWZData();
|
||||||
|
|
||||||
curType = ItemType.UNDEF;
|
curType = ItemType.UNDEF;
|
||||||
readItemWZData();
|
readItemWZData();
|
||||||
readStringWZData(); // calculates the diff and effectively holds all items with no name property on the WZ
|
readStringWZData(); // calculates the diff and effectively holds all items with no name property on the WZ
|
||||||
|
|
||||||
System.out.println("Reporting results...");
|
System.out.println("Reporting results...");
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
|
||||||
printReportFileHeader();
|
printReportFileHeader();
|
||||||
printReportFileResults();
|
printReportFileResults();
|
||||||
printWriter.close();
|
|
||||||
|
|
||||||
Map<String, List<Integer>> missingNames = filterMissingItemNames();
|
Map<String, List<Integer>> missingNames = filterMissingItemNames();
|
||||||
writeMissingStringWZNames(missingNames);
|
writeMissingStringWZNames(missingNames);
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import tools.Pair;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +19,7 @@ import java.util.*;
|
|||||||
* Running it should generate a report file under "output" folder with the search results.
|
* Running it should generate a report file under "output" folder with the search results.
|
||||||
*/
|
*/
|
||||||
public class QuestItemCountFetcher {
|
public class QuestItemCountFetcher {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("quest_item_count_report.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("quest_item_count_report.txt");
|
||||||
private static final String ACT_NAME = WZFiles.QUEST.getFilePath() + "/Act.img.xml";
|
private static final String ACT_NAME = WZFiles.QUEST.getFilePath() + "/Act.img.xml";
|
||||||
private static final String CHECK_NAME = WZFiles.QUEST.getFilePath() + "/Check.img.xml";
|
private static final String CHECK_NAME = WZFiles.QUEST.getFilePath() + "/Check.img.xml";
|
||||||
private static final int INITIAL_STRING_LENGTH = 50;
|
private static final int INITIAL_STRING_LENGTH = 50;
|
||||||
@@ -241,17 +243,16 @@ public class QuestItemCountFetcher {
|
|||||||
private static void reportQuestItemCountData() {
|
private static void reportQuestItemCountData() {
|
||||||
// This will reference one line at a time
|
// This will reference one line at a time
|
||||||
|
|
||||||
try {
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
System.out.println("Reading WZs...");
|
System.out.println("Reading WZs...");
|
||||||
readQuestItemCountData();
|
readQuestItemCountData();
|
||||||
|
|
||||||
System.out.println("Reporting results...");
|
System.out.println("Reporting results...");
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
printWriter = pw;
|
||||||
|
|
||||||
printReportFileHeader();
|
printReportFileHeader();
|
||||||
printReportFileResults();
|
printReportFileResults();
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
System.out.println("Done!");
|
System.out.println("Done!");
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
System.out.println("Unable to open quest file.");
|
System.out.println("Unable to open quest file.");
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import tools.Pair;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -25,7 +27,7 @@ import java.util.*;
|
|||||||
* Estimated parse time: 1 minute
|
* Estimated parse time: 1 minute
|
||||||
*/
|
*/
|
||||||
public class QuestItemFetcher {
|
public class QuestItemFetcher {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("quest_report.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("quest_report.txt");
|
||||||
private static final int INITIAL_STRING_LENGTH = 50;
|
private static final int INITIAL_STRING_LENGTH = 50;
|
||||||
private static final int INITIAL_LENGTH = 200;
|
private static final int INITIAL_LENGTH = 200;
|
||||||
private static final boolean DISPLAY_EXTRA_INFO = true; // display items with zero quantity over the quest act WZ
|
private static final boolean DISPLAY_EXTRA_INFO = true; // display items with zero quantity over the quest act WZ
|
||||||
@@ -409,32 +411,28 @@ public class QuestItemFetcher {
|
|||||||
private static void reportQuestItemData() {
|
private static void reportQuestItemData() {
|
||||||
// This will reference one line at a time
|
// This will reference one line at a time
|
||||||
String line = null;
|
String line = null;
|
||||||
String fileName = null;
|
Path file = null;
|
||||||
|
|
||||||
try {
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
System.out.println("Reading WZs...");
|
System.out.println("Reading WZs...");
|
||||||
|
|
||||||
fileName = WZFiles.QUEST.getFilePath() + "/Check.img.xml";
|
file = WZFiles.QUEST.getFile().resolve("Check.img.xml");
|
||||||
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(fileName), StandardCharsets.UTF_8);
|
bufferedReader = Files.newBufferedReader(file);
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
|
||||||
|
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
translateCheckToken(line); // fetch expired quests through here as well
|
translateCheckToken(line); // fetch expired quests through here as well
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferedReader.close();
|
bufferedReader.close();
|
||||||
fileReader.close();
|
|
||||||
|
|
||||||
fileName = WZFiles.QUEST.getFilePath() + "/Act.img.xml";
|
file = WZFiles.QUEST.getFile().resolve("Act.img.xml");
|
||||||
fileReader = new InputStreamReader(new FileInputStream(fileName), StandardCharsets.UTF_8);
|
bufferedReader = Files.newBufferedReader(file);
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
|
||||||
|
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
translateActToken(line);
|
translateActToken(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferedReader.close();
|
bufferedReader.close();
|
||||||
fileReader.close();
|
|
||||||
|
|
||||||
System.out.println("Calculating table diffs...");
|
System.out.println("Calculating table diffs...");
|
||||||
calculateQuestItemDiff();
|
calculateQuestItemDiff();
|
||||||
@@ -452,8 +450,9 @@ public class QuestItemFetcher {
|
|||||||
filterDirectorySearchMatchingData("src", itemsWithQuest);
|
filterDirectorySearchMatchingData("src", itemsWithQuest);
|
||||||
|
|
||||||
System.out.println("Reporting results...");
|
System.out.println("Reporting results...");
|
||||||
// report suspects of missing quest drop data, as well as those drop data that may have incorrect questids.
|
// report suspects of missing quest drop data, as well as those drop data that
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
// may have incorrect questids.
|
||||||
|
printWriter = pw;
|
||||||
|
|
||||||
printReportFileHeader();
|
printReportFileHeader();
|
||||||
|
|
||||||
@@ -505,12 +504,11 @@ public class QuestItemFetcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
System.out.println("Done!");
|
System.out.println("Done!");
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
System.out.println("Unable to open file '" + fileName + "'");
|
System.out.println("Unable to open file '" + file + "'");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
System.out.println("Error reading file '" + fileName + "'");
|
System.out.println("Error reading file '" + file + "'");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println("Warning: Could not establish connection to database to report quest data.");
|
System.out.println("Warning: Could not establish connection to database to report quest data.");
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ package tools.mapletools;
|
|||||||
import provider.wz.WZFiles;
|
import provider.wz.WZFiles;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,7 +17,7 @@ import java.util.*;
|
|||||||
* Running it should generate a report file under "output" folder with the search results.
|
* Running it should generate a report file under "output" folder with the search results.
|
||||||
*/
|
*/
|
||||||
public class QuestMesoFetcher {
|
public class QuestMesoFetcher {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("quest_meso_report.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("quest_meso_report.txt");
|
||||||
private static final boolean PRINT_FEES = true; // print missing values as additional info report
|
private static final boolean PRINT_FEES = true; // print missing values as additional info report
|
||||||
private static final int INITIAL_STRING_LENGTH = 50;
|
private static final int INITIAL_STRING_LENGTH = 50;
|
||||||
|
|
||||||
@@ -147,25 +148,21 @@ public class QuestMesoFetcher {
|
|||||||
private static void readQuestMesoData() throws IOException {
|
private static void readQuestMesoData() throws IOException {
|
||||||
String line;
|
String line;
|
||||||
|
|
||||||
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(WZFiles.QUEST.getFilePath() + "/Act.img.xml"), StandardCharsets.UTF_8);
|
bufferedReader = Files.newBufferedReader(WZFiles.QUEST.getFile().resolve("Act.img.xml"));
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
|
||||||
|
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
translateTokenAct(line);
|
translateTokenAct(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferedReader.close();
|
bufferedReader.close();
|
||||||
fileReader.close();
|
|
||||||
|
|
||||||
fileReader = new InputStreamReader(new FileInputStream(WZFiles.QUEST.getFilePath() + "/Check.img.xml"), StandardCharsets.UTF_8);
|
bufferedReader = Files.newBufferedReader(WZFiles.QUEST.getFile().resolve("Check.img.xml"));
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
|
||||||
|
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
translateTokenCheck(line);
|
translateTokenCheck(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferedReader.close();
|
bufferedReader.close();
|
||||||
fileReader.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printReportFileHeader() {
|
private static void printReportFileHeader() {
|
||||||
@@ -232,20 +229,19 @@ public class QuestMesoFetcher {
|
|||||||
private static void reportQuestMesoData() {
|
private static void reportQuestMesoData() {
|
||||||
// This will reference one line at a time
|
// This will reference one line at a time
|
||||||
|
|
||||||
try {
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
System.out.println("Reading WZs...");
|
System.out.println("Reading WZs...");
|
||||||
readQuestMesoData();
|
readQuestMesoData();
|
||||||
|
|
||||||
System.out.println("Reporting results...");
|
System.out.println("Reporting results...");
|
||||||
// report missing meso checks on quest completes
|
// report missing meso checks on quest completes
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
printWriter = pw;
|
||||||
|
|
||||||
printReportFileHeader();
|
printReportFileHeader();
|
||||||
|
|
||||||
printReportFileResults(checkedMesoQuests, appliedMesoQuests, true);
|
printReportFileResults(checkedMesoQuests, appliedMesoQuests, true);
|
||||||
printReportFileResults(appliedMesoQuests, checkedMesoQuests, false);
|
printReportFileResults(appliedMesoQuests, checkedMesoQuests, false);
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
System.out.println("Done!");
|
System.out.println("Done!");
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
System.out.println("Unable to open quest file.");
|
System.out.println("Unable to open quest file.");
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import provider.wz.WZFiles;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,7 +22,7 @@ import java.util.*;
|
|||||||
* Running it should generate a report file under "output" folder with the search results.
|
* Running it should generate a report file under "output" folder with the search results.
|
||||||
*/
|
*/
|
||||||
public class QuestlineFetcher {
|
public class QuestlineFetcher {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("questline_report.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("questline_report.txt");
|
||||||
private static final String ACT_NAME = WZFiles.QUEST.getFilePath() + "/Act.img.xml";
|
private static final String ACT_NAME = WZFiles.QUEST.getFilePath() + "/Act.img.xml";
|
||||||
private static final String CHECK_NAME = WZFiles.QUEST.getFilePath() + "/Check.img.xml";
|
private static final String CHECK_NAME = WZFiles.QUEST.getFilePath() + "/Check.img.xml";
|
||||||
private static final int INITIAL_STRING_LENGTH = 50;
|
private static final int INITIAL_STRING_LENGTH = 50;
|
||||||
@@ -289,7 +293,7 @@ public class QuestlineFetcher {
|
|||||||
private static void reportQuestlineData() {
|
private static void reportQuestlineData() {
|
||||||
// This will reference one line at a time
|
// This will reference one line at a time
|
||||||
|
|
||||||
try {
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
System.out.println("Reading quest scripts...");
|
System.out.println("Reading quest scripts...");
|
||||||
instantiateQuestScriptFiles(ToolConstants.SCRIPTS_PATH + "/quest");
|
instantiateQuestScriptFiles(ToolConstants.SCRIPTS_PATH + "/quest");
|
||||||
|
|
||||||
@@ -301,12 +305,11 @@ public class QuestlineFetcher {
|
|||||||
calculateSkillRelatedMissingQuestScripts();
|
calculateSkillRelatedMissingQuestScripts();
|
||||||
|
|
||||||
System.out.println("Reporting results...");
|
System.out.println("Reporting results...");
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
printWriter = pw;
|
||||||
|
|
||||||
printReportFileHeader();
|
printReportFileHeader();
|
||||||
printReportFileResults();
|
printReportFileResults();
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
System.out.println("Done!");
|
System.out.println("Done!");
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
System.out.println("Unable to open quest file.");
|
System.out.println("Unable to open quest file.");
|
||||||
@@ -356,7 +359,13 @@ public class QuestlineFetcher {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Instant instantStarted = Instant.now();
|
||||||
reportQuestlineData();
|
reportQuestlineData();
|
||||||
|
Instant instantStopped = Instant.now();
|
||||||
|
Duration durationBetween = Duration.between(instantStarted, instantStopped);
|
||||||
|
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
|
||||||
|
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package tools.mapletools;
|
package tools.mapletools;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -16,7 +19,7 @@ import java.util.*;
|
|||||||
* not yet coded.
|
* not yet coded.
|
||||||
*/
|
*/
|
||||||
public class ReactorDropFetcher {
|
public class ReactorDropFetcher {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("reactor_drop_report.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("reactor_drop_report.txt");
|
||||||
private static final String REACTOR_SCRIPT_PATH = ToolConstants.SCRIPTS_PATH + "/reactor";
|
private static final String REACTOR_SCRIPT_PATH = ToolConstants.SCRIPTS_PATH + "/reactor";
|
||||||
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
||||||
|
|
||||||
@@ -38,14 +41,14 @@ public class ReactorDropFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void removeScriptedReactorids(String directoryName) {
|
private static void removeScriptedReactorids(String directoryName) {
|
||||||
File directory = new File(directoryName);
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(directoryName))) {
|
||||||
|
for (Path path : stream) {
|
||||||
// get all the files from a directory
|
if (Files.isRegularFile(path)) {
|
||||||
File[] fList = directory.listFiles();
|
reactors.remove(getReactorIdFromFilename(path.getFileName().toString()));
|
||||||
for (File file : fList) {
|
}
|
||||||
if (file.isFile()) {
|
|
||||||
reactors.remove(getReactorIdFromFilename(file.getName()));
|
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,19 +87,18 @@ public class ReactorDropFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void reportMissingReactors() {
|
private static void reportMissingReactors() {
|
||||||
try {
|
try (con; PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
System.out.println("Fetching reactors from DB...");
|
System.out.println("Fetching reactors from DB...");
|
||||||
fetchMissingReactorDrops();
|
fetchMissingReactorDrops();
|
||||||
|
|
||||||
con.close();
|
printWriter = pw;
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
|
||||||
|
|
||||||
// report suspects of missing quest drop data, as well as those drop data that may have incorrect questids.
|
// report suspects of missing quest drop data, as well as those drop data that
|
||||||
|
// may have incorrect questids.
|
||||||
System.out.println("Reporting results...");
|
System.out.println("Reporting results...");
|
||||||
printReportFileHeader();
|
printReportFileHeader();
|
||||||
reportMissingReactorDrops();
|
reportMissingReactorDrops();
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
System.out.println("Done!");
|
System.out.println("Done!");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println("Warning: Could not establish connection to database to report quest data.");
|
System.out.println("Warning: Could not establish connection to database to report quest data.");
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import server.ItemInformationProvider;
|
|||||||
import tools.DatabaseConnection;
|
import tools.DatabaseConnection;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -20,8 +21,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class SkillMakerFetcher {
|
public class SkillMakerFetcher {
|
||||||
private static final File INPUT_FILE = new File(WZFiles.ETC.getFile(), "ItemMake.img.xml");
|
private static final Path INPUT_FILE = WZFiles.ETC.getFile().resolve("ItemMake.img.xml");
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("maker-data.sql");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("maker-data.sql");
|
||||||
private static final int INITIAL_STRING_LENGTH = 50;
|
private static final int INITIAL_STRING_LENGTH = 50;
|
||||||
|
|
||||||
private static PrintWriter printWriter = null;
|
private static PrintWriter printWriter = null;
|
||||||
@@ -299,14 +300,14 @@ public class SkillMakerFetcher {
|
|||||||
printWriter.println(sb_reward);
|
printWriter.println(sb_reward);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeMakerTableData() {
|
private static void writeMakerTableData() {
|
||||||
// This will reference one line at a time
|
// This will reference one line at a time
|
||||||
String line = null;
|
String line = null;
|
||||||
|
|
||||||
try {
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
|
||||||
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(INPUT_FILE), StandardCharsets.UTF_8);
|
printWriter = pw;
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
bufferedReader = br;
|
||||||
|
|
||||||
resetMakerDataFields();
|
resetMakerDataFields();
|
||||||
|
|
||||||
@@ -316,9 +317,6 @@ public class SkillMakerFetcher {
|
|||||||
|
|
||||||
WriteMakerTableFile();
|
WriteMakerTableFile();
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
bufferedReader.close();
|
|
||||||
fileReader.close();
|
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
System.out.println("Unable to open file '" + INPUT_FILE + "'");
|
System.out.println("Unable to open file '" + INPUT_FILE + "'");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
@@ -326,7 +324,7 @@ public class SkillMakerFetcher {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
DatabaseConnection.initializeConnectionPool(); // Using ItemInformationProvider which loads som unrelated things from the db
|
DatabaseConnection.initializeConnectionPool(); // Using ItemInformationProvider which loads som unrelated things from the db
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import provider.wz.WZFiles;
|
|||||||
import tools.Pair;
|
import tools.Pair;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -16,8 +17,8 @@ import java.util.List;
|
|||||||
* by the server source.
|
* by the server source.
|
||||||
*/
|
*/
|
||||||
public class SkillMakerReagentIndexer {
|
public class SkillMakerReagentIndexer {
|
||||||
private static final File INPUT_FILE = new File(WZFiles.ITEM.getFile(), "Etc/0425.img.xml");
|
private static final Path INPUT_FILE = WZFiles.ITEM.getFile().resolve("Etc/0425.img.xml");
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("maker-reagent-data.sql");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("maker-reagent-data.sql");
|
||||||
private static final int INITIAL_STRING_LENGTH = 50;
|
private static final int INITIAL_STRING_LENGTH = 50;
|
||||||
private static final List<Pair<Integer, Pair<String, Integer>>> reagentList = new ArrayList<>();
|
private static final List<Pair<Integer, Pair<String, Integer>>> reagentList = new ArrayList<>();
|
||||||
|
|
||||||
@@ -147,26 +148,22 @@ public class SkillMakerReagentIndexer {
|
|||||||
printWriter.println(sb);
|
printWriter.println(sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeMakerReagentTableData() {
|
private static void writeMakerReagentTableData() {
|
||||||
// This will reference one line at a time
|
// This will reference one line at a time
|
||||||
String line = null;
|
String line = null;
|
||||||
|
|
||||||
try {
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE));
|
||||||
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(INPUT_FILE), StandardCharsets.UTF_8);
|
BufferedReader br = Files.newBufferedReader(INPUT_FILE);) {
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
bufferedReader = br;
|
||||||
|
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
translateToken(line);
|
translateToken(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferedReader.close();
|
|
||||||
fileReader.close();
|
|
||||||
|
|
||||||
SortReagentList();
|
SortReagentList();
|
||||||
|
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
printWriter = pw;
|
||||||
WriteMakerReagentTableFile();
|
WriteMakerReagentTableFile();
|
||||||
printWriter.close();
|
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
System.out.println("Unable to open file '" + OUTPUT_FILE + "'");
|
System.out.println("Unable to open file '" + OUTPUT_FILE + "'");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package tools.mapletools;
|
|||||||
import server.life.MonsterStats;
|
import server.life.MonsterStats;
|
||||||
import tools.Pair;
|
import tools.Pair;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -27,7 +27,7 @@ import java.util.Map;
|
|||||||
* drops.
|
* drops.
|
||||||
*/
|
*/
|
||||||
public class SkillbookChanceFetcher {
|
public class SkillbookChanceFetcher {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("skillbook_drop_data.sql");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("skillbook_drop_data.sql");
|
||||||
private static final Map<Pair<Integer, Integer>, Integer> skillbookChances = new HashMap<>();
|
private static final Map<Pair<Integer, Integer>, Integer> skillbookChances = new HashMap<>();
|
||||||
|
|
||||||
private static PrintWriter printWriter;
|
private static PrintWriter printWriter;
|
||||||
@@ -102,17 +102,17 @@ public class SkillbookChanceFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void generateSkillbookChanceUpdateFile() {
|
private static void generateSkillbookChanceUpdateFile() {
|
||||||
try {
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
printWriter = pw;
|
||||||
|
|
||||||
printSkillbookChanceUpdateSqlHeader();
|
printSkillbookChanceUpdateSqlHeader();
|
||||||
|
|
||||||
List<Map.Entry<Pair<Integer, Integer>, Integer>> skillbookChancesList = sortedSkillbookChances();
|
List<Map.Entry<Pair<Integer, Integer>, Integer>> skillbookChancesList = sortedSkillbookChances();
|
||||||
for (Map.Entry<Pair<Integer, Integer>, Integer> e : skillbookChancesList) {
|
for (Map.Entry<Pair<Integer, Integer>, Integer> e : skillbookChancesList) {
|
||||||
printWriter.println("(" + e.getKey().getLeft() + ", " + e.getKey().getRight() + ", 1, 1, 0, " + e.getValue() + "),");
|
printWriter.println("(" + e.getKey().getLeft() + ", " + e.getKey().getRight() + ", 1, 1, 0, "
|
||||||
|
+ e.getValue() + "),");
|
||||||
}
|
}
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
ioe.printStackTrace();
|
ioe.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ package tools.mapletools;
|
|||||||
import provider.wz.WZFiles;
|
import provider.wz.WZFiles;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.DirectoryStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author RonanLana
|
* @author RonanLana
|
||||||
@@ -15,8 +19,8 @@ import java.nio.charset.StandardCharsets;
|
|||||||
* Estimated parse time: 10 seconds
|
* Estimated parse time: 10 seconds
|
||||||
*/
|
*/
|
||||||
public class SkillbookStackUpdate {
|
public class SkillbookStackUpdate {
|
||||||
private static final File INPUT_DIRECTORY = new File(WZFiles.ITEM.getFile(), "Consume");
|
private static final Path INPUT_DIRECTORY = WZFiles.ITEM.getFile().resolve("Consume");
|
||||||
private static final File OUTPUT_DIRECTORY = ToolConstants.getOutputFile("skillbook-update");
|
private static final Path OUTPUT_DIRECTORY = ToolConstants.getOutputFile("skillbook-update");
|
||||||
private static final int INITIAL_STRING_LENGTH = 50;
|
private static final int INITIAL_STRING_LENGTH = 50;
|
||||||
|
|
||||||
private static PrintWriter printWriter = null;
|
private static PrintWriter printWriter = null;
|
||||||
@@ -65,7 +69,6 @@ public class SkillbookStackUpdate {
|
|||||||
|
|
||||||
private static void forwardCursor(int st) {
|
private static void forwardCursor(int st) {
|
||||||
String line = null;
|
String line = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (status >= st && (line = bufferedReader.readLine()) != null) {
|
while (status >= st && (line = bufferedReader.readLine()) != null) {
|
||||||
simpleToken(line);
|
simpleToken(line);
|
||||||
@@ -111,47 +114,55 @@ public class SkillbookStackUpdate {
|
|||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void parseItemFile(File file, File outputFile) {
|
private static void parseItemFile(Path file, Path outputFile) {
|
||||||
setupDirectories(outputFile);
|
setupDirectories(outputFile);
|
||||||
// This will reference one line at a time
|
|
||||||
String line = null;
|
|
||||||
|
|
||||||
try {
|
try (BufferedReader br = Files.newBufferedReader(file);
|
||||||
printWriter = new PrintWriter(outputFile);
|
PrintWriter pw = new PrintWriter(Files.newOutputStream(outputFile))) {
|
||||||
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
bufferedReader = br;
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
printWriter = pw;
|
||||||
|
String line;
|
||||||
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
|
translateItemToken(line);
|
||||||
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
System.out.println("Error reading file '" + file.getFileName() + "'");
|
||||||
|
ex.printStackTrace();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
private static void setupDirectories(Path file) {
|
||||||
translateItemToken(line);
|
if (!Files.exists(file.getParent())) {
|
||||||
|
try {
|
||||||
|
Files.createDirectories(file.getParent());
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error creating folder '" + file.getParent() + "'");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void parseItemDirectory(Path inputDirectory, Path outputDirectory) {
|
||||||
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(inputDirectory)) {
|
||||||
|
for (Path path : stream) {
|
||||||
|
parseItemFile(path, outputDirectory.resolve(path.getFileName()));
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
bufferedReader.close();
|
e.printStackTrace();
|
||||||
fileReader.close();
|
}
|
||||||
printWriter.close();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
System.out.println("Error reading file '" + file.getName() + "'");
|
|
||||||
ex.printStackTrace();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setupDirectories(File file) {
|
|
||||||
if (!file.getParentFile().exists()) {
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void parseItemDirectory(File inputDirectory, File outputDirectory) {
|
|
||||||
for (File f : inputDirectory.listFiles()) {
|
|
||||||
parseItemFile(f, new File(outputDirectory, f.getName()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Instant instantStarted = Instant.now();
|
||||||
System.out.println("Reading item files...");
|
System.out.println("Reading item files...");
|
||||||
parseItemDirectory(INPUT_DIRECTORY, OUTPUT_DIRECTORY);
|
parseItemDirectory(INPUT_DIRECTORY, OUTPUT_DIRECTORY);
|
||||||
System.out.println("Done!");
|
System.out.println("Done!");
|
||||||
|
Instant instantStopped = Instant.now();
|
||||||
|
Duration durationBetween = Duration.between(instantStarted, instantStopped);
|
||||||
|
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
|
||||||
|
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
package tools.mapletools;
|
package tools.mapletools;
|
||||||
|
|
||||||
import java.io.File;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
class ToolConstants {
|
class ToolConstants {
|
||||||
static final File INPUT_DIRECTORY = new File("tools/input");
|
static final Path INPUT_DIRECTORY = Paths.get("tools/input");
|
||||||
static final File OUTPUT_DIRECTORY = new File("tools/output");
|
static final Path OUTPUT_DIRECTORY = Paths.get("tools/output");
|
||||||
static final String SCRIPTS_PATH = "scripts";
|
static final String SCRIPTS_PATH = "scripts";
|
||||||
static final String HANDBOOK_PATH = "handbook";
|
static final String HANDBOOK_PATH = "handbook";
|
||||||
|
|
||||||
static File getInputFile(String fileName) {
|
static Path getInputFile(String fileName) {
|
||||||
return new File(INPUT_DIRECTORY, fileName);
|
return INPUT_DIRECTORY.resolve(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static File getOutputFile(String fileName) {
|
static Path getOutputFile(String fileName) {
|
||||||
return new File(OUTPUT_DIRECTORY, fileName);
|
return OUTPUT_DIRECTORY.resolve(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import tools.Pair;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,7 +16,7 @@ import java.util.*;
|
|||||||
* throughout the map tree (area map -> continent map -> world map) but are currently missing.
|
* throughout the map tree (area map -> continent map -> world map) but are currently missing.
|
||||||
*/
|
*/
|
||||||
public class WorldmapChecker {
|
public class WorldmapChecker {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("worldmap_report.txt");
|
private static final Path OUTPUT_FILE = ToolConstants.getOutputFile("worldmap_report.txt");
|
||||||
private static final int INITIAL_STRING_LENGTH = 50;
|
private static final int INITIAL_STRING_LENGTH = 50;
|
||||||
private static final Map<String, Set<Integer>> worldMapids = new HashMap<>();
|
private static final Map<String, Set<Integer>> worldMapids = new HashMap<>();
|
||||||
private static final Map<String, String> parentWorldmaps = new HashMap<>();
|
private static final Map<String, String> parentWorldmaps = new HashMap<>();
|
||||||
@@ -186,8 +188,8 @@ public class WorldmapChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void verifyWorldmapTreeMapids() {
|
private static void verifyWorldmapTreeMapids() {
|
||||||
try {
|
try (PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
|
||||||
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
printWriter = pw;
|
||||||
printReportFileHeader();
|
printReportFileHeader();
|
||||||
|
|
||||||
if (rootWorldmaps.size() > 1) {
|
if (rootWorldmaps.size() > 1) {
|
||||||
@@ -242,7 +244,6 @@ public class WorldmapChecker {
|
|||||||
printReportFileResults(unreferencedEntries);
|
printReportFileResults(unreferencedEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
printWriter.close();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user