From 2e6fdb20bb3fe9016c1cb5ed42a5471347d74e17 Mon Sep 17 00:00:00 2001 From: Rogiel Date: Thu, 6 Oct 2011 11:39:56 -0300 Subject: [PATCH] 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. --- .gitignore | 3 +- l2jserver2-common/pom.xml | 11 +- l2jserver2-gameserver/pom.xml | 17 +- .../template/CharacterTemplateConverter.java | 186 ------ .../model/template/NPCTemplateConverter.java | 531 ------------------ .../template/SkillTemplateConverter.java | 188 ------- .../tool/CharacterSQLEnumGenerator.java | 38 -- .../com/l2jserver/tool/EndianessTest.java | 39 -- .../conversor/itemtemplate/ItemListXml.java | 46 -- .../conversor/itemtemplate/ItemSetXml.java | 78 --- .../itemtemplate/ItemTemplateBase.txt | 16 - .../itemtemplate/ItemTemplateConversor.java | 218 ------- .../conversor/itemtemplate/ItemValueXml.java | 61 -- .../tool/conversor/itemtemplate/ItemXml.java | 117 ---- .../tool/conversor/itemtemplate/doc.txt | 13 - l2jserver2-loginserver/pom.xml | 11 +- l2jserver2-tools/.gitignore | 1 + l2jserver2-tools/pom.xml | 12 +- 18 files changed, 30 insertions(+), 1556 deletions(-) delete mode 100644 l2jserver2-gameserver/src/tool/java/com/l2jserver/model/template/CharacterTemplateConverter.java delete mode 100644 l2jserver2-gameserver/src/tool/java/com/l2jserver/model/template/NPCTemplateConverter.java delete mode 100644 l2jserver2-gameserver/src/tool/java/com/l2jserver/model/template/SkillTemplateConverter.java delete mode 100644 l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/CharacterSQLEnumGenerator.java delete mode 100644 l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/EndianessTest.java delete mode 100644 l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemListXml.java delete mode 100644 l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemSetXml.java delete mode 100644 l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemTemplateBase.txt delete mode 100644 l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemTemplateConversor.java delete mode 100644 l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemValueXml.java delete mode 100644 l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemXml.java delete mode 100644 l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/doc.txt create mode 100644 l2jserver2-tools/.gitignore diff --git a/.gitignore b/.gitignore index 905c05116..a68c78eea 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,7 @@ .project .metadata .classpath -.settings/* -.settings +.settings/ # Locally stored "Eclipse launch configurations" *.launch diff --git a/l2jserver2-common/pom.xml b/l2jserver2-common/pom.xml index 706b03915..eb44d3d8c 100644 --- a/l2jserver2-common/pom.xml +++ b/l2jserver2-common/pom.xml @@ -2,12 +2,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - l2jserver2 com.l2jserver + l2jserver2 0.1.0-SNAPSHOT .. l2jserver2-common + + L2JServer 2 - Commons module + Lineage II server emulator + http://github.com/l2jserver2 + 2011 @@ -103,8 +108,4 @@ 2.2 - L2JServer 2 - Commons module - http://github.com/l2jserver2 - Lineage II server emulator - 2011 \ No newline at end of file diff --git a/l2jserver2-gameserver/pom.xml b/l2jserver2-gameserver/pom.xml index 6fe4df8d8..863ad2dfb 100644 --- a/l2jserver2-gameserver/pom.xml +++ b/l2jserver2-gameserver/pom.xml @@ -1,9 +1,18 @@ 4.0.0 + + com.l2jserver + l2jserver2 + 0.1.0-SNAPSHOT + .. + l2jserver2-gameserver + L2JServer 2 - Game server module Lineage II server emulator + http://github.com/l2jserver2 + 2011 package @@ -209,12 +218,4 @@ jar - - com.l2jserver - l2jserver2 - 0.1.0-SNAPSHOT - .. - - http://github.com/l2jserver2 - 2011 diff --git a/l2jserver2-gameserver/src/tool/java/com/l2jserver/model/template/CharacterTemplateConverter.java b/l2jserver2-gameserver/src/tool/java/com/l2jserver/model/template/CharacterTemplateConverter.java deleted file mode 100644 index bb15e7d7a..000000000 --- a/l2jserver2-gameserver/src/tool/java/com/l2jserver/model/template/CharacterTemplateConverter.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * This file is part of l2jserver . - * - * 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 . - */ -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 Rogiel - */ -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(); - } -} diff --git a/l2jserver2-gameserver/src/tool/java/com/l2jserver/model/template/NPCTemplateConverter.java b/l2jserver2-gameserver/src/tool/java/com/l2jserver/model/template/NPCTemplateConverter.java deleted file mode 100644 index 4e2128641..000000000 --- a/l2jserver2-gameserver/src/tool/java/com/l2jserver/model/template/NPCTemplateConverter.java +++ /dev/null @@ -1,531 +0,0 @@ -/* - * This file is part of l2jserver . - * - * 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 . - */ -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> controllers = CollectionFactory - .newMap(); - - private static List templates = CollectionFactory.newList(); - private static Collection 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 fillDropList(ResultSet npcRs, - int npcId) throws SQLException { - final Connection conn = npcRs.getStatement().getConnection(); - final List 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 fillSkillList(ResultSet npcRs, int npcId) - throws SQLException { - final Connection conn = npcRs.getStatement().getConnection(); - final List 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); - } - } -} diff --git a/l2jserver2-gameserver/src/tool/java/com/l2jserver/model/template/SkillTemplateConverter.java b/l2jserver2-gameserver/src/tool/java/com/l2jserver/model/template/SkillTemplateConverter.java deleted file mode 100644 index 33fdb6070..000000000 --- a/l2jserver2-gameserver/src/tool/java/com/l2jserver/model/template/SkillTemplateConverter.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * This file is part of l2jserver . - * - * 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 . - */ -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 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 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 skills; - } - - public static class LegacySkill { - @XmlAttribute(name = "id") - private int id; - @XmlAttribute(name = "name") - private String name; - } -} diff --git a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/CharacterSQLEnumGenerator.java b/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/CharacterSQLEnumGenerator.java deleted file mode 100644 index 2a0871345..000000000 --- a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/CharacterSQLEnumGenerator.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of l2jserver . - * - * 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 . - */ -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(); - } -} diff --git a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/EndianessTest.java b/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/EndianessTest.java deleted file mode 100644 index d5bba02b5..000000000 --- a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/EndianessTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of l2jserver . - * - * 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 . - */ -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())); - } -} diff --git a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemListXml.java b/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemListXml.java deleted file mode 100644 index d111de5c6..000000000 --- a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemListXml.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of l2jserver . - * - * 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 . - */ -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 items; - - /** - * @return the items - */ - public List getItems() { - return items; - } - - /** - * @param items - * the items to set - */ - public void setItems(List items) { - this.items = items; - } -} diff --git a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemSetXml.java b/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemSetXml.java deleted file mode 100644 index 436a03c1d..000000000 --- a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemSetXml.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of l2jserver . - * - * 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 . - */ -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; - } -} diff --git a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemTemplateBase.txt b/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemTemplateBase.txt deleted file mode 100644 index 5c3be42a6..000000000 --- a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemTemplateBase.txt +++ /dev/null @@ -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} - } -} \ No newline at end of file diff --git a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemTemplateConversor.java b/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemTemplateConversor.java deleted file mode 100644 index be6d185d5..000000000 --- a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemTemplateConversor.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * This file is part of l2jserver . - * - * 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 . - */ -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 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(); - } -} diff --git a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemValueXml.java b/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemValueXml.java deleted file mode 100644 index 3da373f68..000000000 --- a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemValueXml.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of l2jserver . - * - * 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 . - */ -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; - } -} diff --git a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemXml.java b/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemXml.java deleted file mode 100644 index dbb71a25f..000000000 --- a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/ItemXml.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * This file is part of l2jserver . - * - * 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 . - */ -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 values; - @XmlElement(name = "for") - private List 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 getValues() { - return values; - } - - /** - * @param values - * the values to set - */ - public void setValues(List values) { - this.values = values; - } - - /** - * @return the sets - */ - public List getSets() { - return sets; - } - - /** - * @param sets - * the sets to set - */ - public void setSets(List sets) { - this.sets = sets; - } -} diff --git a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/doc.txt b/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/doc.txt deleted file mode 100644 index b4a0083c5..000000000 --- a/l2jserver2-gameserver/src/tool/java/com/l2jserver/tool/conversor/itemtemplate/doc.txt +++ /dev/null @@ -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] diff --git a/l2jserver2-loginserver/pom.xml b/l2jserver2-loginserver/pom.xml index b9655e3e9..f0e07033d 100644 --- a/l2jserver2-loginserver/pom.xml +++ b/l2jserver2-loginserver/pom.xml @@ -2,12 +2,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - l2jserver2 com.l2jserver + l2jserver2 0.1.0-SNAPSHOT .. l2jserver2-loginserver + + L2JServer 2 - Login server module + Lineage II server emulator + http://github.com/l2jserver2 + 2011 @@ -76,8 +81,4 @@ runtime - L2JServer 2 - Login server module - http://github.com/l2jserver2 - Lineage II server emulator - 2011 \ No newline at end of file diff --git a/l2jserver2-tools/.gitignore b/l2jserver2-tools/.gitignore new file mode 100644 index 000000000..e324eac91 --- /dev/null +++ b/l2jserver2-tools/.gitignore @@ -0,0 +1 @@ +/generated diff --git a/l2jserver2-tools/pom.xml b/l2jserver2-tools/pom.xml index 813b09408..cd9d2db59 100644 --- a/l2jserver2-tools/pom.xml +++ b/l2jserver2-tools/pom.xml @@ -2,12 +2,18 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - l2jserver2 com.l2jserver + l2jserver2 0.1.0-SNAPSHOT .. l2jserver2-tools + + L2JServer 2 - Commons module + Lineage II server emulator + http://github.com/l2jserver2 + 2011 + com.l2jserver @@ -15,8 +21,4 @@ ${project.version} - L2JServer 2 - Tools module - http://github.com/l2jserver2 - Lineage II server emulator - 2011 \ No newline at end of file