mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-05 23:22:47 +00:00
@@ -12,15 +12,9 @@ public class AdenaItemTemplate extends ItemTemplate implements Stackable<Item> {
|
||||
@Inject
|
||||
public AdenaItemTemplate(ItemTemplateIDFactory factory) {
|
||||
super(factory.createID(ID));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stack(Item... object) {
|
||||
// final Item item1 = object[0];
|
||||
// if (object.length >= 2) {
|
||||
// for (int i = 1; i < object.length; i++) {
|
||||
// // TODO set item amount
|
||||
// }
|
||||
// }
|
||||
this.icon = "icon.etc_adena_i00";
|
||||
this.immediateEffect = true;
|
||||
this.material = ItemMaterial.GOLD;
|
||||
this.price = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package script.template.item.armor;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ArmorTemplate;
|
||||
import com.l2jserver.model.template.capability.Enchantable;
|
||||
import com.l2jserver.model.template.capability.Penalty;
|
||||
import com.l2jserver.model.template.item.ArmorTemplate;
|
||||
import com.l2jserver.model.world.capability.Equiper;
|
||||
|
||||
public abstract class AbstractGradeAArmorTemplate extends ArmorTemplate
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package script.template.item.armor;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ArmorTemplate;
|
||||
import com.l2jserver.model.template.item.ArmorTemplate;
|
||||
|
||||
public abstract class AbstractNoGradeArmorTemplate extends ArmorTemplate {
|
||||
public AbstractNoGradeArmorTemplate(ItemTemplateID id) {
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
package script.template.item;
|
||||
package script.template.item.potion;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.model.id.template.factory.ItemTemplateIDFactory;
|
||||
import com.l2jserver.model.template.PotionTemplate;
|
||||
import com.l2jserver.model.template.item.PotionTemplate;
|
||||
import com.l2jserver.model.world.capability.Attackable;
|
||||
import com.l2jserver.model.world.capability.Attacker;
|
||||
|
||||
public class TestPotionTemplate extends PotionTemplate {
|
||||
public class RedPotionTemplate extends PotionTemplate {
|
||||
public static final int ID = 15;
|
||||
|
||||
@Inject
|
||||
public TestPotionTemplate(ItemTemplateIDFactory factory) {
|
||||
super(factory.createID(ID));
|
||||
public RedPotionTemplate(ItemTemplateIDFactory factory) {
|
||||
super(factory.createID(ID), "icon.etc_potion_red_i00");
|
||||
this.weight = 80;
|
||||
this.price = 40;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,12 @@
|
||||
package script.template.item.weapon;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.item.WeaponTemplate;
|
||||
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
|
||||
|
||||
public abstract class AbstractNoGradeWeaponTemplate extends WeaponTemplate {
|
||||
public AbstractNoGradeWeaponTemplate(ItemTemplateID id, String icon,
|
||||
ItemMaterial material, InventoryPaperdoll paperdoll, WeaponType type) {
|
||||
super(id, icon, material, paperdoll, type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package script.template.item.weapon;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.model.id.template.factory.ItemTemplateIDFactory;
|
||||
import com.l2jserver.model.world.capability.Attackable;
|
||||
import com.l2jserver.model.world.capability.Attacker;
|
||||
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
|
||||
|
||||
public class LongSwordTemplate extends AbstractNoGradeWeaponTemplate {
|
||||
public static final int ID = 57;
|
||||
|
||||
@Inject
|
||||
public LongSwordTemplate(ItemTemplateIDFactory factory) {
|
||||
super(factory.createID(ID), "icon.weapon_long_sword_i00",
|
||||
ItemMaterial.STEEL, InventoryPaperdoll.RIGHT_HAND,
|
||||
WeaponType.SWORD);
|
||||
|
||||
attribute.set(WeaponAttributeType.PHYSICAL_ATTACK, 0x08, 24);
|
||||
attribute.set(WeaponAttributeType.MAGICAL_ATTACK, 0x08, 17);
|
||||
attribute.set(WeaponAttributeType.R_CRITICAL, 0x08, 8);
|
||||
attribute.set(WeaponAttributeType.PHYSICAL_ATTACK_SPEED, 0x08, 379);
|
||||
|
||||
this.randomDamage = 10;
|
||||
this.attackRange = 40;
|
||||
this.damageRange = new int[] { 0, 0, 40, 120 };
|
||||
this.weight = 1560;
|
||||
this.price = 105000;
|
||||
this.soulshots = 2;
|
||||
this.spiritshots = 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Attacker source, Attackable target) {
|
||||
source.attack(target, this);
|
||||
target.receiveAttack(source, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package script.template.item.weapon;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.model.id.template.factory.ItemTemplateIDFactory;
|
||||
import com.l2jserver.model.world.capability.Attackable;
|
||||
import com.l2jserver.model.world.capability.Attacker;
|
||||
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
|
||||
|
||||
public class ShortSwordTemplate extends AbstractNoGradeWeaponTemplate {
|
||||
public static final int ID = 57;
|
||||
|
||||
@Inject
|
||||
public ShortSwordTemplate(ItemTemplateIDFactory factory) {
|
||||
super(factory.createID(ID), "icon.weapon_small_sword_i00",
|
||||
ItemMaterial.STEEL, InventoryPaperdoll.RIGHT_HAND,
|
||||
WeaponType.SWORD);
|
||||
|
||||
attribute.set(WeaponAttributeType.PHYSICAL_ATTACK, 0x08, 8);
|
||||
attribute.set(WeaponAttributeType.MAGICAL_ATTACK, 0x08, 6);
|
||||
attribute.set(WeaponAttributeType.R_CRITICAL, 0x08, 8);
|
||||
attribute.set(WeaponAttributeType.PHYSICAL_ATTACK_SPEED, 0x08, 379);
|
||||
|
||||
this.type = WeaponType.SWORD;
|
||||
this.paperdoll = InventoryPaperdoll.RIGHT_HAND;
|
||||
this.randomDamage = 10;
|
||||
this.attackRange = 40;
|
||||
this.damageRange = new int[] { 0, 0, 40, 120 };
|
||||
this.material = ItemMaterial.STEEL;
|
||||
this.weight = 1600;
|
||||
this.price = 590;
|
||||
this.soulshots = 1;
|
||||
this.spiritshots = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Attacker source, Attackable target) {
|
||||
source.attack(target, this);
|
||||
target.receiveAttack(source, this);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package script.template.item.weapon;
|
||||
|
||||
import com.l2jserver.model.template.WeaponTemplate;
|
||||
import com.l2jserver.model.world.capability.Attackable;
|
||||
import com.l2jserver.model.world.capability.Attacker;
|
||||
|
||||
public class TestWeaponTemplate extends WeaponTemplate {
|
||||
private static final int DAMAGE_PHYSICAL = 10;
|
||||
private static final int DAMAGE_MAGICAL = 10;
|
||||
@SuppressWarnings("unused")
|
||||
private static final int MAX_ENCHANT_LEVEL = 10;
|
||||
|
||||
public TestWeaponTemplate() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Attacker source, Attackable target) {
|
||||
source.attack(target, this);
|
||||
target.receiveAttack(source, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPhysicalDamage() {
|
||||
return DAMAGE_PHYSICAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMagicalDamage() {
|
||||
return DAMAGE_MAGICAL;
|
||||
}
|
||||
}
|
||||
2
pom.xml
2
pom.xml
@@ -14,7 +14,7 @@
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.8.2</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.netty</groupId>
|
||||
|
||||
@@ -23,6 +23,14 @@ import com.l2jserver.model.world.character.CharacterClass;
|
||||
public class RequestCharacterTemplatesPacket extends AbstractClientPacket {
|
||||
public static final int OPCODE = 0x13;
|
||||
|
||||
public static final CharacterClass[] TEMPLATE_CLASSES = {
|
||||
CharacterClass.HUMAN_FIGHTER, CharacterClass.HUMAN_MYSTIC,
|
||||
CharacterClass.ELVEN_FIGHTER, CharacterClass.ELVEN_MYSTIC,
|
||||
CharacterClass.DARK_FIGHTER, CharacterClass.DARK_MYSTIC,
|
||||
CharacterClass.ORC_FIGHTER, CharacterClass.ORC_MYSTIC,
|
||||
CharacterClass.DWARVEN_FIGHTER, CharacterClass.MALE_SOLDIER,
|
||||
CharacterClass.FEMALE_SOLDIER };
|
||||
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
@@ -43,12 +51,13 @@ public class RequestCharacterTemplatesPacket extends AbstractClientPacket {
|
||||
@Override
|
||||
public void process(final Lineage2Connection conn) {
|
||||
log.debug("Requested character templates");
|
||||
final CharacterTemplateID id = idFactory
|
||||
.createID(CharacterClass.HUMAN_FIGHTER.id);
|
||||
final CharacterTemplate template = id.getTemplate();
|
||||
for (final CharacterClass charClass : TEMPLATE_CLASSES) {
|
||||
final CharacterTemplateID id = idFactory.createID(charClass.id);
|
||||
final CharacterTemplate template = id.getTemplate();
|
||||
final CharacterTemplatePacket templatePacket = new CharacterTemplatePacket(
|
||||
template);
|
||||
|
||||
final CharacterTemplatePacket templatePacket = new CharacterTemplatePacket(
|
||||
template);
|
||||
conn.write(templatePacket);
|
||||
conn.write(templatePacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,12 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.capability.Depositable;
|
||||
import com.l2jserver.model.template.capability.Dropable;
|
||||
import com.l2jserver.model.template.capability.Enchantable;
|
||||
import com.l2jserver.model.template.capability.Sellable;
|
||||
import com.l2jserver.model.template.capability.Tradable;
|
||||
import com.l2jserver.model.template.capability.Usable;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
@@ -18,16 +24,114 @@ public abstract class ItemTemplate extends AbstractTemplate<Item> {
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(ItemTemplate.class);
|
||||
|
||||
protected int weight = 0;
|
||||
protected int price = 0;
|
||||
protected String icon;
|
||||
protected boolean immediateEffect = true;
|
||||
|
||||
protected ItemMaterial material;
|
||||
|
||||
public enum ItemMaterial {
|
||||
COTTON, WOOD, PAPER, FISH, ORIHARUKON, HORN, ADAMANTAITE, CHRYSOLITE, MITHRIL, COBWEB, RUNE_XP, CLOTH, SCALE_OF_DRAGON, BONE, GOLD, LEATHER, FINE_STEEL, SILVER, DYESTUFF, CRYSTAL, RUNE_REMOVE_PENALTY, STEEL, BRONZE, RUNE_SP, LIQUID, BLOOD_STEEL, DAMASCUS;
|
||||
}
|
||||
|
||||
public ItemTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public ItemTemplate(final ItemTemplateID id, String icon,
|
||||
ItemMaterial material) {
|
||||
super(id);
|
||||
this.icon = icon;
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item create() {
|
||||
log.debug("Creating a new Item instance with template {}", this);
|
||||
return new Item(this.getID());
|
||||
}
|
||||
|
||||
public void stack(Item... object) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if item is enchantable
|
||||
*/
|
||||
public boolean isEnchantable() {
|
||||
return (this instanceof Enchantable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sellable
|
||||
*/
|
||||
public boolean isSellable() {
|
||||
return (this instanceof Sellable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dropable
|
||||
*/
|
||||
public boolean isDropable() {
|
||||
return (this instanceof Dropable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tradable
|
||||
*/
|
||||
public boolean isTradable() {
|
||||
return (this instanceof Tradable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the usable
|
||||
*/
|
||||
public boolean isUsable() {
|
||||
return (this instanceof Usable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the usable
|
||||
*/
|
||||
public boolean isDepositable() {
|
||||
return (this instanceof Depositable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the weight
|
||||
*/
|
||||
public int getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the price
|
||||
*/
|
||||
public int getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the icon
|
||||
*/
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the immediateEffect
|
||||
*/
|
||||
public boolean isImmediateEffect() {
|
||||
return immediateEffect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the material
|
||||
*/
|
||||
public ItemMaterial getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTemplateID getID() {
|
||||
return (ItemTemplateID) super.getID();
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.l2jserver.model.template;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.capability.Attackable;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for Weapon {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class WeaponTemplate extends ItemTemplate implements Attackable {
|
||||
public WeaponTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,4 @@ import com.l2jserver.model.world.capability.Attacker;
|
||||
public interface Attackable extends TemplateCapability {
|
||||
void attack(Attacker source,
|
||||
com.l2jserver.model.world.capability.Attackable target);
|
||||
|
||||
int getPhysicalDamage();
|
||||
|
||||
int getMagicalDamage();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.l2jserver.model.template.capability;
|
||||
|
||||
import com.l2jserver.model.template.Template;
|
||||
import com.l2jserver.model.world.capability.Attacker;
|
||||
|
||||
/**
|
||||
* Defines an {@link Template template} {@link TemplateCapability capability}
|
||||
* that can be selled.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Depositable extends TemplateCapability {
|
||||
void sell(Attacker source,
|
||||
com.l2jserver.model.world.capability.Attackable target);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.l2jserver.model.template.capability;
|
||||
|
||||
import com.l2jserver.model.template.Template;
|
||||
import com.l2jserver.model.world.capability.Attacker;
|
||||
|
||||
/**
|
||||
* Defines an {@link Template template} {@link TemplateCapability capability}
|
||||
* that can be selled.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Dropable extends TemplateCapability {
|
||||
void sell(Attacker source,
|
||||
com.l2jserver.model.world.capability.Attackable target);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.l2jserver.model.template.capability;
|
||||
|
||||
import com.l2jserver.model.template.Template;
|
||||
import com.l2jserver.model.world.capability.Attacker;
|
||||
|
||||
/**
|
||||
* Defines an {@link Template template} {@link TemplateCapability capability}
|
||||
* that can be selled.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Sellable extends TemplateCapability {
|
||||
void sell(Attacker source,
|
||||
com.l2jserver.model.world.capability.Attackable target);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.l2jserver.model.template.capability;
|
||||
|
||||
import com.l2jserver.model.template.Template;
|
||||
import com.l2jserver.model.world.capability.Attacker;
|
||||
|
||||
/**
|
||||
* Defines an {@link Template template} {@link TemplateCapability capability}
|
||||
* that can be selled.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Tradable extends TemplateCapability {
|
||||
void sell(Attacker source,
|
||||
com.l2jserver.model.world.capability.Attackable target);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.l2jserver.model.template.capability;
|
||||
|
||||
import com.l2jserver.model.template.Template;
|
||||
|
||||
/**
|
||||
* Defines an {@link Template template} {@link TemplateCapability capability}
|
||||
* that can be used.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Usable extends TemplateCapability {
|
||||
void canUse();
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.l2jserver.model.template;
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.template.capability.Defendable;
|
||||
import com.l2jserver.model.template.capability.IncomingDamageIntercept;
|
||||
import com.l2jserver.model.world.Item;
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for consumable arrow {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class ArrowTemplate extends ConsumableTemplate {
|
||||
public ArrowTemplate(ItemTemplateID id, String icon, ItemMaterial material) {
|
||||
super(id, icon, material);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for Castle Guard {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class CastleGuardTemplate extends ItemTemplate {
|
||||
public CastleGuardTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.l2jserver.model.template;
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.template.capability.Consumable;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
@@ -11,7 +12,8 @@ import com.l2jserver.model.world.Item;
|
||||
*/
|
||||
public abstract class ConsumableTemplate extends ItemTemplate implements
|
||||
Consumable {
|
||||
public ConsumableTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
public ConsumableTemplate(ItemTemplateID id, String icon,
|
||||
ItemMaterial material) {
|
||||
super(id, icon, material);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for coupom {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class CoupomTemplate extends ItemTemplate {
|
||||
public CoupomTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for crop {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class CropTemplate extends ItemTemplate {
|
||||
public CropTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for consumable Dye {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class DyeTemplate extends ConsumableTemplate {
|
||||
public DyeTemplate(ItemTemplateID id, String icon, ItemMaterial material) {
|
||||
super(id, icon, material);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for consumable elixir {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class ElixirTemplate extends ConsumableTemplate {
|
||||
public ElixirTemplate(ItemTemplateID id, String icon, ItemMaterial material) {
|
||||
super(id, icon, material);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for consumable enchant scroll {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class EnchantScrollTemplate extends ScrollTemplate {
|
||||
public EnchantScrollTemplate(ItemTemplateID id, String icon) {
|
||||
super(id, icon);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for harvest {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class HarvestTemplate extends ItemTemplate {
|
||||
public HarvestTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for lottery ticket {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class LotteryTicketTemplate extends TicketTemplate {
|
||||
public LotteryTicketTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for lure {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class LureTemplate extends ItemTemplate {
|
||||
public LureTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for material {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class MaterialTemplate extends ItemTemplate {
|
||||
public MaterialTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for pet collar {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class PetCollarTemplate extends ItemTemplate {
|
||||
public PetCollarTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.l2jserver.model.template;
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.capability.Stackable;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
@@ -8,8 +9,9 @@ import com.l2jserver.model.world.Item;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class PotionTemplate extends ConsumableTemplate {
|
||||
public PotionTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
public abstract class PotionTemplate extends ConsumableTemplate implements
|
||||
Stackable<Item> {
|
||||
public PotionTemplate(ItemTemplateID id, String icon) {
|
||||
super(id, icon, ItemMaterial.LIQUID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for Race Ticket {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class RaceTicketTemplate extends TicketTemplate {
|
||||
public RaceTicketTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for recipe {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class RecipeTemplate extends ItemTemplate {
|
||||
private ItemTemplateID item;
|
||||
|
||||
public RecipeTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for rune {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class RuneTemplate extends ItemTemplate {
|
||||
public RuneTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for consumable scroll {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class ScrollTemplate extends ConsumableTemplate {
|
||||
public ScrollTemplate(ItemTemplateID id, String icon) {
|
||||
super(id, icon, ItemMaterial.PAPER);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for seed {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class SeedTemplate extends ItemTemplate {
|
||||
public SeedTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for ticket of lord {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class TicketOfLordTemplate extends TicketTemplate {
|
||||
public TicketOfLordTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.world.Item;
|
||||
|
||||
/**
|
||||
* Template for ticket {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class TicketTemplate extends ItemTemplate {
|
||||
public TicketTemplate(ItemTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
package com.l2jserver.model.template.item;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.template.capability.Attackable;
|
||||
import com.l2jserver.model.world.Item;
|
||||
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
|
||||
|
||||
/**
|
||||
* Template for Weapon {@link Item}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class WeaponTemplate extends ItemTemplate implements Attackable {
|
||||
protected InventoryPaperdoll paperdoll = null;
|
||||
protected WeaponType type;
|
||||
|
||||
public enum WeaponType {
|
||||
FISHINGROD, CROSSBOW, BIG_SWORD, RAPIER, DUAL_FIST, ETC, DAGGER, BLUNT, BIG_BLUNT, DUAL_DAGGER, DUAL, FLAG, POLE, FIST, BOW, OWN_THING, SWORD, ANCIENT_SWORD;
|
||||
}
|
||||
|
||||
protected final WeaponAttribute attribute = new WeaponAttribute();
|
||||
|
||||
protected int randomDamage = 0;
|
||||
protected int attackRange = 0;
|
||||
protected int[] damageRange = new int[] {};
|
||||
|
||||
protected int soulshots = 0;
|
||||
protected int spiritshots = 0;
|
||||
|
||||
protected int crystals;
|
||||
protected CrystalType crystal;
|
||||
|
||||
public enum CrystalType {
|
||||
GRADE_A, GRADE_B, GRADE_C, GRADE_D;
|
||||
}
|
||||
|
||||
public WeaponTemplate(ItemTemplateID id, String icon,
|
||||
ItemMaterial material, InventoryPaperdoll paperdoll, WeaponType type) {
|
||||
super(id, icon, material);
|
||||
this.paperdoll = paperdoll;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public enum WeaponAttributeType {
|
||||
PHYSICAL_ATTACK, MAGICAL_ATTACK, R_CRITICAL, PHYSICAL_ATTACK_SPEED;
|
||||
}
|
||||
|
||||
public class WeaponAttribute {
|
||||
public void add(WeaponAttributeType type, int order, int value) {
|
||||
}
|
||||
|
||||
public void set(WeaponAttributeType type, int order, int value) {
|
||||
}
|
||||
|
||||
public void enchant(WeaponAttributeType type, int order, int value) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the paperdoll
|
||||
*/
|
||||
public InventoryPaperdoll getPaperdoll() {
|
||||
return paperdoll;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param paperdoll
|
||||
* the paperdoll to set
|
||||
*/
|
||||
public void setPaperdoll(InventoryPaperdoll paperdoll) {
|
||||
this.paperdoll = paperdoll;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public WeaponType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* the type to set
|
||||
*/
|
||||
public void setType(WeaponType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the randomDamage
|
||||
*/
|
||||
public int getRandomDamage() {
|
||||
return randomDamage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param randomDamage
|
||||
* the randomDamage to set
|
||||
*/
|
||||
public void setRandomDamage(int randomDamage) {
|
||||
this.randomDamage = randomDamage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the attackRange
|
||||
*/
|
||||
public int getAttackRange() {
|
||||
return attackRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param attackRange
|
||||
* the attackRange to set
|
||||
*/
|
||||
public void setAttackRange(int attackRange) {
|
||||
this.attackRange = attackRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the damageRange
|
||||
*/
|
||||
public int[] getDamageRange() {
|
||||
return damageRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param damageRange
|
||||
* the damageRange to set
|
||||
*/
|
||||
public void setDamageRange(int[] damageRange) {
|
||||
this.damageRange = damageRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the soulshots
|
||||
*/
|
||||
public int getSoulshots() {
|
||||
return soulshots;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param soulshots
|
||||
* the soulshots to set
|
||||
*/
|
||||
public void setSoulshots(int soulshots) {
|
||||
this.soulshots = soulshots;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the spiritshots
|
||||
*/
|
||||
public int getSpiritshots() {
|
||||
return spiritshots;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param spiritshots
|
||||
* the spiritshots to set
|
||||
*/
|
||||
public void setSpiritshots(int spiritshots) {
|
||||
this.spiritshots = spiritshots;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the crystals
|
||||
*/
|
||||
public int getCrystals() {
|
||||
return crystals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param crystals
|
||||
* the crystals to set
|
||||
*/
|
||||
public void setCrystals(int crystals) {
|
||||
this.crystals = crystals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the crystal
|
||||
*/
|
||||
public CrystalType getCrystal() {
|
||||
return crystal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param crystal
|
||||
* the crystal to set
|
||||
*/
|
||||
public void setCrystal(CrystalType crystal) {
|
||||
this.crystal = crystal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the attribute
|
||||
*/
|
||||
public WeaponAttribute getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,8 @@ public class Item extends AbstractObject implements Playable, Spawnable,
|
||||
* Drop coordinate of this item
|
||||
*/
|
||||
private Coordinate coordinate;
|
||||
|
||||
private int count = 1;
|
||||
|
||||
public Item(ItemTemplateID templateID) {
|
||||
this.templateID = templateID;
|
||||
|
||||
@@ -59,6 +59,11 @@ public class ScriptTemplateService extends AbstractService implements
|
||||
|
||||
public void addTemplate(Class<? extends Template<?>> t) {
|
||||
final Template<?> template = injector.getInstance(t);
|
||||
if (templates.containsKey(template.getID()))
|
||||
throw new TemplateException("Template with ID" + template.getID()
|
||||
+ " is already registered for "
|
||||
+ templates.get(template.getID()));
|
||||
|
||||
if (template.getID() != null)
|
||||
templates.put(template.getID(), template);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.l2jserver.service.game.template;
|
||||
|
||||
public class TemplateException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public TemplateException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TemplateException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public TemplateException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public TemplateException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
38
src/main/java/com/l2jserver/util/calculator/Formula.java
Normal file
38
src/main/java/com/l2jserver/util/calculator/Formula.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.util.calculator.operation.AddOperation;
|
||||
import com.l2jserver.util.calculator.operation.CalculatorOperation;
|
||||
import com.l2jserver.util.calculator.operation.SetOperation;
|
||||
import com.l2jserver.util.calculator.operation.SubtractOperation;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
public class Formula {
|
||||
private List<CalculatorOperation<Integer>> operations = CollectionFactory
|
||||
.newList(null);
|
||||
|
||||
public void addOperation(int order, CalculatorOperation<Integer> operation) {
|
||||
operations.set(order, operation);
|
||||
}
|
||||
|
||||
public void add(int order, int value) {
|
||||
addOperation(order, new AddOperation(value));
|
||||
}
|
||||
|
||||
public void subtract(int order, int value) {
|
||||
addOperation(order, new SubtractOperation(value));
|
||||
}
|
||||
|
||||
public void set(int order, int value) {
|
||||
addOperation(order, new SetOperation(value));
|
||||
}
|
||||
|
||||
public int calculate() {
|
||||
int value = 0;
|
||||
for (CalculatorOperation<Integer> operation : operations) {
|
||||
value = operation.calculate(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.l2jserver.util.calculator.operation;
|
||||
|
||||
public class AddOperation implements CalculatorOperation<Integer> {
|
||||
private Integer value;
|
||||
|
||||
public AddOperation(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer calculate(Integer value) {
|
||||
return value + this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.l2jserver.util.calculator.operation;
|
||||
|
||||
public interface CalculatorOperation<T extends Number> {
|
||||
T calculate(T value);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.l2jserver.util.calculator.operation;
|
||||
|
||||
public class MultiplyOperation implements CalculatorOperation<Integer> {
|
||||
private Integer value;
|
||||
|
||||
public MultiplyOperation(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer calculate(Integer value) {
|
||||
return value * this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.l2jserver.util.calculator.operation;
|
||||
|
||||
public class SetOperation implements CalculatorOperation<Integer> {
|
||||
private Integer value;
|
||||
|
||||
public SetOperation(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer calculate(Integer value) {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.l2jserver.util.calculator.operation;
|
||||
|
||||
public class SubtractOperation implements CalculatorOperation<Integer> {
|
||||
private Integer value;
|
||||
|
||||
public SubtractOperation(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer calculate(Integer value) {
|
||||
return value - this.value;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.l2jserver.tool.conversor;
|
||||
package com.l2jserver.tool.conversor.chartemplate;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -0,0 +1,30 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
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"));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
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);
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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]
|
||||
Reference in New Issue
Block a user