From 9f7b05c7a8152693fcd2b37fbe1f8fd6d65bce05 Mon Sep 17 00:00:00 2001 From: Rogiel Date: Tue, 20 Dec 2011 02:34:16 -0200 Subject: [PATCH] Implements item shortcut creation and deleting --- .../distribution/sql/sql/actor_skill.sql | 4 +- .../distribution/sql/sql/character.sql | 4 +- .../distribution/sql/sql/character_friend.sql | 2 +- .../sql/sql/character_shortcut.sql | 15 +- .../distribution/sql/sql/clan.sql | 4 +- .../distribution/sql/sql/item.sql | 4 +- .../distribution/sql/sql/log_chat.sql | 4 +- .../distribution/sql/sql/npc.sql | 2 +- .../java/com/l2jserver/GameServerModule.java | 4 +- .../java/com/l2jserver/L2JGameServerMain.java | 6 +- .../game/net/codec/Lineage2PacketReader.java | 6 + .../client/CM_CHAR_SHORTCUT_CREATE.java | 125 ++++++ .../client/CM_CHAR_SHORTCUT_REMOVE.java | 77 ++++ .../packet/server/SM_CHAR_SHORTCUT_LIST.java | 66 +++ .../server/SM_CHAR_SHORTCUT_REGISTER.java | 62 +++ .../com/l2jserver/model/dao/CharacterDAO.java | 3 +- .../model/dao/CharacterFriendDAO.java | 3 +- .../model/dao/CharacterShortcutDAO.java | 43 ++ .../l2jserver/model/dao/ChatMessageDAO.java | 3 +- .../java/com/l2jserver/model/dao/ClanDAO.java | 3 +- .../java/com/l2jserver/model/dao/ItemDAO.java | 7 +- .../java/com/l2jserver/model/dao/NPCDAO.java | 3 +- .../java/com/l2jserver/model/dao/PetDAO.java | 3 +- .../model/game/CharacterShortcut.java | 383 ++++++++++++++++++ .../model/id/CharacterShortcutID.java | 54 +++ .../java/com/l2jserver/model/id/ObjectID.java | 3 +- .../provider/CharacterShortcutIDProvider.java | 29 ++ .../model/id/provider/IDProviderModule.java | 5 +- .../l2jserver/model/world/WorldObject.java | 3 +- .../character/CharacterShortcutContainer.java | 96 ++--- .../event/CharacterCreateShortcutEvent.java | 86 ++++ .../event/CharacterDeleteShortcutEvent.java | 86 ++++ .../event/CharacterListShortcutEvent.java | 88 ++++ .../com/l2jserver/service/ServiceModule.java | 6 + .../service/database/DerbyDAOModule.java | 57 --- .../service/database/H2DAOModule.java | 60 --- ...ySQL5DAOModule.java => JDBCDAOModule.java} | 32 +- .../database/jdbc/JDBCCharacterDAO.java | 2 +- .../database/jdbc/JDBCCharacterFriendDAO.java | 2 +- .../jdbc/JDBCCharacterShortcutDAO.java | 298 ++++++++++++++ .../database/jdbc/JDBCChatMessageDAO.java | 2 +- .../service/database/jdbc/JDBCClanDAO.java | 2 +- .../service/database/jdbc/JDBCItemDAO.java | 10 +- .../service/database/jdbc/JDBCNPCDAO.java | 2 +- .../jdbc/derby/DerbyCharacterDAO.java | 55 --- .../jdbc/derby/DerbyCharacterFriendDAO.java | 46 --- .../jdbc/derby/DerbyChatMessageDAO.java | 46 --- .../database/jdbc/derby/DerbyClanDAO.java | 46 --- .../database/jdbc/derby/DerbyItemDAO.java | 49 --- .../database/jdbc/derby/DerbyNPCDAO.java | 46 --- .../database/jdbc/h2/H2CharacterDAO.java | 54 --- .../jdbc/h2/H2CharacterFriendDAO.java | 46 --- .../database/jdbc/h2/H2ChatMessageDAO.java | 46 --- .../service/database/jdbc/h2/H2ClanDAO.java | 46 --- .../service/database/jdbc/h2/H2ItemDAO.java | 49 --- .../service/database/jdbc/h2/H2NPCDAO.java | 46 --- .../jdbc/mysql5/MySQL5CharacterDAO.java | 55 --- .../jdbc/mysql5/MySQL5CharacterFriendDAO.java | 46 --- .../jdbc/mysql5/MySQL5ChatMessageDAO.java | 46 --- .../database/jdbc/mysql5/MySQL5ClanDAO.java | 46 --- .../database/jdbc/mysql5/MySQL5ItemDAO.java | 49 --- .../database/jdbc/mysql5/MySQL5NPCDAO.java | 46 --- .../game/character/CharacterServiceImpl.java | 16 +- .../game/character/ShortcutService.java | 62 +++ .../character/ShortcutServiceException.java | 68 ++++ .../game/character/ShortcutServiceImpl.java | 107 +++++ .../ShortcutSlotEmptyServiceException.java | 30 ++ .../ShortcutSlotNotFreeServiceException.java | 30 ++ .../broadcast/BroadcastServiceImpl.java | 25 +- .../id/provider/CharacterIDProviderTest.java | 4 +- .../template/StaticTemplateServiceTest.java | 4 +- 71 files changed, 1848 insertions(+), 1120 deletions(-) create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/client/CM_CHAR_SHORTCUT_CREATE.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/client/CM_CHAR_SHORTCUT_REMOVE.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/server/SM_CHAR_SHORTCUT_LIST.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/server/SM_CHAR_SHORTCUT_REGISTER.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/CharacterShortcutDAO.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/model/game/CharacterShortcut.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/CharacterShortcutID.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/provider/CharacterShortcutIDProvider.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/event/CharacterCreateShortcutEvent.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/event/CharacterDeleteShortcutEvent.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/event/CharacterListShortcutEvent.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/DerbyDAOModule.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/H2DAOModule.java rename l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/{MySQL5DAOModule.java => JDBCDAOModule.java} (57%) create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCCharacterShortcutDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyCharacterDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyCharacterFriendDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyChatMessageDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyClanDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyItemDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyNPCDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2CharacterDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2CharacterFriendDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2ChatMessageDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2ClanDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2ItemDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2NPCDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5CharacterDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5CharacterFriendDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5ChatMessageDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5ClanDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5ItemDAO.java delete mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5NPCDAO.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutService.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutServiceException.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutServiceImpl.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutSlotEmptyServiceException.java create mode 100644 l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutSlotNotFreeServiceException.java diff --git a/l2jserver2-gameserver/distribution/sql/sql/actor_skill.sql b/l2jserver2-gameserver/distribution/sql/sql/actor_skill.sql index 1109f650c..6a2209359 100644 --- a/l2jserver2-gameserver/distribution/sql/sql/actor_skill.sql +++ b/l2jserver2-gameserver/distribution/sql/sql/actor_skill.sql @@ -1,8 +1,8 @@ -CREATE TABLE IF NOT EXISTS `actor_skill` ( +CREATE TABLE `actor_skill` ( `actor_id` int(10) NOT NULL, `skill_id` int(10) NOT NULL, `level` int(2) NOT NULL DEFAULT '1', PRIMARY KEY (`actor_id`,`skill_id`), KEY `actor_id` (`actor_id`), KEY `skill_id` (`skill_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; \ No newline at end of file +); \ No newline at end of file diff --git a/l2jserver2-gameserver/distribution/sql/sql/character.sql b/l2jserver2-gameserver/distribution/sql/sql/character.sql index 6454f1328..9e082315f 100644 --- a/l2jserver2-gameserver/distribution/sql/sql/character.sql +++ b/l2jserver2-gameserver/distribution/sql/sql/character.sql @@ -1,4 +1,4 @@ -CREATE TABLE IF NOT EXISTS `character` ( +CREATE TABLE `character` ( `character_id` int(12) NOT NULL, `account_id` varchar(50) NOT NULL, `clan_id` int(10) DEFAULT NULL, @@ -23,4 +23,4 @@ CREATE TABLE IF NOT EXISTS `character` ( KEY `account_id` (`account_id`), KEY `name` (`name`), KEY `clan_id` (`clan_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; \ No newline at end of file +); \ No newline at end of file diff --git a/l2jserver2-gameserver/distribution/sql/sql/character_friend.sql b/l2jserver2-gameserver/distribution/sql/sql/character_friend.sql index dac7f0b88..2fea472d4 100644 --- a/l2jserver2-gameserver/distribution/sql/sql/character_friend.sql +++ b/l2jserver2-gameserver/distribution/sql/sql/character_friend.sql @@ -2,4 +2,4 @@ CREATE TABLE `character_friend` ( `character_id` int(10) NOT NULL, `character_id_friend` int(10) NOT NULL, PRIMARY KEY (`character_id`,`character_id_friend`) -) ENGINE=MyISAM; \ No newline at end of file +); \ No newline at end of file diff --git a/l2jserver2-gameserver/distribution/sql/sql/character_shortcut.sql b/l2jserver2-gameserver/distribution/sql/sql/character_shortcut.sql index f434f9323..f3d644eeb 100644 --- a/l2jserver2-gameserver/distribution/sql/sql/character_shortcut.sql +++ b/l2jserver2-gameserver/distribution/sql/sql/character_shortcut.sql @@ -1,12 +1,15 @@ -CREATE TABLE IF NOT EXISTS `character_shortcut` ( +CREATE TABLE `character_shortcut` ( + `shortcut_id` int(10) NOT NULL AUTO_INCREMENT, `character_id` int(10) NOT NULL, - `shortcut_id` int(10) DEFAULT NULL, `slot` int(2) NOT NULL, `page` int(1) NOT NULL, `type` enum('ITEM','SKILL','ACTION','MACRO','RECIPE','TPBOOKMARK') NOT NULL, + `object_id` int(10) NOT NULL, `level` int(2) DEFAULT NULL, - `character_type` int(10) NOT NULL, - PRIMARY KEY (`character_id`,`slot`,`page`), + `character_type` int(10) DEFAULT NULL, + PRIMARY KEY (`shortcut_id`), + UNIQUE KEY `character_id-slot-page` (`character_id`,`slot`,`page`), KEY `character_id` (`character_id`), - KEY `shortcut_id` (`shortcut_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; \ No newline at end of file + KEY `character_id-page` (`character_id`,`page`), + KEY `character_id-type` (`character_id`,`type`) +); \ No newline at end of file diff --git a/l2jserver2-gameserver/distribution/sql/sql/clan.sql b/l2jserver2-gameserver/distribution/sql/sql/clan.sql index 8cf3b35f6..38b907bb8 100644 --- a/l2jserver2-gameserver/distribution/sql/sql/clan.sql +++ b/l2jserver2-gameserver/distribution/sql/sql/clan.sql @@ -1,6 +1,6 @@ -CREATE TABLE IF NOT EXISTS `clan` ( +CREATE TABLE `clan` ( `clan_id` int(10) NOT NULL, `character_id_leader` int(10) NOT NULL, PRIMARY KEY (`clan_id`), KEY `character_id_leader` (`character_id_leader`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; \ No newline at end of file +); \ No newline at end of file diff --git a/l2jserver2-gameserver/distribution/sql/sql/item.sql b/l2jserver2-gameserver/distribution/sql/sql/item.sql index 2bf9dabe9..5f1cf9d35 100644 --- a/l2jserver2-gameserver/distribution/sql/sql/item.sql +++ b/l2jserver2-gameserver/distribution/sql/sql/item.sql @@ -1,4 +1,4 @@ -CREATE TABLE IF NOT EXISTS `item` ( +CREATE TABLE `item` ( `item_id` int(12) NOT NULL, `template_id` int(10) NOT NULL, `character_id` int(12) DEFAULT NULL, @@ -11,4 +11,4 @@ CREATE TABLE IF NOT EXISTS `item` ( PRIMARY KEY (`item_id`), KEY `character_id` (`character_id`), KEY `template_id` (`template_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; \ No newline at end of file +); \ No newline at end of file diff --git a/l2jserver2-gameserver/distribution/sql/sql/log_chat.sql b/l2jserver2-gameserver/distribution/sql/sql/log_chat.sql index 5b81f7a45..5b7bca172 100644 --- a/l2jserver2-gameserver/distribution/sql/sql/log_chat.sql +++ b/l2jserver2-gameserver/distribution/sql/sql/log_chat.sql @@ -1,4 +1,4 @@ -CREATE TABLE IF NOT EXISTS `log_chat` ( +CREATE TABLE `log_chat` ( `message_id` int(12) NOT NULL AUTO_INCREMENT, `type` enum('ALL','SHOUT','TELL','PARTY','CLAN','GM','PETITION_PLAYER','PETITION_GM','TRADE','ALLIANCE','ANNOUNCEMENT','BOAT','L2FRIEND','MSNCHAT','PARTYMATCH_ROOM','PARTYROOM_COMMANDER','PARTYROOM_ALL','HERO_VOICE','CRITICAL_ANNOUNCE','SCREEN_ANNOUNCE','BATTLEFIELD','MPCC_ROOM') NOT NULL, `channel_id` int(12) NOT NULL, @@ -6,4 +6,4 @@ CREATE TABLE IF NOT EXISTS `log_chat` ( `date` TIMESTAMP NOT NULL, `message` text NOT NULL, PRIMARY KEY (`message_id`) -) ENGINE=MyISAM; \ No newline at end of file +); \ No newline at end of file diff --git a/l2jserver2-gameserver/distribution/sql/sql/npc.sql b/l2jserver2-gameserver/distribution/sql/sql/npc.sql index 52f4fada5..0d0a33e84 100644 --- a/l2jserver2-gameserver/distribution/sql/sql/npc.sql +++ b/l2jserver2-gameserver/distribution/sql/sql/npc.sql @@ -13,7 +13,7 @@ CREATE TABLE `npc` ( KEY `point` (`point_x`,`point_y`,`point_z`,`point_angle`), KEY `xy` (`point_x`,`point_y`), KEY `xyz` (`point_x`,`point_y`,`point_z`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +); -- -- STATIC DATA diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/GameServerModule.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/GameServerModule.java index 799ce5b75..2305e5a18 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/GameServerModule.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/GameServerModule.java @@ -20,7 +20,7 @@ import com.google.inject.AbstractModule; import com.google.inject.Module; import com.l2jserver.model.id.provider.IDProviderModule; import com.l2jserver.service.ServiceModule; -import com.l2jserver.service.database.MySQL5DAOModule; +import com.l2jserver.service.database.JDBCDAOModule; /** * The game server Google Guice {@link Module}. @@ -32,6 +32,6 @@ public class GameServerModule extends AbstractModule { protected void configure() { install(new ServiceModule()); install(new IDProviderModule()); - install(new MySQL5DAOModule()); + install(new JDBCDAOModule()); } } diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/L2JGameServerMain.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/L2JGameServerMain.java index 1394ad5fa..0b2df8d12 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/L2JGameServerMain.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/L2JGameServerMain.java @@ -23,6 +23,7 @@ import com.l2jserver.service.cache.CacheService; import com.l2jserver.service.configuration.ConfigurationService; import com.l2jserver.service.database.DatabaseService; import com.l2jserver.service.game.character.CharacterService; +import com.l2jserver.service.game.character.ShortcutService; import com.l2jserver.service.game.chat.ChatService; import com.l2jserver.service.game.item.ItemService; import com.l2jserver.service.game.map.pathing.PathingService; @@ -43,8 +44,9 @@ public class L2JGameServerMain { ConfigurationService.class, DatabaseService.class, WorldIDService.class, ScriptingService.class, TemplateService.class, ChatService.class, NPCService.class, - ItemService.class, CharacterService.class, PathingService.class, - BlowfishKeygenService.class, NetworkService.class }; + ItemService.class, CharacterService.class, ShortcutService.class, + PathingService.class, BlowfishKeygenService.class, + NetworkService.class }; /** * Main method diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/codec/Lineage2PacketReader.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/codec/Lineage2PacketReader.java index 262e7f384..67b2aa39d 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/codec/Lineage2PacketReader.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/codec/Lineage2PacketReader.java @@ -41,6 +41,8 @@ import com.l2jserver.game.net.packet.client.CM_CHAR_OPEN_MAP; import com.l2jserver.game.net.packet.client.CM_CHAR_POSITION; import com.l2jserver.game.net.packet.client.CM_CHAR_REQ_INVENTORY; import com.l2jserver.game.net.packet.client.CM_CHAR_SELECT; +import com.l2jserver.game.net.packet.client.CM_CHAR_SHORTCUT_REMOVE; +import com.l2jserver.game.net.packet.client.CM_CHAR_SHORTCUT_CREATE; import com.l2jserver.game.net.packet.client.CM_CHAR_TARGET_UNSELECT; import com.l2jserver.game.net.packet.client.CM_ENTER_WORLD; import com.l2jserver.game.net.packet.client.CM_EXT_REQ_ALL_FORTRESS_INFO; @@ -196,6 +198,10 @@ public class Lineage2PacketReader extends OneToOneDecoder { return CM_ITEM_DESTROY.class; case CM_CHAR_TARGET_UNSELECT.OPCODE: return CM_CHAR_TARGET_UNSELECT.class; + case CM_CHAR_SHORTCUT_CREATE.OPCODE: + return CM_CHAR_SHORTCUT_CREATE.class; + case CM_CHAR_SHORTCUT_REMOVE.OPCODE: + return CM_CHAR_SHORTCUT_REMOVE.class; default: logger.warn("Unknown packet for 0x{}", Integer.toHexString(opcode)); break; diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/client/CM_CHAR_SHORTCUT_CREATE.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/client/CM_CHAR_SHORTCUT_CREATE.java new file mode 100644 index 000000000..75d85b291 --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/client/CM_CHAR_SHORTCUT_CREATE.java @@ -0,0 +1,125 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.game.net.packet.client; + +import org.jboss.netty.buffer.ChannelBuffer; + +import com.google.inject.Inject; +import com.l2jserver.game.net.Lineage2Client; +import com.l2jserver.game.net.packet.AbstractClientPacket; +import com.l2jserver.model.game.CharacterShortcut.ShortcutActorType; +import com.l2jserver.model.game.CharacterShortcut.ShortcutType; +import com.l2jserver.model.id.object.ItemID; +import com.l2jserver.model.id.object.provider.ItemIDProvider; +import com.l2jserver.model.world.Item; +import com.l2jserver.model.world.L2Character; +import com.l2jserver.service.game.character.ShortcutSlotNotFreeServiceException; +import com.l2jserver.service.game.character.ShortcutService; + +/** + * Completes the creation of an character. Creates the object, inserts into the + * database and notifies the client about the status of the operation. + * + * @author Rogiel + */ +public class CM_CHAR_SHORTCUT_CREATE extends AbstractClientPacket { + /** + * The packet OPCODE + */ + public static final int OPCODE = 0x3d; + + /** + * The {@link ShortcutService} + */ + private final ShortcutService shortcutService; + /** + * The {@link ItemID} provider + */ + private final ItemIDProvider itemIdProvider; + + /** + * The shortcut type + */ + private ShortcutType type; + /** + * The shortcut object ID (depends on type) + */ + private int objectId; + /** + * The slot + */ + private int slot; + /** + * The page + */ + private int page; + /** + * The skill level + */ + @SuppressWarnings("unused") + private int level; + /** + * Whether the shortcut is an for an character(1) or a pet(2) + */ + @SuppressWarnings("unused") + private ShortcutActorType actorType; + + /** + * @param shortcutService + * the shortcut service + * @param itemIdProvider + * the item id provider + */ + @Inject + private CM_CHAR_SHORTCUT_CREATE(ShortcutService shortcutService, + ItemIDProvider itemIdProvider) { + this.shortcutService = shortcutService; + this.itemIdProvider = itemIdProvider; + } + + @Override + public void read(Lineage2Client conn, ChannelBuffer buffer) { + type = ShortcutType.fromID(buffer.readInt()); + int slot = buffer.readInt(); + objectId = buffer.readInt(); + level = buffer.readInt(); + actorType = ShortcutActorType.fromID(buffer.readInt()); + + this.slot = slot % 12; + this.page = slot / 12; + } + + @Override + public void process(final Lineage2Client conn) { + final L2Character character = conn.getCharacter(); + try { + switch (type) { + case ITEM: + final ItemID itemID = itemIdProvider.resolveID(objectId); + final Item item = itemID.getObject(); + if (item == null) { + conn.sendActionFailed(); + return; + } + shortcutService.create(character, item, page, slot); + break; + } + } catch (ShortcutSlotNotFreeServiceException e) { + conn.sendActionFailed(); + } + } +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/client/CM_CHAR_SHORTCUT_REMOVE.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/client/CM_CHAR_SHORTCUT_REMOVE.java new file mode 100644 index 000000000..8612212d9 --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/client/CM_CHAR_SHORTCUT_REMOVE.java @@ -0,0 +1,77 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.game.net.packet.client; + +import org.jboss.netty.buffer.ChannelBuffer; + +import com.google.inject.Inject; +import com.l2jserver.game.net.Lineage2Client; +import com.l2jserver.game.net.packet.AbstractClientPacket; +import com.l2jserver.service.game.character.ShortcutService; +import com.l2jserver.service.game.character.ShortcutSlotEmptyServiceException; + +/** + * Completes the creation of an character. Creates the object, inserts into the + * database and notifies the client about the status of the operation. + * + * @author Rogiel + */ +public class CM_CHAR_SHORTCUT_REMOVE extends AbstractClientPacket { + /** + * The packet OPCODE + */ + public static final int OPCODE = 0x3f; + + /** + * The {@link ShortcutService} + */ + private final ShortcutService shortcutService; + + /** + * The slot + */ + private int slot; + /** + * The page + */ + private int page; + + /** + * @param shortcutService + * the shortcut service + */ + @Inject + private CM_CHAR_SHORTCUT_REMOVE(ShortcutService shortcutService) { + this.shortcutService = shortcutService; + } + + @Override + public void read(Lineage2Client conn, ChannelBuffer buffer) { + int slot = buffer.readInt(); + this.slot = slot % 12; + this.page = slot / 12; + } + + @Override + public void process(final Lineage2Client conn) { + try { + shortcutService.remove(conn.getCharacter(), page, slot); + } catch (ShortcutSlotEmptyServiceException e) { + conn.sendActionFailed(); + } + } +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/server/SM_CHAR_SHORTCUT_LIST.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/server/SM_CHAR_SHORTCUT_LIST.java new file mode 100644 index 000000000..5fed1804f --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/server/SM_CHAR_SHORTCUT_LIST.java @@ -0,0 +1,66 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.game.net.packet.server; + +import org.jboss.netty.buffer.ChannelBuffer; + +import com.l2jserver.game.net.Lineage2Client; +import com.l2jserver.game.net.packet.AbstractServerPacket; +import com.l2jserver.model.game.CharacterShortcut; +import com.l2jserver.model.world.character.CharacterShortcutContainer; + +/** + * This packet sends to the client his shortcut list + * + * @author Rogiel + */ +public class SM_CHAR_SHORTCUT_LIST extends AbstractServerPacket { + /** + * The packet OPCODE + */ + public static final int OPCODE = 0x45; + + /** + * The shortcut list + */ + private final CharacterShortcutContainer shortcuts; + + public SM_CHAR_SHORTCUT_LIST(CharacterShortcutContainer shortcuts) { + super(OPCODE); + this.shortcuts = shortcuts; + } + + @Override + public void write(Lineage2Client conn, ChannelBuffer buffer) { + buffer.writeInt(shortcuts.getShortcutCount()); + for (final CharacterShortcut shortcut : shortcuts) { + buffer.writeInt(shortcut.getType().id); + buffer.writeInt(shortcut.getPage() * 12 + shortcut.getSlot()); + switch (shortcut.getType()) { + case ITEM: + buffer.writeInt(shortcut.getItemID().getID()); + buffer.writeInt(0x01); // unk1f + buffer.writeInt(-1); // reuse group + buffer.writeInt(0x00); // unk2 + buffer.writeInt(0x00); // unk3 + buffer.writeShort(0x00); // unk4 + buffer.writeShort(0x00); // unk5 + break; + } + } + } +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/server/SM_CHAR_SHORTCUT_REGISTER.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/server/SM_CHAR_SHORTCUT_REGISTER.java new file mode 100644 index 000000000..58afeb0f7 --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/server/SM_CHAR_SHORTCUT_REGISTER.java @@ -0,0 +1,62 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.game.net.packet.server; + +import org.jboss.netty.buffer.ChannelBuffer; + +import com.l2jserver.game.net.Lineage2Client; +import com.l2jserver.game.net.packet.AbstractServerPacket; +import com.l2jserver.model.game.CharacterShortcut; + +/** + * This packet informs the client that a new shortcut has been created + * + * @author Rogiel + */ +public class SM_CHAR_SHORTCUT_REGISTER extends AbstractServerPacket { + /** + * The packet OPCODE + */ + public static final int OPCODE = 0x44; + + /** + * The shortcut + */ + private final CharacterShortcut shortcut; + + public SM_CHAR_SHORTCUT_REGISTER(CharacterShortcut shortcut) { + super(OPCODE); + this.shortcut = shortcut; + } + + @Override + public void write(Lineage2Client conn, ChannelBuffer buffer) { + buffer.writeInt(shortcut.getType().id); + buffer.writeInt(shortcut.getPage() * 12 + shortcut.getSlot()); + switch (shortcut.getType()) { + case ITEM: + buffer.writeInt(shortcut.getItemID().getID()); + buffer.writeInt(0x01); // unk1f + buffer.writeInt(-1); // reuse group + buffer.writeInt(0x00); // unk2 + buffer.writeInt(0x00); // unk3 + buffer.writeShort(0x00); // unk4 + buffer.writeShort(0x00); // unk5 + break; + } + } +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/CharacterDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/CharacterDAO.java index ea186d851..75d11a51b 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/CharacterDAO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/CharacterDAO.java @@ -22,7 +22,6 @@ import com.l2jserver.model.id.AccountID; import com.l2jserver.model.id.object.CharacterID; import com.l2jserver.model.world.Clan; import com.l2jserver.model.world.L2Character; -import com.l2jserver.service.cache.Cacheable; import com.l2jserver.service.database.DataAccessObject; /** @@ -32,7 +31,7 @@ import com.l2jserver.service.database.DataAccessObject; * @author Rogiel */ public interface CharacterDAO extends - DataAccessObject, Cacheable { + DataAccessObject { /** * Load the members of the given clan * diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/CharacterFriendDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/CharacterFriendDAO.java index 0f1d988e2..61631912c 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/CharacterFriendDAO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/CharacterFriendDAO.java @@ -20,7 +20,6 @@ import com.l2jserver.model.game.CharacterFriend; import com.l2jserver.model.id.FriendID; import com.l2jserver.model.world.L2Character; import com.l2jserver.model.world.character.CharacterFriendList; -import com.l2jserver.service.cache.Cacheable; import com.l2jserver.service.cache.IgnoreCaching; import com.l2jserver.service.database.DataAccessObject; @@ -31,7 +30,7 @@ import com.l2jserver.service.database.DataAccessObject; * @author Rogiel */ public interface CharacterFriendDAO extends - DataAccessObject, Cacheable { + DataAccessObject { /** * Load the friend list for character represented by character from * the database diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/CharacterShortcutDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/CharacterShortcutDAO.java new file mode 100644 index 000000000..2e404cbef --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/CharacterShortcutDAO.java @@ -0,0 +1,43 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.model.dao; + +import java.util.List; + +import com.l2jserver.model.game.CharacterShortcut; +import com.l2jserver.model.id.CharacterShortcutID; +import com.l2jserver.model.world.L2Character; +import com.l2jserver.model.world.character.CharacterFriendList; +import com.l2jserver.service.database.DataAccessObject; + +/** + * The {@link CharacterShortcutDAO} is can load and save + * {@link CharacterFriendList character friend list}. + * + * @author Rogiel + */ +public interface CharacterShortcutDAO extends + DataAccessObject { + /** + * Loads the shortcuts at the list fors character from the database + * + * @param character + * the character + * @return all shortcuts from the given character + */ + List selectByCharacter(L2Character character); +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/ChatMessageDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/ChatMessageDAO.java index 1a85c808f..3a618cac8 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/ChatMessageDAO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/ChatMessageDAO.java @@ -18,7 +18,6 @@ package com.l2jserver.model.dao; import com.l2jserver.model.id.ChatMessageID; import com.l2jserver.model.server.ChatMessage; -import com.l2jserver.service.cache.Cacheable; import com.l2jserver.service.database.DataAccessObject; /** @@ -28,5 +27,5 @@ import com.l2jserver.service.database.DataAccessObject; * @author Rogiel */ public interface ChatMessageDAO extends - DataAccessObject, Cacheable { + DataAccessObject { } diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/ClanDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/ClanDAO.java index 39ce94f17..a390e754b 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/ClanDAO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/ClanDAO.java @@ -18,7 +18,6 @@ package com.l2jserver.model.dao; import com.l2jserver.model.id.object.ClanID; import com.l2jserver.model.world.Clan; -import com.l2jserver.service.cache.Cacheable; import com.l2jserver.service.database.DataAccessObject; /** @@ -26,5 +25,5 @@ import com.l2jserver.service.database.DataAccessObject; * * @author Rogiel */ -public interface ClanDAO extends DataAccessObject, Cacheable { +public interface ClanDAO extends DataAccessObject { } diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/ItemDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/ItemDAO.java index d6d4974bc..c1aede20b 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/ItemDAO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/ItemDAO.java @@ -21,7 +21,6 @@ import java.util.List; import com.l2jserver.model.id.object.ItemID; import com.l2jserver.model.world.Item; import com.l2jserver.model.world.L2Character; -import com.l2jserver.service.cache.Cacheable; import com.l2jserver.service.database.DataAccessObject; /** @@ -30,15 +29,15 @@ import com.l2jserver.service.database.DataAccessObject; * * @author Rogiel */ -public interface ItemDAO extends DataAccessObject, Cacheable { +public interface ItemDAO extends DataAccessObject { /** * Load the inventory for an {@link L2Character character}. * * @param character * the character - * @return amount of items loaded + * @return amount list of character items */ - int loadInventory(L2Character character); + List selectByCharacter(L2Character character); /** * Select from the database the items dropped on the ground diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/NPCDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/NPCDAO.java index e6cbf531c..bf402a3e1 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/NPCDAO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/NPCDAO.java @@ -22,7 +22,6 @@ import java.util.List; import com.l2jserver.model.id.object.NPCID; import com.l2jserver.model.id.template.NPCTemplateID; import com.l2jserver.model.world.NPC; -import com.l2jserver.service.cache.Cacheable; import com.l2jserver.service.database.DataAccessObject; /** @@ -30,7 +29,7 @@ import com.l2jserver.service.database.DataAccessObject; * * @author Rogiel */ -public interface NPCDAO extends DataAccessObject, Cacheable { +public interface NPCDAO extends DataAccessObject { /** * Load all {@link NPC} instances * diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/PetDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/PetDAO.java index 0283be592..e1a0d846a 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/PetDAO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/dao/PetDAO.java @@ -18,7 +18,6 @@ package com.l2jserver.model.dao; import com.l2jserver.model.id.object.PetID; import com.l2jserver.model.world.Pet; -import com.l2jserver.service.cache.Cacheable; import com.l2jserver.service.database.DataAccessObject; /** @@ -26,5 +25,5 @@ import com.l2jserver.service.database.DataAccessObject; * * @author Rogiel */ -public interface PetDAO extends DataAccessObject, Cacheable { +public interface PetDAO extends DataAccessObject { } diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/game/CharacterShortcut.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/game/CharacterShortcut.java new file mode 100644 index 000000000..e68765d75 --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/game/CharacterShortcut.java @@ -0,0 +1,383 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.model.game; + +import com.l2jserver.model.AbstractModel; +import com.l2jserver.model.id.CharacterShortcutID; +import com.l2jserver.model.id.object.CharacterID; +import com.l2jserver.model.id.object.ItemID; +import com.l2jserver.model.id.template.SkillTemplateID; +import com.l2jserver.model.world.L2Character; +import com.l2jserver.model.world.Pet; + +/** + * An shortcut in Lineage II game interface + * + * @author Rogiel + */ +public class CharacterShortcut extends AbstractModel { + /** + * The character id + */ + private CharacterID characterID; + /** + * The shortcut skill id (only if type is + * {@link ShortcutType#SKILL}) + */ + private SkillTemplateID skillID; + + /** + * The shortcut item id (only if type is {@link ShortcutType#ITEM}) + */ + private ItemID itemID; + + /** + * The shortcut slot (0 - 11 = 12 slots/page) + */ + private int slot; + /** + * The shortcut page (0-3 = 4 pages) + */ + private int page; + /** + * The shortcut type + */ + private ShortcutType type; + + /** + * Enum with all shortcut types supported + * + * @author Rogiel + */ + public enum ShortcutType { + /** + * Item shortcut + */ + ITEM(1), + /** + * Skill shortcut + */ + SKILL(2), + /** + * Social action shortcut + */ + ACTION(3), + /** + * Macro shortcut + */ + MACRO(4), + /** + * Recipe shortcut + */ + RECIPE(5), + /** + * Bookmark shortcut + */ + TPBOOKMARK(6); + + /** + * The shortcut type id + */ + public final int id; + + /** + * @param id + * the numeric id + */ + ShortcutType(int id) { + this.id = id; + } + + /** + * + * @param id + * the type id + * @return the {@link ShortcutType} + */ + public static ShortcutType fromID(int id) { + for (final ShortcutType shortcut : values()) { + if (shortcut.id == id) + return shortcut; + } + return null; + } + } + + /** + * The skill level (only if type is {@link ShortcutType#SKILL}) + */ + private int level; + /** + * The kind of actor that this shortcut is attached to + */ + private ShortcutActorType actorType; + + /** + * Enum with all supported actor types + * + * @author Rogiel + */ + public enum ShortcutActorType { + /** + * Shortcut is for an {@link L2Character} + */ + CHARACTER(1), + /** + * Shortcut is for an {@link Pet} + */ + PET(2); + + /** + * The shortcut type id + */ + public final int id; + + /** + * @param id + * the numeric id + */ + ShortcutActorType(int id) { + this.id = id; + } + + /** + * + * @param id + * the type id + * @return the {@link ShortcutType} + */ + public static ShortcutActorType fromID(int id) { + for (final ShortcutActorType shortcut : values()) { + if (shortcut.id == id) + return shortcut; + } + return null; + } + } + + /** + * Creates a new instance + */ + public CharacterShortcut() { + } + + /** + * Creates a new instance + * + * @param characterID + * the character id + */ + public CharacterShortcut(CharacterID characterID) { + this.characterID = characterID; + } + + /** + * Creates a new Item Shortcut + * + * @param characterID + * the character id + * @param itemID + * the item id + * @param actorType + * the actor type + */ + public CharacterShortcut(CharacterID characterID, ItemID itemID, + ShortcutActorType actorType) { + this.type = ShortcutType.ITEM; + this.characterID = characterID; + this.itemID = itemID; + this.actorType = actorType; + } + + /** + * Creates a new Skill Shortcut + * + * @param characterID + * the character id + * @param skillID + * the skill id + * @param level + * the skill level + * @param actorType + * the actor type + */ + public CharacterShortcut(CharacterID characterID, SkillTemplateID skillID, + int level, ShortcutActorType actorType) { + this.type = ShortcutType.SKILL; + this.characterID = characterID; + this.skillID = skillID; + this.level = level; + this.actorType = actorType; + } + + /** + * Creates another type of shortcut + * + * @param characterID + * the character id + * @param type + * the shortcut type + * @param slot + * the shortcut slot + * @param page + * the shortcut page + * @param actorType + * the actor type + */ + public CharacterShortcut(CharacterID characterID, ShortcutType type, + int slot, int page, ShortcutActorType actorType) { + this.characterID = characterID; + this.slot = slot; + this.page = page; + this.type = type; + this.actorType = actorType; + } + + /** + * @return the character id + */ + public CharacterID getCharacterID() { + return characterID; + } + + /** + * @return the character + */ + public L2Character getCharacter() { + return characterID.getObject(); + } + + /** + * @param characterID + * the character ID to set + */ + public void setCharacterID(CharacterID characterID) { + this.characterID = characterID; + } + + /** + * @return the skillID + */ + public SkillTemplateID getSkillID() { + return skillID; + } + + /** + * @param skillID + * the skillID to set + */ + public void setSkillID(SkillTemplateID skillID) { + desireUpdate(); + this.skillID = skillID; + } + + /** + * @return the itemID + */ + public ItemID getItemID() { + return itemID; + } + + /** + * @param itemID + * the itemID to set + */ + public void setItemID(ItemID itemID) { + desireUpdate(); + this.itemID = itemID; + } + + /** + * @return the slot + */ + public int getSlot() { + return slot; + } + + /** + * @param slot + * the slot to set + */ + public void setSlot(int slot) { + desireUpdate(); + this.slot = slot; + } + + /** + * @return the page + */ + public int getPage() { + return page; + } + + /** + * @param page + * the page to set + */ + public void setPage(int page) { + desireUpdate(); + this.page = page; + } + + /** + * @return the type + */ + public ShortcutType getType() { + return type; + } + + /** + * @param type + * the type to set + */ + public void setType(ShortcutType type) { + desireUpdate(); + this.type = type; + } + + /** + * @return the level + */ + public int getLevel() { + return level; + } + + /** + * @param level + * the level to set + */ + public void setLevel(int level) { + desireUpdate(); + this.level = level; + } + + /** + * @return the actorType + */ + public ShortcutActorType getCharacterType() { + return actorType; + } + + /** + * @param actorType + * the actorType to set + */ + public void setCharacterType(ShortcutActorType actorType) { + desireUpdate(); + this.actorType = actorType; + } +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/CharacterShortcutID.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/CharacterShortcutID.java new file mode 100644 index 000000000..88a4e4365 --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/CharacterShortcutID.java @@ -0,0 +1,54 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.model.id; + +import com.google.inject.Inject; +import com.google.inject.assistedinject.Assisted; +import com.l2jserver.model.dao.CharacterShortcutDAO; +import com.l2jserver.model.game.CharacterShortcut; +import com.l2jserver.model.id.provider.IDProvider; + +/** + * Each {@link CharacterShortcut} is identified by an {@link ID}. + *

+ * Please, do not directly instantiate this class, use an {@link IDProvider} + * instead. + * + * @author Rogiel + */ +public class CharacterShortcutID extends + AbstractModelID { + private final CharacterShortcutDAO shortcutDao; + + /** + * Creates a new instance + * + * @param id + * the id + * @param shortcutDao the shortcut DAO + */ + @Inject + public CharacterShortcutID(@Assisted int id, CharacterShortcutDAO shortcutDao) { + super(id); + this.shortcutDao = shortcutDao; + } + + @Override + public CharacterShortcut getObject() { + return shortcutDao.select(this); + } +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/ObjectID.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/ObjectID.java index e44fe5fa2..39e58df7a 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/ObjectID.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/ObjectID.java @@ -34,7 +34,8 @@ import com.l2jserver.model.world.WorldObject; * @param * the {@link WorldObject} type */ -public abstract class ObjectID extends ID { +public abstract class ObjectID extends + AbstractModelID { /** * Creates a new instance * diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/provider/CharacterShortcutIDProvider.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/provider/CharacterShortcutIDProvider.java new file mode 100644 index 000000000..020c60062 --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/provider/CharacterShortcutIDProvider.java @@ -0,0 +1,29 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.model.id.provider; + +import com.l2jserver.model.id.CastleID; +import com.l2jserver.model.id.CharacterShortcutID; + +/** + * Creates a new {@link CastleID} + * + * @author Rogiel + */ +public interface CharacterShortcutIDProvider extends + IDProvider { +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/provider/IDProviderModule.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/provider/IDProviderModule.java index fbe7caa62..edfcb8a4a 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/provider/IDProviderModule.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/provider/IDProviderModule.java @@ -69,13 +69,16 @@ public class IDProviderModule extends AbstractModule { // MISC OBJECTS install(new FactoryModuleBuilder().build(AccountIDProvider.class)); + install(new FactoryModuleBuilder() + .build(CharacterShortcutIDProvider.class)); install(new FactoryModuleBuilder().build(FortIDProvider.class)); install(new FactoryModuleBuilder().build(FriendIDProvider.class)); install(new FactoryModuleBuilder().build(ChatMessageIDProvider.class)); // TEMPLATE IDS install(new FactoryModuleBuilder().build(ItemTemplateIDProvider.class)); - install(new FactoryModuleBuilder().build(EffectTemplateIDProvider.class)); + install(new FactoryModuleBuilder() + .build(EffectTemplateIDProvider.class)); install(new FactoryModuleBuilder().build(SkillTemplateIDProvider.class)); install(new FactoryModuleBuilder() .build(CharacterTemplateIDProvider.class)); diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/WorldObject.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/WorldObject.java index bf8d37ab0..e774bbef4 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/WorldObject.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/WorldObject.java @@ -16,6 +16,7 @@ */ package com.l2jserver.model.world; +import com.l2jserver.model.Model; import com.l2jserver.model.id.ObjectID; /** @@ -25,7 +26,7 @@ import com.l2jserver.model.id.ObjectID; * * @author Rogiel */ -public interface WorldObject { +public interface WorldObject extends Model> { /** * Get the object's ID * diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/CharacterShortcutContainer.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/CharacterShortcutContainer.java index dfa86fa9e..ac7b30b50 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/CharacterShortcutContainer.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/CharacterShortcutContainer.java @@ -16,14 +16,12 @@ */ package com.l2jserver.model.world.character; -import java.io.Serializable; import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; import java.util.Iterator; -import java.util.List; +import java.util.Map; +import java.util.Map.Entry; -import com.l2jserver.model.game.Shortcut; +import com.l2jserver.model.game.CharacterShortcut; import com.l2jserver.model.world.L2Character; import com.l2jserver.util.factory.CollectionFactory; @@ -32,7 +30,7 @@ import com.l2jserver.util.factory.CollectionFactory; * * @author Rogiel */ -public class CharacterShortcutContainer implements Iterable { +public class CharacterShortcutContainer implements Iterable { /** * The character */ @@ -40,7 +38,8 @@ public class CharacterShortcutContainer implements Iterable { /** * The shortcut list */ - private List shortcuts = CollectionFactory.newList(); + private Map shortcuts = CollectionFactory + .newMap(); /** * Creates a new instance @@ -58,9 +57,8 @@ public class CharacterShortcutContainer implements Iterable { * @param shortcut * the shortcut to be added */ - public void register(Shortcut shortcut) { - shortcuts.add(shortcut); - Collections.sort(shortcuts, new ShortcutSlotComparator()); + public void register(CharacterShortcut shortcut) { + shortcuts.put(shortcut.getPage() * 12 + shortcut.getSlot(), shortcut); } /** @@ -69,41 +67,32 @@ public class CharacterShortcutContainer implements Iterable { * @param shortcut * the shortcut to be removed */ - public void unregister(Shortcut shortcut) { - shortcuts.remove(shortcut); - Collections.sort(shortcuts, new ShortcutSlotComparator()); + public void unregister(CharacterShortcut shortcut) { + for (final Entry entry : shortcuts + .entrySet()) { + if (entry.getValue().getID().equals(shortcut.getID())) { + shortcuts.remove(entry.getKey()); + return; + } + } } /** - * Swap two shortcuts between them. Once swap is complete, - * shortcut1 will be in the place of shortcut2, and - * shortcut2 in shortcut1. - * - * @param shortcut1 - * the first shortcut - * @param shortcut2 - * the second shortcut + * @param page + * the page + * @param slot + * the slot + * @return the given character shortcut, if registered. */ - public void swap(Shortcut shortcut1, Shortcut shortcut2) { - // only swap if is registered already - if (!shortcuts.contains(shortcut1) || !shortcuts.contains(shortcut2)) - return; - - final int slot1 = shortcut1.getSlot(); - final int page1 = shortcut1.getPage(); - shortcut1.setSlot(shortcut2.getSlot()); - shortcut1.setPage(shortcut2.getPage()); - shortcut2.setSlot(slot1); - shortcut2.setPage(page1); - - Collections.sort(shortcuts, new ShortcutSlotComparator()); + public CharacterShortcut get(int page, int slot) { + return shortcuts.get(page * 12 + slot); } /** * @return true if container is full */ public boolean isFull() { - return shortcuts.size() >= 12 * 4; + return shortcuts.size() >= 12 * 10; } /** @@ -120,14 +109,22 @@ public class CharacterShortcutContainer implements Iterable { * @param shortcuts * the collection of shortcuts */ - public void load(Collection shortcuts) { - this.shortcuts.addAll(shortcuts); - Collections.sort(this.shortcuts, new ShortcutSlotComparator()); + public void load(Collection shortcuts) { + for (final CharacterShortcut shortcut : shortcuts) { + register(shortcut); + } + } + + /** + * @return the amount if shortcuts in the container + */ + public int getShortcutCount() { + return shortcuts.size(); } @Override - public Iterator iterator() { - return shortcuts.iterator(); + public Iterator iterator() { + return shortcuts.values().iterator(); } /** @@ -136,23 +133,4 @@ public class CharacterShortcutContainer implements Iterable { public L2Character getCharacter() { return character; } - - /** - * Compares two shortcut slots - * - * @author Rogiel - */ - public static class ShortcutSlotComparator implements Comparator, - Serializable { - /** - * The Java Serialization API serial - */ - private static final long serialVersionUID = 1L; - - @Override - public int compare(Shortcut o1, Shortcut o2) { - return ((o1.getPage() * o1.getSlot()) - (o2.getPage() * o2 - .getSlot())); - } - } } diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/event/CharacterCreateShortcutEvent.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/event/CharacterCreateShortcutEvent.java new file mode 100644 index 000000000..7d0e51931 --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/event/CharacterCreateShortcutEvent.java @@ -0,0 +1,86 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.model.world.character.event; + +import com.l2jserver.model.game.CharacterShortcut; +import com.l2jserver.model.id.ObjectID; +import com.l2jserver.model.world.Actor; +import com.l2jserver.model.world.L2Character; +import com.l2jserver.model.world.Player; +import com.l2jserver.model.world.WorldObject; + +/** + * Event triggered once a character creates a new shortcut + * + * @author Rogiel + */ +public class CharacterCreateShortcutEvent implements CharacterEvent { + /** + * The character that has created the shortcut + */ + private final L2Character character; + /** + * The created shortcut + */ + private final CharacterShortcut shortcut; + + /** + * Creates a new instance + * + * @param character + * the character + * @param shortcut + * the created shortcut + */ + public CharacterCreateShortcutEvent(L2Character character, + CharacterShortcut shortcut) { + this.character = character; + this.shortcut = shortcut; + } + + /** + * @return the shortcut + */ + public CharacterShortcut getShortcut() { + return shortcut; + } + + @Override + public Player getPlayer() { + return character; + } + + @Override + public Actor getActor() { + return character; + } + + @Override + public WorldObject getObject() { + return character; + } + + @Override + public L2Character getCharacter() { + return character; + } + + @Override + public ObjectID[] getDispatchableObjects() { + return new ObjectID[] { character.getID() }; + } +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/event/CharacterDeleteShortcutEvent.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/event/CharacterDeleteShortcutEvent.java new file mode 100644 index 000000000..073b6a05d --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/event/CharacterDeleteShortcutEvent.java @@ -0,0 +1,86 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.model.world.character.event; + +import com.l2jserver.model.game.CharacterShortcut; +import com.l2jserver.model.id.ObjectID; +import com.l2jserver.model.world.Actor; +import com.l2jserver.model.world.L2Character; +import com.l2jserver.model.world.Player; +import com.l2jserver.model.world.WorldObject; + +/** + * Event triggered once a character deletes an existing shortcut + * + * @author Rogiel + */ +public class CharacterDeleteShortcutEvent implements CharacterEvent { + /** + * The character that deleted an shortcut + */ + private final L2Character character; + /** + * The deleted shortcut + */ + private final CharacterShortcut shortcut; + + /** + * Creates a new instance + * + * @param character + * the character + * @param shortcut + * the deleted shortcut + */ + public CharacterDeleteShortcutEvent(L2Character character, + CharacterShortcut shortcut) { + this.character = character; + this.shortcut = shortcut; + } + + /** + * @return the shortcut + */ + public CharacterShortcut getShortcut() { + return shortcut; + } + + @Override + public Player getPlayer() { + return character; + } + + @Override + public Actor getActor() { + return character; + } + + @Override + public WorldObject getObject() { + return character; + } + + @Override + public L2Character getCharacter() { + return character; + } + + @Override + public ObjectID[] getDispatchableObjects() { + return new ObjectID[] { character.getID() }; + } +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/event/CharacterListShortcutEvent.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/event/CharacterListShortcutEvent.java new file mode 100644 index 000000000..11c71ff82 --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/world/character/event/CharacterListShortcutEvent.java @@ -0,0 +1,88 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.model.world.character.event; + +import java.util.List; + +import com.l2jserver.model.game.CharacterShortcut; +import com.l2jserver.model.id.ObjectID; +import com.l2jserver.model.world.Actor; +import com.l2jserver.model.world.L2Character; +import com.l2jserver.model.world.Player; +import com.l2jserver.model.world.WorldObject; + +/** + * Event triggered once a character moves + * + * @author Rogiel + */ +public class CharacterListShortcutEvent implements CharacterEvent { + /** + * The character that is logging in + */ + private final L2Character character; + /** + * The list of all shortcuts + */ + private final List shortcuts; + + /** + * Creates a new instance + * + * @param character + * the character + * @param shortcuts + * the list of all shortcuts + */ + public CharacterListShortcutEvent(L2Character character, + List shortcuts) { + this.character = character; + this.shortcuts = shortcuts; + } + + /** + * @return the shortcuts + */ + public List getShortcuts() { + return shortcuts; + } + + @Override + public Player getPlayer() { + return character; + } + + @Override + public Actor getActor() { + return character; + } + + @Override + public WorldObject getObject() { + return character; + } + + @Override + public L2Character getCharacter() { + return character; + } + + @Override + public ObjectID[] getDispatchableObjects() { + return new ObjectID[] { character.getID() }; + } +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/ServiceModule.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/ServiceModule.java index 6b503e431..27dbd3044 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/ServiceModule.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/ServiceModule.java @@ -37,6 +37,8 @@ import com.l2jserver.service.game.admin.AdministratorService; import com.l2jserver.service.game.admin.AdministratorServiceImpl; import com.l2jserver.service.game.character.CharacterService; import com.l2jserver.service.game.character.CharacterServiceImpl; +import com.l2jserver.service.game.character.ShortcutService; +import com.l2jserver.service.game.character.ShortcutServiceImpl; import com.l2jserver.service.game.chat.ChatLoggingService; import com.l2jserver.service.game.chat.ChatService; import com.l2jserver.service.game.chat.DatabaseChatLoggingService; @@ -116,8 +118,12 @@ public class ServiceModule extends AbstractModule { .in(Scopes.SINGLETON); bind(BroadcastService.class).to(BroadcastServiceImpl.class).in( Scopes.SINGLETON); + bind(CharacterService.class).to(CharacterServiceImpl.class).in( Scopes.SINGLETON); + bind(ShortcutService.class).to(ShortcutServiceImpl.class).in( + Scopes.SINGLETON); + bind(AttackService.class).to(AttackServiceImpl.class).in( Scopes.SINGLETON); bind(NPCService.class).to(NPCServiceImpl.class).in(Scopes.SINGLETON); diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/DerbyDAOModule.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/DerbyDAOModule.java deleted file mode 100644 index 199cc56ef..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/DerbyDAOModule.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database; - -import com.google.inject.AbstractModule; -import com.google.inject.Module; -import com.google.inject.Scopes; -import com.l2jserver.model.dao.CharacterDAO; -import com.l2jserver.model.dao.CharacterFriendDAO; -import com.l2jserver.model.dao.ChatMessageDAO; -import com.l2jserver.model.dao.ClanDAO; -import com.l2jserver.model.dao.ItemDAO; -import com.l2jserver.model.dao.NPCDAO; -import com.l2jserver.service.database.jdbc.derby.DerbyCharacterDAO; -import com.l2jserver.service.database.jdbc.derby.DerbyCharacterFriendDAO; -import com.l2jserver.service.database.jdbc.derby.DerbyChatMessageDAO; -import com.l2jserver.service.database.jdbc.derby.DerbyClanDAO; -import com.l2jserver.service.database.jdbc.derby.DerbyItemDAO; -import com.l2jserver.service.database.jdbc.derby.DerbyNPCDAO; - -/** - * Google Guice {@link Module} for Derby DAOs - * - * @author Rogiel - */ -public class DerbyDAOModule extends AbstractModule { - @Override - protected void configure() { - bind(CharacterDAO.class).to(DerbyCharacterDAO.class).in( - Scopes.SINGLETON); - bind(CharacterFriendDAO.class).to(DerbyCharacterFriendDAO.class).in( - Scopes.SINGLETON); - - bind(NPCDAO.class).to(DerbyNPCDAO.class).in(Scopes.SINGLETON); - - bind(ItemDAO.class).to(DerbyItemDAO.class).in(Scopes.SINGLETON); - bind(ClanDAO.class).to(DerbyClanDAO.class).in(Scopes.SINGLETON); - - // logs - bind(ChatMessageDAO.class).to(DerbyChatMessageDAO.class).in( - Scopes.SINGLETON); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/H2DAOModule.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/H2DAOModule.java deleted file mode 100644 index babb45012..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/H2DAOModule.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database; - -import com.google.inject.AbstractModule; -import com.google.inject.Module; -import com.google.inject.Scopes; -import com.l2jserver.model.dao.CharacterDAO; -import com.l2jserver.model.dao.CharacterFriendDAO; -import com.l2jserver.model.dao.ChatMessageDAO; -import com.l2jserver.model.dao.ClanDAO; -import com.l2jserver.model.dao.ItemDAO; -import com.l2jserver.model.dao.NPCDAO; -import com.l2jserver.service.database.jdbc.h2.H2CharacterDAO; -import com.l2jserver.service.database.jdbc.h2.H2CharacterFriendDAO; -import com.l2jserver.service.database.jdbc.h2.H2ChatMessageDAO; -import com.l2jserver.service.database.jdbc.h2.H2ClanDAO; -import com.l2jserver.service.database.jdbc.h2.H2ItemDAO; -import com.l2jserver.service.database.jdbc.h2.H2NPCDAO; - -/** - * Google Guice {@link Module} for H2 DAOs - * - * @author Rogiel - */ -public class H2DAOModule extends AbstractModule { - @Override - protected void configure() { - bind(CharacterDAO.class).to(H2CharacterDAO.class).in(Scopes.SINGLETON); - bind(CharacterFriendDAO.class).to(H2CharacterFriendDAO.class).in( - Scopes.SINGLETON); - - bind(NPCDAO.class).to(H2NPCDAO.class).in(Scopes.SINGLETON); - - bind(ItemDAO.class).to(H2ItemDAO.class).in(Scopes.SINGLETON); - bind(ClanDAO.class).to(H2ClanDAO.class).in(Scopes.SINGLETON); - - // logs - bind(ChatMessageDAO.class).to(H2ChatMessageDAO.class).in( - Scopes.SINGLETON); - - // DAO Resolver - bind(DAOResolver.class).to(GameServerDAOResolver.class).in( - Scopes.SINGLETON); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/MySQL5DAOModule.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/JDBCDAOModule.java similarity index 57% rename from l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/MySQL5DAOModule.java rename to l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/JDBCDAOModule.java index 14458a195..311757af5 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/MySQL5DAOModule.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/JDBCDAOModule.java @@ -21,37 +21,41 @@ import com.google.inject.Module; import com.google.inject.Scopes; import com.l2jserver.model.dao.CharacterDAO; import com.l2jserver.model.dao.CharacterFriendDAO; +import com.l2jserver.model.dao.CharacterShortcutDAO; import com.l2jserver.model.dao.ChatMessageDAO; import com.l2jserver.model.dao.ClanDAO; import com.l2jserver.model.dao.ItemDAO; import com.l2jserver.model.dao.NPCDAO; -import com.l2jserver.service.database.jdbc.mysql5.MySQL5CharacterDAO; -import com.l2jserver.service.database.jdbc.mysql5.MySQL5CharacterFriendDAO; -import com.l2jserver.service.database.jdbc.mysql5.MySQL5ChatMessageDAO; -import com.l2jserver.service.database.jdbc.mysql5.MySQL5ClanDAO; -import com.l2jserver.service.database.jdbc.mysql5.MySQL5ItemDAO; -import com.l2jserver.service.database.jdbc.mysql5.MySQL5NPCDAO; +import com.l2jserver.service.database.jdbc.JDBCCharacterDAO; +import com.l2jserver.service.database.jdbc.JDBCCharacterFriendDAO; +import com.l2jserver.service.database.jdbc.JDBCCharacterShortcutDAO; +import com.l2jserver.service.database.jdbc.JDBCChatMessageDAO; +import com.l2jserver.service.database.jdbc.JDBCClanDAO; +import com.l2jserver.service.database.jdbc.JDBCItemDAO; +import com.l2jserver.service.database.jdbc.JDBCNPCDAO; /** - * Google Guice {@link Module} for MySQL5 DAOs + * Google Guice {@link Module} for JDBC DAOs * * @author Rogiel */ -public class MySQL5DAOModule extends AbstractModule { +public class JDBCDAOModule extends AbstractModule { @Override protected void configure() { - bind(CharacterDAO.class).to(MySQL5CharacterDAO.class).in( + bind(CharacterDAO.class).to(JDBCCharacterDAO.class) + .in(Scopes.SINGLETON); + bind(CharacterFriendDAO.class).to(JDBCCharacterFriendDAO.class).in( Scopes.SINGLETON); - bind(CharacterFriendDAO.class).to(MySQL5CharacterFriendDAO.class).in( + bind(CharacterShortcutDAO.class).to(JDBCCharacterShortcutDAO.class).in( Scopes.SINGLETON); - bind(NPCDAO.class).to(MySQL5NPCDAO.class).in(Scopes.SINGLETON); + bind(NPCDAO.class).to(JDBCNPCDAO.class).in(Scopes.SINGLETON); - bind(ItemDAO.class).to(MySQL5ItemDAO.class).in(Scopes.SINGLETON); - bind(ClanDAO.class).to(MySQL5ClanDAO.class).in(Scopes.SINGLETON); + bind(ItemDAO.class).to(JDBCItemDAO.class).in(Scopes.SINGLETON); + bind(ClanDAO.class).to(JDBCClanDAO.class).in(Scopes.SINGLETON); // logs - bind(ChatMessageDAO.class).to(MySQL5ChatMessageDAO.class).in( + bind(ChatMessageDAO.class).to(JDBCChatMessageDAO.class).in( Scopes.SINGLETON); // DAO Resolver diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCCharacterDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCCharacterDAO.java index 50e92a762..0b5749135 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCCharacterDAO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCCharacterDAO.java @@ -56,7 +56,7 @@ import com.l2jserver.util.geometry.Point3D; * * @author Rogiel */ -public abstract class JDBCCharacterDAO extends +public class JDBCCharacterDAO extends AbstractJDBCDAO implements CharacterDAO { /** * The {@link CharacterID} factory diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCCharacterFriendDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCCharacterFriendDAO.java index cbe6fde7e..14af02728 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCCharacterFriendDAO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCCharacterFriendDAO.java @@ -43,7 +43,7 @@ import com.l2jserver.service.database.DatabaseService; * * @author Rogiel */ -public abstract class JDBCCharacterFriendDAO extends +public class JDBCCharacterFriendDAO extends AbstractJDBCDAO implements CharacterFriendDAO { /** diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCCharacterShortcutDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCCharacterShortcutDAO.java new file mode 100644 index 000000000..ef4d6a6c9 --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCCharacterShortcutDAO.java @@ -0,0 +1,298 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.service.database.jdbc; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; + +import com.google.inject.Inject; +import com.l2jserver.model.Model; +import com.l2jserver.model.dao.CharacterFriendDAO; +import com.l2jserver.model.dao.CharacterShortcutDAO; +import com.l2jserver.model.game.CharacterFriend; +import com.l2jserver.model.game.CharacterShortcut; +import com.l2jserver.model.game.CharacterShortcut.ShortcutType; +import com.l2jserver.model.id.CharacterShortcutID; +import com.l2jserver.model.id.FriendID; +import com.l2jserver.model.id.object.CharacterID; +import com.l2jserver.model.id.object.ItemID; +import com.l2jserver.model.id.object.provider.CharacterIDProvider; +import com.l2jserver.model.id.object.provider.ItemIDProvider; +import com.l2jserver.model.id.provider.CharacterShortcutIDProvider; +import com.l2jserver.model.world.L2Character; +import com.l2jserver.service.database.AbstractJDBCDatabaseService.CachedMapper; +import com.l2jserver.service.database.AbstractJDBCDatabaseService.InsertUpdateQuery; +import com.l2jserver.service.database.AbstractJDBCDatabaseService.Mapper; +import com.l2jserver.service.database.AbstractJDBCDatabaseService.SelectListQuery; +import com.l2jserver.service.database.AbstractJDBCDatabaseService.SelectSingleQuery; +import com.l2jserver.service.database.DatabaseService; + +/** + * {@link CharacterFriendDAO} implementation for JDBC + * + * @author Rogiel + */ +public class JDBCCharacterShortcutDAO extends + AbstractJDBCDAO implements + CharacterShortcutDAO { + /** + * The {@link CharacterShortcutID} provider + */ + private final CharacterShortcutIDProvider idProvider; + /** + * The {@link CharacterID} provider + */ + private final CharacterIDProvider charIdProvider; + /** + * The {@link ItemID} provider + */ + private final ItemIDProvider itemIdProvider; + + /** + * Character table name + */ + public static final String TABLE = "character_shortcut"; + // FIELDS + public static final String SHORTCUT_ID = "shortcut_id"; + public static final String CHAR_ID = JDBCCharacterDAO.CHAR_ID; + public static final String TYPE = "type"; + public static final String SLOT = "slot"; + public static final String PAGE = "page"; + + // item id, skill id (pretty much anything!) + public static final String OBJECT_ID = "object_id"; + public static final String SKILL_LEVEL = "skill_level"; + + /** + * @param database + * the database service + * @param idProvider + * the frind id provider + * @param charIdProvider + * the character id provider + * @param itemIdProvider + * the item id provider + */ + @Inject + public JDBCCharacterShortcutDAO(DatabaseService database, + final CharacterShortcutIDProvider idProvider, + CharacterIDProvider charIdProvider, ItemIDProvider itemIdProvider) { + super(database); + this.idProvider = idProvider; + this.charIdProvider = charIdProvider; + this.itemIdProvider = itemIdProvider; + } + + /** + * The {@link Mapper} for {@link FriendID} + */ + private final Mapper idMapper = new Mapper() { + @Override + public CharacterShortcutID map(ResultSet rs) throws SQLException { + return idProvider.resolveID(rs.getInt(SHORTCUT_ID)); + } + }; + + /** + * The {@link Mapper} for {@link CharacterFriend} + */ + private final Mapper mapper = new CachedMapper( + database, idMapper) { + @Override + protected CharacterShortcut map(CharacterShortcutID id, ResultSet rs) + throws SQLException { + final CharacterShortcut shortcut = new CharacterShortcut(); + shortcut.setID(id); + final CharacterID charId = charIdProvider.resolveID(rs + .getInt(CHAR_ID)); + shortcut.setCharacterID(charId); + + // resolve type + final ShortcutType type = ShortcutType.valueOf(rs.getString(TYPE)); + shortcut.setType(type); + switch (type) { + case ITEM: + final ItemID itemId = itemIdProvider.resolveID(rs + .getInt(OBJECT_ID)); + shortcut.setItemID(itemId); + break; + } + + shortcut.setPage(rs.getInt(PAGE)); + shortcut.setSlot(rs.getInt(SLOT)); + + return shortcut; + } + }; + + @Override + public CharacterShortcut select(final CharacterShortcutID id) { + return database.query(new SelectSingleQuery() { + @Override + protected String query() { + return "SELECT * FROM `" + TABLE + "` WHERE `" + SHORTCUT_ID + + "` = ?"; + } + + @Override + protected void parametize(PreparedStatement st) throws SQLException { + st.setInt(1, id.getID()); + } + + @Override + protected Mapper mapper() { + return mapper; + } + }); + } + + @Override + public List selectByCharacter(final L2Character character) { + return database.query(new SelectListQuery() { + @Override + protected String query() { + return "SELECT * FROM `" + TABLE + "` WHERE `" + CHAR_ID + + "` = ?"; + } + + @Override + protected void parametize(PreparedStatement st) throws SQLException { + st.setInt(1, character.getID().getID()); + } + + @Override + protected Mapper mapper() { + return mapper; + } + }); + } + + @Override + public List selectIDs() { + return database.query(new SelectListQuery() { + @Override + protected String query() { + return "SELECT * FROM `" + TABLE + "`"; + } + + @Override + protected Mapper mapper() { + return idMapper; + } + }); + } + + @Override + public int insertObjects(CharacterShortcut... shortcuts) { + return database.query(new InsertUpdateQuery( + shortcuts) { + @Override + protected String query() { + return "INSERT INTO `" + TABLE + "` (`" + CHAR_ID + "`,`" + + TYPE + "`, `" + OBJECT_ID + "`, `" + SLOT + "`, `" + + PAGE + "`) VALUES(?,?,?,?,?)"; + } + + @Override + protected void parametize(PreparedStatement st, + CharacterShortcut shortcut) throws SQLException { + int i = 1; + st.setInt(i++, shortcut.getCharacterID().getID()); + st.setString(i++, shortcut.getType().name()); + switch (shortcut.getType()) { + case ITEM: + st.setInt(i++, shortcut.getItemID().getID()); + break; + } + st.setInt(i++, shortcut.getSlot()); + st.setInt(i++, shortcut.getPage()); + } + + @Override + protected Mapper keyMapper() { + return new Mapper() { + @Override + public CharacterShortcutID map(ResultSet rs) + throws SQLException { + return idProvider.resolveID(rs.getInt(1)); + }; + }; + } + }); + } + + @Override + public int updateObjects(CharacterShortcut... shortcuts) { + return database.query(new InsertUpdateQuery( + shortcuts) { + @Override + protected String query() { + return "UPDATE `" + TABLE + "` SET `" + CHAR_ID + "` = ?,`" + + TYPE + "` = ?, `" + OBJECT_ID + "` = ?, `" + SLOT + + "` = ?, `" + PAGE + "` = ? WHERE `" + SHORTCUT_ID + + "` = ?"; + } + + @Override + protected void parametize(PreparedStatement st, + CharacterShortcut shortcut) throws SQLException { + int i = 1; + st.setInt(i++, shortcut.getCharacterID().getID()); + st.setString(i++, shortcut.getType().name()); + switch (shortcut.getType()) { + case ITEM: + st.setInt(i++, shortcut.getItemID().getID()); + break; + } + st.setInt(i++, shortcut.getSlot()); + st.setInt(i++, shortcut.getPage()); + + st.setInt(i++, shortcut.getID().getID()); + } + }); + } + + @Override + public int deleteObjects(CharacterShortcut... shortcuts) { + return database.query(new InsertUpdateQuery( + shortcuts) { + @Override + protected String query() { + return "DELETE FROM `" + TABLE + "` WHERE `" + SHORTCUT_ID + + "` = ?"; + } + + @Override + protected void parametize(PreparedStatement st, + CharacterShortcut shortcut) throws SQLException { + st.setInt(1, shortcut.getID().getID()); + } + }); + } + + @Override + protected CharacterShortcut[] wrap(Model... objects) { + final CharacterShortcut[] array = new CharacterShortcut[objects.length]; + int i = 0; + for (final Model object : objects) { + array[i++] = (CharacterShortcut) object; + } + return array; + } +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCChatMessageDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCChatMessageDAO.java index c43a76cbc..284e572fd 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCChatMessageDAO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCChatMessageDAO.java @@ -45,7 +45,7 @@ import com.l2jserver.service.game.chat.ChatMessageType; * * @author Rogiel */ -public abstract class JDBCChatMessageDAO extends +public class JDBCChatMessageDAO extends AbstractJDBCDAO implements ChatMessageDAO { /** * The {@link ChatMessageID} factory diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCClanDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCClanDAO.java index 96a66cad1..de3841b0b 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCClanDAO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCClanDAO.java @@ -42,7 +42,7 @@ import com.l2jserver.service.database.DatabaseService; * * @author Rogiel */ -public abstract class JDBCClanDAO extends AbstractJDBCDAO +public class JDBCClanDAO extends AbstractJDBCDAO implements ClanDAO { /** * The {@link ClanID} factory diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCItemDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCItemDAO.java index 982b2ca53..fd08d95f9 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCItemDAO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCItemDAO.java @@ -37,7 +37,6 @@ import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider; import com.l2jserver.model.template.item.ItemTemplate; import com.l2jserver.model.world.Item; import com.l2jserver.model.world.L2Character; -import com.l2jserver.model.world.character.CharacterInventory; import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll; import com.l2jserver.model.world.character.CharacterInventory.ItemLocation; import com.l2jserver.service.database.AbstractJDBCDatabaseService.CachedMapper; @@ -54,7 +53,7 @@ import com.l2jserver.util.geometry.Coordinate; * * @author Rogiel */ -public abstract class JDBCItemDAO extends AbstractJDBCDAO +public class JDBCItemDAO extends AbstractJDBCDAO implements ItemDAO { /** * The logger @@ -180,9 +179,8 @@ public abstract class JDBCItemDAO extends AbstractJDBCDAO } @Override - public int loadInventory(final L2Character character) { - final CharacterInventory inventory = character.getInventory(); - final List items = database.query(new SelectListQuery() { + public List selectByCharacter(final L2Character character) { + return database.query(new SelectListQuery() { @Override protected String query() { return "SELECT * FROM `" + TABLE + "` WHERE `" + CHAR_ID @@ -200,8 +198,6 @@ public abstract class JDBCItemDAO extends AbstractJDBCDAO return mapper; } }); - inventory.load(items); - return items.size(); } @Override diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCNPCDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCNPCDAO.java index 7041622ff..97598757b 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCNPCDAO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/JDBCNPCDAO.java @@ -47,7 +47,7 @@ import com.l2jserver.util.geometry.Point3D; * * @author Rogiel */ -public abstract class JDBCNPCDAO extends AbstractJDBCDAO implements +public class JDBCNPCDAO extends AbstractJDBCDAO implements NPCDAO { /** * The logger diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyCharacterDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyCharacterDAO.java deleted file mode 100644 index ceda5f974..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyCharacterDAO.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.derby; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.CharacterDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.object.provider.ClanIDProvider; -import com.l2jserver.model.id.provider.AccountIDProvider; -import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCCharacterDAO; - -/** - * {@link CharacterDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class DerbyCharacterDAO extends JDBCCharacterDAO implements - CharacterDAO { - /** - * @param database - * the database service - * @param idFactory - * the character id provider - * @param templateIdFactory - * the template id provider - * @param accountIdFactory - * the account id provider - * @param clanIdFactory - * the clan id provider - */ - @Inject - public DerbyCharacterDAO(DatabaseService database, - CharacterIDProvider idFactory, - CharacterTemplateIDProvider templateIdFactory, - AccountIDProvider accountIdFactory, ClanIDProvider clanIdFactory) { - super(database, idFactory, templateIdFactory, accountIdFactory, - clanIdFactory); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyCharacterFriendDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyCharacterFriendDAO.java deleted file mode 100644 index 46be85c1b..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyCharacterFriendDAO.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.derby; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.CharacterFriendDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.provider.FriendIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCCharacterFriendDAO; - -/** - * {@link CharacterFriendDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class DerbyCharacterFriendDAO extends JDBCCharacterFriendDAO implements - CharacterFriendDAO { - /** - * @param database - * the database service - * @param idProvider - * the frind id provider - * @param charIdProvider - * the character id provider - */ - @Inject - public DerbyCharacterFriendDAO(DatabaseService database, - FriendIDProvider idProvider, CharacterIDProvider charIdProvider) { - super(database, idProvider, charIdProvider); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyChatMessageDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyChatMessageDAO.java deleted file mode 100644 index 46a180fdd..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyChatMessageDAO.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.derby; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.ChatMessageDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.provider.ChatMessageIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCChatMessageDAO; - -/** - * {@link ChatMessageDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class DerbyChatMessageDAO extends JDBCChatMessageDAO implements - ChatMessageDAO { - /** - * @param database - * the database service - * @param idFactory - * the chat message id provider - * @param charIdFactory - * the character id provider - */ - @Inject - public DerbyChatMessageDAO(DatabaseService database, - ChatMessageIDProvider idFactory, CharacterIDProvider charIdFactory) { - super(database, idFactory, charIdFactory); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyClanDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyClanDAO.java deleted file mode 100644 index 009b1d2fc..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyClanDAO.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.derby; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.CharacterDAO; -import com.l2jserver.model.dao.ClanDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.object.provider.ClanIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCClanDAO; - -/** - * {@link CharacterDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class DerbyClanDAO extends JDBCClanDAO implements ClanDAO { - /** - * @param database - * the database service - * @param clanIdFactory - * the clan id provider - * @param idFactory - * the character id provider - */ - @Inject - public DerbyClanDAO(DatabaseService database, - ClanIDProvider clanIdFactory, CharacterIDProvider idFactory) { - super(database, clanIdFactory, idFactory); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyItemDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyItemDAO.java deleted file mode 100644 index 925328244..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyItemDAO.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.derby; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.ItemDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.object.provider.ItemIDProvider; -import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCItemDAO; - -/** - * {@link ItemDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class DerbyItemDAO extends JDBCItemDAO implements ItemDAO { - /** - * @param database - * the database service - * @param idFactory - * the item id provider - * @param templateIdFactory - * the item template id provider - * @param charIdFactory - * the character id provider - */ - @Inject - public DerbyItemDAO(DatabaseService database, ItemIDProvider idFactory, - ItemTemplateIDProvider templateIdFactory, - CharacterIDProvider charIdFactory) { - super(database, idFactory, templateIdFactory, charIdFactory); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyNPCDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyNPCDAO.java deleted file mode 100644 index 62985c4db..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/derby/DerbyNPCDAO.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.derby; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.CharacterDAO; -import com.l2jserver.model.dao.NPCDAO; -import com.l2jserver.model.id.object.provider.NPCIDProvider; -import com.l2jserver.model.id.template.provider.NPCTemplateIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCNPCDAO; - -/** - * {@link CharacterDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class DerbyNPCDAO extends JDBCNPCDAO implements NPCDAO { - /** - * @param database - * the database service - * @param idProvider - * the npc id provider - * @param templateIdProvider - * the npc template id provider - */ - @Inject - public DerbyNPCDAO(DatabaseService database, NPCIDProvider idProvider, - NPCTemplateIDProvider templateIdProvider) { - super(database, idProvider, templateIdProvider); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2CharacterDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2CharacterDAO.java deleted file mode 100644 index 5148cee47..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2CharacterDAO.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.h2; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.CharacterDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.object.provider.ClanIDProvider; -import com.l2jserver.model.id.provider.AccountIDProvider; -import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCCharacterDAO; - -/** - * {@link CharacterDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class H2CharacterDAO extends JDBCCharacterDAO implements CharacterDAO { - /** - * @param database - * the database service - * @param idFactory - * the character id provider - * @param templateIdFactory - * the template id provider - * @param accountIdFactory - * the account id provider - * @param clanIdFactory - * the clan id provider - */ - @Inject - public H2CharacterDAO(DatabaseService database, - CharacterIDProvider idFactory, - CharacterTemplateIDProvider templateIdFactory, - AccountIDProvider accountIdFactory, ClanIDProvider clanIdFactory) { - super(database, idFactory, templateIdFactory, accountIdFactory, - clanIdFactory); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2CharacterFriendDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2CharacterFriendDAO.java deleted file mode 100644 index c48d54347..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2CharacterFriendDAO.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.h2; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.CharacterFriendDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.provider.FriendIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCCharacterFriendDAO; - -/** - * {@link CharacterFriendDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class H2CharacterFriendDAO extends JDBCCharacterFriendDAO implements - CharacterFriendDAO { - /** - * @param database - * the database service - * @param idProvider - * the frind id provider - * @param charIdProvider - * the character id provider - */ - @Inject - public H2CharacterFriendDAO(DatabaseService database, - FriendIDProvider idProvider, CharacterIDProvider charIdProvider) { - super(database, idProvider, charIdProvider); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2ChatMessageDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2ChatMessageDAO.java deleted file mode 100644 index cb588a39b..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2ChatMessageDAO.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.h2; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.ChatMessageDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.provider.ChatMessageIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCChatMessageDAO; - -/** - * {@link ChatMessageDAO} implementation for H2 database - * - * @author Rogiel - */ -public class H2ChatMessageDAO extends JDBCChatMessageDAO implements - ChatMessageDAO { - /** - * @param database - * the database service - * @param idFactory - * the chat message id provider - * @param charIdFactory - * the character id provider - */ - @Inject - public H2ChatMessageDAO(DatabaseService database, - ChatMessageIDProvider idFactory, CharacterIDProvider charIdFactory) { - super(database, idFactory, charIdFactory); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2ClanDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2ClanDAO.java deleted file mode 100644 index e0e13f35d..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2ClanDAO.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.h2; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.CharacterDAO; -import com.l2jserver.model.dao.ClanDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.object.provider.ClanIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCClanDAO; - -/** - * {@link CharacterDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class H2ClanDAO extends JDBCClanDAO implements ClanDAO { - /** - * @param database - * the database service - * @param clanIdFactory - * the clan id provider - * @param idFactory - * the character id provider - */ - @Inject - public H2ClanDAO(DatabaseService database, ClanIDProvider clanIdFactory, - CharacterIDProvider idFactory) { - super(database, clanIdFactory, idFactory); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2ItemDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2ItemDAO.java deleted file mode 100644 index 215ce4e70..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2ItemDAO.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.h2; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.ItemDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.object.provider.ItemIDProvider; -import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCItemDAO; - -/** - * {@link ItemDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class H2ItemDAO extends JDBCItemDAO implements ItemDAO { - /** - * @param database - * the database service - * @param idFactory - * the item id provider - * @param templateIdFactory - * the item template id provider - * @param charIdFactory - * the character id provider - */ - @Inject - public H2ItemDAO(DatabaseService database, ItemIDProvider idFactory, - ItemTemplateIDProvider templateIdFactory, - CharacterIDProvider charIdFactory) { - super(database, idFactory, templateIdFactory, charIdFactory); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2NPCDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2NPCDAO.java deleted file mode 100644 index 04458bbd1..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/h2/H2NPCDAO.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.h2; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.CharacterDAO; -import com.l2jserver.model.dao.NPCDAO; -import com.l2jserver.model.id.object.provider.NPCIDProvider; -import com.l2jserver.model.id.template.provider.NPCTemplateIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCNPCDAO; - -/** - * {@link CharacterDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class H2NPCDAO extends JDBCNPCDAO implements NPCDAO { - /** - * @param database - * the database service - * @param idProvider - * the npc id provider - * @param templateIdProvider - * the npc template id provider - */ - @Inject - public H2NPCDAO(DatabaseService database, NPCIDProvider idProvider, - NPCTemplateIDProvider templateIdProvider) { - super(database, idProvider, templateIdProvider); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5CharacterDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5CharacterDAO.java deleted file mode 100644 index 85425948a..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5CharacterDAO.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.mysql5; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.CharacterDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.object.provider.ClanIDProvider; -import com.l2jserver.model.id.provider.AccountIDProvider; -import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCCharacterDAO; - -/** - * {@link CharacterDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class MySQL5CharacterDAO extends JDBCCharacterDAO implements - CharacterDAO { - /** - * @param database - * the database service - * @param idFactory - * the character id provider - * @param templateIdFactory - * the template id provider - * @param accountIdFactory - * the account id provider - * @param clanIdFactory - * the clan id provider - */ - @Inject - public MySQL5CharacterDAO(DatabaseService database, - CharacterIDProvider idFactory, - CharacterTemplateIDProvider templateIdFactory, - AccountIDProvider accountIdFactory, ClanIDProvider clanIdFactory) { - super(database, idFactory, templateIdFactory, accountIdFactory, - clanIdFactory); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5CharacterFriendDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5CharacterFriendDAO.java deleted file mode 100644 index 6725647cb..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5CharacterFriendDAO.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.mysql5; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.CharacterFriendDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.provider.FriendIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCCharacterFriendDAO; - -/** - * {@link CharacterFriendDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class MySQL5CharacterFriendDAO extends JDBCCharacterFriendDAO implements - CharacterFriendDAO { - /** - * @param database - * the database service - * @param idProvider - * the frind id provider - * @param charIdProvider - * the character id provider - */ - @Inject - public MySQL5CharacterFriendDAO(DatabaseService database, - FriendIDProvider idProvider, CharacterIDProvider charIdProvider) { - super(database, idProvider, charIdProvider); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5ChatMessageDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5ChatMessageDAO.java deleted file mode 100644 index e83d8e766..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5ChatMessageDAO.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.mysql5; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.ChatMessageDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.provider.ChatMessageIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCChatMessageDAO; - -/** - * {@link ChatMessageDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class MySQL5ChatMessageDAO extends JDBCChatMessageDAO implements - ChatMessageDAO { - /** - * @param database - * the database service - * @param idFactory - * the chat message id provider - * @param charIdFactory - * the character id provider - */ - @Inject - public MySQL5ChatMessageDAO(DatabaseService database, - ChatMessageIDProvider idFactory, CharacterIDProvider charIdFactory) { - super(database, idFactory, charIdFactory); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5ClanDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5ClanDAO.java deleted file mode 100644 index 0f78dce59..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5ClanDAO.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.mysql5; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.CharacterDAO; -import com.l2jserver.model.dao.ClanDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.object.provider.ClanIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCClanDAO; - -/** - * {@link CharacterDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class MySQL5ClanDAO extends JDBCClanDAO implements ClanDAO { - /** - * @param database - * the database service - * @param clanIdFactory - * the clan id provider - * @param idFactory - * the character id provider - */ - @Inject - public MySQL5ClanDAO(DatabaseService database, - ClanIDProvider clanIdFactory, CharacterIDProvider idFactory) { - super(database, clanIdFactory, idFactory); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5ItemDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5ItemDAO.java deleted file mode 100644 index 600b687d1..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5ItemDAO.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.mysql5; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.ItemDAO; -import com.l2jserver.model.id.object.provider.CharacterIDProvider; -import com.l2jserver.model.id.object.provider.ItemIDProvider; -import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCItemDAO; - -/** - * {@link ItemDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class MySQL5ItemDAO extends JDBCItemDAO implements ItemDAO { - /** - * @param database - * the database service - * @param idFactory - * the item id provider - * @param templateIdFactory - * the item template id provider - * @param charIdFactory - * the character id provider - */ - @Inject - public MySQL5ItemDAO(DatabaseService database, ItemIDProvider idFactory, - ItemTemplateIDProvider templateIdFactory, - CharacterIDProvider charIdFactory) { - super(database, idFactory, templateIdFactory, charIdFactory); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5NPCDAO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5NPCDAO.java deleted file mode 100644 index 62eef0732..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/database/jdbc/mysql5/MySQL5NPCDAO.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 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. - * - * l2jserver2 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 l2jserver2. If not, see . - */ -package com.l2jserver.service.database.jdbc.mysql5; - -import com.google.inject.Inject; -import com.l2jserver.model.dao.CharacterDAO; -import com.l2jserver.model.dao.NPCDAO; -import com.l2jserver.model.id.object.provider.NPCIDProvider; -import com.l2jserver.model.id.template.provider.NPCTemplateIDProvider; -import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.jdbc.JDBCNPCDAO; - -/** - * {@link CharacterDAO} implementation for MySQL5 - * - * @author Rogiel - */ -public class MySQL5NPCDAO extends JDBCNPCDAO implements NPCDAO { - /** - * @param database - * the database service - * @param idProvider - * the npc id provider - * @param templateIdProvider - * the npc template id provider - */ - @Inject - public MySQL5NPCDAO(DatabaseService database, NPCIDProvider idProvider, - NPCTemplateIDProvider templateIdProvider) { - super(database, idProvider, templateIdProvider); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/CharacterServiceImpl.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/CharacterServiceImpl.java index 1fdefc6f1..a91a8de61 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/CharacterServiceImpl.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/CharacterServiceImpl.java @@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Preconditions; import com.google.inject.Inject; import com.l2jserver.model.dao.CharacterDAO; +import com.l2jserver.model.dao.CharacterShortcutDAO; import com.l2jserver.model.dao.ItemDAO; import com.l2jserver.model.id.object.CharacterID; import com.l2jserver.model.id.object.provider.CharacterIDProvider; @@ -106,6 +107,10 @@ public class CharacterServiceImpl extends AbstractService implements * The {@link ItemDAO} */ private final ItemDAO itemDao; + /** + * The {@link CharacterShortcutDAO} + */ + private final CharacterShortcutDAO shortcutDao; /** * The character ID provider @@ -136,6 +141,8 @@ public class CharacterServiceImpl extends AbstractService implements * the character DAO * @param itemDao * the item DAO + * @param shortcutDao + * the shortcut DAO * @param charTemplateIdProvider * the character template id provider * @param charIdProvider @@ -146,6 +153,7 @@ public class CharacterServiceImpl extends AbstractService implements WorldEventDispatcher eventDispatcher, SpawnService spawnService, NPCService npcService, GameGuardService ggService, CharacterDAO characterDao, ItemDAO itemDao, + CharacterShortcutDAO shortcutDao, CharacterTemplateIDProvider charTemplateIdProvider, CharacterIDProvider charIdProvider) { this.broadcastService = broadcastService; @@ -155,6 +163,7 @@ public class CharacterServiceImpl extends AbstractService implements this.ggService = ggService; this.characterDao = characterDao; this.itemDao = itemDao; + this.shortcutDao = shortcutDao; this.charTemplateIdProvider = charTemplateIdProvider; this.charIdProvider = charIdProvider; } @@ -223,7 +232,10 @@ public class CharacterServiceImpl extends AbstractService implements log.debug("Character {} is entering world", character); - itemDao.loadInventory(character); + // load character data + character.getInventory().load(itemDao.selectByCharacter(character)); + character.getShortcuts().load(shortcutDao.selectByCharacter(character)); + character.setOnline(true); // inventory interfere on calculators character.getStats().updateCalculator(); @@ -403,7 +415,7 @@ public class CharacterServiceImpl extends AbstractService implements // TODO dispatch stop event } } - + characterDao.saveObjectsAsync(character); } diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutService.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutService.java new file mode 100644 index 000000000..9196ab497 --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutService.java @@ -0,0 +1,62 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.service.game.character; + +import com.l2jserver.model.game.CharacterShortcut; +import com.l2jserver.model.world.Item; +import com.l2jserver.model.world.L2Character; +import com.l2jserver.service.Service; + +/** + * This services handles {@link CharacterShortcut}s + * + * @author Rogiel + */ +public interface ShortcutService extends Service { + /** + * Creates a new {@link Item} {@link CharacterShortcut shortcut}. + * + * @param character + * the character that will be using the shortcut + * @param item + * the item + * @param page + * the page in which the shortcut should be created + * @param slot + * the slot in which the shortcut should be created + * @return the nerly created shortcut + * @throws ShortcutSlotNotFreeServiceException + * if there is no free shortcut slot + */ + CharacterShortcut create(L2Character character, Item item, int page, + int slot) throws ShortcutSlotNotFreeServiceException; + + /** + * Deletes an existing {@link CharacterShortcut}. + * + * @param character + * the character + * @param page + * the page in which the shortcut should be removed + * @param slot + * the slot in which the shortcut should be removed + * @throws ShortcutSlotEmptyServiceException + * if the shortcut slot was empty + */ + void remove(L2Character character, int page, int slot) + throws ShortcutSlotEmptyServiceException; +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutServiceException.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutServiceException.java new file mode 100644 index 000000000..15fcce707 --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutServiceException.java @@ -0,0 +1,68 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.service.game.character; + +import com.l2jserver.service.ServiceException; + +/** + * @author Rogiel + */ +public class ShortcutServiceException extends ServiceException { + /** + * The Java Serialization API serial + */ + private static final long serialVersionUID = 1L; + + /** + * Creates a new instance of this exception + */ + public ShortcutServiceException() { + super(); + } + + /** + * Creates a new instance of this exception + * + * @param message + * the message + * @param cause + * the root cause + */ + public ShortcutServiceException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Creates a new instance of this exception + * + * @param message + * the message + */ + public ShortcutServiceException(String message) { + super(message); + } + + /** + * Creates a new instance of this exception + * + * @param cause + * the root cause + */ + public ShortcutServiceException(Throwable cause) { + super(cause); + } +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutServiceImpl.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutServiceImpl.java new file mode 100644 index 000000000..a01034e1e --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutServiceImpl.java @@ -0,0 +1,107 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.service.game.character; + +import com.google.common.base.Preconditions; +import com.google.inject.Inject; +import com.l2jserver.model.dao.CharacterShortcutDAO; +import com.l2jserver.model.game.CharacterShortcut; +import com.l2jserver.model.game.CharacterShortcut.ShortcutType; +import com.l2jserver.model.world.Item; +import com.l2jserver.model.world.L2Character; +import com.l2jserver.model.world.character.event.CharacterCreateShortcutEvent; +import com.l2jserver.model.world.character.event.CharacterDeleteShortcutEvent; +import com.l2jserver.service.AbstractService; +import com.l2jserver.service.game.world.WorldService; +import com.l2jserver.service.game.world.event.WorldEventDispatcher; + +/** + * @author Rogiel + * + */ +public class ShortcutServiceImpl extends AbstractService implements + ShortcutService { + /** + * The {@link WorldService} event dispatcher + */ + private final WorldEventDispatcher eventDispatcher; + /** + * The {@link CharacterShortcut} DAO + */ + private final CharacterShortcutDAO shortcutDao; + + /** + * @param eventDispatcher + * the event dispatcher + * @param shortcutDao + * the shortcut DAO + */ + @Inject + private ShortcutServiceImpl(WorldEventDispatcher eventDispatcher, + CharacterShortcutDAO shortcutDao) { + this.eventDispatcher = eventDispatcher; + this.shortcutDao = shortcutDao; + } + + @Override + public CharacterShortcut create(L2Character character, Item item, int page, + int slot) throws ShortcutSlotNotFreeServiceException { + Preconditions.checkNotNull(character, "character"); + Preconditions.checkNotNull(item, "item"); + Preconditions.checkArgument(page >= 0 && page <= 10, "0 <= page <= 10"); + Preconditions.checkArgument(page >= 0 && slot <= 12, "0 <= slot <= 10"); + + if (character.getShortcuts().get(page, slot) != null) + throw new ShortcutSlotNotFreeServiceException(); + + final CharacterShortcut shortcut = new CharacterShortcut(); + + shortcut.setType(ShortcutType.ITEM); + shortcut.setCharacterID(character.getID()); + shortcut.setItemID(item.getID()); + shortcut.setPage(page); + shortcut.setSlot(slot); + + // synchronous save here + shortcutDao.save(shortcut); + character.getShortcuts().register(shortcut); + + eventDispatcher.dispatch(new CharacterCreateShortcutEvent(character, + shortcut)); + + return shortcut; + } + + @Override + public void remove(L2Character character, int page, int slot) + throws ShortcutSlotEmptyServiceException { + Preconditions.checkNotNull(character, "character"); + Preconditions.checkArgument(page >= 0 && page <= 10, "0 <= page <= 10"); + Preconditions.checkArgument(page >= 0 && slot <= 12, "0 <= slot <= 10"); + final CharacterShortcut shortcut = character.getShortcuts().get(page, + slot); + if (shortcut == null) + throw new ShortcutSlotEmptyServiceException(); + + // synchronous delete here + shortcutDao.delete(shortcut); + character.getShortcuts().unregister(shortcut); + + eventDispatcher.dispatch(new CharacterDeleteShortcutEvent(character, + shortcut)); + } +} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutSlotEmptyServiceException.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutSlotEmptyServiceException.java new file mode 100644 index 000000000..0672a32f5 --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutSlotEmptyServiceException.java @@ -0,0 +1,30 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.service.game.character; + +/** + * Exception thrown when the requested shortcut slot is empty + * + * @author Rogiel + */ +public class ShortcutSlotEmptyServiceException extends + CharacterServiceException { + /** + * The Java Serialization API serial + */ + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutSlotNotFreeServiceException.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutSlotNotFreeServiceException.java new file mode 100644 index 000000000..fe2438bc8 --- /dev/null +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutSlotNotFreeServiceException.java @@ -0,0 +1,30 @@ +/* + * This file is part of l2jserver2 . + * + * l2jserver2 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. + * + * l2jserver2 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 l2jserver2. If not, see . + */ +package com.l2jserver.service.game.character; + +/** + * Exception thrown when the shortcut slot is not free + * + * @author Rogiel + */ +public class ShortcutSlotNotFreeServiceException extends + CharacterServiceException { + /** + * The Java Serialization API serial + */ + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/network/broadcast/BroadcastServiceImpl.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/network/broadcast/BroadcastServiceImpl.java index 35d7f55dc..a54a33532 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/network/broadcast/BroadcastServiceImpl.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/network/broadcast/BroadcastServiceImpl.java @@ -23,23 +23,25 @@ import com.google.common.base.Preconditions; import com.google.inject.Inject; import com.l2jserver.game.net.Lineage2Client; import com.l2jserver.game.net.SystemMessage; +import com.l2jserver.game.net.packet.server.SM_ACTOR_ATTACK; import com.l2jserver.game.net.packet.server.SM_ACTOR_CHAT; import com.l2jserver.game.net.packet.server.SM_ACTOR_DIE; import com.l2jserver.game.net.packet.server.SM_ACTOR_MOVE; import com.l2jserver.game.net.packet.server.SM_ACTOR_STATUS_UPDATE; import com.l2jserver.game.net.packet.server.SM_ACTOR_STATUS_UPDATE.Stat; -import com.l2jserver.game.net.packet.server.SM_ACTOR_ATTACK; import com.l2jserver.game.net.packet.server.SM_CHAR_INFO; import com.l2jserver.game.net.packet.server.SM_CHAR_INFO_BROADCAST; import com.l2jserver.game.net.packet.server.SM_CHAR_INFO_EXTRA; import com.l2jserver.game.net.packet.server.SM_CHAR_INVENTORY; +import com.l2jserver.game.net.packet.server.SM_CHAR_MOVE_TYPE; +import com.l2jserver.game.net.packet.server.SM_CHAR_SHORTCUT_LIST; +import com.l2jserver.game.net.packet.server.SM_CHAR_SHORTCUT_REGISTER; import com.l2jserver.game.net.packet.server.SM_CHAR_TARGET; import com.l2jserver.game.net.packet.server.SM_CHAR_TARGET_UNSELECT; import com.l2jserver.game.net.packet.server.SM_CHAR_TELEPORT; import com.l2jserver.game.net.packet.server.SM_HTML; import com.l2jserver.game.net.packet.server.SM_ITEM_GROUND; import com.l2jserver.game.net.packet.server.SM_ITEM_PICK; -import com.l2jserver.game.net.packet.server.SM_CHAR_MOVE_TYPE; import com.l2jserver.game.net.packet.server.SM_NPC_INFO; import com.l2jserver.game.net.packet.server.SM_OBJECT_REMOVE; import com.l2jserver.model.id.object.CharacterID; @@ -54,6 +56,7 @@ import com.l2jserver.model.world.actor.event.ActorAttackHitEvent; import com.l2jserver.model.world.actor.event.ActorDieEvent; import com.l2jserver.model.world.actor.event.ActorTeleportingEvent; import com.l2jserver.model.world.actor.event.ActorUnspawnEvent; +import com.l2jserver.model.world.character.event.CharacterCreateShortcutEvent; import com.l2jserver.model.world.character.event.CharacterEnterWorldEvent; import com.l2jserver.model.world.character.event.CharacterEvent; import com.l2jserver.model.world.character.event.CharacterLeaveWorldEvent; @@ -171,11 +174,11 @@ public class BroadcastServiceImpl extends AbstractService implements // object is now out of sight conn.write(new SM_OBJECT_REMOVE(object)); } else if (e instanceof CharacterWalkingEvent) { - conn.write(new SM_CHAR_MOVE_TYPE(((CharacterWalkingEvent) e) - .getCharacter())); + conn.write(new SM_CHAR_MOVE_TYPE( + ((CharacterWalkingEvent) e).getCharacter())); } else if (e instanceof CharacterRunningEvent) { - conn.write(new SM_CHAR_MOVE_TYPE(((CharacterRunningEvent) e) - .getCharacter())); + conn.write(new SM_CHAR_MOVE_TYPE( + ((CharacterRunningEvent) e).getCharacter())); } else if (e instanceof ActorDieEvent) { conn.write(new SM_ACTOR_DIE(((ActorDieEvent) e).getActor())); } @@ -225,13 +228,15 @@ public class BroadcastServiceImpl extends AbstractService implements conn.write(new SM_CHAR_INFO_EXTRA(character)); broadcastAll(conn, character); } else if (e instanceof ActorAttackHitEvent) { - conn.write(new SM_ACTOR_ATTACK(((ActorAttackHitEvent) e).getHit())); + conn.write(new SM_ACTOR_ATTACK(((ActorAttackHitEvent) e) + .getHit())); conn.sendSystemMessage(SystemMessage.YOU_DID_S1_DMG, (int) ((ActorAttackHitEvent) e).getHit() .getDamage()); } else if (e instanceof CharacterWalkingEvent || e instanceof CharacterRunningEvent) { - conn.write(new SM_CHAR_MOVE_TYPE((L2Character) e.getObject())); + conn.write(new SM_CHAR_MOVE_TYPE((L2Character) e + .getObject())); } else if (e instanceof ActorTeleportingEvent) { final ActorTeleportingEvent evt = (ActorTeleportingEvent) e; conn.write(new SM_CHAR_TELEPORT((L2Character) evt @@ -240,6 +245,9 @@ public class BroadcastServiceImpl extends AbstractService implements conn.write(new SM_HTML(((NPCTalkEvent) e).getNPC(), ((NPCTalkEvent) e).getHtml())); conn.sendActionFailed(); + } else if (e instanceof CharacterCreateShortcutEvent) { + conn.write(new SM_CHAR_SHORTCUT_REGISTER( + ((CharacterCreateShortcutEvent) e).getShortcut())); } // keep listener alive return true; @@ -369,6 +377,7 @@ public class BroadcastServiceImpl extends AbstractService implements conn.write(new SM_CHAR_INFO(e.getCharacter())); conn.write(new SM_CHAR_INFO_EXTRA(e.getCharacter())); conn.write(new SM_CHAR_INVENTORY(e.getCharacter().getInventory())); + conn.write(new SM_CHAR_SHORTCUT_LIST(e.getCharacter().getShortcuts())); broadcastAll(conn, character); } diff --git a/l2jserver2-gameserver/src/test/java/com/l2jserver/model/id/provider/CharacterIDProviderTest.java b/l2jserver2-gameserver/src/test/java/com/l2jserver/model/id/provider/CharacterIDProviderTest.java index 07eec683e..41ceacff1 100644 --- a/l2jserver2-gameserver/src/test/java/com/l2jserver/model/id/provider/CharacterIDProviderTest.java +++ b/l2jserver2-gameserver/src/test/java/com/l2jserver/model/id/provider/CharacterIDProviderTest.java @@ -31,13 +31,13 @@ import com.l2jserver.service.ServiceManager; import com.l2jserver.service.ServiceModule; import com.l2jserver.service.ServiceStartException; import com.l2jserver.service.database.DatabaseService; -import com.l2jserver.service.database.H2DAOModule; +import com.l2jserver.service.database.JDBCDAOModule; import com.l2jserver.service.game.template.TemplateService; import com.l2jserver.service.game.world.WorldService; public class CharacterIDProviderTest { private final Injector injector = Guice.createInjector(new ServiceModule(), - new H2DAOModule(), new IDProviderModule()); + new JDBCDAOModule(), new IDProviderModule()); private CharacterIDProvider charIdFactory; @Before diff --git a/l2jserver2-gameserver/src/test/java/com/l2jserver/service/game/template/StaticTemplateServiceTest.java b/l2jserver2-gameserver/src/test/java/com/l2jserver/service/game/template/StaticTemplateServiceTest.java index b081ae6d7..f5a0d4e60 100644 --- a/l2jserver2-gameserver/src/test/java/com/l2jserver/service/game/template/StaticTemplateServiceTest.java +++ b/l2jserver2-gameserver/src/test/java/com/l2jserver/service/game/template/StaticTemplateServiceTest.java @@ -25,11 +25,11 @@ import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider; import com.l2jserver.service.ServiceManager; import com.l2jserver.service.ServiceModule; import com.l2jserver.service.ServiceStartException; -import com.l2jserver.service.database.H2DAOModule; +import com.l2jserver.service.database.JDBCDAOModule; public class StaticTemplateServiceTest { private final Injector injector = Guice.createInjector(new ServiceModule(), - new IDProviderModule(), new H2DAOModule()); + new IDProviderModule(), new JDBCDAOModule()); private final ItemTemplateIDProvider factory = injector .getInstance(ItemTemplateIDProvider.class);