Move MapleMobBookUpdate to main module
This commit is contained in:
@@ -1,65 +1,39 @@
|
|||||||
/*
|
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,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
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 maplemobbookupdate;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author RonanLana
|
* @author RonanLana
|
||||||
*
|
* <p>
|
||||||
* This application updates the Monster Book drop data with the actual underlying drop data from
|
* This application updates the Monster Book drop data with the actual underlying drop data from
|
||||||
* the Maplestory database specified in the URL below.
|
* the Maplestory database specified in the URL below.
|
||||||
*
|
* <p>
|
||||||
* In other words all items drops from monsters listed inside the Mob Book feature will be patched to match exactly like the item
|
* In other words all items drops from monsters listed inside the Mob Book feature will be patched to match exactly like the item
|
||||||
* drop list specified in the URL's Maplestory database.
|
* drop list specified in the URL's Maplestory database.
|
||||||
*
|
* <p>
|
||||||
* The original file "MonsterBook.img.xml" from String.wz must be copied to the directory of this application and only then
|
* The original file "MonsterBook.img.xml" from String.wz must be copied to the directory of this application and only then
|
||||||
* executed. This program will generate another file that must replace the original server file to make the effects take place
|
* executed. This program will generate another file that must replace the original server file to make the effects take place
|
||||||
* to on your server.
|
* to on your server.
|
||||||
*
|
* <p>
|
||||||
* After replacing on server, this XML must be updated on the client via WZ Editor (HaRepack for instance). Once inside the repack,
|
* After replacing on server, this XML must be updated on the client via WZ Editor (HaRepack for instance). Once inside the repack,
|
||||||
* 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 MapleMobBookUpdate {
|
public class MobBookUpdate {
|
||||||
static String host = "jdbc:mysql://localhost:3306/cosmic";
|
private static final File INPUT_FILE = new File(WZFiles.STRING.getFile(), "MonsterBook.img.xml");
|
||||||
static String driver = "com.mysql.jdbc.Driver";
|
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("MonsterBook_updated.img.xml");
|
||||||
static String username = "cosmic_server";
|
private static final Connection con = SimpleDatabaseConnection.getConnection();
|
||||||
static String password = "snailshell";
|
|
||||||
|
|
||||||
static String fileName = "lib/MonsterBook.img.xml";
|
private static PrintWriter printWriter = null;
|
||||||
static String newFile = "lib/MonsterBook_updated.img.xml";
|
private static BufferedReader bufferedReader = null;
|
||||||
|
private static byte status = 0;
|
||||||
static Connection con = null;
|
private static int mobId = -1;
|
||||||
static PrintWriter printWriter = null;
|
|
||||||
static InputStreamReader fileReader = null;
|
|
||||||
static BufferedReader bufferedReader = null;
|
|
||||||
static byte status = 0;
|
|
||||||
static int mobId = -1;
|
|
||||||
|
|
||||||
private static String getName(String token) {
|
private static String getName(String token) {
|
||||||
int i, j;
|
int i, j;
|
||||||
@@ -70,33 +44,36 @@ public class MapleMobBookUpdate {
|
|||||||
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
|
||||||
|
|
||||||
if(j - i < 7) dest = new char[6];
|
if (j - i < 7) {
|
||||||
else dest = new char[7];
|
dest = new char[6];
|
||||||
|
} else {
|
||||||
|
dest = new char[7];
|
||||||
|
}
|
||||||
token.getChars(i, j, dest, 0);
|
token.getChars(i, j, dest, 0);
|
||||||
|
|
||||||
d = new String(dest);
|
d = new String(dest);
|
||||||
return(d);
|
return (d);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
if(line != null) printWriter.println(line);
|
if (line != null) {
|
||||||
}
|
printWriter.println(line);
|
||||||
catch(Exception e) {
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,9 +89,11 @@ public class MapleMobBookUpdate {
|
|||||||
ps.setInt(1, mobId);
|
ps.setInt(1, mobId);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
while(rs.next()) {
|
while (rs.next()) {
|
||||||
toPrint = "";
|
toPrint = "";
|
||||||
for(int k = 0; k <= status; k++) toPrint += " ";
|
for (int k = 0; k <= status; k++) {
|
||||||
|
toPrint += " ";
|
||||||
|
}
|
||||||
|
|
||||||
toPrint += "<int name=\"";
|
toPrint += "<int name=\"";
|
||||||
toPrint += cont;
|
toPrint += cont;
|
||||||
@@ -127,11 +106,10 @@ public class MapleMobBookUpdate {
|
|||||||
printWriter.println(toPrint);
|
printWriter.println(toPrint);
|
||||||
cont++;
|
cont++;
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
}
|
} catch (SQLException e) {
|
||||||
catch(SQLException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,18 +120,16 @@ public class MapleMobBookUpdate {
|
|||||||
|
|
||||||
printWriter.println(token);
|
printWriter.println(token);
|
||||||
|
|
||||||
if(token.contains("/imgdir")) {
|
if (token.contains("/imgdir")) {
|
||||||
status -= 1;
|
status -= 1;
|
||||||
}
|
} else if (token.contains("imgdir")) {
|
||||||
else if(token.contains("imgdir")) {
|
if (status == 1) { //getting MobId
|
||||||
if(status == 1) { //getting MobId
|
|
||||||
d = getName(token);
|
d = getName(token);
|
||||||
mobId = Integer.parseInt(d);
|
mobId = Integer.parseInt(d);
|
||||||
}
|
} else if (status == 2) {
|
||||||
else if(status == 2) {
|
|
||||||
d = getName(token);
|
d = getName(token);
|
||||||
|
|
||||||
if(d.contains("reward")) {
|
if (d.contains("reward")) {
|
||||||
temp = status;
|
temp = status;
|
||||||
|
|
||||||
loadDropsFromMob();
|
loadDropsFromMob();
|
||||||
@@ -166,19 +142,16 @@ public class MapleMobBookUpdate {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UpdateFromDropData() {
|
private static void updateFromDropData() {
|
||||||
// This will reference one line at a time
|
// This will reference one line at a time
|
||||||
String line = null;
|
String line = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName(driver).newInstance();
|
printWriter = new PrintWriter(OUTPUT_FILE, StandardCharsets.UTF_8);
|
||||||
con = DriverManager.getConnection(host, username, password);
|
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(INPUT_FILE), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
printWriter = new PrintWriter(newFile, "UTF-8");
|
|
||||||
fileReader = new InputStreamReader(new FileInputStream(fileName), "UTF-8");
|
|
||||||
bufferedReader = new BufferedReader(fileReader);
|
bufferedReader = new BufferedReader(fileReader);
|
||||||
|
|
||||||
while((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
translateToken(line);
|
translateToken(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,37 +160,20 @@ public class MapleMobBookUpdate {
|
|||||||
fileReader.close();
|
fileReader.close();
|
||||||
|
|
||||||
con.close();
|
con.close();
|
||||||
}
|
} catch (FileNotFoundException ex) {
|
||||||
|
System.out.println("Unable to open file '" + INPUT_FILE + "'");
|
||||||
catch(FileNotFoundException ex) {
|
} catch (IOException ex) {
|
||||||
System.out.println("Unable to open file '" + fileName + "'");
|
System.out.println("Error reading file '" + INPUT_FILE + "'");
|
||||||
}
|
} catch (SQLException e) {
|
||||||
catch(IOException ex) {
|
|
||||||
System.out.println("Error reading file '" + fileName + "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
catch(SQLException e) {
|
|
||||||
System.out.println("Warning: Could not establish connection to database to change card chance rate.");
|
System.out.println("Warning: Could not establish connection to database to change card chance rate.");
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
|
||||||
catch(ClassNotFoundException e) {
|
|
||||||
System.out.println("Error: could not find class");
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
catch(InstantiationException e) {
|
|
||||||
System.out.println("Error: instantiation failure");
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
UpdateFromDropData();
|
updateFromDropData();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user