1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-06 07:32:46 +00:00

Implements item shortcut creation and deleting

This commit is contained in:
2011-12-20 02:34:16 -02:00
parent affa2b6c1a
commit 9f7b05c7a8
71 changed files with 1848 additions and 1120 deletions

View File

@@ -1,8 +1,8 @@
CREATE TABLE IF NOT EXISTS `actor_skill` ( CREATE TABLE `actor_skill` (
`actor_id` int(10) NOT NULL, `actor_id` int(10) NOT NULL,
`skill_id` int(10) NOT NULL, `skill_id` int(10) NOT NULL,
`level` int(2) NOT NULL DEFAULT '1', `level` int(2) NOT NULL DEFAULT '1',
PRIMARY KEY (`actor_id`,`skill_id`), PRIMARY KEY (`actor_id`,`skill_id`),
KEY `actor_id` (`actor_id`), KEY `actor_id` (`actor_id`),
KEY `skill_id` (`skill_id`) KEY `skill_id` (`skill_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1; );

View File

@@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS `character` ( CREATE TABLE `character` (
`character_id` int(12) NOT NULL, `character_id` int(12) NOT NULL,
`account_id` varchar(50) NOT NULL, `account_id` varchar(50) NOT NULL,
`clan_id` int(10) DEFAULT NULL, `clan_id` int(10) DEFAULT NULL,
@@ -23,4 +23,4 @@ CREATE TABLE IF NOT EXISTS `character` (
KEY `account_id` (`account_id`), KEY `account_id` (`account_id`),
KEY `name` (`name`), KEY `name` (`name`),
KEY `clan_id` (`clan_id`) KEY `clan_id` (`clan_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1; );

View File

@@ -2,4 +2,4 @@ CREATE TABLE `character_friend` (
`character_id` int(10) NOT NULL, `character_id` int(10) NOT NULL,
`character_id_friend` int(10) NOT NULL, `character_id_friend` int(10) NOT NULL,
PRIMARY KEY (`character_id`,`character_id_friend`) PRIMARY KEY (`character_id`,`character_id_friend`)
) ENGINE=MyISAM; );

View File

@@ -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, `character_id` int(10) NOT NULL,
`shortcut_id` int(10) DEFAULT NULL,
`slot` int(2) NOT NULL, `slot` int(2) NOT NULL,
`page` int(1) NOT NULL, `page` int(1) NOT NULL,
`type` enum('ITEM','SKILL','ACTION','MACRO','RECIPE','TPBOOKMARK') NOT NULL, `type` enum('ITEM','SKILL','ACTION','MACRO','RECIPE','TPBOOKMARK') NOT NULL,
`object_id` int(10) NOT NULL,
`level` int(2) DEFAULT NULL, `level` int(2) DEFAULT NULL,
`character_type` int(10) NOT NULL, `character_type` int(10) DEFAULT NULL,
PRIMARY KEY (`character_id`,`slot`,`page`), PRIMARY KEY (`shortcut_id`),
UNIQUE KEY `character_id-slot-page` (`character_id`,`slot`,`page`),
KEY `character_id` (`character_id`), KEY `character_id` (`character_id`),
KEY `shortcut_id` (`shortcut_id`) KEY `character_id-page` (`character_id`,`page`),
) ENGINE=MyISAM DEFAULT CHARSET=latin1; KEY `character_id-type` (`character_id`,`type`)
);

View File

