1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-05 23:22:47 +00:00

Remove deprecated 'l2jserver2-gameserver/src/tool' source folder

Removes the now deprecated 'l2jserver2-gameserver/src/tool' source
folder since it has been refactored to an maven module.
This commit is contained in:
2011-10-06 11:39:56 -03:00
parent 19d025e3fd
commit 2e6fdb20bb
18 changed files with 30 additions and 1556 deletions

3
.gitignore vendored
View File

@@ -2,8 +2,7 @@
.project .project
.metadata .metadata
.classpath .classpath
.settings/* .settings/
.settings
# Locally stored "Eclipse launch configurations" # Locally stored "Eclipse launch configurations"
*.launch *.launch

View File

@@ -2,12 +2,17 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>l2jserver2</artifactId>
<groupId>com.l2jserver</groupId> <groupId>com.l2jserver</groupId>
<artifactId>l2jserver2</artifactId>
<version>0.1.0-SNAPSHOT</version> <version>0.1.0-SNAPSHOT</version>
<relativePath>..</relativePath> <relativePath>..</relativePath>
</parent> </parent>
<artifactId>l2jserver2-common</artifactId> <artifactId>l2jserver2-common</artifactId>
<name>L2JServer 2 - Commons module</name>
<description>Lineage II server emulator</description>
<url>http://github.com/l2jserver2</url>
<inceptionYear>2011</inceptionYear>
<dependencies> <dependencies>
<!-- junit --> <!-- junit -->
@@ -103,8 +108,4 @@
<version>2.2</version> <version>2.2</version>
</dependency> </dependency>
</dependencies> </dependencies>
<name>L2JServer 2 - Commons module</name>
<url>http://github.com/l2jserver2</url>
<description>Lineage II server emulator</description>
<inceptionYear>2011</inceptionYear>
</project> </project>

View File

@@ -1,9 +1,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.l2jserver</groupId>
<artifactId>l2jserver2</artifactId>
<version>0.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>l2jserver2-gameserver</artifactId> <artifactId>l2jserver2-gameserver</artifactId>
<name>L2JServer 2 - Game server module</name> <name>L2JServer 2 - Game server module</name>
<description>Lineage II server emulator</description> <description>Lineage II server emulator</description>
<url>http://github.com/l2jserver2</url>
<inceptionYear>2011</inceptionYear>
<build> <build>
<defaultGoal>package</defaultGoal> <defaultGoal>package</defaultGoal>
@@ -209,12 +218,4 @@
<type>jar</type> <type>jar</type>
</dependency> </dependency>
</dependencies> </dependencies>
<parent>
<groupId>com.l2jserver</groupId>
<artifactId>l2jserver2</artifactId>
<version>0.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<url>http://github.com/l2jserver2</url>
<inceptionYear>2011</inceptionYear>
</project> </project>

View File

@@ -1,186 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.template;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.SchemaOutputResolver;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
import com.l2jserver.model.template.CharacterTemplate.CharacterStatsMetadata;
import com.l2jserver.model.template.CharacterTemplate.CharacterStatsMetadata.AttackMetadata;
import com.l2jserver.model.template.CharacterTemplate.CharacterStatsMetadata.AttackMetadata.AttackValueMetadata;
import com.l2jserver.model.template.CharacterTemplate.CharacterStatsMetadata.BaseMetadata;
import com.l2jserver.model.template.CharacterTemplate.CharacterStatsMetadata.DefenseMetadata;
import com.l2jserver.model.template.CharacterTemplate.CharacterStatsMetadata.DefenseMetadata.DefenseValueMetadata;
import com.l2jserver.model.template.CharacterTemplate.CharacterStatsMetadata.MoveMetadata;
import com.l2jserver.model.template.CharacterTemplate.CharacterStatsMetadata.Stat;
import com.l2jserver.model.template.CharacterTemplate.CollitionMetadataContainer;
import com.l2jserver.model.template.CharacterTemplate.CollitionMetadataContainer.CollisionMetadata;
/**
* The need to use this package to get access to protected fields.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterTemplateConverter {
private static final String JDBC_URL = "jdbc:mysql://localhost/l2j-old";
private static final String JDBC_USERNAME = "l2j";
private static final String JDBC_PASSWORD = "changeme";
public static void main(String[] args) throws SQLException, IOException,
ClassNotFoundException, JAXBException {
Class.forName("com.mysql.jdbc.Driver");
final File target = new File("generated/template");
System.out.println("Generating template classes...");
final JAXBContext c = JAXBContext.newInstance(CharacterTemplate.class);
c.generateSchema(new SchemaOutputResolver() {
@Override
public Result createOutput(String namespaceUri,
String suggestedFileName) throws IOException {
return new StreamResult(new File(target, "character.xsd"));
}
});
final Marshaller m = c.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.setProperty(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION, "character");
m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
"character ../character.xsd");
final Connection conn = DriverManager.getConnection(JDBC_URL,
JDBC_USERNAME, JDBC_PASSWORD);
try {
final PreparedStatement st = conn
.prepareStatement("SELECT * FROM char_templates "
+ "LEFT JOIN lvlupgain ON (char_templates.Classid = lvlupgain.classid)");
try {
st.execute();
final ResultSet rs = st.getResultSet();
while (rs.next()) {
CharacterTemplate t = fillTemplate(rs);
final File file = new File(target, "character/"
+ camelCase(t.getCharacterClass().name()) + ".xml");
file.getParentFile().mkdirs();
m.marshal(t, file);
// m.marshal(t, System.out);
// System.exit(0);
}
} finally {
st.close();
}
} finally {
conn.close();
}
}
private static CharacterTemplate fillTemplate(ResultSet rs)
throws SQLException {
final CharacterTemplate t = new CharacterTemplate();
t.stats = new CharacterStatsMetadata();
t.stats.hp = new Stat();
t.stats.hp.base = rs.getDouble("defaulthpbase");
t.stats.hp.modifier = rs.getDouble("defaulthpmod");
t.stats.hp.add = rs.getDouble("defaulthpadd");
t.stats.mp = new Stat();
t.stats.mp.base = rs.getDouble("defaultmpbase");
t.stats.mp.modifier = rs.getDouble("defaultmpmod");
t.stats.mp.add = rs.getDouble("defaultmpadd");
t.stats.cp = new Stat();
t.stats.cp.base = rs.getDouble("defaultcpbase");
t.stats.cp.modifier = rs.getDouble("defaultcpmod");
t.stats.cp.add = rs.getDouble("defaultcpadd");
t.stats.base = new BaseMetadata();
t.stats.base.intelligence = rs.getInt("_INT");
t.stats.base.strength = rs.getInt("STR");
t.stats.base.concentration = rs.getInt("CON");
t.stats.base.mentality = rs.getInt("MEN");
t.stats.base.dexterity = rs.getInt("DEX");
t.stats.base.witness = rs.getInt("WIT");
t.stats.attack = new AttackMetadata();
t.stats.attack.critical = rs.getInt("CRITICAL");
t.stats.attack.evasion = rs.getInt("EVASION");
t.stats.attack.accuracy = rs.getInt("ACC");
t.stats.attack.physical = new AttackValueMetadata();
t.stats.attack.physical.damage = rs.getDouble("P_ATK");
t.stats.attack.physical.speed = rs.getDouble("P_SPD");
t.stats.attack.magical = new AttackValueMetadata();
t.stats.attack.magical.damage = rs.getDouble("M_ATK");
t.stats.attack.magical.speed = rs.getDouble("M_SPD");
t.stats.defense = new DefenseMetadata();
t.stats.defense.physical = new DefenseValueMetadata();
t.stats.defense.physical.value = rs.getDouble("P_DEF");
t.stats.defense.magical = new DefenseValueMetadata();
t.stats.defense.magical.value = rs.getDouble("M_DEF");
t.stats.move = new MoveMetadata();
t.stats.move.run = rs.getInt("MOVE_SPD");
// TODO this is not really the same
t.stats.move.walk = rs.getInt("MOVE_SPD");
t.stats.level = rs.getInt("class_lvl");
t.stats.maximumLoad = rs.getInt("_LOAD");
t.stats.crafter = rs.getBoolean("canCraft");
t.collision = new CollitionMetadataContainer();
t.collision.male = new CollisionMetadata();
t.collision.male.radius = rs.getDouble("M_COL_R");
t.collision.male.height = rs.getDouble("M_COL_H");
t.collision.female = new CollisionMetadata();
t.collision.female.radius = rs.getDouble("F_COL_R");
t.collision.female.height = rs.getDouble("F_COL_H");
return t;
}
private static String camelCase(String c) {
Pattern p = Pattern.compile("[a-zA-Z0-9]+");
Matcher m = p.matcher(c.replaceAll("_", " "));
StringBuffer result = new StringBuffer();
String word;
while (m.find()) {
word = m.group();
result.append(word.substring(0, 1).toUpperCase()
+ word.substring(1).toLowerCase());
}
return result.toString();
}
}

View File

@@ -1,531 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.template;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.MarshalException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.SchemaOutputResolver;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.io.FileUtils;
import com.l2jserver.model.id.template.ItemTemplateID;
import com.l2jserver.model.id.template.NPCTemplateID;
import com.l2jserver.model.id.template.SkillTemplateID;
import com.l2jserver.model.id.template.TeleportationTemplateID;
import com.l2jserver.model.template.NPCTemplate.Chat;
import com.l2jserver.model.template.NPCTemplate.DropItemMetadata;
import com.l2jserver.model.template.NPCTemplate.DropItemMetadata.DropCategory;
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata;
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.CollisionMetadata;
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.ItemMetadata;
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCNameMetadata;
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCStatsMetadata;
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCStatsMetadata.AttackMetadata;
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCStatsMetadata.AttackMetadata.AttackValueMetadata;
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCStatsMetadata.BaseMetadata;
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCStatsMetadata.DefenseMetadata;
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCStatsMetadata.DefenseMetadata.DefenseValueMetadata;
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCStatsMetadata.MoveMetadata;
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCStatsMetadata.Stat;
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCTitleMetadata;
import com.l2jserver.model.template.NPCTemplate.SkillMetadata;
import com.l2jserver.model.template.NPCTemplate.TalkMetadata;
import com.l2jserver.model.template.TeleportationTemplate.TeleportRestriction;
import com.l2jserver.model.template.actor.ActorSex;
import com.l2jserver.model.template.npc.NPCRace;
import com.l2jserver.model.world.npc.controller.BaseNPCController;
import com.l2jserver.model.world.npc.controller.MonsterController;
import com.l2jserver.model.world.npc.controller.NPCController;
import com.l2jserver.model.world.npc.controller.NotImplementedNPCController;
import com.l2jserver.model.world.npc.controller.TeleporterController;
import com.l2jserver.service.game.template.XMLTemplateService.TeleportationTemplateContainer;
import com.l2jserver.util.factory.CollectionFactory;
import com.l2jserver.util.geometry.Coordinate;
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
@SuppressWarnings("restriction")
public class NPCTemplateConverter {
private static final String JDBC_URL = "jdbc:mysql://localhost/l2jlegacy";
private static final String JDBC_USERNAME = "l2j";
private static final String JDBC_PASSWORD = "changeme";
private static final File L2J_HTML_FOLDER = new File(
"../L2J_DataPack_BETA/data/html");
private static final Map<String, Class<? extends NPCController>> controllers = CollectionFactory
.newMap();
private static List<NPCTemplate> templates = CollectionFactory.newList();
private static Collection<File> htmlScannedFiles;
private static TeleportationTemplateContainer teleportation = new TeleportationTemplateContainer();
public static void main(String[] args) throws SQLException, IOException,
ClassNotFoundException, JAXBException {
controllers.put("L2Teleporter", TeleporterController.class);
controllers.put("L2CastleTeleporter", TeleporterController.class);
controllers.put("L2Npc", BaseNPCController.class);
controllers.put("L2Monster", MonsterController.class);
controllers.put("L2FlyMonster", MonsterController.class);
Class.forName("com.mysql.jdbc.Driver");
final File target = new File("data/templates");
System.out.println("Scaning legacy HTML files...");
htmlScannedFiles = FileUtils.listFiles(L2J_HTML_FOLDER, new String[] {
"html", "htm" }, true);
final JAXBContext c = JAXBContext.newInstance(NPCTemplate.class,
TeleportationTemplateContainer.class);
final Connection conn = DriverManager.getConnection(JDBC_URL,
JDBC_USERNAME, JDBC_PASSWORD);
{
System.out.println("Converting teleport templates...");
teleportation.templates = CollectionFactory.newList();
final Marshaller m = c.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.setProperty(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION,
"teleportation");
m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
"teleportation teleportation.xsd");
final PreparedStatement st = conn
.prepareStatement("SELECT * FROM teleport");
st.execute();
final ResultSet rs = st.getResultSet();
while (rs.next()) {
final TeleportationTemplate template = new TeleportationTemplate();
template.id = new TeleportationTemplateID(rs.getInt("id"), null);
template.name = rs.getString("Description");
template.coordinate = Coordinate.fromXYZ(rs.getInt("loc_x"),
rs.getInt("loc_y"), rs.getInt("loc_z"));
template.price = rs.getInt("price");
template.itemTemplateID = new ItemTemplateID(
rs.getInt("itemId"), null);
if (rs.getBoolean("fornoble")) {
template.restrictions = Arrays
.asList(TeleportRestriction.NOBLE);
}
teleportation.templates.add(template);
}
m.marshal(teleportation, getXMLSerializer(new FileOutputStream(
new File(target, "../teleports.xml"))));
// System.exit(0);
}
System.out.println("Generating template XML files...");
c.generateSchema(new SchemaOutputResolver() {
@Override
public Result createOutput(String namespaceUri,
String suggestedFileName) throws IOException {
// System.out.println(new File(target, suggestedFileName));
// return null;
return new StreamResult(new File(target, suggestedFileName));
}
});
try {
final Marshaller m = c.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.setProperty(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION, "npc");
final PreparedStatement st = conn
.prepareStatement("SELECT npc.*, npcskills.level AS race "
+ "FROM npc "
+ "LEFT JOIN npcskills "
+ "ON(npc.idTemplate = npcskills.npcid AND npcskills.skillid = ?)");
st.setInt(1, 4416);
st.execute();
final ResultSet rs = st.getResultSet();
while (rs.next()) {
Object[] result = fillNPC(rs);
NPCTemplate t = (NPCTemplate) result[0];
String type = (String) result[1];
String folder = createFolder(type);
if (folder.isEmpty()) {
m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
"npc ../npc.xsd");
} else {
m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
"npc ../../npc.xsd");
}
final File file = new File(target, "npc/"
+ folder
+ "/"
+ t.id.getID()
+ (t.info.nameMetadata != null ? "-"
+ camelCase(t.info.nameMetadata.name) : "")
+ ".xml");
file.getParentFile().mkdirs();
templates.add(t);
try {
m.marshal(t, getXMLSerializer(new FileOutputStream(file)));
} catch (MarshalException e) {
System.err
.println("Could not generate XML template file for "
+ t.getName() + " - " + t.getID());
file.delete();
}
}
System.out.println("Generated " + templates.size() + " templates");
System.gc();
System.out.println("Free: "
+ FileUtils.byteCountToDisplaySize(Runtime.getRuntime()
.freeMemory()));
System.out.println("Total: "
+ FileUtils.byteCountToDisplaySize(Runtime.getRuntime()
.totalMemory()));
System.out
.println("Used: "
+ FileUtils.byteCountToDisplaySize(Runtime
.getRuntime().totalMemory()
- Runtime.getRuntime().freeMemory()));
System.out.println("Max: "
+ FileUtils.byteCountToDisplaySize(Runtime.getRuntime()
.maxMemory()));
} finally {
conn.close();
}
}
private static Object[] fillNPC(ResultSet rs) throws SQLException,
IOException {
final NPCTemplate template = new NPCTemplate();
template.id = new NPCTemplateID(rs.getInt("idTemplate"), null);
template.controller = controllers.get(rs.getString("type"));
if (template.controller == null)
template.controller = NotImplementedNPCController.class;
template.info = new NPCInformationMetadata();
template.info.nameMetadata = new NPCNameMetadata();
template.info.nameMetadata.name = rs.getString("name");
template.info.nameMetadata.display = rs.getBoolean("show_name");
template.info.nameMetadata.send = rs.getBoolean("serverSideName");
template.info.titleMetadata = new NPCTitleMetadata();
template.info.titleMetadata.title = rs.getString("title");
template.info.titleMetadata.send = rs.getBoolean("serverSideTitle");
if (template.info.titleMetadata.title.length() == 0)
template.info.titleMetadata = null;
if (template.info.nameMetadata.name.length() == 0)
template.info.nameMetadata = null;
template.info.level = rs.getInt("level");
template.info.race = getRace(rs.getInt("race"));
if (!rs.getString("sex").equals("etc"))
template.info.sex = ActorSex.valueOf(rs.getString("sex")
.toUpperCase());
// template.info.attackable = rs.getBoolean("attackable");
template.info.targetable = rs.getBoolean("targetable");
template.info.aggressive = rs.getBoolean("aggro");
template.info.attackable = true; // FIXME
template.info.stats = new NPCStatsMetadata();
template.info.stats.hp = new Stat();
template.info.stats.hp.max = rs.getDouble("hp");
template.info.stats.hp.regen = rs.getDouble("hpreg");
template.info.stats.mp = new Stat();
template.info.stats.mp.max = rs.getDouble("mp");
template.info.stats.mp.regen = rs.getDouble("mpreg");
template.info.stats.attack = new AttackMetadata();
template.info.stats.attack.range = rs.getInt("attackrange");
template.info.stats.attack.critical = rs.getInt("critical");
template.info.stats.attack.physical = new AttackValueMetadata();
template.info.stats.attack.physical.damage = rs.getDouble("patk");
template.info.stats.attack.physical.speed = rs.getDouble("atkspd");
template.info.stats.attack.magical = new AttackValueMetadata();
template.info.stats.attack.magical.damage = rs.getDouble("matk");
template.info.stats.attack.magical.speed = rs.getDouble("matkspd");
template.info.stats.defense = new DefenseMetadata();
template.info.stats.defense.physical = new DefenseValueMetadata();
template.info.stats.defense.physical.value = rs.getDouble("pdef");
template.info.stats.defense.magical = new DefenseValueMetadata();
template.info.stats.defense.magical.value = rs.getDouble("mdef");
template.info.stats.move = new MoveMetadata();
template.info.stats.move.run = rs.getDouble("runspd");
template.info.stats.move.walk = rs.getDouble("walkspd");
template.info.stats.base = new BaseMetadata();
template.info.stats.base.intelligence = rs.getInt("int");
template.info.stats.base.strength = rs.getInt("str");
template.info.stats.base.concentration = rs.getInt("con");
template.info.stats.base.dexterity = rs.getInt("dex");
template.info.stats.base.witness = rs.getInt("wit");
template.info.stats.base.mentality = rs.getInt("men");
template.info.experience = rs.getLong("exp");
template.info.sp = rs.getInt("sp");
if (rs.getInt("rhand") > 0 || rs.getInt("lhand") > 0)
template.info.item = new ItemMetadata();
if (rs.getInt("rhand") > 0)
template.info.item.rightHand = new ItemTemplateID(
rs.getInt("rhand"), null);
if (rs.getInt("lhand") > 0)
template.info.item.leftHand = new ItemTemplateID(
rs.getInt("lhand"), null);
template.info.collision = new CollisionMetadata();
template.info.collision.radius = rs.getDouble("collision_radius");
template.info.collision.height = rs.getDouble("collision_height");
template.droplist = fillDropList(rs, template.id.getID());
template.skills = fillSkillList(rs, template.id.getID());
template.talk = fillHtmlChat(template.id.getID());
return new Object[] { template, createParentType(rs.getString("type")) };
}
private static List<DropItemMetadata> fillDropList(ResultSet npcRs,
int npcId) throws SQLException {
final Connection conn = npcRs.getStatement().getConnection();
final List<DropItemMetadata> drops = CollectionFactory.newList();
final PreparedStatement st = conn
.prepareStatement("SELECT * FROM droplist WHERE mobId = ?");
st.setInt(1, npcId);
st.execute();
final ResultSet rs = st.getResultSet();
while (rs.next()) {
DropItemMetadata m = new DropItemMetadata();
m.item = new ItemTemplateID(rs.getInt("itemId"), null);
m.min = rs.getInt("min");
m.max = rs.getInt("max");
m.chance = rs.getInt("chance");
m.category = getCategory(rs.getInt("category"));
drops.add(m);
}
if (drops.size() == 0)
return null;
return drops;
}
private static TalkMetadata fillHtmlChat(int npcId) throws IOException {
final TalkMetadata talk = new TalkMetadata();
talk.defaultChat = "default";
talk.chats = CollectionFactory.newList();
for (final File file : htmlScannedFiles) {
String id = null;
if (file.getName().startsWith(npcId + "-")) {
int preffixLength = (npcId + "-").length();
id = file.getName().substring(preffixLength,
file.getName().indexOf("."));
} else if (file.getName().startsWith(npcId + ".")) {
id = "default";
}
if (id != null && !file.getAbsolutePath().contains("/half/")
&& !file.getAbsolutePath().contains("/free/")) {
Chat chat = new Chat();
chat.id = id;
chat.html = FileUtils.readFileToString(file);
talk.chats.add(chat);
}
}
if (talk.chats.size() == 0)
return null;
return talk;
}
private static List<SkillMetadata> fillSkillList(ResultSet npcRs, int npcId)
throws SQLException {
final Connection conn = npcRs.getStatement().getConnection();
final List<SkillMetadata> skills = CollectionFactory.newList();
final PreparedStatement st = conn
.prepareStatement("SELECT * FROM npcskills WHERE npcid = ?");
st.setInt(1, npcId);
st.execute();
final ResultSet rs = st.getResultSet();
while (rs.next()) {
SkillMetadata m = new SkillMetadata();
m.skill = new SkillTemplateID(rs.getInt("skillid"), null);
m.level = rs.getInt("level");
skills.add(m);
}
if (skills.size() == 0)
return null;
return skills;
}
private static String camelCase(String c) {
Pattern p = Pattern.compile("[a-zA-Z0-9]+");
Matcher m = p.matcher(c.replaceAll("_", " ").replaceAll("\\.", " "));
StringBuffer result = new StringBuffer();
String word;
while (m.find()) {
word = m.group();
result.append(word.substring(0, 1).toUpperCase()
+ word.substring(1).toLowerCase());
}
return result.toString();
}
private static String createParentType(String l2j) {
if (l2j.startsWith("L2"))
l2j = l2j.substring(2);
if (l2j.equals("Npc"))
return "";
if (l2j.contains("VillageMaster"))
return (l2j.replaceAll("VillageMaster", "") + "VillageMaster");
if (l2j.contains("Npc"))
l2j = l2j.replaceAll("Npc", "");
return l2j;
}
private static String createFolder(String l2j) {
if (l2j.startsWith("L2"))
l2j = l2j.substring(2);
if (l2j.equals("Npc"))
return "";
if (l2j.toLowerCase().contains("monster"))
return "monster";
if (l2j.toLowerCase().contains("castle"))
return "castle";
if (l2j.toLowerCase().contains("fort"))
return "fort";
if (l2j.toLowerCase().contains("xmasstree"))
return "misc";
return l2j.toLowerCase();
}
private static XMLSerializer getXMLSerializer(OutputStream w) {
// configure an OutputFormat to handle CDATA
OutputFormat of = new OutputFormat();
// specify which of your elements you want to be handled as CDATA.
// The use of the '^' between the namespaceURI and the localname
// seems to be an implementation detail of the xerces code.
// When processing xml that doesn't use namespaces, simply omit the
// namespace prefix as shown in the third CDataElement below.
of.setCDataElements(new String[] { "^chat" });
// set any other options you'd like
of.setPreserveSpace(false);
of.setIndenting(true);
// create the serializer
XMLSerializer serializer = new XMLSerializer(of);
serializer.setOutputByteStream(w);
return serializer;
}
public static NPCRace getRace(int id) {
switch (id) {
case 1:
return NPCRace.UNDEAD;
case 2:
return NPCRace.MAGIC_CREATURE;
case 3:
return NPCRace.BEAST;
case 4:
return NPCRace.ANIMAL;
case 5:
return NPCRace.PLANT;
case 6:
return NPCRace.HUMANOID;
case 7:
return NPCRace.SPIRIT;
case 8:
return NPCRace.ANGEL;
case 9:
return NPCRace.DEMON;
case 10:
return NPCRace.DRAGON;
case 11:
return NPCRace.GIANT;
case 12:
return NPCRace.BUG;
case 13:
return NPCRace.FAIRIE;
case 14:
return NPCRace.HUMAN;
case 15:
return NPCRace.ELVEN;
case 16:
return NPCRace.DARKELVEN;
case 17:
return NPCRace.ORC;
case 18:
return NPCRace.DWARVEN;
case 19:
return NPCRace.OTHER;
case 20:
return NPCRace.NON_LIVING;
case 21:
return NPCRace.SIEGE_WEAPON;
case 22:
return NPCRace.DEFENDING_ARMY;
case 23:
return NPCRace.MERCENARIE;
case 24:
return NPCRace.UNKNOWN;
case 25:
return NPCRace.KAMAEL;
default:
return NPCRace.NONE;
}
}
public static DropCategory getCategory(int id) {
switch (id) {
case -1:
return DropCategory.SPOIL;
case 0:
return DropCategory.DROP;
default:
return DropCategory.valueOf("UNK_" + id);
}
}
}

View File

@@ -1,188 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.template;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.MarshalException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.SchemaOutputResolver;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.io.FileUtils;
import com.l2jserver.model.id.template.SkillTemplateID;
import com.l2jserver.util.factory.CollectionFactory;
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
@SuppressWarnings("restriction")
public class SkillTemplateConverter {
private static final String JDBC_URL = "jdbc:mysql://localhost/l2jlegacy";
private static final String JDBC_USERNAME = "l2j";
private static final String JDBC_PASSWORD = "changeme";
private static final String LEGACY_SKILL_FOLDER = "../L2J_DataPack_BETA/data/stats/skills";
private static List<SkillTemplate> templates = CollectionFactory.newList();
public static void main(String[] args) throws SQLException, IOException,
ClassNotFoundException, JAXBException {
Class.forName("com.mysql.jdbc.Driver");
final File target = new File("data/templates");
final JAXBContext c = JAXBContext.newInstance(SkillTemplate.class,
LegacySkillList.class);
final Connection conn = DriverManager.getConnection(JDBC_URL,
JDBC_USERNAME, JDBC_PASSWORD);
System.out.println("Generating template XML files...");
c.generateSchema(new SchemaOutputResolver() {
@Override
public Result createOutput(String namespaceUri,
String suggestedFileName) throws IOException {
return new StreamResult(new File(target, suggestedFileName));
}
});
try {
final Unmarshaller u = c.createUnmarshaller();
final Marshaller m = c.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.setProperty(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION, "skill");
m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "skill ../skill.xsd");
Collection<File> files = FileUtils.listFiles(new File(
LEGACY_SKILL_FOLDER), new String[] { "xml" }, true);
for (final File legacyFile : files) {
LegacySkillList list = (LegacySkillList) u
.unmarshal(legacyFile);
for (final LegacySkill legacySkill : list.skills) {
SkillTemplate t = fillSkill(legacySkill);
final File file = new File(target, "skill/"
+ t.id.getID()
+ (t.getName() != null ? "-"
+ camelCase(t.getName()) : "") + ".xml");
templates.add(t);
try {
m.marshal(t,
getXMLSerializer(new FileOutputStream(file)));
} catch (MarshalException e) {
System.err
.println("Could not generate XML template file for "
+ t.getName() + " - " + t.getID());
file.delete();
}
}
}
System.out.println("Generated " + templates.size() + " templates");
System.gc();
System.out.println("Free: "
+ FileUtils.byteCountToDisplaySize(Runtime.getRuntime()
.freeMemory()));
System.out.println("Total: "
+ FileUtils.byteCountToDisplaySize(Runtime.getRuntime()
.totalMemory()));
System.out
.println("Used: "
+ FileUtils.byteCountToDisplaySize(Runtime
.getRuntime().totalMemory()
- Runtime.getRuntime().freeMemory()));
System.out.println("Max: "
+ FileUtils.byteCountToDisplaySize(Runtime.getRuntime()
.maxMemory()));
} finally {
conn.close();
}
}
private static SkillTemplate fillSkill(LegacySkill legacy)
throws SQLException, IOException {
final SkillTemplate template = new SkillTemplate();
template.id = new SkillTemplateID(legacy.id, null);
template.name = legacy.name;
return template;
}
private static String camelCase(String c) {
Pattern p = Pattern.compile("[a-zA-Z0-9]+");
Matcher m = p.matcher(c.replaceAll("_", " ").replaceAll("\\.", " "));
StringBuffer result = new StringBuffer();
String word;
while (m.find()) {
word = m.group();
result.append(word.substring(0, 1).toUpperCase()
+ word.substring(1).toLowerCase());
}
return result.toString();
}
private static XMLSerializer getXMLSerializer(OutputStream w) {
// configure an OutputFormat to handle CDATA
OutputFormat of = new OutputFormat();
// specify which of your elements you want to be handled as CDATA.
// The use of the '^' between the namespaceURI and the localname
// seems to be an implementation detail of the xerces code.
// When processing xml that doesn't use namespaces, simply omit the
// namespace prefix as shown in the third CDataElement below.
of.setCDataElements(new String[] { "^chat" });
// set any other options you'd like
of.setPreserveSpace(false);
of.setIndenting(true);
// create the serializer
XMLSerializer serializer = new XMLSerializer(of);
serializer.setOutputByteStream(w);
return serializer;
}
@XmlRootElement(name = "list")
public static class LegacySkillList {
@XmlElement(name = "skill")
private List<LegacySkill> skills;
}
public static class LegacySkill {
@XmlAttribute(name = "id")
private int id;
@XmlAttribute(name = "name")
private String name;
}
}

View File

@@ -1,38 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.tool;
import com.l2jserver.model.template.character.CharacterClass;
public class CharacterSQLEnumGenerator {
public static void main(String[] args) {
System.out.println("== 'Character' SQL STATEMENT ==");
System.out.println(createClassStatement());
}
private static String createClassStatement() {
final StringBuilder builder = new StringBuilder();
builder.append("ALTER TABLE `character` CHANGE `class` `class` ENUM(");
for (CharacterClass c : CharacterClass.values()) {
if (!c.name().startsWith("DUMMY"))
builder.append("'" + c.name() + "',");
}
builder.replace(builder.length() - 1, builder.length(), "");
builder.append(") CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT 'HUMAN_FIGHTER';");
return builder.toString();
}
}

View File

@@ -1,39 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.tool;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
public class EndianessTest {
/**
* @param args
* the arguments
*/
public static void main(String[] args) {
final ByteBuffer bigEndian = ByteBuffer.allocate(8);
bigEndian.order(ByteOrder.BIG_ENDIAN);
bigEndian.putDouble(20);
System.out.println(Arrays.toString(bigEndian.array()));
final ByteBuffer littleEndian = ByteBuffer.allocate(8);
littleEndian.order(ByteOrder.LITTLE_ENDIAN);
littleEndian.putDouble(20);
System.out.println(Arrays.toString(littleEndian.array()));
}
}

