1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-09 17:02:53 +00:00

Modularizes the Maven project

This commit modularizes the maven project into several modules:
 - l2jserver2-common: common sources for both login and gameserver
 - l2jserver2-gameserver: the game server
 - l2jserver2-loginserver: the login server
 - l2jserver2-tools: refactored src/tools/java soure folder
This commit is contained in:
2011-10-05 17:32:04 -03:00
parent c4052ccb3b
commit 22c136ab17
18930 changed files with 4292 additions and 231 deletions

View File

@@ -0,0 +1,38 @@
/*
* 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

@@ -0,0 +1,39 @@
/*
* 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

@@ -0,0 +1,46 @@
/*
* 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

@@ -0,0 +1,78 @@
/*
* 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

@@ -0,0 +1,16 @@
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

@@ -0,0 +1,218 @@
/*
* 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

@@ -0,0 +1,61 @@
/*
* 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

@@ -0,0 +1,117 @@
/*
* 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

@@ -0,0 +1,13 @@
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]