1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-09 08:52:51 +00:00

Implemented new packets and several services

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-17 12:37:52 -03:00
parent 5e21f16735
commit 31cc1a97e3
66 changed files with 2767 additions and 104 deletions

View File

@@ -0,0 +1,67 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model;
import com.l2jserver.model.id.ID;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class AbstractModel<T extends ID<?>> implements Model<T> {
/**
* The object id
*/
protected T id;
@Override
public T getID() {
return id;
}
@Override
public void setID(T ID) {
if(this.id != null)
throw new IllegalStateException("ID is already set");
this.id = ID;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AbstractModel<?> other = (AbstractModel<?>) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}

View File

@@ -0,0 +1,36 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model;
import com.l2jserver.model.id.ID;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public interface Model<T extends ID<?>> {
/**
* @return the object ID
*/
T getID();
/**
* @param ID
* the object ID to set
*/
void setID(T ID);
}

View File

@@ -0,0 +1,214 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.game;
import java.util.Date;
import com.l2jserver.model.AbstractModel;
import com.l2jserver.model.id.CastleID;
import com.l2jserver.model.id.FortID;
import com.l2jserver.model.id.object.CharacterID;
/**
* An fort in Lineage II game world
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class Fort extends AbstractModel<FortID> {
/**
* The {@link Castle} of which this {@link Fort} belongs to
*/
private CastleID castleID;
/**
* The owner (clan leader) of which this {@link Fort} belongs to.
*/
private CharacterID ownerID;
/**
* The fort name
*/
private String name;
/**
* The siege date
*/
private Date siegeDate;
/**
* The last time this fort was owned by someone
*/
private Date lastOwnedTime;
/**
* The fort type. TODO values names are unknown so far!
*/
private FortType fortType;
/**
* The {@link Fort} types
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public enum FortType {
TYPE1, TYPE2;
}
/**
* The {@link Fort} state
*/
private boolean state;
/**
* The {@link Fort} blood state
*/
private boolean blood;
/**
* The {@link Fort} supply level
*/
private int supplyLvL;
/**
* @return the castleID
*/
public CastleID getCastleID() {
return castleID;
}
/**
* @param castleID
* the castleID to set
*/
public void setCastleID(CastleID castleID) {
this.castleID = castleID;
}
/**
* @return the ownerID
*/
public CharacterID getOwnerID() {
return ownerID;
}
/**
* @param ownerID
* the ownerID to set
*/
public void setOwnerID(CharacterID ownerID) {
this.ownerID = ownerID;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the siegeDate
*/
public Date getSiegeDate() {
return siegeDate;
}
/**
* @param siegeDate
* the siegeDate to set
*/
public void setSiegeDate(Date siegeDate) {
this.siegeDate = siegeDate;
}
/**
* @return the lastOwnedTime
*/
public Date getLastOwnedTime() {
return lastOwnedTime;
}
/**
* @param lastOwnedTime
* the lastOwnedTime to set
*/
public void setLastOwnedTime(Date lastOwnedTime) {
this.lastOwnedTime = lastOwnedTime;
}
/**
* @return the fortType
*/
public FortType getFortType() {
return fortType;
}
/**
* @param fortType
* the fortType to set
*/
public void setFortType(FortType fortType) {
this.fortType = fortType;
}
/**
* @return the state
*/
public boolean isState() {
return state;
}
/**
* @param state
* the state to set
*/
public void setState(boolean state) {
this.state = state;
}
/**
* @return the blood
*/
public boolean isBlood() {
return blood;
}
/**
* @param blood
* the blood to set
*/
public void setBlood(boolean blood) {
this.blood = blood;
}
/**
* @return the supplyLvL
*/
public int getSupplyLvL() {
return supplyLvL;
}
/**
* @param supplyLvL
* the supplyLvL to set
*/
public void setSupplyLvL(int supplyLvL) {
this.supplyLvL = supplyLvL;
}
}

View File

@@ -0,0 +1,43 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id;
import com.l2jserver.model.Model;
/**
* This is an abstract ID for most model objects that do not extend
* {@link ObjectID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class AbstractModelID<T, O extends Model<? extends ID<T>>>
extends ID<T> {
/**
* @param id
* the id
*/
protected AbstractModelID(T id) {
super(id);
}
/**
* @return the {@link Model} object associated with this
* {@link AbstractModelID}. <tt>null</tt> if {@link Model} does not
* exists.
*/
public abstract O getObject();
}

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.model.id;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
/**
* Each {@link Castle} is identified by an {@link ID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CastleID extends ID<Integer> {
/**
* Creates a new instance
*
* @param id
* the id
*/
@Inject
public CastleID(@Assisted int id) {
super(id);
}
}