View File

@@ -1,46 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.tool.conversor.itemtemplate;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "list")
@XmlAccessorType(XmlAccessType.NONE)
public class ItemListXml {
@XmlElement(name = "item")
private List<ItemXml> items;
/**
* @return the items
*/
public List<ItemXml> getItems() {
return items;
}
/**
* @param items
* the items to set
*/
public void setItems(List<ItemXml> items) {
this.items = items;
}
}

View File

@@ -1,78 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.tool.conversor.itemtemplate;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "set")
@XmlAccessorType(XmlAccessType.NONE)
public class ItemSetXml {
@XmlAttribute(name = "order")
private int order;
@XmlAttribute(name = "stat")
private String stat;
@XmlAttribute(name = "val")
private int val;
/**
* @return the order
*/
public int getOrder() {
return order;
}
/**
* @param order
* the order to set
*/
public void setOrder(int order) {
this.order = order;
}
/**
* @return the stat
*/
public String getStat() {
return stat;
}
/**
* @param stat
* the stat to set
*/
public void setStat(String stat) {
this.stat = stat;
}
/**
* @return the val
*/
public int getVal() {
return val;
}
/**
* @param val
* the val to set
*/
public void setVal(int val) {
this.val = val;
}
}

View File

@@ -1,16 +0,0 @@
package script.template.item${package};
import com.google.inject.Inject;
import com.l2jserver.model.id.template.factory.ItemTemplateIDFactory;
${import}
import com.l2jserver.model.world.Item;
public class ${className}Template ${extends} ${implements} {
public static final int ID = ${id};
@Inject
public ${className}Template(ItemTemplateIDFactory factory) {
super(factory.createID(ID));
${values}
}
}

