mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-05 23:22:47 +00:00
Implemented new packets and several services
Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
@@ -14,9 +13,14 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
package script.template.item.weapon;
|
||||
|
||||
import static com.l2jserver.model.template.item.WeaponTemplate.WeaponAttributeType.MAGICAL_ATTACK;
|
||||
import static com.l2jserver.model.template.item.WeaponTemplate.WeaponAttributeType.PHYSICAL_ATTACK;
|
||||
import static com.l2jserver.model.template.item.WeaponTemplate.WeaponAttributeType.PHYSICAL_ATTACK_SPEED;
|
||||
import static com.l2jserver.model.template.item.WeaponTemplate.WeaponAttributeType.R_CRITICAL;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.model.id.template.factory.ItemTemplateIDFactory;
|
||||
import com.l2jserver.model.world.capability.Attackable;
|
||||
@@ -32,10 +36,10 @@ public class LongSwordTemplate extends AbstractNoGradeWeaponTemplate {
|
||||
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);
|
||||
attribute.set(PHYSICAL_ATTACK, 0x80, 24);
|
||||
attribute.set(MAGICAL_ATTACK, 0x80, 17);
|
||||
attribute.set(R_CRITICAL, 0x80, 8);
|
||||
attribute.set(PHYSICAL_ATTACK_SPEED, 0x80, 379);
|
||||
|
||||
this.randomDamage = 10;
|
||||
this.attackRange = 40;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
@@ -14,9 +13,14 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
package script.template.item.weapon;
|
||||
|
||||
import static com.l2jserver.model.template.item.WeaponTemplate.WeaponAttributeType.MAGICAL_ATTACK;
|
||||
import static com.l2jserver.model.template.item.WeaponTemplate.WeaponAttributeType.PHYSICAL_ATTACK;
|
||||
import static com.l2jserver.model.template.item.WeaponTemplate.WeaponAttributeType.PHYSICAL_ATTACK_SPEED;
|
||||
import static com.l2jserver.model.template.item.WeaponTemplate.WeaponAttributeType.R_CRITICAL;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.model.id.template.factory.ItemTemplateIDFactory;
|
||||
import com.l2jserver.model.world.capability.Attackable;
|
||||
@@ -32,10 +36,10 @@ public class ShortSwordTemplate extends AbstractNoGradeWeaponTemplate {
|
||||
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);
|
||||
attribute.set(PHYSICAL_ATTACK, 0x08, 8);
|
||||
attribute.set(MAGICAL_ATTACK, 0x08, 6);
|
||||
attribute.set(R_CRITICAL, 0x08, 8);
|
||||
attribute.set(PHYSICAL_ATTACK_SPEED, 0x08, 379);
|
||||
|
||||
this.type = WeaponType.SWORD;
|
||||
this.paperdoll = InventoryPaperdoll.RIGHT_HAND;
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
*/
|
||||
package com.l2jserver;
|
||||
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
|
||||
import com.l2jserver.routines.GameServerInitializationRoutine;
|
||||
|
||||
public class L2JGameServerMain {
|
||||
@@ -26,8 +24,6 @@ public class L2JGameServerMain {
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
BasicConfigurator.configure();
|
||||
|
||||
final L2JGameServer server = new L2JGameServer();
|
||||
try {
|
||||
server.getInjector()
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.l2jserver.game.net;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class Lineage2CryptographyKey implements Cloneable {
|
||||
public class Lineage2CryptographyKey {
|
||||
/**
|
||||
* The raw key
|
||||
*/
|
||||
@@ -76,12 +76,7 @@ public class Lineage2CryptographyKey implements Cloneable {
|
||||
key[11] = (byte) (old >> 0x18 & 0xff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Lineage2CryptographyKey clone() {
|
||||
try {
|
||||
return (Lineage2CryptographyKey) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
return null;
|
||||
}
|
||||
public Lineage2CryptographyKey copy() {
|
||||
return new Lineage2CryptographyKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,11 @@ import com.l2jserver.game.net.packet.client.CharacterCreatePacket;
|
||||
import com.l2jserver.game.net.packet.client.EnterWorld;
|
||||
import com.l2jserver.game.net.packet.client.LogoutPacket;
|
||||
import com.l2jserver.game.net.packet.client.ProtocolVersionPacket;
|
||||
import com.l2jserver.game.net.packet.client.RequestAllFortressInfoPacket;
|
||||
import com.l2jserver.game.net.packet.client.RequestCharacterTemplatesPacket;
|
||||
import com.l2jserver.game.net.packet.client.RequestGotoLobby;
|
||||
import com.l2jserver.game.net.packet.client.RequestKeyMapping;
|
||||
import com.l2jserver.game.net.packet.client.RequestManorList;
|
||||
import com.l2jserver.game.net.packet.client.RequestGotoLobbyPacket;
|
||||
import com.l2jserver.game.net.packet.client.RequestKeyMappingPacket;
|
||||
import com.l2jserver.game.net.packet.client.RequestManorListPacket;
|
||||
|
||||
/**
|
||||
* This decoder reads an frame and decodes the packet in it. Each packet has an
|
||||
@@ -128,12 +129,14 @@ public class Lineage2PacketReader extends OneToOneDecoder {
|
||||
case 0xd0: // COMPOSED
|
||||
final int opcode2 = buffer.readUnsignedShort();
|
||||
switch (opcode2) {
|
||||
case RequestGotoLobby.OPCODE2:
|
||||
return RequestGotoLobby.class;
|
||||
case RequestKeyMapping.OPCODE2:
|
||||
return RequestKeyMapping.class;
|
||||
case RequestManorList.OPCODE2:
|
||||
return RequestManorList.class;
|
||||
case RequestGotoLobbyPacket.OPCODE2:
|
||||
return RequestGotoLobbyPacket.class;
|
||||
case RequestKeyMappingPacket.OPCODE2:
|
||||
return RequestKeyMappingPacket.class;
|
||||
case RequestManorListPacket.OPCODE2:
|
||||
return RequestManorListPacket.class;
|
||||
case RequestAllFortressInfoPacket.OPCODE2:
|
||||
return RequestAllFortressInfoPacket.class;
|
||||
default:
|
||||
logger.warn("Unknown opcode2 for 0xd0: 0x{}",
|
||||
Integer.toHexString(opcode2));
|
||||
|
||||
@@ -88,6 +88,7 @@ public class AuthLoginPacket extends AbstractClientPacket {
|
||||
final List<L2Character> chars = characterDao.selectByAccount(accountId);
|
||||
// conn.write(CharacterSelectionListPacket.fromL2Session(
|
||||
// conn.getSession(), chars.toArray(new L2Character[0])));
|
||||
conn.setCharacterID(chars.get(0).getID());
|
||||
conn.write(new CharacterEnterWorldPacket(chars.get(0), playKey1));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.game.net.packet.server.InventoryPacket;
|
||||
import com.l2jserver.game.net.packet.server.GameGuardQueryPacket;
|
||||
import com.l2jserver.game.net.packet.server.UserInformationPacket;
|
||||
|
||||
/**
|
||||
* The client is requesting a logout. Currently, when this packet is received
|
||||
@@ -51,6 +52,8 @@ public class EnterWorld extends AbstractClientPacket {
|
||||
|
||||
@Override
|
||||
public void process(final Lineage2Connection conn) {
|
||||
conn.write(new InventoryPacket(conn.getCharacter().getInventory()));
|
||||
conn.write(new UserInformationPacket(conn.getCharacter()));
|
||||
conn.write(new GameGuardQueryPacket());
|
||||
//conn.write(new InventoryPacket(conn.getCharacter().getInventory()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ProtocolVersionPacket extends AbstractClientPacket {
|
||||
keygen.generate());
|
||||
|
||||
conn.getDecrypter().enable(inKey);
|
||||
final Lineage2CryptographyKey outKey = inKey.clone();
|
||||
final Lineage2CryptographyKey outKey = inKey.copy();
|
||||
log.debug("Decrypter has been enabled");
|
||||
|
||||
log.debug("Client protocol version: {}", version);
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.game.net.packet.client;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.game.net.packet.server.FortInfoPacket;
|
||||
|
||||
/**
|
||||
* The client is requesting the manor list.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class RequestAllFortressInfoPacket extends AbstractClientPacket {
|
||||
/**
|
||||
* The packet OPCODE1
|
||||
*/
|
||||
public static final int OPCODE1 = 0xd0;
|
||||
/**
|
||||
* The packet OPCODE2
|
||||
*/
|
||||
public static final int OPCODE2 = 0x3d;
|
||||
|
||||
@Override
|
||||
public void read(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final Lineage2Connection conn) {
|
||||
conn.write(new FortInfoPacket());
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ import com.l2jserver.model.world.L2Character;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class RequestGotoLobby extends AbstractClientPacket {
|
||||
public class RequestGotoLobbyPacket extends AbstractClientPacket {
|
||||
/**
|
||||
* The packet OPCODE1
|
||||
*/
|
||||
@@ -49,7 +49,7 @@ public class RequestGotoLobby extends AbstractClientPacket {
|
||||
private final CharacterDAO characterDao;
|
||||
|
||||
@Inject
|
||||
public RequestGotoLobby(CharacterDAO characterDao) {
|
||||
public RequestGotoLobbyPacket(CharacterDAO characterDao) {
|
||||
this.characterDao = characterDao;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class RequestKeyMapping extends AbstractClientPacket {
|
||||
public class RequestKeyMappingPacket extends AbstractClientPacket {
|
||||
/**
|
||||
* The packet OPCODE1
|
||||
*/
|
||||
@@ -27,7 +27,7 @@ import com.l2jserver.game.net.packet.server.ManorListPacket;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class RequestManorList extends AbstractClientPacket {
|
||||
public class RequestManorListPacket extends AbstractClientPacket {
|
||||
/**
|
||||
* The packet OPCODE1
|
||||
*/
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.game.net.packet.client;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
|
||||
/**
|
||||
* The client is requesting a logout. Currently, when this packet is received
|
||||
* the connection is immediately closed.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class RequestShortcutRegistry extends AbstractClientPacket {
|
||||
/**
|
||||
* The packet OPCODE1
|
||||
*/
|
||||
public static final int OPCODE1 = 0xd0;
|
||||
/**
|
||||
* The packet OPCODE2
|
||||
*/
|
||||
public static final int OPCODE2 = 0x3d;
|
||||
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(RequestShortcutRegistry.class);
|
||||
|
||||
/**
|
||||
* The shortcut type
|
||||
*/
|
||||
private int type;
|
||||
/**
|
||||
* The shortcut ID
|
||||
*/
|
||||
private int id;
|
||||
private int slot;
|
||||
private int page;
|
||||
private int lvl;
|
||||
private int characterType;
|
||||
|
||||
@Override
|
||||
public void read(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final Lineage2Connection conn) {
|
||||
log.debug("Logging out client {}", conn);
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.game.net.packet.server;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
||||
import com.l2jserver.util.BufferUtils;
|
||||
|
||||
/**
|
||||
* This packet send the manor list to the client
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class FortInfoPacket extends AbstractServerPacket {
|
||||
/**
|
||||
* The packet OPCODE
|
||||
*/
|
||||
public static final int OPCODE = 0xfe;
|
||||
|
||||
public FortInfoPacket() {
|
||||
super(OPCODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
buffer.writeShort(0x15);
|
||||
buffer.writeInt(21);
|
||||
int i = 101;
|
||||
for (; i < 122; i++) {
|
||||
buffer.writeInt(i); // fort id
|
||||
BufferUtils.writeString(buffer, ""); // clan name
|
||||
buffer.writeInt(0x00); // is in siege
|
||||
buffer.writeInt(0x00); // Time of possession
|
||||
}
|
||||
|
||||
// TODO implement fort service
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.game.net.packet.server;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
||||
|
||||
/**
|
||||
* This packet send the GameGuard query to the client. The client will send an
|
||||
* notification, but this can be ignored if GG is not supposed to be enforced.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class GameGuardQueryPacket extends AbstractServerPacket {
|
||||
/**
|
||||
* The packet OPCODE
|
||||
*/
|
||||
public static final int OPCODE = 0x74;
|
||||
|
||||
public GameGuardQueryPacket() {
|
||||
super(OPCODE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
buffer.writeInt(0x27533DD9);
|
||||
buffer.writeInt(0x2E72A51D);
|
||||
buffer.writeInt(0x2017038B);
|
||||
buffer.writeInt(0xC35B1EA3);
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,40 @@
|
||||
*/
|
||||
package com.l2jserver.game.net.packet.server;
|
||||
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.BELT;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.CHEST;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.CLOAK;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.DECORATION_1;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.DECORATION_2;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.DECORATION_3;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.DECORATION_4;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.DECORATION_5;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.DECORATION_6;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.FEET;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.GLOVES;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.HAIR1;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.HAIR2;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.HEAD;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.LEFT_BRACELET;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.LEFT_EAR;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.LEFT_FINGER;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.LEFT_HAND;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.LEGS;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.NECK;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.RIGHT_BRACELET;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.RIGHT_EAR;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.RIGHT_FINGER;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.RIGHT_HAND;
|
||||
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.UNDERWEAR;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
||||
import com.l2jserver.model.world.Item;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.actor.ActorExperience;
|
||||
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
|
||||
import com.l2jserver.util.BufferUtils;
|
||||
|
||||
/**
|
||||
@@ -31,26 +61,296 @@ public class UserInformationPacket extends AbstractServerPacket {
|
||||
/**
|
||||
* The packet OPCODE
|
||||
*/
|
||||
public static final int OPCODE = 0xfe;
|
||||
public static final int OPCODE = 0x32;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* The character
|
||||
*/
|
||||
private String[] manors;
|
||||
private L2Character character;
|
||||
|
||||
public UserInformationPacket(String... manors) {
|
||||
public UserInformationPacket(L2Character character) {
|
||||
super(OPCODE);
|
||||
this.manors = manors;
|
||||
this.character = character;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
buffer.writeShort(0x22);
|
||||
buffer.writeInt(manors.length);
|
||||
int i = 1;
|
||||
for (String manor : manors) {
|
||||
buffer.writeInt(i++);
|
||||
BufferUtils.writeString(buffer, manor);
|
||||
}
|
||||
buffer.writeInt(character.getPoint().getX());
|
||||
buffer.writeInt(character.getPoint().getY());
|
||||
buffer.writeInt(character.getPoint().getZ());
|
||||
buffer.writeInt(0); // vehicle
|
||||
buffer.writeInt(character.getID().getID());
|
||||
BufferUtils.writeString(buffer, character.getName());
|
||||
buffer.writeInt(character.getRace().id);
|
||||
buffer.writeInt(character.getSex().option);
|
||||
|
||||
buffer.writeInt(character.getCharacterClass().id);
|
||||
|
||||
buffer.writeInt(character.getLevel());
|
||||
buffer.writeLong(ActorExperience.LEVEL_1.experience);
|
||||
buffer.writeInt(character.getAttributes().getStrength());
|
||||
buffer.writeInt(character.getAttributes().getDexterity());
|
||||
buffer.writeInt(character.getAttributes().getConcentration());
|
||||
buffer.writeInt(character.getAttributes().getIntelligence());
|
||||
buffer.writeInt(character.getAttributes().getWitness());
|
||||
buffer.writeInt(character.getAttributes().getMentality());
|
||||
buffer.writeInt(200); // hp
|
||||
buffer.writeInt((int) 200); // cur hp
|
||||
buffer.writeInt(200); // mp
|
||||
buffer.writeInt((int) 200); // cur mp
|
||||
buffer.writeInt(0); // sp
|
||||
buffer.writeInt(0); // load
|
||||
buffer.writeInt(200); // max load
|
||||
|
||||
// 20 no weapon, 40 weapon equippe
|
||||
buffer.writeInt(20);
|
||||
|
||||
writePaperdollObjectID(buffer, character, UNDERWEAR);
|
||||
writePaperdollObjectID(buffer, character, RIGHT_EAR);
|
||||
writePaperdollObjectID(buffer, character, LEFT_EAR);
|
||||
writePaperdollObjectID(buffer, character, NECK);
|
||||
writePaperdollObjectID(buffer, character, RIGHT_FINGER);
|
||||
writePaperdollObjectID(buffer, character, LEFT_FINGER);
|
||||
writePaperdollObjectID(buffer, character, HEAD);
|
||||
writePaperdollObjectID(buffer, character, RIGHT_HAND);
|
||||
writePaperdollObjectID(buffer, character, LEFT_HAND);
|
||||
writePaperdollObjectID(buffer, character, GLOVES);
|
||||
writePaperdollObjectID(buffer, character, CHEST);
|
||||
writePaperdollObjectID(buffer, character, LEGS);
|
||||
writePaperdollObjectID(buffer, character, FEET);
|
||||
writePaperdollObjectID(buffer, character, CLOAK);
|
||||
writePaperdollObjectID(buffer, character, RIGHT_HAND);
|
||||
writePaperdollObjectID(buffer, character, HAIR1);
|
||||
writePaperdollObjectID(buffer, character, HAIR2);
|
||||
writePaperdollObjectID(buffer, character, RIGHT_BRACELET);
|
||||
writePaperdollObjectID(buffer, character, LEFT_BRACELET);
|
||||
writePaperdollObjectID(buffer, character, DECORATION_1);
|
||||
writePaperdollObjectID(buffer, character, DECORATION_2);
|
||||
writePaperdollObjectID(buffer, character, DECORATION_3);
|
||||
writePaperdollObjectID(buffer, character, DECORATION_4);
|
||||
writePaperdollObjectID(buffer, character, DECORATION_5);
|
||||
writePaperdollObjectID(buffer, character, DECORATION_6);
|
||||
writePaperdollObjectID(buffer, character, BELT);
|
||||
|
||||
writePaperdollItemID(buffer, character, UNDERWEAR);
|
||||
writePaperdollItemID(buffer, character, RIGHT_EAR);
|
||||
writePaperdollItemID(buffer, character, LEFT_EAR);
|
||||
writePaperdollItemID(buffer, character, NECK);
|
||||
writePaperdollItemID(buffer, character, RIGHT_FINGER);
|
||||
writePaperdollItemID(buffer, character, LEFT_FINGER);
|
||||
writePaperdollItemID(buffer, character, HEAD);
|
||||
buffer.writeInt(246);
|
||||
//writePaperdollItemID(buffer, character, RIGHT_HAND);
|
||||
writePaperdollItemID(buffer, character, LEFT_HAND);
|
||||
writePaperdollItemID(buffer, character, GLOVES);
|
||||
writePaperdollItemID(buffer, character, CHEST);
|
||||
writePaperdollItemID(buffer, character, LEGS);
|
||||
writePaperdollItemID(buffer, character, FEET);
|
||||
writePaperdollItemID(buffer, character, CLOAK);
|
||||
///writePaperdollItemID(buffer, character, RIGHT_HAND);
|
||||
buffer.writeInt(246);
|
||||
writePaperdollItemID(buffer, character, HAIR1);
|
||||
writePaperdollItemID(buffer, character, HAIR2);
|
||||
writePaperdollItemID(buffer, character, RIGHT_BRACELET);
|
||||
writePaperdollItemID(buffer, character, LEFT_BRACELET);
|
||||
writePaperdollItemID(buffer, character, DECORATION_1);
|
||||
writePaperdollItemID(buffer, character, DECORATION_2);
|
||||
writePaperdollItemID(buffer, character, DECORATION_3);
|
||||
writePaperdollItemID(buffer, character, DECORATION_4);
|
||||
writePaperdollItemID(buffer, character, DECORATION_5);
|
||||
writePaperdollItemID(buffer, character, DECORATION_6);
|
||||
writePaperdollItemID(buffer, character, BELT);
|
||||
|
||||
writePaperdollAugumentID(buffer, character, UNDERWEAR);
|
||||
writePaperdollAugumentID(buffer, character, RIGHT_EAR);
|
||||
writePaperdollAugumentID(buffer, character, LEFT_EAR);
|
||||
writePaperdollAugumentID(buffer, character, NECK);
|
||||
writePaperdollAugumentID(buffer, character, RIGHT_FINGER);
|
||||
writePaperdollAugumentID(buffer, character, LEFT_FINGER);
|
||||
writePaperdollAugumentID(buffer, character, HEAD);
|
||||
writePaperdollAugumentID(buffer, character, RIGHT_HAND);
|
||||
writePaperdollAugumentID(buffer, character, LEFT_HAND);
|
||||
writePaperdollAugumentID(buffer, character, GLOVES);
|
||||
writePaperdollAugumentID(buffer, character, CHEST);
|
||||
writePaperdollAugumentID(buffer, character, LEGS);
|
||||
writePaperdollAugumentID(buffer, character, FEET);
|
||||
writePaperdollAugumentID(buffer, character, CLOAK);
|
||||
writePaperdollAugumentID(buffer, character, RIGHT_HAND);
|
||||
writePaperdollAugumentID(buffer, character, HAIR1);
|
||||
writePaperdollAugumentID(buffer, character, HAIR2);
|
||||
writePaperdollAugumentID(buffer, character, RIGHT_BRACELET);
|
||||
writePaperdollAugumentID(buffer, character, LEFT_BRACELET);
|
||||
writePaperdollAugumentID(buffer, character, DECORATION_1);
|
||||
writePaperdollAugumentID(buffer, character, DECORATION_2);
|
||||
writePaperdollAugumentID(buffer, character, DECORATION_3);
|
||||
writePaperdollAugumentID(buffer, character, DECORATION_4);
|
||||
writePaperdollAugumentID(buffer, character, DECORATION_5);
|
||||
writePaperdollAugumentID(buffer, character, DECORATION_6);
|
||||
writePaperdollAugumentID(buffer, character, BELT);
|
||||
|
||||
buffer.writeInt(0x00); // (max?) talismans count
|
||||
buffer.writeInt(0x00); // cloak sratus
|
||||
buffer.writeInt(character.getAttributes().getPhysicalAttack());
|
||||
buffer.writeInt(character.getAttributes().getAttackSpeed());
|
||||
buffer.writeInt(character.getAttributes().getPhysicalDefense());
|
||||
|
||||
buffer.writeInt(character.getAttributes().getEvasionChance()); // evasion
|
||||
buffer.writeInt(character.getAttributes().getAccuracy());
|
||||
buffer.writeInt(character.getAttributes().getCriticalChance());
|
||||
|
||||
buffer.writeInt(character.getAttributes().getMagicalAttack());
|
||||
buffer.writeInt(character.getAttributes().getCastSpeed());
|
||||
buffer.writeInt(character.getAttributes().getAttackSpeed());
|
||||
|
||||
buffer.writeInt(character.getAttributes().getMagicalDefense());
|
||||
|
||||
buffer.writeInt(0x00); // 0-non-pvp 1-pvp = violett name
|
||||
buffer.writeInt(0x00); // karma
|
||||
|
||||
buffer.writeInt(0x10); // run speed
|
||||
buffer.writeInt(0x20); // walk speed
|
||||
buffer.writeInt(0x10); // swim run speed
|
||||
buffer.writeInt(0x20); // swim walk speed
|
||||
buffer.writeInt(0); // unk
|
||||
buffer.writeInt(0); // unk
|
||||
buffer.writeInt(0); // fly speed -only if flying
|
||||
buffer.writeInt(0); // fly speed -only if flying
|
||||
buffer.writeDouble(0x01); // move speed multiplier
|
||||
buffer.writeDouble(0x01); // attack speed multiplier
|
||||
|
||||
// L2Summon pet = _activeChar.getPet();
|
||||
// L2Transformation trans;
|
||||
// if (_activeChar.getMountType() != 0 && pet != null) {
|
||||
// writeF(pet.getTemplate().fCollisionRadius);
|
||||
// writeF(pet.getTemplate().fCollisionHeight);
|
||||
// } else if ((trans = _activeChar.getTransformation()) != null) {
|
||||
// writeF(trans.getCollisionRadius());
|
||||
// writeF(trans.getCollisionHeight());
|
||||
// } else {
|
||||
// writeF(_activeChar.getCollisionRadius());
|
||||
// writeF(_activeChar.getCollisionHeight());
|
||||
// }
|
||||
buffer.writeDouble(9.0); // collision radius
|
||||
buffer.writeDouble(23.0); // collision heigth
|
||||
|
||||
buffer.writeInt(character.getAppearance().getHairStyle().option);
|
||||
buffer.writeInt(character.getAppearance().getHairColor().option);
|
||||
buffer.writeInt(character.getAppearance().getFace().option);
|
||||
buffer.writeInt(0x00); // is gm
|
||||
|
||||
String title = "Testing"; // title
|
||||
BufferUtils.writeString(buffer, title);
|
||||
|
||||
int clanid = 0;
|
||||
if (character.getClanID() != null)
|
||||
clanid = character.getClanID().getID();
|
||||
buffer.writeInt(clanid); // clanid
|
||||
buffer.writeInt(0x00); // clan crest id
|
||||
buffer.writeInt(0x00); // ally id
|
||||
buffer.writeInt(0x00); // ally crest id
|
||||
// 0x40 leader rights
|
||||
// siege flags: attacker - 0x180 sword over name, defender - 0x80
|
||||
// shield, 0xC0 crown (|leader), 0x1C0 flag (|leader)
|
||||
buffer.writeInt(0x40);
|
||||
buffer.writeByte(0x00); // mount type
|
||||
buffer.writeByte(0x00); // private store type
|
||||
buffer.writeByte(0x00); // dwarven craft
|
||||
buffer.writeInt(0x00); // pk kills
|
||||
buffer.writeInt(0x00); // pvp kills
|
||||
|
||||
buffer.writeShort(0x00); // cubics size
|
||||
// short:cubicsid[cubicssize]
|
||||
// buffer.writeShort(cubicid);
|
||||
|
||||
buffer.writeByte(0); // is party match room
|
||||
|
||||
buffer.writeInt(0x100000); // abnormal effect
|
||||
buffer.writeByte(0x0); // flying mounted = 2; otherwise: 0
|
||||
|
||||
buffer.writeInt(0x00); // clan privileges
|
||||
|
||||
buffer.writeShort(2); // c2 recommendations remaining
|
||||
buffer.writeShort(1); // c2 recommendations received
|
||||
buffer.writeInt(0); // mount npc id
|
||||
buffer.writeShort(500); // inventory limit
|
||||
|
||||
buffer.writeInt(character.getCharacterClass().id);
|
||||
buffer.writeInt(0x00); // special effects? circles around player...
|
||||
buffer.writeInt(200); // max cp
|
||||
buffer.writeInt(200); // cur cp
|
||||
buffer.writeByte(127); // is mount or is airshilhelp = 0; otherwise
|
||||
// enchant effect (minimum 127)
|
||||
|
||||
buffer.writeByte(0x01);// team, 1=blue,2 red,0 is unknown
|
||||
|
||||
buffer.writeInt(0x00); // clan crest large id
|
||||
// 0x01: symbol on char menu ctrl+I
|
||||
buffer.writeByte(0x00); // is noble
|
||||
buffer.writeByte(0x00); // 0x01: Hero Aura
|
||||
|
||||
buffer.writeByte(0x00); // Fishing Mode
|
||||
buffer.writeInt(0x00); // fishing x
|
||||
buffer.writeInt(0x00); // fishing y
|
||||
buffer.writeInt(0x00); // fishing z
|
||||
buffer.writeInt(character.getAppearance().getNameColor().toInteger());
|
||||
|
||||
// new c5
|
||||
// is running
|
||||
buffer.writeByte(0x00); // changes the Speed
|
||||
// display on Status
|
||||
// Window
|
||||
|
||||
// pledge class
|
||||
buffer.writeInt(0x00); // changes the text above
|
||||
// CP on Status Window
|
||||
buffer.writeInt(0x00); // pledge type
|
||||
|
||||
buffer.writeInt(character.getAppearance().getTitleColor().toInteger());
|
||||
|
||||
// cursed weapon ID equipped
|
||||
buffer.writeInt(0x00);
|
||||
|
||||
// T1 Starts
|
||||
buffer.writeInt(0x00); // transformation id
|
||||
|
||||
buffer.writeShort(0x00); // attack element
|
||||
buffer.writeShort(0x10); // attack element value
|
||||
buffer.writeShort(0x10); // fire defense value
|
||||
buffer.writeShort(0x10); // water def value
|
||||
buffer.writeShort(0x10); // wind def value
|
||||
buffer.writeShort(0x10); // earth def value
|
||||
buffer.writeShort(0x10); // holy def value
|
||||
buffer.writeShort(0x10); // dark def value
|
||||
|
||||
buffer.writeInt(0x00); // getAgathionId
|
||||
|
||||
// T2 Starts
|
||||
buffer.writeInt(0x00); // Fame
|
||||
buffer.writeInt(0x01); // Minimap on Hellbound
|
||||
buffer.writeInt(1); // Vitality Points
|
||||
buffer.writeInt(0x000001); // special effects
|
||||
}
|
||||
|
||||
private void writePaperdollObjectID(ChannelBuffer buffer,
|
||||
L2Character character, InventoryPaperdoll paperdoll) {
|
||||
final Item item = character.getInventory().getItem(paperdoll);
|
||||
int id = 0;
|
||||
if (item != null)
|
||||
id = item.getID().getID();
|
||||
buffer.writeInt(id);
|
||||
}
|
||||
|
||||
private void writePaperdollItemID(ChannelBuffer buffer,
|
||||
L2Character character, InventoryPaperdoll paperdoll) {
|
||||
final Item item = character.getInventory().getItem(paperdoll);
|
||||
int id = 0;
|
||||
if (item != null)
|
||||
id = item.getTemplateID().getID();
|
||||
buffer.writeInt(id);
|
||||
}
|
||||
|
||||
private void writePaperdollAugumentID(ChannelBuffer buffer,
|
||||
L2Character character, InventoryPaperdoll paperdoll) {
|
||||
buffer.writeInt(0x00);
|
||||
}
|
||||
}
|
||||
|
||||
67
src/main/java/com/l2jserver/model/AbstractModel.java
Normal file
67
src/main/java/com/l2jserver/model/AbstractModel.java
Normal 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;
|
||||
}
|
||||
}
|
||||
36
src/main/java/com/l2jserver/model/Model.java
Normal file
36
src/main/java/com/l2jserver/model/Model.java
Normal 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);
|
||||
}
|
||||
214
src/main/java/com/l2jserver/model/game/Fort.java
Normal file
214
src/main/java/com/l2jserver/model/game/Fort.java
Normal 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;
|
||||
}
|
||||
}
|
||||
43
src/main/java/com/l2jserver/model/id/AbstractModelID.java
Normal file
43
src/main/java/com/l2jserver/model/id/AbstractModelID.java
Normal 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();
|
||||
}
|
||||
38
src/main/java/com/l2jserver/model/id/CastleID.java
Normal file
38
src/main/java/com/l2jserver/model/id/CastleID.java
Normal 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);
|
||||
}
|
||||
}
|
||||
45
src/main/java/com/l2jserver/model/id/FortID.java
Normal file
45
src/main/java/com/l2jserver/model/id/FortID.java
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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> {
|
||||
}
|
||||
@@ -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> {
|
||||
}
|
||||
@@ -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));
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.l2jserver.routines;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.service.ServiceManager;
|
||||
import com.l2jserver.service.blowfish.BlowfishKeygenService;
|
||||
import com.l2jserver.service.cache.CacheService;
|
||||
import com.l2jserver.service.configuration.ConfigurationService;
|
||||
import com.l2jserver.service.database.DatabaseService;
|
||||
import com.l2jserver.service.game.scripting.ScriptingService;
|
||||
@@ -48,13 +50,14 @@ public class GameServerInitializationRoutine implements Routine<Boolean> {
|
||||
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
// serviceManager.start(LoggingService.class);
|
||||
serviceManager.start(CacheService.class);
|
||||
serviceManager.start(ConfigurationService.class);
|
||||
serviceManager.start(DatabaseService.class);
|
||||
|
||||
serviceManager.start(ScriptingService.class);
|
||||
serviceManager.start(TemplateService.class);
|
||||
|
||||
serviceManager.start(BlowfishKeygenService.class);
|
||||
serviceManager.start(NetworkService.class);
|
||||
return true;
|
||||
}
|
||||
|
||||
28
src/main/java/com/l2jserver/service/admin/AdminService.java
Normal file
28
src/main/java/com/l2jserver/service/admin/AdminService.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.service.admin;
|
||||
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service handles administrators in the server
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface AdminService extends Service {
|
||||
|
||||
}
|
||||
28
src/main/java/com/l2jserver/service/admin/GMService.java
Normal file
28
src/main/java/com/l2jserver/service/admin/GMService.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.service.admin;
|
||||
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service handles GM in the server
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface GMService extends Service {
|
||||
|
||||
}
|
||||
@@ -23,8 +23,18 @@ import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.ServiceStopException;
|
||||
|
||||
/**
|
||||
* This implementation of {@link BlowfishKeygenService} generates
|
||||
* cryptographically safe keys but at the cost of speed. The key generation is
|
||||
* much slower than on a pseudo-random generator.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SecureBlowfishKeygenService extends AbstractService implements
|
||||
BlowfishKeygenService {
|
||||
/**
|
||||
* The random number generator
|
||||
*/
|
||||
private RandomData random;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -84,7 +84,7 @@ public class EhCacheService extends AbstractService implements CacheService {
|
||||
@Override
|
||||
public Cache createCache(String name, int size) {
|
||||
Cache cache = new Cache(
|
||||
new CacheConfiguration("database-service", size)
|
||||
new CacheConfiguration(name, size)
|
||||
.memoryStoreEvictionPolicy(
|
||||
MemoryStoreEvictionPolicy.LRU)
|
||||
.overflowToDisk(true).eternal(false)
|
||||
|
||||
28
src/main/java/com/l2jserver/service/game/DuelService.java
Normal file
28
src/main/java/com/l2jserver/service/game/DuelService.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.service.game;
|
||||
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service handles duel events.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface DuelService extends Service {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.service.game;
|
||||
|
||||
import com.l2jserver.service.AbstractService;
|
||||
|
||||
/**
|
||||
* Default implementation for {@link DuelService}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class DuelServiceImpl extends AbstractService implements DuelService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.service.game;
|
||||
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service is responsible for managing the time in-game world.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface GameTimeService extends Service {
|
||||
/**
|
||||
* Returns the in-game time
|
||||
*
|
||||
* @return the game time
|
||||
*/
|
||||
int getGameTime();
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.service.game;
|
||||
|
||||
import com.l2jserver.service.AbstractService;
|
||||
|
||||
/**
|
||||
* Default implementation for {@link GameTimeService}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class GameTimeServiceImpl extends AbstractService implements
|
||||
GameTimeService {
|
||||
@Override
|
||||
public int getGameTime() {
|
||||
//TODO implement this!
|
||||
return (int) (System.currentTimeMillis() / 1000);
|
||||
}
|
||||
}
|
||||
28
src/main/java/com/l2jserver/service/game/PKService.java
Normal file
28
src/main/java/com/l2jserver/service/game/PKService.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.service.game;
|
||||
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service handles PK events.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface PKService extends Service {
|
||||
|
||||
}
|
||||
28
src/main/java/com/l2jserver/service/game/PVPService.java
Normal file
28
src/main/java/com/l2jserver/service/game/PVPService.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.service.game;
|
||||
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service handles PVP battles.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface PVPService extends Service {
|
||||
|
||||
}
|
||||
51
src/main/java/com/l2jserver/service/game/SpawnService.java
Normal file
51
src/main/java/com/l2jserver/service/game/SpawnService.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.service.game;
|
||||
|
||||
import com.l2jserver.model.world.capability.Spawnable;
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service is responsible for spawning monsters, npcs and players.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface SpawnService extends Service {
|
||||
/**
|
||||
* Spawns an object in the world
|
||||
*
|
||||
* @param spawnable
|
||||
* the spawnable object
|
||||
*/
|
||||
void spawn(Spawnable spawnable);
|
||||
|
||||
/**
|
||||
* Schedules an {@link Spawnable} object to be respawn in a certain time.
|
||||
*
|
||||
* @param spawnable
|
||||
* the spawnable object
|
||||
*/
|
||||
void scheduleRespawn(Spawnable spawnable);
|
||||
|
||||
/**
|
||||
* Unspawns an object from the world
|
||||
*
|
||||
* @param spawnable
|
||||
* the spawnable object
|
||||
*/
|
||||
void unspawn(Spawnable spawnable);
|
||||
}
|
||||
@@ -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.service.game;
|
||||
|
||||
import com.l2jserver.model.world.capability.Spawnable;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
|
||||
/**
|
||||
* Default implementation for {@link SpawnService}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SpawnServiceImpl extends AbstractService implements SpawnService {
|
||||
@Override
|
||||
public void spawn(Spawnable spawnable) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleRespawn(Spawnable spawnable) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unspawn(Spawnable spawnable) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.service.game.castle;
|
||||
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service is responsible for managing {@link Castle castles}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface CastleService extends Service {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.service.game.castle;
|
||||
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service is responsible for keeping a track on siege events. Once a siege
|
||||
* has begun it will perform all operations that need to be executed during a
|
||||
* siege. It will also reschedule the next one.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface SiegeService extends Service {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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.service.game.chat;
|
||||
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.id.object.ClanID;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.service.Service;
|
||||
import com.l2jserver.service.game.chat.channel.ChatChannel;
|
||||
import com.l2jserver.service.game.chat.channel.PrivateChatChannel;
|
||||
import com.l2jserver.service.game.chat.channel.PublicChatChannel;
|
||||
|
||||
/**
|
||||
* This service chatting in the server
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface ChatService extends Service {
|
||||
/**
|
||||
* @return the global {@link ChatChannel}
|
||||
*/
|
||||
PublicChatChannel getGlobalChannel();
|
||||
|
||||
/**
|
||||
* @param character
|
||||
* the character in the region
|
||||
* @return the global {@link ChatChannel}
|
||||
*/
|
||||
PublicChatChannel getRegionChannel(L2Character character);
|
||||
|
||||
/**
|
||||
* Get an private {@link ChatChannel} to {@link CharacterID}
|
||||
*
|
||||
* @param character
|
||||
* the target character
|
||||
* @return the private {@link ChatChannel}
|
||||
*/
|
||||
PrivateChatChannel getChannel(CharacterID character);
|
||||
|
||||
/**
|
||||
* @param clan
|
||||
* the clan
|
||||
* @return the public clan {@link ChatChannel}
|
||||
*/
|
||||
PublicChatChannel getChannel(ClanID clan);
|
||||
|
||||
// TODO party chat
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* 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.service.game.chat;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.id.object.ClanID;
|
||||
import com.l2jserver.model.world.Clan;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.game.chat.channel.ChatChannel;
|
||||
import com.l2jserver.service.game.chat.channel.ChatChannelListener;
|
||||
import com.l2jserver.service.game.chat.channel.PrivateChatChannel;
|
||||
import com.l2jserver.service.game.chat.channel.PublicChatChannel;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
/**
|
||||
* Default {@link ChatService} implementation
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SimpleChatService extends AbstractService implements ChatService {
|
||||
/**
|
||||
* The global chat channel
|
||||
*/
|
||||
private GlobalChatChannelImpl global;
|
||||
/**
|
||||
* The list of private chat channels
|
||||
*/
|
||||
// TODO remove private chats from disconnected characters. Maybe plugging it
|
||||
// in the NetworkService?
|
||||
private Map<CharacterID, PrivateChatChannelImpl> privateChannels;
|
||||
/**
|
||||
* The list of clan chat channels
|
||||
*/
|
||||
private Map<ClanID, ClanChatChannelImpl> clanChannels;
|
||||
|
||||
@Override
|
||||
public void start() throws ServiceStartException {
|
||||
this.global = new GlobalChatChannelImpl();
|
||||
this.privateChannels = CollectionFactory.newMap(null, null);
|
||||
this.clanChannels = CollectionFactory.newMap(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicChatChannel getGlobalChannel() {
|
||||
return global;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicChatChannel getRegionChannel(L2Character character) {
|
||||
// TODO Region chat channels
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrivateChatChannel getChannel(CharacterID character) {
|
||||
PrivateChatChannelImpl channel = privateChannels.get(character);
|
||||
if (channel == null) {
|
||||
channel = new PrivateChatChannelImpl(character);
|
||||
privateChannels.put(character, channel);
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicChatChannel getChannel(ClanID clan) {
|
||||
ClanChatChannelImpl channel = clanChannels.get(clan);
|
||||
if (channel == null) {
|
||||
channel = new ClanChatChannelImpl(clan);
|
||||
clanChannels.put(clan, channel);
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ChatChannel} abstract implementation
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
private abstract class ChatChannelImpl implements ChatChannel {
|
||||
/**
|
||||
* The list of all listeners on this channel
|
||||
*/
|
||||
protected final Set<ChatChannelListener> listeners = CollectionFactory
|
||||
.newSet(null);
|
||||
|
||||
@Override
|
||||
public void send(CharacterID sender, String message) {
|
||||
for (final ChatChannelListener listener : listeners) {
|
||||
listener.onMessage(this, sender, message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChatChannelListener(ChatChannelListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeChatChannelListener(ChatChannelListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link PrivateChatChannel} implementation
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
private class PrivateChatChannelImpl extends ChatChannelImpl implements
|
||||
PrivateChatChannel {
|
||||
private final CharacterID character;
|
||||
|
||||
public PrivateChatChannelImpl(CharacterID character) {
|
||||
this.character = character;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharacterID getTarget() {
|
||||
return character;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Global {@link PublicChatChannel} implemenetation
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
private class GlobalChatChannelImpl extends ChatChannelImpl implements
|
||||
PublicChatChannel {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link PublicChatChannel} implemenetation for {@link Clan clans}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
private class ClanChatChannelImpl extends ChatChannelImpl implements
|
||||
PublicChatChannel {
|
||||
/**
|
||||
* The clan ID
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private final ClanID clanID;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param clanID
|
||||
*/
|
||||
public ClanChatChannelImpl(ClanID clanID) {
|
||||
this.clanID = clanID;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.service.game.chat.channel;
|
||||
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
|
||||
/**
|
||||
* The {@link ChatChannel} object is used to send messages to a channel.
|
||||
* <p>
|
||||
* Note that this is a base for all types of channel.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @see PrivateChatChannel
|
||||
* @see PublicChatChannel
|
||||
*/
|
||||
public interface ChatChannel {
|
||||
/**
|
||||
* Sends a message to this channel
|
||||
*
|
||||
* @param sender
|
||||
* the character sending the message
|
||||
* @param message
|
||||
* the message to be sent
|
||||
*/
|
||||
void send(CharacterID sender, String message);
|
||||
|
||||
/**
|
||||
* Adds a {@link ChatChannelListener} that will be notified once a message
|
||||
* has been received.
|
||||
*
|
||||
* @param listener
|
||||
* the listener
|
||||
*/
|
||||
void addChatChannelListener(ChatChannelListener listener);
|
||||
|
||||
/**
|
||||
* Removes a {@link ChatChannelListener}.
|
||||
*
|
||||
* @param listener
|
||||
* the listener
|
||||
*/
|
||||
void removeChatChannelListener(ChatChannelListener listener);
|
||||
}
|
||||
@@ -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.service.game.chat.channel;
|
||||
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
|
||||
/**
|
||||
* This listener is used to received notifications once a new message is sent to
|
||||
* an given {@link ChatChannel}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface ChatChannelListener {
|
||||
/**
|
||||
* Notification of a new message received
|
||||
*
|
||||
* @param channel
|
||||
* the chat channel
|
||||
* @param source
|
||||
* the character sending this message
|
||||
* @param message
|
||||
* the message
|
||||
*/
|
||||
void onMessage(ChatChannel channel, CharacterID source, String message);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.service.game.chat.channel;
|
||||
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
|
||||
/**
|
||||
* An private {@link ChatChannel}. Please note that the concept of "private"
|
||||
* does not mean it requires a password or something like that to join, but the
|
||||
* message is only broadcasted to a single character (i.e. private messages).
|
||||
* The target can be retrieved by {@link #getTarget()}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface PrivateChatChannel extends ChatChannel {
|
||||
/**
|
||||
* @return the target of this private chat channel.
|
||||
*/
|
||||
CharacterID getTarget();
|
||||
}
|
||||
@@ -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.service.game.chat.channel;
|
||||
|
||||
/**
|
||||
* An public {@link ChatChannel}. Please note that the concept of "public" does
|
||||
* not mean it is available to anyone, but there are more than 2 player chatting
|
||||
* (i.e. clan, global, region, etc...)
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface PublicChatChannel extends ChatChannel {
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.service.game.clan;
|
||||
|
||||
import com.l2jserver.model.world.Clan;
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service is responsible for managing {@link Clan clans}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface ClanService extends Service {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.service.game.clan;
|
||||
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service manages Fort instances.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface FortService extends Service {
|
||||
|
||||
}
|
||||
25
src/main/java/com/l2jserver/service/game/region/Region.java
Normal file
25
src/main/java/com/l2jserver/service/game/region/Region.java
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.service.game.region;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public interface Region {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.service.game.region;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service manages Lineage II Regions
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface RegionService extends Service {
|
||||
Region getRegion(L2Character character);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class BufferUtils {
|
||||
* the string
|
||||
*/
|
||||
public static final void writeString(ChannelBuffer buffer, String str) {
|
||||
if (str != null) {
|
||||
if (str != null && str.length() > 0) {
|
||||
final int len = str.length();
|
||||
for (int i = 0; i < len; i++) {
|
||||
buffer.writeChar(str.charAt(i));
|
||||
|
||||
65
src/main/java/com/l2jserver/util/calculator/Calculator.java
Normal file
65
src/main/java/com/l2jserver/util/calculator/Calculator.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.util.calculator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
/**
|
||||
* An calculator is used to compute data and outputs its result. Note also, that
|
||||
* an calculator is also an operation, that way you can nest calculators.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class Calculator implements Operation<Double> {
|
||||
/**
|
||||
* List of operations in this calculator
|
||||
*/
|
||||
private final List<Operation<Double>> operations = CollectionFactory
|
||||
.newList(null);
|
||||
|
||||
/**
|
||||
* Adds a new operation to this calculator. Operations with the same order
|
||||
* are replaced.
|
||||
*
|
||||
* @param order
|
||||
* the operation order, starting at 0.
|
||||
* @param operation
|
||||
* the operation
|
||||
*/
|
||||
public void add(int order, Operation<Double> operation) {
|
||||
operations.add(order, operation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the result and output it
|
||||
*
|
||||
* @return the computed value
|
||||
*/
|
||||
public double compute() {
|
||||
return perform(0.00);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double perform(Double result) {
|
||||
for (final Operation<Double> operation : operations) {
|
||||
result = operation.perform(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -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.util.calculator;
|
||||
|
||||
/**
|
||||
* This operation performs a division: <blockquote><code>chain value /
|
||||
* value</code></blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class DivisionOperation implements Operation<Double> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
private final double value;
|
||||
|
||||
public DivisionOperation(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double perform(Double value) {
|
||||
return value / this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.util.calculator;
|
||||
|
||||
/**
|
||||
* This operation performs an modulus: <blockquote><code>|chain value|</code>
|
||||
* </blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ModulusOperation implements Operation<Double> {
|
||||
@Override
|
||||
public Double perform(Double value) {
|
||||
if (value < 0)
|
||||
return value * -1;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -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.util.calculator;
|
||||
|
||||
/**
|
||||
* This operation performs an multiplication: <blockquote><code>chain value *
|
||||
* value</code></blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class MultiplicationOperation implements Operation<Double> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
private final double value;
|
||||
|
||||
public MultiplicationOperation(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double perform(Double value) {
|
||||
return value * this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.util.calculator;
|
||||
|
||||
/**
|
||||
* This operation performs an negate: <blockquote><code>-chain value</code>
|
||||
* </blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NegateOperation implements Operation<Double> {
|
||||
@Override
|
||||
public Double perform(Double value) {
|
||||
return -value;
|
||||
}
|
||||
}
|
||||
31
src/main/java/com/l2jserver/util/calculator/Operation.java
Normal file
31
src/main/java/com/l2jserver/util/calculator/Operation.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.util.calculator;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Operation<T extends Number> {
|
||||
/**
|
||||
* Performs the operation in the calculation process
|
||||
*
|
||||
* @param value
|
||||
* the chain input value
|
||||
* @return the output value
|
||||
*/
|
||||
T perform(T value);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.util.calculator;
|
||||
|
||||
/**
|
||||
* This operation performs a multiplication: <blockquote><code>chain value *
|
||||
* (value / 100)</code></blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class PercentOperation extends MultiplicationOperation {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
public PercentOperation(double value) {
|
||||
super(value / 100);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.util.calculator;
|
||||
|
||||
/**
|
||||
* This operation performs an rounding in the number.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class RoundOperation implements Operation<Double> {
|
||||
@Override
|
||||
public Double perform(Double value) {
|
||||
return (double) Math.round(value);
|
||||
}
|
||||
}
|
||||
@@ -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.util.calculator;
|
||||
|
||||
/**
|
||||
* This operation performs an set. It ignores the input value and return its
|
||||
* own.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SetOperation implements Operation<Double> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
private final double value;
|
||||
|
||||
public SetOperation(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double perform(Double value) {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -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.util.calculator;
|
||||
|
||||
/**
|
||||
* This operation performs an subtraction: <blockquote><code>chain value -
|
||||
* value</code></blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SubtractOperation implements Operation<Double> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
private final double value;
|
||||
|
||||
public SubtractOperation(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double perform(Double value) {
|
||||
return value - this.value;
|
||||
}
|
||||
}
|
||||
@@ -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.util.calculator;
|
||||
|
||||
/**
|
||||
* This operation performs a sum: <blockquote><code>chain value +
|
||||
* value</code></blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SumOperation implements Operation<Double> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
private final double value;
|
||||
|
||||
public SumOperation(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double perform(Double value) {
|
||||
return value + this.value;
|
||||
}
|
||||
}
|
||||
57
src/main/java/com/l2jserver/util/exception/L2Exception.java
Normal file
57
src/main/java/com/l2jserver/util/exception/L2Exception.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.util.exception;
|
||||
|
||||
/**
|
||||
* Base exception for Lineage 2
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class L2Exception extends Exception {
|
||||
/**
|
||||
* Default Serial Version UID
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see Exception#Exception()
|
||||
*/
|
||||
public L2Exception() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Exception#Exception(String, Throwable)
|
||||
*/
|
||||
public L2Exception(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Exception#Exception(String)
|
||||
*/
|
||||
public L2Exception(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Exception#Exception(Throwable)
|
||||
*/
|
||||
public L2Exception(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
104
src/test/java/com/l2jserver/util/calculator/CalculatorTest.java
Normal file
104
src/test/java/com/l2jserver/util/calculator/CalculatorTest.java
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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.util.calculator;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class CalculatorTest {
|
||||
@Test
|
||||
public void testSimple() {
|
||||
final Calculator calc = new Calculator();
|
||||
|
||||
calc.add(0, new SetOperation(10));
|
||||
calc.add(1, new MultiplicationOperation(2));
|
||||
calc.add(2, new SetOperation(30));
|
||||
|
||||
Assert.assertEquals(30.0, calc.compute());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPercent() {
|
||||
final Calculator calc = new Calculator();
|
||||
|
||||
calc.add(0, new SetOperation(10));
|
||||
calc.add(1, new MultiplicationOperation(2));
|
||||
calc.add(2, new PercentOperation(75));
|
||||
|
||||
Assert.assertEquals(15.0, calc.compute());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplex() {
|
||||
final Calculator calc = new Calculator();
|
||||
|
||||
calc.add(0, new SetOperation(10));
|
||||
calc.add(1, new MultiplicationOperation(2));
|
||||
calc.add(2, new PercentOperation(75));
|
||||
calc.add(3, new SumOperation(3));
|
||||
calc.add(4, new SubtractOperation(8));
|
||||
calc.add(5, new DivisionOperation(2));
|
||||
|
||||
Assert.assertEquals(5.0, calc.compute());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNesting() {
|
||||
final Calculator calc1 = new Calculator();
|
||||
|
||||
calc1.add(0, new SetOperation(10));
|
||||
calc1.add(1, new MultiplicationOperation(2));
|
||||
calc1.add(2, new PercentOperation(75));
|
||||
calc1.add(3, new SumOperation(3));
|
||||
calc1.add(4, new SubtractOperation(8));
|
||||
calc1.add(5, new DivisionOperation(2));
|
||||
Assert.assertEquals(5.0, calc1.compute());
|
||||
|
||||
final Calculator calc2 = new Calculator();
|
||||
|
||||
calc2.add(0, new MultiplicationOperation(2));
|
||||
calc2.add(1, new PercentOperation(75));
|
||||
calc2.add(2, new SumOperation(3));
|
||||
calc2.add(3, new SubtractOperation(8));
|
||||
calc2.add(4, new DivisionOperation(2));
|
||||
Assert.assertEquals(-2.5, calc2.compute());
|
||||
|
||||
final Calculator calc3 = new Calculator();
|
||||
calc3.add(0, calc1);
|
||||
calc3.add(1, calc2);
|
||||
|
||||
Assert.assertEquals(1.25, calc3.compute());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRounding() {
|
||||
final Calculator calc1 = new Calculator();
|
||||
|
||||
calc1.add(0, new MultiplicationOperation(2));
|
||||
calc1.add(1, new PercentOperation(75));
|
||||
calc1.add(2, new SumOperation(3));
|
||||
calc1.add(3, new SubtractOperation(8.1));
|
||||
calc1.add(4, new DivisionOperation(2));
|
||||
calc1.add(5, new RoundOperation());
|
||||
Assert.assertEquals(-3.0, calc1.compute());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user