@@ -1,6 +1,6 @@
CREATE TABLE IF NOT EXISTS `clan` ( CREATE TABLE `clan` (
`clan_id` int(10) NOT NULL, `clan_id` int(10) NOT NULL,
`character_id_leader` int(10) NOT NULL, `character_id_leader` int(10) NOT NULL,
PRIMARY KEY (`clan_id`), PRIMARY KEY (`clan_id`),
KEY `character_id_leader` (`character_id_leader`) KEY `character_id_leader` (`character_id_leader`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1; );

View File

@@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS `item` ( CREATE TABLE `item` (
`item_id` int(12) NOT NULL, `item_id` int(12) NOT NULL,
`template_id` int(10) NOT NULL, `template_id` int(10) NOT NULL,
`character_id` int(12) DEFAULT NULL, `character_id` int(12) DEFAULT NULL,
@@ -11,4 +11,4 @@ CREATE TABLE IF NOT EXISTS `item` (
PRIMARY KEY (`item_id`), PRIMARY KEY (`item_id`),
KEY `character_id` (`character_id`), KEY `character_id` (`character_id`),
KEY `template_id` (`template_id`) KEY `template_id` (`template_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1; );

View File

@@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS `log_chat` ( CREATE TABLE `log_chat` (
`message_id` int(12) NOT NULL AUTO_INCREMENT, `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, `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, `channel_id` int(12) NOT NULL,
@@ -6,4 +6,4 @@ CREATE TABLE IF NOT EXISTS `log_chat` (
`date` TIMESTAMP NOT NULL, `date` TIMESTAMP NOT NULL,
`message` text NOT NULL, `message` text NOT NULL,
PRIMARY KEY (`message_id`) PRIMARY KEY (`message_id`)
) ENGINE=MyISAM; );

View File

@@ -13,7 +13,7 @@ CREATE TABLE `npc` (
KEY `point` (`point_x`,`point_y`,`point_z`,`point_angle`), KEY `point` (`point_x`,`point_y`,`point_z`,`point_angle`),
KEY `xy` (`point_x`,`point_y`), KEY `xy` (`point_x`,`point_y`),
KEY `xyz` (`point_x`,`point_y`,`point_z`) KEY `xyz` (`point_x`,`point_y`,`point_z`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1; );
-- --
-- STATIC DATA -- STATIC DATA

View File

@@ -20,7 +20,7 @@ import com.google.inject.AbstractModule;
import com.google.inject.Module; import com.google.inject.Module;
import com.l2jserver.model.id.provider.IDProviderModule; import com.l2jserver.model.id.provider.IDProviderModule;
import com.l2jserver.service.ServiceModule; import com.l2jserver.service.ServiceModule;
import com.l2jserver.service.database.MySQL5DAOModule; import com.l2jserver.service.database.JDBCDAOModule;
/** /**
* The game server Google Guice {@link Module}. * The game server Google Guice {@link Module}.
@@ -32,6 +32,6 @@ public class GameServerModule extends AbstractModule {
protected void configure() { protected void configure() {
install(new ServiceModule()); install(new ServiceModule());
install(new IDProviderModule()); install(new IDProviderModule());
install(new MySQL5DAOModule()); install(new JDBCDAOModule());
} }
} }

View File

@@ -23,6 +23,7 @@ import com.l2jserver.service.cache.CacheService;
import com.l2jserver.service.configuration.ConfigurationService; import com.l2jserver.service.configuration.ConfigurationService;
import com.l2jserver.service.database.DatabaseService; import com.l2jserver.service.database.DatabaseService;
import com.l2jserver.service.game.character.CharacterService; 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.chat.ChatService;
import com.l2jserver.service.game.item.ItemService; import com.l2jserver.service.game.item.ItemService;
import com.l2jserver.service.game.map.pathing.PathingService; import com.l2jserver.service.game.map.pathing.PathingService;
@@ -43,8 +44,9 @@ public class L2JGameServerMain {
ConfigurationService.class, DatabaseService.class, ConfigurationService.class, DatabaseService.class,
WorldIDService.class, ScriptingService.class, WorldIDService.class, ScriptingService.class,
TemplateService.class, ChatService.class, NPCService.class, TemplateService.class, ChatService.class, NPCService.class,
ItemService.class, CharacterService.class, PathingService.class, ItemService.class, CharacterService.class, ShortcutService.class,
BlowfishKeygenService.class, NetworkService.class }; PathingService.class, BlowfishKeygenService.class,
NetworkService.class };
/** /**
* Main method * Main method

View File

@@ -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_POSITION;
import com.l2jserver.game.net.packet.client.CM_CHAR_REQ_INVENTORY; 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_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_CHAR_TARGET_UNSELECT;
import com.l2jserver.game.net.packet.client.CM_ENTER_WORLD; import com.l2jserver.game.net.packet.client.CM_ENTER_WORLD;
import com.l2jserver.game.net.packet.client.CM_EXT_REQ_ALL_FORTRESS_INFO; 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; return CM_ITEM_DESTROY.class;
case CM_CHAR_TARGET_UNSELECT.OPCODE: case CM_CHAR_TARGET_UNSELECT.OPCODE:
return CM_CHAR_TARGET_UNSELECT.class; 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: default:
logger.warn("Unknown packet for 0x{}", Integer.toHexString(opcode)); logger.warn("Unknown packet for 0x{}", Integer.toHexString(opcode));
break; break;

View File

@@ -0,0 +1,125 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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();
}
}
}

View File

@@ -0,0 +1,77 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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();
}
}
}

View File

@@ -0,0 +1,66 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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;
}
}
}
}

View File

@@ -0,0 +1,62 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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;
}
}
}

View File

@@ -22,7 +22,6 @@ import com.l2jserver.model.id.AccountID;
import com.l2jserver.model.id.object.CharacterID; import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.world.Clan; import com.l2jserver.model.world.Clan;
import com.l2jserver.model.world.L2Character; import com.l2jserver.model.world.L2Character;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.database.DataAccessObject; import com.l2jserver.service.database.DataAccessObject;
/** /**
@@ -32,7 +31,7 @@ import com.l2jserver.service.database.DataAccessObject;
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public interface CharacterDAO extends public interface CharacterDAO extends
DataAccessObject<L2Character, CharacterID>, Cacheable { DataAccessObject<L2Character, CharacterID> {
/** /**
* Load the members of the given <tt>clan</tt> * Load the members of the given <tt>clan</tt>
* *

View File

@@ -20,7 +20,6 @@ import com.l2jserver.model.game.CharacterFriend;
import com.l2jserver.model.id.FriendID; import com.l2jserver.model.id.FriendID;
import com.l2jserver.model.world.L2Character; import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.character.CharacterFriendList; import com.l2jserver.model.world.character.CharacterFriendList;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.cache.IgnoreCaching; import com.l2jserver.service.cache.IgnoreCaching;
import com.l2jserver.service.database.DataAccessObject; import com.l2jserver.service.database.DataAccessObject;
@@ -31,7 +30,7 @@ import com.l2jserver.service.database.DataAccessObject;
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public interface CharacterFriendDAO extends public interface CharacterFriendDAO extends
DataAccessObject<CharacterFriend, FriendID>, Cacheable { DataAccessObject<CharacterFriend, FriendID> {
/** /**
* Load the friend list for character represented by <tt>character</tt> from * Load the friend list for character represented by <tt>character</tt> from
* the database * the database

View File

@@ -0,0 +1,43 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface CharacterShortcutDAO extends
DataAccessObject<CharacterShortcut, CharacterShortcutID> {
/**
* Loads the shortcuts at the list fors <tt>character</tt> from the database
*
* @param character
* the character
* @return all shortcuts from the given character
*/
List<CharacterShortcut> selectByCharacter(L2Character character);
}

View File

@@ -18,7 +18,6 @@ package com.l2jserver.model.dao;
import com.l2jserver.model.id.ChatMessageID; import com.l2jserver.model.id.ChatMessageID;
import com.l2jserver.model.server.ChatMessage; import com.l2jserver.model.server.ChatMessage;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.database.DataAccessObject; import com.l2jserver.service.database.DataAccessObject;
/** /**
@@ -28,5 +27,5 @@ import com.l2jserver.service.database.DataAccessObject;
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public interface ChatMessageDAO extends public interface ChatMessageDAO extends
DataAccessObject<ChatMessage, ChatMessageID>, Cacheable { DataAccessObject<ChatMessage, ChatMessageID> {
} }

View File

@@ -18,7 +18,6 @@ package com.l2jserver.model.dao;
import com.l2jserver.model.id.object.ClanID; import com.l2jserver.model.id.object.ClanID;
import com.l2jserver.model.world.Clan; import com.l2jserver.model.world.Clan;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.database.DataAccessObject; import com.l2jserver.service.database.DataAccessObject;
/** /**
@@ -26,5 +25,5 @@ import com.l2jserver.service.database.DataAccessObject;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public interface ClanDAO extends DataAccessObject<Clan, ClanID>, Cacheable { public interface ClanDAO extends DataAccessObject<Clan, ClanID> {
} }

View File

@@ -21,7 +21,6 @@ import java.util.List;
import com.l2jserver.model.id.object.ItemID; import com.l2jserver.model.id.object.ItemID;
import com.l2jserver.model.world.Item; import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.L2Character; import com.l2jserver.model.world.L2Character;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.database.DataAccessObject; import com.l2jserver.service.database.DataAccessObject;
/** /**
@@ -30,15 +29,15 @@ import com.l2jserver.service.database.DataAccessObject;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public interface ItemDAO extends DataAccessObject<Item, ItemID>, Cacheable { public interface ItemDAO extends DataAccessObject<Item, ItemID> {
/** /**
* Load the inventory for an {@link L2Character character}. * Load the inventory for an {@link L2Character character}.
* *
* @param character * @param character
* the character * the character
* @return amount of items loaded * @return amount list of character items
*/ */
int loadInventory(L2Character character); List<Item> selectByCharacter(L2Character character);
/** /**
* Select from the database the items dropped on the ground * Select from the database the items dropped on the ground

View File

@@ -22,7 +22,6 @@ import java.util.List;
import com.l2jserver.model.id.object.NPCID; import com.l2jserver.model.id.object.NPCID;
import com.l2jserver.model.id.template.NPCTemplateID; import com.l2jserver.model.id.template.NPCTemplateID;
import com.l2jserver.model.world.NPC; import com.l2jserver.model.world.NPC;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.database.DataAccessObject; import com.l2jserver.service.database.DataAccessObject;
/** /**
@@ -30,7 +29,7 @@ import com.l2jserver.service.database.DataAccessObject;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public interface NPCDAO extends DataAccessObject<NPC, NPCID>, Cacheable { public interface NPCDAO extends DataAccessObject<NPC, NPCID> {
/** /**
* Load all {@link NPC} instances * Load all {@link NPC} instances
* *

View File

@@ -18,7 +18,6 @@ package com.l2jserver.model.dao;
import com.l2jserver.model.id.object.PetID; import com.l2jserver.model.id.object.PetID;
import com.l2jserver.model.world.Pet; import com.l2jserver.model.world.Pet;
import com.l2jserver.service.cache.Cacheable;
import com.l2jserver.service.database.DataAccessObject; import com.l2jserver.service.database.DataAccessObject;
/** /**
@@ -26,5 +25,5 @@ import com.l2jserver.service.database.DataAccessObject;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public interface PetDAO extends DataAccessObject<Pet, PetID>, Cacheable { public interface PetDAO extends DataAccessObject<Pet, PetID> {
} }

View File

@@ -0,0 +1,383 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterShortcut extends AbstractModel<CharacterShortcutID> {
/**
* The character id
*/
private CharacterID characterID;
/**
* The shortcut skill id (only if <tt>type</tt> is
* {@link ShortcutType#SKILL})
*/
private SkillTemplateID skillID;
/**
* The shortcut item id (only if <tt>type</tt> 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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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 <tt>type</tt> 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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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;
}
}

View File

@@ -0,0 +1,54 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.dao.CharacterShortcutDAO;
import com.l2jserver.model.game.CharacterShortcut;
import com.l2jserver.model.id.provider.IDProvider;
/**
* Each {@link CharacterShortcut} is identified by an {@link ID}.
* <p>
* Please, do not directly instantiate this class, use an {@link IDProvider}
* instead.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterShortcutID extends
AbstractModelID<Integer, CharacterShortcut> {
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);
}
}

View File

@@ -34,7 +34,8 @@ import com.l2jserver.model.world.WorldObject;
* @param <T> * @param <T>
* the {@link WorldObject} type * the {@link WorldObject} type
*/ */
public abstract class ObjectID<T extends WorldObject> extends ID<Integer> { public abstract class ObjectID<T extends WorldObject> extends
AbstractModelID<Integer, T> {
/** /**
* Creates a new instance * Creates a new instance
* *

View File

@@ -0,0 +1,29 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.provider;
import com.l2jserver.model.id.CastleID;
import com.l2jserver.model.id.CharacterShortcutID;
/**
* Creates a new {@link CastleID}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface CharacterShortcutIDProvider extends
IDProvider<Integer, CharacterShortcutID> {
}

View File

@@ -69,13 +69,16 @@ public class IDProviderModule extends AbstractModule {
// MISC OBJECTS // MISC OBJECTS
install(new FactoryModuleBuilder().build(AccountIDProvider.class)); install(new FactoryModuleBuilder().build(AccountIDProvider.class));
install(new FactoryModuleBuilder()
.build(CharacterShortcutIDProvider.class));
install(new FactoryModuleBuilder().build(FortIDProvider.class)); install(new FactoryModuleBuilder().build(FortIDProvider.class));
install(new FactoryModuleBuilder().build(FriendIDProvider.class)); install(new FactoryModuleBuilder().build(FriendIDProvider.class));
install(new FactoryModuleBuilder().build(ChatMessageIDProvider.class)); install(new FactoryModuleBuilder().build(ChatMessageIDProvider.class));
// TEMPLATE IDS // TEMPLATE IDS
install(new FactoryModuleBuilder().build(ItemTemplateIDProvider.class)); 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(SkillTemplateIDProvider.class));
install(new FactoryModuleBuilder() install(new FactoryModuleBuilder()
.build(CharacterTemplateIDProvider.class)); .build(CharacterTemplateIDProvider.class));

View File

@@ -16,6 +16,7 @@
*/ */
package com.l2jserver.model.world; package com.l2jserver.model.world;
import com.l2jserver.model.Model;
import com.l2jserver.model.id.ObjectID; import com.l2jserver.model.id.ObjectID;
/** /**
@@ -25,7 +26,7 @@ import com.l2jserver.model.id.ObjectID;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public interface WorldObject { public interface WorldObject extends Model<ObjectID<?>> {
/** /**
* Get the object's ID * Get the object's ID
* *

View File

@@ -16,14 +16,12 @@
*/ */
package com.l2jserver.model.world.character; package com.l2jserver.model.world.character;
import java.io.Serializable;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator; 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.model.world.L2Character;
import com.l2jserver.util.factory.CollectionFactory; import com.l2jserver.util.factory.CollectionFactory;
@@ -32,7 +30,7 @@ import com.l2jserver.util.factory.CollectionFactory;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public class CharacterShortcutContainer implements Iterable<Shortcut> { public class CharacterShortcutContainer implements Iterable<CharacterShortcut> {
/** /**
* The character * The character
*/ */
@@ -40,7 +38,8 @@ public class CharacterShortcutContainer implements Iterable<Shortcut> {
/** /**
* The shortcut list * The shortcut list
*/ */
private List<Shortcut> shortcuts = CollectionFactory.newList(); private Map<Integer, CharacterShortcut> shortcuts = CollectionFactory
.newMap();
/** /**
* Creates a new instance * Creates a new instance
@@ -58,9 +57,8 @@ public class CharacterShortcutContainer implements Iterable<Shortcut> {
* @param shortcut * @param shortcut
* the shortcut to be added * the shortcut to be added
*/ */
public void register(Shortcut shortcut) { public void register(CharacterShortcut shortcut) {
shortcuts.add(shortcut); shortcuts.put(shortcut.getPage() * 12 + shortcut.getSlot(), shortcut);
Collections.sort(shortcuts, new ShortcutSlotComparator());
} }
/** /**
@@ -69,41 +67,32 @@ public class CharacterShortcutContainer implements Iterable<Shortcut> {
* @param shortcut * @param shortcut
* the shortcut to be removed * the shortcut to be removed
*/ */
public void unregister(Shortcut shortcut) { public void unregister(CharacterShortcut shortcut) {
shortcuts.remove(shortcut); for (final Entry<Integer, CharacterShortcut> entry : shortcuts
Collections.sort(shortcuts, new ShortcutSlotComparator()); .entrySet()) {
if (entry.getValue().getID().equals(shortcut.getID())) {
shortcuts.remove(entry.getKey());
return;
}
}
} }
/** /**
* Swap two shortcuts between them. Once swap is complete, * @param page
* <tt>shortcut1</tt> will be in the place of <tt>shortcut2</tt>, and * the page
* <tt>shortcut2</tt> in <tt>shortcut1</tt>. * @param slot
* * the slot
* @param shortcut1 * @return the given character shortcut, if registered.
* the first shortcut
* @param shortcut2
* the second shortcut
*/ */
public void swap(Shortcut shortcut1, Shortcut shortcut2) { public CharacterShortcut get(int page, int slot) {
// only swap if is registered already return shortcuts.get(page * 12 + slot);
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());
} }
/** /**
* @return true if container is full * @return true if container is full
*/ */
public boolean isFull() { public boolean isFull() {
return shortcuts.size() >= 12 * 4; return shortcuts.size() >= 12 * 10;
} }
/** /**
@@ -120,14 +109,22 @@ public class CharacterShortcutContainer implements Iterable<Shortcut> {
* @param shortcuts * @param shortcuts
* the collection of shortcuts * the collection of shortcuts
*/ */
public void load(Collection<Shortcut> shortcuts) { public void load(Collection<CharacterShortcut> shortcuts) {
this.shortcuts.addAll(shortcuts); for (final CharacterShortcut shortcut : shortcuts) {
Collections.sort(this.shortcuts, new ShortcutSlotComparator()); register(shortcut);
}
}
/**
* @return the amount if shortcuts in the container
*/
public int getShortcutCount() {
return shortcuts.size();
} }
@Override @Override
public Iterator<Shortcut> iterator() { public Iterator<CharacterShortcut> iterator() {
return shortcuts.iterator(); return shortcuts.values().iterator();
} }
/** /**
@@ -136,23 +133,4 @@ public class CharacterShortcutContainer implements Iterable<Shortcut> {
public L2Character getCharacter() { public L2Character getCharacter() {
return character; return character;
} }
/**
* Compares two shortcut slots
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public static class ShortcutSlotComparator implements Comparator<Shortcut>,
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()));
}
}
} }

View File

@@ -0,0 +1,86 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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() };
}
}

View File

@@ -0,0 +1,86 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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() };
}
}

View File

@@ -0,0 +1,88 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterListShortcutEvent implements CharacterEvent {
/**
* The character that is logging in
*/
private final L2Character character;
/**
* The list of all shortcuts
*/
private final List<CharacterShortcut> shortcuts;
/**
* Creates a new instance
*
* @param character
* the character
* @param shortcuts
* the list of all shortcuts
*/
public CharacterListShortcutEvent(L2Character character,
List<CharacterShortcut> shortcuts) {
this.character = character;
this.shortcuts = shortcuts;
}
/**
* @return the shortcuts
*/
public List<CharacterShortcut> 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() };
}
}

View File

@@ -37,6 +37,8 @@ import com.l2jserver.service.game.admin.AdministratorService;
import com.l2jserver.service.game.admin.AdministratorServiceImpl; import com.l2jserver.service.game.admin.AdministratorServiceImpl;
import com.l2jserver.service.game.character.CharacterService; import com.l2jserver.service.game.character.CharacterService;
import com.l2jserver.service.game.character.CharacterServiceImpl; 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.ChatLoggingService;
import com.l2jserver.service.game.chat.ChatService; import com.l2jserver.service.game.chat.ChatService;
import com.l2jserver.service.game.chat.DatabaseChatLoggingService; import com.l2jserver.service.game.chat.DatabaseChatLoggingService;
@@ -116,8 +118,12 @@ public class ServiceModule extends AbstractModule {
.in(Scopes.SINGLETON); .in(Scopes.SINGLETON);
bind(BroadcastService.class).to(BroadcastServiceImpl.class).in( bind(BroadcastService.class).to(BroadcastServiceImpl.class).in(
Scopes.SINGLETON); Scopes.SINGLETON);
bind(CharacterService.class).to(CharacterServiceImpl.class).in( bind(CharacterService.class).to(CharacterServiceImpl.class).in(
Scopes.SINGLETON); Scopes.SINGLETON);
bind(ShortcutService.class).to(ShortcutServiceImpl.class).in(
Scopes.SINGLETON);
bind(AttackService.class).to(AttackServiceImpl.class).in( bind(AttackService.class).to(AttackServiceImpl.class).in(
Scopes.SINGLETON); Scopes.SINGLETON);
bind(NPCService.class).to(NPCServiceImpl.class).in(Scopes.SINGLETON); bind(NPCService.class).to(NPCServiceImpl.class).in(Scopes.SINGLETON);

View File

@@ -1,57 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,60 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -21,37 +21,41 @@ import com.google.inject.Module;
import com.google.inject.Scopes; import com.google.inject.Scopes;
import com.l2jserver.model.dao.CharacterDAO; import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.CharacterFriendDAO; import com.l2jserver.model.dao.CharacterFriendDAO;
import com.l2jserver.model.dao.CharacterShortcutDAO;
import com.l2jserver.model.dao.ChatMessageDAO; import com.l2jserver.model.dao.ChatMessageDAO;
import com.l2jserver.model.dao.ClanDAO; import com.l2jserver.model.dao.ClanDAO;
import com.l2jserver.model.dao.ItemDAO; import com.l2jserver.model.dao.ItemDAO;
import com.l2jserver.model.dao.NPCDAO; import com.l2jserver.model.dao.NPCDAO;
import com.l2jserver.service.database.jdbc.mysql5.MySQL5CharacterDAO; import com.l2jserver.service.database.jdbc.JDBCCharacterDAO;
import com.l2jserver.service.database.jdbc.mysql5.MySQL5CharacterFriendDAO; import com.l2jserver.service.database.jdbc.JDBCCharacterFriendDAO;
import com.l2jserver.service.database.jdbc.mysql5.MySQL5ChatMessageDAO; import com.l2jserver.service.database.jdbc.JDBCCharacterShortcutDAO;
import com.l2jserver.service.database.jdbc.mysql5.MySQL5ClanDAO; import com.l2jserver.service.database.jdbc.JDBCChatMessageDAO;
import com.l2jserver.service.database.jdbc.mysql5.MySQL5ItemDAO; import com.l2jserver.service.database.jdbc.JDBCClanDAO;
import com.l2jserver.service.database.jdbc.mysql5.MySQL5NPCDAO; 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 <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public class MySQL5DAOModule extends AbstractModule { public class JDBCDAOModule extends AbstractModule {
@Override @Override
protected void configure() { 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); Scopes.SINGLETON);
bind(CharacterFriendDAO.class).to(MySQL5CharacterFriendDAO.class).in( bind(CharacterShortcutDAO.class).to(JDBCCharacterShortcutDAO.class).in(
Scopes.SINGLETON); 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(ItemDAO.class).to(JDBCItemDAO.class).in(Scopes.SINGLETON);
bind(ClanDAO.class).to(MySQL5ClanDAO.class).in(Scopes.SINGLETON); bind(ClanDAO.class).to(JDBCClanDAO.class).in(Scopes.SINGLETON);
// logs // logs
bind(ChatMessageDAO.class).to(MySQL5ChatMessageDAO.class).in( bind(ChatMessageDAO.class).to(JDBCChatMessageDAO.class).in(
Scopes.SINGLETON); Scopes.SINGLETON);
// DAO Resolver // DAO Resolver

View File

@@ -56,7 +56,7 @@ import com.l2jserver.util.geometry.Point3D;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public abstract class JDBCCharacterDAO extends public class JDBCCharacterDAO extends
AbstractJDBCDAO<L2Character, CharacterID> implements CharacterDAO { AbstractJDBCDAO<L2Character, CharacterID> implements CharacterDAO {
/** /**
* The {@link CharacterID} factory * The {@link CharacterID} factory

View File

@@ -43,7 +43,7 @@ import com.l2jserver.service.database.DatabaseService;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public abstract class JDBCCharacterFriendDAO extends public class JDBCCharacterFriendDAO extends
AbstractJDBCDAO<CharacterFriend, FriendID> implements AbstractJDBCDAO<CharacterFriend, FriendID> implements
CharacterFriendDAO { CharacterFriendDAO {
/** /**

View File

@@ -0,0 +1,298 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
public class JDBCCharacterShortcutDAO extends
AbstractJDBCDAO<CharacterShortcut, CharacterShortcutID> 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<CharacterShortcutID> idMapper = new Mapper<CharacterShortcutID>() {
@Override
public CharacterShortcutID map(ResultSet rs) throws SQLException {
return idProvider.resolveID(rs.getInt(SHORTCUT_ID));
}
};
/**
* The {@link Mapper} for {@link CharacterFriend}
*/
private final Mapper<CharacterShortcut> mapper = new CachedMapper<CharacterShortcut, CharacterShortcutID>(
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<CharacterShortcut>() {
@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<CharacterShortcut> mapper() {
return mapper;
}
});
}
@Override
public List<CharacterShortcut> selectByCharacter(final L2Character character) {
return database.query(new SelectListQuery<CharacterShortcut>() {
@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<CharacterShortcut> mapper() {
return mapper;
}
});
}
@Override
public List<CharacterShortcutID> selectIDs() {
return database.query(new SelectListQuery<CharacterShortcutID>() {
@Override
protected String query() {
return "SELECT * FROM `" + TABLE + "`";
}
@Override
protected Mapper<CharacterShortcutID> mapper() {
return idMapper;
}
});
}
@Override
public int insertObjects(CharacterShortcut... shortcuts) {
return database.query(new InsertUpdateQuery<CharacterShortcut>(
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<CharacterShortcutID> keyMapper() {
return new Mapper<CharacterShortcutID>() {
@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<CharacterShortcut>(
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<CharacterShortcut>(
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;
}
}

View File

@@ -45,7 +45,7 @@ import com.l2jserver.service.game.chat.ChatMessageType;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public abstract class JDBCChatMessageDAO extends public class JDBCChatMessageDAO extends
AbstractJDBCDAO<ChatMessage, ChatMessageID> implements ChatMessageDAO { AbstractJDBCDAO<ChatMessage, ChatMessageID> implements ChatMessageDAO {
/** /**
* The {@link ChatMessageID} factory * The {@link ChatMessageID} factory

View File

@@ -42,7 +42,7 @@ import com.l2jserver.service.database.DatabaseService;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public abstract class JDBCClanDAO extends AbstractJDBCDAO<Clan, ClanID> public class JDBCClanDAO extends AbstractJDBCDAO<Clan, ClanID>
implements ClanDAO { implements ClanDAO {
/** /**
* The {@link ClanID} factory * The {@link ClanID} factory

View File

@@ -37,7 +37,6 @@ import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
import com.l2jserver.model.template.item.ItemTemplate; import com.l2jserver.model.template.item.ItemTemplate;
import com.l2jserver.model.world.Item; import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.L2Character; 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.InventoryPaperdoll;
import com.l2jserver.model.world.character.CharacterInventory.ItemLocation; import com.l2jserver.model.world.character.CharacterInventory.ItemLocation;
import com.l2jserver.service.database.AbstractJDBCDatabaseService.CachedMapper; import com.l2jserver.service.database.AbstractJDBCDatabaseService.CachedMapper;
@@ -54,7 +53,7 @@ import com.l2jserver.util.geometry.Coordinate;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public abstract class JDBCItemDAO extends AbstractJDBCDAO<Item, ItemID> public class JDBCItemDAO extends AbstractJDBCDAO<Item, ItemID>
implements ItemDAO { implements ItemDAO {
/** /**
* The logger * The logger
@@ -180,9 +179,8 @@ public abstract class JDBCItemDAO extends AbstractJDBCDAO<Item, ItemID>
} }
@Override @Override
public int loadInventory(final L2Character character) { public List<Item> selectByCharacter(final L2Character character) {
final CharacterInventory inventory = character.getInventory(); return database.query(new SelectListQuery<Item>() {
final List<Item> items = database.query(new SelectListQuery<Item>() {
@Override @Override
protected String query() { protected String query() {
return "SELECT * FROM `" + TABLE + "` WHERE `" + CHAR_ID return "SELECT * FROM `" + TABLE + "` WHERE `" + CHAR_ID
@@ -200,8 +198,6 @@ public abstract class JDBCItemDAO extends AbstractJDBCDAO<Item, ItemID>
return mapper; return mapper;
} }
}); });
inventory.load(items);
return items.size();
} }
@Override @Override

View File

@@ -47,7 +47,7 @@ import com.l2jserver.util.geometry.Point3D;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public abstract class JDBCNPCDAO extends AbstractJDBCDAO<NPC, NPCID> implements public class JDBCNPCDAO extends AbstractJDBCDAO<NPC, NPCID> implements
NPCDAO { NPCDAO {
/** /**
* The logger * The logger

View File

@@ -1,55 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,46 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,46 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,46 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,49 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,46 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,54 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,46 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,46 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,46 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,49 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,46 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,55 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,46 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,46 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,46 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,49 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -1,46 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterDAO; import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.CharacterShortcutDAO;
import com.l2jserver.model.dao.ItemDAO; import com.l2jserver.model.dao.ItemDAO;
import com.l2jserver.model.id.object.CharacterID; import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.provider.CharacterIDProvider; import com.l2jserver.model.id.object.provider.CharacterIDProvider;
@@ -106,6 +107,10 @@ public class CharacterServiceImpl extends AbstractService implements
* The {@link ItemDAO} * The {@link ItemDAO}
*/ */
private final ItemDAO itemDao; private final ItemDAO itemDao;
/**
* The {@link CharacterShortcutDAO}
*/
private final CharacterShortcutDAO shortcutDao;
/** /**
* The character ID provider * The character ID provider
@@ -136,6 +141,8 @@ public class CharacterServiceImpl extends AbstractService implements
* the character DAO * the character DAO
* @param itemDao * @param itemDao
* the item DAO * the item DAO
* @param shortcutDao
* the shortcut DAO
* @param charTemplateIdProvider * @param charTemplateIdProvider
* the character template id provider * the character template id provider
* @param charIdProvider * @param charIdProvider
@@ -146,6 +153,7 @@ public class CharacterServiceImpl extends AbstractService implements
WorldEventDispatcher eventDispatcher, SpawnService spawnService, WorldEventDispatcher eventDispatcher, SpawnService spawnService,
NPCService npcService, GameGuardService ggService, NPCService npcService, GameGuardService ggService,
CharacterDAO characterDao, ItemDAO itemDao, CharacterDAO characterDao, ItemDAO itemDao,
CharacterShortcutDAO shortcutDao,
CharacterTemplateIDProvider charTemplateIdProvider, CharacterTemplateIDProvider charTemplateIdProvider,
CharacterIDProvider charIdProvider) { CharacterIDProvider charIdProvider) {
this.broadcastService = broadcastService; this.broadcastService = broadcastService;
@@ -155,6 +163,7 @@ public class CharacterServiceImpl extends AbstractService implements
this.ggService = ggService; this.ggService = ggService;
this.characterDao = characterDao; this.characterDao = characterDao;
this.itemDao = itemDao; this.itemDao = itemDao;
this.shortcutDao = shortcutDao;
this.charTemplateIdProvider = charTemplateIdProvider; this.charTemplateIdProvider = charTemplateIdProvider;
this.charIdProvider = charIdProvider; this.charIdProvider = charIdProvider;
} }
@@ -223,7 +232,10 @@ public class CharacterServiceImpl extends AbstractService implements
log.debug("Character {} is entering world", character); 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); character.setOnline(true);
// inventory interfere on calculators // inventory interfere on calculators
character.getStats().updateCalculator(); character.getStats().updateCalculator();
@@ -403,7 +415,7 @@ public class CharacterServiceImpl extends AbstractService implements
// TODO dispatch stop event // TODO dispatch stop event
} }
} }
characterDao.saveObjectsAsync(character); characterDao.saveObjectsAsync(character);
} }

View File

@@ -0,0 +1,62 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*/
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;
}

View File

@@ -0,0 +1,68 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.service.game.character;
import com.l2jserver.service.ServiceException;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
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);
}
}

View File

@@ -0,0 +1,107 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 <a href="http://www.rogiel.com">Rogiel</a>
*
*/
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));
}
}

View File

@@ -0,0 +1,30 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.service.game.character;
/**
* Exception thrown when the requested shortcut slot is empty
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ShortcutSlotEmptyServiceException extends
CharacterServiceException {
/**
* The Java Serialization API serial
*/
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,30 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.service.game.character;
/**
* Exception thrown when the shortcut slot is not free
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ShortcutSlotNotFreeServiceException extends
CharacterServiceException {
/**
* The Java Serialization API serial
*/
private static final long serialVersionUID = 1L;
}

View File

@@ -23,23 +23,25 @@ import com.google.common.base.Preconditions;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.l2jserver.game.net.Lineage2Client; import com.l2jserver.game.net.Lineage2Client;
import com.l2jserver.game.net.SystemMessage; 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_CHAT;
import com.l2jserver.game.net.packet.server.SM_ACTOR_DIE; 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_MOVE;
import com.l2jserver.game.net.packet.server.SM_ACTOR_STATUS_UPDATE; 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_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;
import com.l2jserver.game.net.packet.server.SM_CHAR_INFO_BROADCAST; 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_INFO_EXTRA;
import com.l2jserver.game.net.packet.server.SM_CHAR_INVENTORY; 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;
import com.l2jserver.game.net.packet.server.SM_CHAR_TARGET_UNSELECT; 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_CHAR_TELEPORT;
import com.l2jserver.game.net.packet.server.SM_HTML; 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_GROUND;
import com.l2jserver.game.net.packet.server.SM_ITEM_PICK; 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_NPC_INFO;
import com.l2jserver.game.net.packet.server.SM_OBJECT_REMOVE; import com.l2jserver.game.net.packet.server.SM_OBJECT_REMOVE;
import com.l2jserver.model.id.object.CharacterID; 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.ActorDieEvent;
import com.l2jserver.model.world.actor.event.ActorTeleportingEvent; import com.l2jserver.model.world.actor.event.ActorTeleportingEvent;
import com.l2jserver.model.world.actor.event.ActorUnspawnEvent; 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.CharacterEnterWorldEvent;
import com.l2jserver.model.world.character.event.CharacterEvent; import com.l2jserver.model.world.character.event.CharacterEvent;
import com.l2jserver.model.world.character.event.CharacterLeaveWorldEvent; import com.l2jserver.model.world.character.event.CharacterLeaveWorldEvent;
@@ -171,11 +174,11 @@ public class BroadcastServiceImpl extends AbstractService implements
// object is now out of sight // object is now out of sight
conn.write(new SM_OBJECT_REMOVE(object)); conn.write(new SM_OBJECT_REMOVE(object));
} else if (e instanceof CharacterWalkingEvent) { } else if (e instanceof CharacterWalkingEvent) {
conn.write(new SM_CHAR_MOVE_TYPE(((CharacterWalkingEvent) e) conn.write(new SM_CHAR_MOVE_TYPE(
.getCharacter())); ((CharacterWalkingEvent) e).getCharacter()));
} else if (e instanceof CharacterRunningEvent) { } else if (e instanceof CharacterRunningEvent) {
conn.write(new SM_CHAR_MOVE_TYPE(((CharacterRunningEvent) e) conn.write(new SM_CHAR_MOVE_TYPE(
.getCharacter())); ((CharacterRunningEvent) e).getCharacter()));
} else if (e instanceof ActorDieEvent) { } else if (e instanceof ActorDieEvent) {
conn.write(new SM_ACTOR_DIE(((ActorDieEvent) e).getActor())); 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)); conn.write(new SM_CHAR_INFO_EXTRA(character));
broadcastAll(conn, character); broadcastAll(conn, character);
} else if (e instanceof ActorAttackHitEvent) { } 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, conn.sendSystemMessage(SystemMessage.YOU_DID_S1_DMG,
(int) ((ActorAttackHitEvent) e).getHit() (int) ((ActorAttackHitEvent) e).getHit()
.getDamage()); .getDamage());
} else if (e instanceof CharacterWalkingEvent } else if (e instanceof CharacterWalkingEvent
|| e instanceof CharacterRunningEvent) { || 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) { } else if (e instanceof ActorTeleportingEvent) {
final ActorTeleportingEvent evt = (ActorTeleportingEvent) e; final ActorTeleportingEvent evt = (ActorTeleportingEvent) e;
conn.write(new SM_CHAR_TELEPORT((L2Character) evt 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(), conn.write(new SM_HTML(((NPCTalkEvent) e).getNPC(),
((NPCTalkEvent) e).getHtml())); ((NPCTalkEvent) e).getHtml()));
conn.sendActionFailed(); conn.sendActionFailed();
} else if (e instanceof CharacterCreateShortcutEvent) {
conn.write(new SM_CHAR_SHORTCUT_REGISTER(
((CharacterCreateShortcutEvent) e).getShortcut()));
} }
// keep listener alive // keep listener alive
return true; 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(e.getCharacter()));
conn.write(new SM_CHAR_INFO_EXTRA(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_INVENTORY(e.getCharacter().getInventory()));
conn.write(new SM_CHAR_SHORTCUT_LIST(e.getCharacter().getShortcuts()));
broadcastAll(conn, character); broadcastAll(conn, character);
} }

View File

@@ -31,13 +31,13 @@ import com.l2jserver.service.ServiceManager;
import com.l2jserver.service.ServiceModule; import com.l2jserver.service.ServiceModule;
import com.l2jserver.service.ServiceStartException; import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.database.DatabaseService; 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.template.TemplateService;
import com.l2jserver.service.game.world.WorldService; import com.l2jserver.service.game.world.WorldService;
public class CharacterIDProviderTest { public class CharacterIDProviderTest {
private final Injector injector = Guice.createInjector(new ServiceModule(), private final Injector injector = Guice.createInjector(new ServiceModule(),
new H2DAOModule(), new IDProviderModule()); new JDBCDAOModule(), new IDProviderModule());
private CharacterIDProvider charIdFactory; private CharacterIDProvider charIdFactory;
@Before @Before

View File

@@ -25,11 +25,11 @@ import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
import com.l2jserver.service.ServiceManager; import com.l2jserver.service.ServiceManager;
import com.l2jserver.service.ServiceModule; import com.l2jserver.service.ServiceModule;
import com.l2jserver.service.ServiceStartException; import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.database.H2DAOModule; import com.l2jserver.service.database.JDBCDAOModule;
public class StaticTemplateServiceTest { public class StaticTemplateServiceTest {
private final Injector injector = Guice.createInjector(new ServiceModule(), private final Injector injector = Guice.createInjector(new ServiceModule(),
new IDProviderModule(), new H2DAOModule()); new IDProviderModule(), new JDBCDAOModule());
private final ItemTemplateIDProvider factory = injector private final ItemTemplateIDProvider factory = injector
.getInstance(ItemTemplateIDProvider.class); .getInstance(ItemTemplateIDProvider.class);