View File

@@ -1,218 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.tool.conversor.itemtemplate;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.bind.JAXB;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
public class ItemTemplateConversor {
private static String template;
public static void main(String[] args) throws IOException {
template = IOUtils.toString(ItemTemplateConversor.class
.getResourceAsStream("ItemTemplateBase.txt"));
Collection<File> files = FileUtils
.listFiles(
new File(
"/home/rogiel/Documents/Eclipse/lineage2/L2J_DataPack_BETA/data/stats/items"),
new String[] { "xml" }, false);
for (final File file : files) {
processFile(file.getAbsolutePath());
}
}
private static void processFile(String file) throws FileNotFoundException {
ItemListXml xml = JAXB.unmarshal(new FileInputStream(file),
ItemListXml.class);
for (final ItemXml item : xml.getItems()) {
String template = ItemTemplateConversor.template;
String values = "";
for (final ItemValueXml val : item.getValues()) {
values += generateSet(val.getName(), val.getValue());
}
template = replace(template, "values", values);
template = replace(template, "package", "");
template = replace(template, "import", "");
template = replace(template, "className", camelCase(item.getName()));
template = replace(template, "extends", " extends "
+ camelCase(item.getType()) + "Template");
template = replace(template, "implements", "");
template = replace(template, "id", item.getId() + "");
}
}
private static String generateSet(String property, String value) {
value = convertValue(property, value);
if (value == null)
return "";
property = convertPropertyName(property);
if (property == null)
return "";
if (property.contains("_")) {
System.out.println(property + " -> " + value);
System.exit(0);
}
return "this." + convertPropertyName(property) + " = " + value + ";\n";
}
private static String convertPropertyName(String property) {
if ("default_action".equals(property))
return null;
if ("is_tradable".equals(property))
return null;
if ("is_dropable".equals(property))
return null;
if ("is_sellable".equals(property))
return null;
if ("is_destroyable".equals(property))
return null;
if ("is_depositable".equals(property))
return null;
if ("is_questitem".equals(property))
return null;
if ("enchant_enabled".equals(property))
return null;
if ("element_enabled".equals(property))
return null;
if ("enchant4_skill".equals(property))
return null;
if ("is_premium".equals(property))
return null;
if ("is_oly_restricted".equals(property))
return null;
if ("change_weaponId".equals(property))
return null;
if ("use_condition".equals(property))
return null;
if ("oncast_chance".equals(property))
return "castChance";
if ("oncast_skill".equals(property))
return "castSkill";
if ("oncrit_skill".equals(property))
return "criticalSkill";
if ("unequip_skill".equals(property))
return "unequipSkill";
if ("equip_condition".equals(property))
return null;
if ("reduced_soulshot".equals(property))
return null;
if ("reduced_mp_consume".equals(property))
return null;
if ("equip_reuse_delay".equals(property))
return null;
if ("recipe_id".equals(property))
return null;
if ("shared_reuse_group".equals(property))
return null;
if ("ex_immediate_effect".equals(property))
return null;
if ("oncrit_chance".equals(property))
return null; // TODO
if ("capsuled_items".equals(property))
return "capsuled";
if ("mp_consume".equals(property))
return "mpConsume";
if ("reuse_delay".equals(property))
return "reuseDelay";
if ("item_skill".equals(property))
return "itemSkill";
if ("is_magic_weapon".equals(property))
return null;
if ("immediate_effect".equals(property))
return "immediateEffect";
if ("bodypart".equals(property))
return "paperdoll";
if ("is_stackable".equals(property))
return null;
if ("etcitem_type".equals(property))
return null;
if ("weapon_type".equals(property))
return "type";
if ("armor_type".equals(property))
return "type";
if ("attack_range".equals(property))
return "attackRange";
if ("damage_range".equals(property))
return "damageRange";
if ("random_damage".equals(property))
return "randomDamage";
if ("crystal_count".equals(property))
return "crystals";
if ("crystal_type".equals(property))
return "crystal";
return property;
}
private static String convertValue(String property, String value) {
if ("material".equals(property))
return "ItemMaterial." + value.toUpperCase();
if ("weapon_type".equals(property))
return "WeaponType." + value.toUpperCase();
if ("bodypart".equals(property))
return "InventoryPaperdoll." + value.toUpperCase();
if ("icon".equals(property))
return convertString(value);
if ("damage_range".equals(property))
return convertArray(value, "int");
return value;
}
public static String convertString(String value) {
return "\"" + value + "\"";
}
public static String convertArray(String value, String type) {
String v = "new " + type + "[] {";
String[] args = value.split(";");
for (final String r : args) {
v += r + ",";
}
v = v.substring(0, v.length() - 1);
return v + "}";
}
private static String replace(String template, String key, String value) {
return template.replaceAll("\\$\\{" + key + "\\}", value);
}
private static String camelCase(String c) {
Pattern p = Pattern.compile("[a-zA-Z0-9]+");
Matcher m = p.matcher(c.replaceAll("_", " "));
StringBuffer result = new StringBuffer();
String word;
while (m.find()) {
word = m.group();
result.append(word.substring(0, 1).toUpperCase()
+ word.substring(1).toLowerCase());
}
return result.toString();
}
}

