Move MapleEquipmentOmnileveler to main module, use existing wz files
This commit is contained in:
@@ -1,82 +1,51 @@
|
|||||||
/*
|
package tools.mapletools;
|
||||||
This file is part of the HeavenMS MapleStory Server
|
|
||||||
Copyleft (L) 2016 - 2019 RonanLana
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
import provider.wz.WZFiles;
|
||||||
it under the terms of the GNU Affero General Public License as
|
|
||||||
published by the Free Software Foundation version 3 as published by
|
|
||||||
the Free Software Foundation. You may not use, modify or distribute
|
|
||||||
this program under any other version of the GNU Affero General Public
|
|
||||||
License.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
import java.io.*;
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
import java.nio.charset.StandardCharsets;
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package mapleequipmentomnileveler;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.sql.Connection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author RonanLana
|
* @author RonanLana
|
||||||
|
* <p>
|
||||||
This application parses the Character.wz folder inputted and adds/updates the "info/level"
|
* This application parses the Character.wz folder inputted and adds/updates the "info/level"
|
||||||
node on every known equipment id. This addition enables client-side view of the equipment
|
* node on every known equipment id. This addition enables client-side view of the equipment
|
||||||
level attribute on every equipment in the game, given proper item visibility, be it from
|
* level attribute on every equipment in the game, given proper item visibility, be it from
|
||||||
own equipments or from other players.
|
* own equipments or from other players.
|
||||||
|
* <p>
|
||||||
Estimated parse time: 7 minutes
|
* Estimated parse time: 7 minutes
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public class MapleEquipmentOmnileveler {
|
public class EquipmentOmniLeveller {
|
||||||
|
private static final File INPUT_DIRECTORY = WZFiles.CHARACTER.getFile();
|
||||||
|
private static final File OUTPUT_DIRECTORY = ToolConstants.getOutputFile("equips-with-levels");
|
||||||
|
private static final int INITIAL_STRING_LENGTH = 250;
|
||||||
|
private static final int FIXED_EXP = 10000;
|
||||||
|
private static final int MAX_EQP_LEVEL = 30;
|
||||||
|
|
||||||
|
private static PrintWriter printWriter = null;
|
||||||
|
private static InputStreamReader fileReader = null;
|
||||||
|
private static BufferedReader bufferedReader = null;
|
||||||
|
|
||||||
|
private static int infoTagState = -1;
|
||||||
|
private static int infoTagExpState = -1;
|
||||||
|
private static boolean infoTagLevel;
|
||||||
|
private static boolean infoTagLevelExp;
|
||||||
|
private static boolean infoTagLevelInfo;
|
||||||
|
private static int parsedLevels = 0;
|
||||||
|
private static byte status;
|
||||||
|
private static boolean upgradeable;
|
||||||
|
private static boolean cash;
|
||||||
|
|
||||||
static String equipDirectory = "lib/original/";
|
|
||||||
static String outputDirectory = "lib/updated/";
|
|
||||||
|
|
||||||
static Connection con = null;
|
|
||||||
static PrintWriter printWriter = null;
|
|
||||||
static InputStreamReader fileReader = null;
|
|
||||||
static BufferedReader bufferedReader = null;
|
|
||||||
|
|
||||||
static int initialStringLength = 250;
|
|
||||||
|
|
||||||
static int fixedExp = 10000;
|
|
||||||
static int maxEqpLevel = 30;
|
|
||||||
|
|
||||||
static int infoTagState = -1, infoTagExpState = -1;
|
|
||||||
|
|
||||||
static boolean infoTagLevel;
|
|
||||||
static boolean infoTagLevelExp;
|
|
||||||
static boolean infoTagLevelInfo;
|
|
||||||
|
|
||||||
static int parsedLevels = 0;
|
|
||||||
|
|
||||||
static byte status;
|
|
||||||
static boolean upgradeable;
|
|
||||||
static boolean cash;
|
|
||||||
|
|
||||||
private static String getName(String token) {
|
private static String getName(String token) {
|
||||||
int i, j;
|
int i, j;
|
||||||
char[] dest;
|
char[] dest;
|
||||||
String d;
|
String d;
|
||||||
|
|
||||||
i = token.lastIndexOf("name");
|
i = token.lastIndexOf("name");
|
||||||
i = token.indexOf("\"", i) + 1; //lower bound of the string
|
i = token.indexOf("\"", i) + 1; //lower bound of the string
|
||||||
j = token.indexOf("\"", i); //upper bound
|
j = token.indexOf("\"", i); //upper bound
|
||||||
|
|
||||||
dest = new char[initialStringLength];
|
dest = new char[INITIAL_STRING_LENGTH];
|
||||||
try {
|
try {
|
||||||
token.getChars(i, j, dest, 0);
|
token.getChars(i, j, dest, 0);
|
||||||
} catch (StringIndexOutOfBoundsException e) {
|
} catch (StringIndexOutOfBoundsException e) {
|
||||||
@@ -87,14 +56,15 @@ public class MapleEquipmentOmnileveler {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100000000);
|
Thread.sleep(100000000);
|
||||||
} catch (Exception ex) {}
|
} catch (Exception ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
d = new String(dest);
|
d = new String(dest);
|
||||||
return(d.trim());
|
return (d.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getValue(String token) {
|
private static String getValue(String token) {
|
||||||
int i, j;
|
int i, j;
|
||||||
char[] dest;
|
char[] dest;
|
||||||
@@ -104,153 +74,147 @@ public class MapleEquipmentOmnileveler {
|
|||||||
i = token.indexOf("\"", i) + 1; //lower bound of the string
|
i = token.indexOf("\"", i) + 1; //lower bound of the string
|
||||||
j = token.indexOf("\"", i); //upper bound
|
j = token.indexOf("\"", i); //upper bound
|
||||||
|
|
||||||
dest = new char[initialStringLength];
|
dest = new char[INITIAL_STRING_LENGTH];
|
||||||
token.getChars(i, j, dest, 0);
|
token.getChars(i, j, dest, 0);
|
||||||
|
|
||||||
d = new String(dest);
|
d = new String(dest);
|
||||||
return(d.trim());
|
return (d.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
printWriter.println(line);
|
printWriter.println(line);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void translateLevelCursor(int st) {
|
private static void translateLevelCursor(int st) {
|
||||||
String line = null;
|
String line = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
infoTagLevelInfo = false;
|
infoTagLevelInfo = false;
|
||||||
while (status >= st && (line = bufferedReader.readLine()) != null) {
|
while (status >= st && (line = bufferedReader.readLine()) != null) {
|
||||||
translateLevelToken(line);
|
translateLevelToken(line);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void translateInfoTag(int st) {
|
private static void translateInfoTag(int st) {
|
||||||
infoTagLevel = false;
|
infoTagLevel = false;
|
||||||
String line = null;
|
String line = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while(status >= st && (line = bufferedReader.readLine()) != null) { // skipping directory & canvas definition
|
while (status >= st && (line = bufferedReader.readLine()) != null) { // skipping directory & canvas definition
|
||||||
translateInfoToken(line);
|
translateInfoToken(line);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!upgradeable || cash) {
|
if (!upgradeable || cash) {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void simpleToken(String token) {
|
private static void simpleToken(String token) {
|
||||||
if(token.contains("/imgdir")) {
|
if (token.contains("/imgdir")) {
|
||||||
status -= 1;
|
status -= 1;
|
||||||
}
|
} else if (token.contains("imgdir")) {
|
||||||
else if(token.contains("imgdir")) {
|
|
||||||
status += 1;
|
status += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printUpdatedLevelExp() {
|
private static void printUpdatedLevelExp() {
|
||||||
printWriter.println(" <int name=\"exp\" value=\"" + fixedExp + "\"/>");
|
printWriter.println(" <int name=\"exp\" value=\"" + FIXED_EXP + "\"/>");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printDefaultLevel(int level) {
|
private static void printDefaultLevel(int level) {
|
||||||
printWriter.println(" <imgdir name=\"" + level + "\">");
|
printWriter.println(" <imgdir name=\"" + level + "\">");
|
||||||
printUpdatedLevelExp();
|
printUpdatedLevelExp();
|
||||||
printWriter.println(" </imgdir>");
|
printWriter.println(" </imgdir>");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printDefaultLevelInfoTag() {
|
private static void printDefaultLevelInfoTag() {
|
||||||
printWriter.println(" <imgdir name=\"info\">");
|
printWriter.println(" <imgdir name=\"info\">");
|
||||||
for (int i = 1; i <= maxEqpLevel; i++) printDefaultLevel(i);
|
for (int i = 1; i <= MAX_EQP_LEVEL; i++) {
|
||||||
|
printDefaultLevel(i);
|
||||||
|
}
|
||||||
printWriter.println(" </imgdir>");
|
printWriter.println(" </imgdir>");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printDefaultLevelTag() {
|
private static void printDefaultLevelTag() {
|
||||||
printWriter.println(" <imgdir name=\"level\">");
|
printWriter.println(" <imgdir name=\"level\">");
|
||||||
printDefaultLevelInfoTag();
|
printDefaultLevelInfoTag();
|
||||||
printWriter.println(" </imgdir>");
|
printWriter.println(" </imgdir>");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void processLevelInfoTag(int st) {
|
private static void processLevelInfoTag(int st) {
|
||||||
String line;
|
String line;
|
||||||
try {
|
try {
|
||||||
while(status >= st && (line = bufferedReader.readLine()) != null) {
|
while (status >= st && (line = bufferedReader.readLine()) != null) {
|
||||||
translateLevelExpToken(line);
|
translateLevelExpToken(line);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void processLevelInfoSet(int st) {
|
private static void processLevelInfoSet(int st) {
|
||||||
parsedLevels = (1 << maxEqpLevel) - 1;
|
parsedLevels = (1 << MAX_EQP_LEVEL) - 1;
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
try {
|
try {
|
||||||
while(status >= st && (line = bufferedReader.readLine()) != null) {
|
while (status >= st && (line = bufferedReader.readLine()) != null) {
|
||||||
translateLevelInfoSetToken(line);
|
translateLevelInfoSetToken(line);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void translateLevelToken(String token) {
|
private static void translateLevelToken(String token) {
|
||||||
if(token.contains("/imgdir")) {
|
if (token.contains("/imgdir")) {
|
||||||
if (status == 3) {
|
if (status == 3) {
|
||||||
if (!infoTagLevelInfo) {
|
if (!infoTagLevelInfo) {
|
||||||
printDefaultLevelInfoTag();
|
printDefaultLevelInfoTag();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
|
|
||||||
status -= 1;
|
status -= 1;
|
||||||
}
|
} else if (token.contains("imgdir")) {
|
||||||
else if(token.contains("imgdir")) {
|
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
status += 1;
|
status += 1;
|
||||||
|
|
||||||
if (status == 4) {
|
if (status == 4) {
|
||||||
String d = getName(token);
|
String d = getName(token);
|
||||||
if(d.contentEquals("info")) {
|
if (d.contentEquals("info")) {
|
||||||
infoTagLevelInfo = true;
|
infoTagLevelInfo = true;
|
||||||
processLevelInfoSet(status);
|
processLevelInfoSet(status);
|
||||||
} else {
|
} else {
|
||||||
forwardCursor(status);
|
forwardCursor(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void translateLevelInfoSetToken(String token) {
|
private static void translateLevelInfoSetToken(String token) {
|
||||||
if(token.contains("/imgdir")) {
|
if (token.contains("/imgdir")) {
|
||||||
status -= 1;
|
status -= 1;
|
||||||
|
|
||||||
if (status == 3) {
|
if (status == 3) {
|
||||||
if (parsedLevels != 0) {
|
if (parsedLevels != 0) {
|
||||||
for (int i = 0; i < maxEqpLevel; i++) {
|
for (int i = 0; i < MAX_EQP_LEVEL; i++) {
|
||||||
if ((parsedLevels >> i) % 2 != 0) {
|
if ((parsedLevels >> i) % 2 != 0) {
|
||||||
int level = i + 1;
|
int level = i + 1;
|
||||||
printDefaultLevel(level);
|
printDefaultLevel(level);
|
||||||
@@ -258,47 +222,43 @@ public class MapleEquipmentOmnileveler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
}
|
} else if (token.contains("imgdir")) {
|
||||||
else if(token.contains("imgdir")) {
|
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
status += 1;
|
status += 1;
|
||||||
|
|
||||||
if (status == 5) {
|
if (status == 5) {
|
||||||
int level = Integer.parseInt(getName(token)) - 1;
|
int level = Integer.parseInt(getName(token)) - 1;
|
||||||
parsedLevels ^= (1 << level);
|
parsedLevels ^= (1 << level);
|
||||||
|
|
||||||
infoTagLevelExp = false;
|
infoTagLevelExp = false;
|
||||||
infoTagExpState = status; // status: 5
|
infoTagExpState = status; // status: 5
|
||||||
processLevelInfoTag(status);
|
processLevelInfoTag(status);
|
||||||
infoTagExpState = -1;
|
infoTagExpState = -1;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void translateLevelExpToken(String token) {
|
private static void translateLevelExpToken(String token) {
|
||||||
if(token.contains("/imgdir")) {
|
if (token.contains("/imgdir")) {
|
||||||
status -= 1;
|
status -= 1;
|
||||||
|
|
||||||
if (status < infoTagExpState) {
|
if (status < infoTagExpState) {
|
||||||
if (!infoTagLevelExp) {
|
if (!infoTagLevelExp) {
|
||||||
printUpdatedLevelExp();
|
printUpdatedLevelExp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
}
|
} else if (token.contains("imgdir")) {
|
||||||
else if(token.contains("imgdir")) {
|
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
status += 1;
|
status += 1;
|
||||||
|
|
||||||
forwardCursor(status);
|
forwardCursor(status);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
String name = getName(token);
|
String name = getName(token);
|
||||||
if (name.contentEquals("exp")) {
|
if (name.contentEquals("exp")) {
|
||||||
infoTagLevelExp = true;
|
infoTagLevelExp = true;
|
||||||
@@ -308,23 +268,22 @@ public class MapleEquipmentOmnileveler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void translateInfoToken(String token) {
|
private static void translateInfoToken(String token) {
|
||||||
if(token.contains("/imgdir")) {
|
if (token.contains("/imgdir")) {
|
||||||
status -= 1;
|
status -= 1;
|
||||||
|
|
||||||
if (status < infoTagState) {
|
if (status < infoTagState) {
|
||||||
if (!infoTagLevel) {
|
if (!infoTagLevel) {
|
||||||
printDefaultLevelTag();
|
printDefaultLevelTag();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
}
|
} else if (token.contains("imgdir")) {
|
||||||
else if(token.contains("imgdir")) {
|
|
||||||
status += 1;
|
status += 1;
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
|
|
||||||
String d = getName(token);
|
String d = getName(token);
|
||||||
if (d.contentEquals("level")) {
|
if (d.contentEquals("level")) {
|
||||||
infoTagLevel = true;
|
infoTagLevel = true;
|
||||||
@@ -332,17 +291,16 @@ public class MapleEquipmentOmnileveler {
|
|||||||
} else {
|
} else {
|
||||||
forwardCursor(status);
|
forwardCursor(status);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
String name = getName(token);
|
String name = getName(token);
|
||||||
|
|
||||||
switch(name) {
|
switch (name) {
|
||||||
case "cash":
|
case "cash":
|
||||||
if (!getValue(token).contentEquals("0")) {
|
if (!getValue(token).contentEquals("0")) {
|
||||||
cash = true;
|
cash = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "tuc":
|
case "tuc":
|
||||||
case "incPAD":
|
case "incPAD":
|
||||||
case "incMAD":
|
case "incMAD":
|
||||||
@@ -363,25 +321,24 @@ public class MapleEquipmentOmnileveler {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean translateToken(String token) {
|
private static boolean translateToken(String token) {
|
||||||
boolean accessInfoTag = false;
|
boolean accessInfoTag = false;
|
||||||
|
|
||||||
if(token.contains("/imgdir")) {
|
if (token.contains("/imgdir")) {
|
||||||
status -= 1;
|
status -= 1;
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
}
|
} else if (token.contains("imgdir")) {
|
||||||
else if(token.contains("imgdir")) {
|
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
status += 1;
|
status += 1;
|
||||||
|
|
||||||
if (status == 2) {
|
if (status == 2) {
|
||||||
String d = getName(token);
|
String d = getName(token);
|
||||||
if(!d.contentEquals("info")) {
|
if (!d.contentEquals("info")) {
|
||||||
forwardCursor(status);
|
forwardCursor(status);
|
||||||
} else {
|
} else {
|
||||||
accessInfoTag = true;
|
accessInfoTag = true;
|
||||||
@@ -389,22 +346,21 @@ public class MapleEquipmentOmnileveler {
|
|||||||
} else if (status > 2) {
|
} else if (status > 2) {
|
||||||
forwardCursor(status);
|
forwardCursor(status);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
return accessInfoTag;
|
return accessInfoTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyCashItemData(File file, String curPath) throws IOException {
|
private static void copyCashItemData(File file, String curPath) throws IOException {
|
||||||
printWriter = new PrintWriter(outputDirectory + curPath + file.getName(), "UTF-8");
|
printWriter = new PrintWriter(new File(OUTPUT_DIRECTORY, curPath + file.getName()), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
fileReader = new InputStreamReader(new FileInputStream(file), "UTF-8");
|
fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
bufferedReader = new BufferedReader(fileReader);
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
while((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
printWriter.println(line);
|
printWriter.println(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,70 +369,66 @@ public class MapleEquipmentOmnileveler {
|
|||||||
|
|
||||||
printWriter.close();
|
printWriter.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void parseEquipData(File file, String curPath) throws IOException {
|
private static void parseEquipData(File file, String curPath) throws IOException {
|
||||||
printWriter = new PrintWriter(outputDirectory + curPath + file.getName(), "UTF-8");
|
printWriter = new PrintWriter(new File(OUTPUT_DIRECTORY, curPath + file.getName()), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
fileReader = new InputStreamReader(new FileInputStream(file), "UTF-8");
|
fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
bufferedReader = new BufferedReader(fileReader);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
status = 0;
|
status = 0;
|
||||||
upgradeable = false;
|
upgradeable = false;
|
||||||
cash = false;
|
cash = false;
|
||||||
|
|
||||||
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();
|
bufferedReader.close();
|
||||||
fileReader.close();
|
fileReader.close();
|
||||||
|
|
||||||
printFileFooter();
|
printFileFooter();
|
||||||
printWriter.close();
|
printWriter.close();
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
bufferedReader.close();
|
bufferedReader.close();
|
||||||
fileReader.close();
|
fileReader.close();
|
||||||
|
|
||||||
printWriter.close();
|
printWriter.close();
|
||||||
|
|
||||||
copyCashItemData(file, curPath);
|
copyCashItemData(file, curPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printFileFooter() {
|
private static void printFileFooter() {
|
||||||
printWriter.println("<!--");
|
printWriter.println("<!--");
|
||||||
printWriter.println(" # WZ XML File parsed by the MapleEquipmentOmnilever feature by Ronan Lana.");
|
printWriter.println(" # WZ XML File parsed by the MapleEquipmentOmnilever feature by Ronan Lana.");
|
||||||
printWriter.println(" # Generated data takes into account info from the server-side WZ.xmls.");
|
printWriter.println(" # Generated data takes into account info from the server-side WZ.xmls.");
|
||||||
printWriter.println("-->");
|
printWriter.println("-->");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void parseDirectoryEquipData(String curPath) {
|
private static void parseDirectoryEquipData(String curPath) {
|
||||||
File folder = new File(outputDirectory + curPath);
|
File folder = new File(OUTPUT_DIRECTORY, curPath);
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
folder.mkdir();
|
folder.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Parsing directory '" + curPath + "'");
|
System.out.println("Parsing directory '" + curPath + "'");
|
||||||
folder = new File(equipDirectory + curPath);
|
folder = new File(INPUT_DIRECTORY, curPath);
|
||||||
for (File file : folder.listFiles()) {
|
for (File file : folder.listFiles()) {
|
||||||
if (file.isFile()) {
|
if (file.isFile()) {
|
||||||
try {
|
try {
|
||||||
parseEquipData(file, curPath);
|
parseEquipData(file, curPath);
|
||||||
}
|
} catch (FileNotFoundException ex) {
|
||||||
catch(FileNotFoundException ex) {
|
|
||||||
System.out.println("Unable to open equip file " + file.getAbsolutePath() + ".");
|
System.out.println("Unable to open equip file " + file.getAbsolutePath() + ".");
|
||||||
}
|
} catch (IOException ex) {
|
||||||
catch(IOException ex) {
|
|
||||||
System.out.println("Error reading equip file " + file.getAbsolutePath() + ".");
|
System.out.println("Error reading equip file " + file.getAbsolutePath() + ".");
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -484,9 +436,8 @@ public class MapleEquipmentOmnileveler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
parseDirectoryEquipData("");
|
parseDirectoryEquipData("");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user