View File

@@ -0,0 +1,45 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.game.Fort;
/**
* Each {@link Fort} is identified by an {@link ID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class FortID extends AbstractModelID<Integer, Fort> {
/**
* Creates a new instance
*
* @param id
* the id
*/
@Inject
public FortID(@Assisted int id) {
super(id);
}
@Override
public Fort getObject() {
// TODO Auto-generated method stub
return null;
}
}

View File

@@ -0,0 +1,27 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.factory;
import com.l2jserver.model.id.CastleID;
/**
* Creates a new {@link CastleID}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface CastleIDFactory extends IDFactory<Integer, CastleID> {
}

View File

@@ -0,0 +1,27 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.factory;
import com.l2jserver.model.id.FortID;
/**
* Creates a new {@link FortID}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface FortIDFactory extends IDFactory<Integer, FortID> {
}

View File

@@ -43,9 +43,6 @@ public class IDFactoryModule extends AbstractModule {
bind(IDAllocator.class).to(BitSetIDAllocator.class)
.in(Scopes.SINGLETON);
// ACCOUNT ID
install(new FactoryModuleBuilder().build(AccountIDFactory.class));
// OBJECT IDS
bind(CharacterIDFactory.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(CharacterIDGuiceFactory.class));
@@ -59,6 +56,10 @@ public class IDFactoryModule extends AbstractModule {
// bind(PetIDFactory.class).in(Scopes.SINGLETON);
// install(new FactoryModuleBuilder().build(PetIDGuiceFactory.class));
// MISC OBJECTS
install(new FactoryModuleBuilder().build(AccountIDFactory.class));
install(new FactoryModuleBuilder().build(FortIDFactory.class));
// TEMPLATE IDS
install(new FactoryModuleBuilder().build(ItemTemplateIDFactory.class));
install(new FactoryModuleBuilder().build(SkillTemplateIDFactory.class));

View File

@@ -16,11 +16,22 @@
*/
package com.l2jserver.model.template.item;
import java.util.Map;
import java.util.Map.Entry;
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;
import com.l2jserver.util.calculator.Calculator;
import com.l2jserver.util.calculator.DivisionOperation;
import com.l2jserver.util.calculator.MultiplicationOperation;
import com.l2jserver.util.calculator.Operation;
import com.l2jserver.util.calculator.SetOperation;
import com.l2jserver.util.calculator.SubtractOperation;
import com.l2jserver.util.calculator.SumOperation;
import com.l2jserver.util.factory.CollectionFactory;
/**
* Template for Weapon {@link Item}
@@ -28,29 +39,83 @@ import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class WeaponTemplate extends ItemTemplate implements Attackable {
/**
* The paperldoll slot used by this weapon
*/
protected InventoryPaperdoll paperdoll = null;
/**
* The weapon type
*/
protected WeaponType type;
/**
* The weapon type enum
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
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;
}
/**
* The weapon's attributes
*/
protected final WeaponAttribute attribute = new WeaponAttribute();
/**
* This weapon random damage
*/
protected int randomDamage = 0;
/**
* This weapon attack range
*/
protected int attackRange = 0;
/**
* Unknown!
*/
protected int[] damageRange = new int[] {};
/**
* Number of soulshots used per attack
*/
protected int soulshots = 0;
/**
* Number of spirithots used per cast
*/
protected int spiritshots = 0;
protected int crystals;
/**
* The crystal count for this weapon
*/
protected int crystals = 0;
/**
* This weapon crystal type
*/
protected CrystalType crystal;
/**
* Enum containing all crystal types possible
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public enum CrystalType {
GRADE_A, GRADE_B, GRADE_C, GRADE_D;
}
/**
* Creates a new instance. All arguments are required!
*
* @param id
* the template id
* @param icon
* the item icon
* @param material
* the item material
* @param paperdoll
* the paperdoll slot
* @param type
* the weapon type
*/
public WeaponTemplate(ItemTemplateID id, String icon,
ItemMaterial material, InventoryPaperdoll paperdoll, WeaponType type) {
super(id, icon, material);
@@ -58,18 +123,152 @@ public abstract class WeaponTemplate extends ItemTemplate implements Attackable
this.type = type;
}
/**
* Append all operation for this weapon
*
* @param type
* the attribute type
* @param calc
* the calculator
*/
public void calculator(WeaponAttributeType type, Calculator calc) {
attribute.calculator(type, calc);
}
/**
* Attribute types for weapons
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public enum WeaponAttributeType {
PHYSICAL_ATTACK, MAGICAL_ATTACK, R_CRITICAL, PHYSICAL_ATTACK_SPEED;
}
/**
* This class handles the Weapon attributes an can add operations to the
* calculator
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class WeaponAttribute {
public void add(WeaponAttributeType type, int order, int value) {
private final Map<WeaponAttributeType, Map<Integer, Operation<Double>>> operations = CollectionFactory
.newMap(null, null);
/**
* Sets the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to set
*/
public void set(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new SetOperation(value));
}
public void set(WeaponAttributeType type, int order, int value) {
/**
* Adds <tt>value</tt> to the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be summed
*/
public void add(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new SumOperation(value));
}
public void enchant(WeaponAttributeType type, int order, int value) {
/**
* Subtracts <tt>value</tt> from the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be subtracted
*/
public void sub(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new SubtractOperation(value));
}
/**
* Multiply <tt>value</tt> the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be multiplied
*/
public void mult(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new MultiplicationOperation(value));
}
/**
* Divides by <tt>value</tt> the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be divided by
*/
public void div(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new DivisionOperation(value));
}
/**
* Performs an enchant operation. Note that this is not implemented yet!
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* TODO
*/
public void enchant(WeaponAttributeType type, int order, double value) {
// TODO enchant operation for weapon
}
/**
* Returns the Order-Operation map for <tt>type</tt>
*
* @param type
* the type
* @return the order-operation map
*/
private Map<Integer, Operation<Double>> getMap(WeaponAttributeType type) {
Map<Integer, Operation<Double>> map = operations.get(type);
if (map == null) {
map = CollectionFactory.newMap(null, null);
operations.put(type, map);
}
return map;
}
/**
* Creates the calculator object for this weapon
*
* @param type
* the type
* @param calculator
* the calculator
*/
private void calculator(WeaponAttributeType type, Calculator calculator) {
final Map<Integer, Operation<Double>> operations = this.operations
.get(type);
for (final Entry<Integer, Operation<Double>> entry : operations
.entrySet()) {
calculator.add(entry.getKey(), entry.getValue());
}
}
}

View File

@@ -16,6 +16,7 @@
*/
package com.l2jserver.model.world;
import com.l2jserver.model.AbstractModel;
import com.l2jserver.model.id.ObjectID;
/**
@@ -23,46 +24,6 @@ import com.l2jserver.model.id.ObjectID;
*
* @author Rogiel
*/
public abstract class AbstractObject implements WorldObject {
/**
* The {@link ObjectID}
*/
protected ObjectID<?> id;
@Override
public ObjectID<?> getID() {
return id;
}
@Override
public void setID(ObjectID<?> id) {
if (this.id != null)
throw new IllegalStateException("ID is already set!");
this.id = id;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AbstractObject other = (AbstractObject) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
public abstract class AbstractObject extends AbstractModel<ObjectID<?>>
implements WorldObject {
}