View File

@@ -1,61 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.tool.conversor.itemtemplate;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "set")
@XmlAccessorType(XmlAccessType.NONE)
public class ItemValueXml {
@XmlAttribute(name = "name")
private String name;
@XmlAttribute(name = "val")
private String value;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the value
*/
public String getValue() {
return value;
}
/**
* @param value
* the value to set
*/
public void setValue(String value) {
this.value = value;
}
}

View File

@@ -1,117 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.tool.conversor.itemtemplate;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "item")
@XmlAccessorType(XmlAccessType.NONE)
public class ItemXml {
@XmlAttribute(name = "id")
private int id;
@XmlAttribute(name = "name")
private String name;
@XmlAttribute(name = "type")
private String type;
@XmlElementRef
private List<ItemValueXml> values;
@XmlElement(name = "for")
private List<ItemSetXml> sets;
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the values
*/
public List<ItemValueXml> getValues() {
return values;
}
/**
* @param values
* the values to set
*/
public void setValues(List<ItemValueXml> values) {
this.values = values;
}
/**
* @return the sets
*/
public List<ItemSetXml> getSets() {
return sets;
}
/**
* @param sets
* the sets to set
*/
public void setSets(List<ItemSetXml> sets) {
this.sets = sets;
}
}

View File

@@ -1,13 +0,0 @@
possible attribs: [blessed, item_skill, change_weaponId, is_oly_restricted, is_sellable, time, crystal_type,
oncast_chance, random_damage, bodypart, spiritshots, soulshots, crystal_count, enchant_enabled,
is_destroyable, armor_type, attack_range, is_stackable, etcitem_type, mp_consume, reduced_soulshot,
is_questitem, immediate_effect, price, use_condition, is_premium, shared_reuse_group, equip_reuse_delay,
weight, reuse_delay, capsuled_items, is_tradable, is_magic_weapon, icon, item_equip_option, oncrit_skill,
is_dropable, enchant4_skill, damage_range, is_depositable, default_action, material, equip_condition,
recipe_id, ex_immediate_effect, duration, unequip_skill, oncast_skill, element_enabled, reduced_mp_consume,
handler, weapon_type, oncrit_chance]
etc_types: [race_ticket, castle_guard, dye, bolt, recipe, arrow, bless_scrl_enchant_wp, lure, rune, crop,
scrl_enchant_am, ancient_crystal_enchant_am, bless_scrl_enchant_am, potion, scrl_enchant_wp, coupon,
scrl_enchant_attr, seed2, scroll, seed, ticket_of_lord, rune_select, maturecrop, elixir, material,
lotto, scrl_inc_enchant_prop_wp, ancient_crystal_enchant_wp, scrl_inc_enchant_prop_am, harvest, pet_collar]

View File

@@ -2,12 +2,17 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>l2jserver2</artifactId>
<groupId>com.l2jserver</groupId> <groupId>com.l2jserver</groupId>
<artifactId>l2jserver2</artifactId>
<version>0.1.0-SNAPSHOT</version> <version>0.1.0-SNAPSHOT</version>
<relativePath>..</relativePath> <relativePath>..</relativePath>
</parent> </parent>
<artifactId>l2jserver2-loginserver</artifactId> <artifactId>l2jserver2-loginserver</artifactId>
<name>L2JServer 2 - Login server module</name>
<description>Lineage II server emulator</description>
<url>http://github.com/l2jserver2</url>
<inceptionYear>2011</inceptionYear>
<dependencies> <dependencies>
<dependency> <dependency>
@@ -76,8 +81,4 @@
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<name>L2JServer 2 - Login server module</name>
<url>http://github.com/l2jserver2</url>
<description>Lineage II server emulator</description>
<inceptionYear>2011</inceptionYear>
</project> </project>

1
l2jserver2-tools/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/generated

View File

@@ -2,12 +2,18 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>l2jserver2</artifactId>
<groupId>com.l2jserver</groupId> <groupId>com.l2jserver</groupId>
<artifactId>l2jserver2</artifactId>
<version>0.1.0-SNAPSHOT</version> <version>0.1.0-SNAPSHOT</version>
<relativePath>..</relativePath> <relativePath>..</relativePath>
</parent> </parent>
<artifactId>l2jserver2-tools</artifactId> <artifactId>l2jserver2-tools</artifactId>
<name>L2JServer 2 - Commons module</name>
<description>Lineage II server emulator</description>
<url>http://github.com/l2jserver2</url>
<inceptionYear>2011</inceptionYear>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.l2jserver</groupId> <groupId>com.l2jserver</groupId>
@@ -15,8 +21,4 @@
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
<name>L2JServer 2 - Tools module</name>
<url>http://github.com/l2jserver2</url>
<description>Lineage II server emulator</description>
<inceptionYear>2011</inceptionYear>
</project> </project>