diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/game/Shortcut.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/game/Shortcut.java deleted file mode 100644 index 0b39e07ca..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/game/Shortcut.java +++ /dev/null @@ -1,324 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * l2jserver2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with l2jserver2. If not, see . - */ -package com.l2jserver.model.game; - -import com.l2jserver.model.AbstractModel; -import com.l2jserver.model.id.ShortcutID; -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; - -/** - * An shortcut in Lineage II game interface - * - * @author Rogiel - */ -public class Shortcut extends AbstractModel { - /** - * The character id - */ - private final CharacterID characterID; - /** - * The shortcut skill id (only if type is - * {@link ShortcutType#SKILL}) - */ - private SkillTemplateID skillID; - - /** - * The shortcut item id (only if type is {@link ShortcutType#ITEM}) - */ - private ItemID itemID; - - /** - * The shortcut slot (0 - 11 = 12 slots/page) - */ - private int slot; - /** - * The shortcut page (0-3 = 4 pages) - */ - private int page; - /** - * The shortcut type - */ - private ShortcutType type; - - /** - * Enum with all shortcut types supported - * - * @author Rogiel - */ - public enum ShortcutType { - /** - * Item shortcut - */ - ITEM(1), - /** - * Skill shortcut - */ - SKILL(2), - /** - * Social action shortcut - */ - ACTION(3), - /** - * Macro shortcut - */ - MACRO(4), - /** - * Recipe shortcut - */ - RECIPE(5), - /** - * Bookmark shortcut - */ - TPBOOKMARK(6); - - /** - * The shortcut type id - */ - public final int id; - - /** - * @param id - * the numeric id - */ - ShortcutType(int id) { - this.id = id; - } - - /** - * - * @param id - * the type id - * @return the {@link ShortcutType} - */ - public static ShortcutType fromID(int id) { - for (final ShortcutType shortcut : values()) { - if (shortcut.id == id) - return shortcut; - } - return null; - } - } - - /** - * The skill level (only if type is {@link ShortcutType#SKILL}) - */ - private int level; - /** - * unknown! - */ - private int characterType; - - /** - * Creates a new instance - * - * @param characterID - * the character id - */ - public Shortcut(CharacterID characterID) { - this.characterID = characterID; - } - - /** - * Creates a new Item Shortcut - * - * @param characterID - * the character id - * @param itemID - * the item id - * @param characterType - * the character type - */ - public Shortcut(CharacterID characterID, ItemID itemID, int characterType) { - this.type = ShortcutType.ITEM; - this.characterID = characterID; - this.itemID = itemID; - this.characterType = characterType; - } - - /** - * Creates a new Skill Shortcut - * - * @param characterID - * the character id - * @param skillID - * the skill id - * @param level - * the skill level - * @param characterType - * the character type - */ - public Shortcut(CharacterID characterID, SkillTemplateID skillID, - int level, int characterType) { - this.type = ShortcutType.SKILL; - this.characterID = characterID; - this.skillID = skillID; - this.level = level; - this.characterType = characterType; - } - - /** - * 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 characterType - * the character type - */ - public Shortcut(CharacterID characterID, ShortcutType type, int slot, - int page, int characterType) { - this.characterID = characterID; - this.slot = slot; - this.page = page; - this.type = type; - this.characterType = characterType; - } - - /** - * @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 characterType - */ - public int getCharacterType() { - return characterType; - } - - /** - * @param characterType - * the characterType to set - */ - public void setCharacterType(int characterType) { - desireUpdate(); - this.characterType = characterType; - } - - /** - * @return the character id - */ - public CharacterID getCharacterID() { - return characterID; - } - - /** - * @return the character - */ - public L2Character getCharacter() { - return characterID.getObject(); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/ShortcutID.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/ShortcutID.java deleted file mode 100644 index 90177e0e4..000000000 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/model/id/ShortcutID.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * l2jserver2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with l2jserver2. If not, see . - */ -package com.l2jserver.model.id; - -import com.google.inject.Inject; -import com.google.inject.assistedinject.Assisted; -import com.l2jserver.model.game.Shortcut; -import com.l2jserver.model.id.compound.AbstractCompoundID; -import com.l2jserver.model.id.object.CharacterID; -import com.l2jserver.model.id.object.ItemID; -import com.l2jserver.model.id.provider.IDProvider; -import com.l2jserver.model.id.template.SkillTemplateID; - -/** - * Each {@link Shortcut} is identified by an {@link ID}. - *

- * Please, do not directly instantiate this class, use an {@link IDProvider} - * instead. - * - * @author Rogiel - */ -public class ShortcutID extends AbstractCompoundID> { - /** - * Creates a new instance - * - * @param id1 - * the first id - * @param id2 - * the second id - */ - @Inject - public ShortcutID(@Assisted("id1") CharacterID id1, - @Assisted("id2") ID id2) { - super(id1, id2); - } - - /** - * @return the character ID - */ - public CharacterID getCharacterID() { - return getID1(); - } - - /** - * @return the shortcut target ID - */ - public ID getTargetID() { - return getID2(); - } - - /** - * @return true if the {@link #getTargetID()} returns an - * {@link SkillTemplateID} - */ - public boolean isSkill() { - return getID2() instanceof SkillTemplateID; - } - - /** - * @return return the {@link #getTargetID()} casted to - * {@link SkillTemplateID} - * @throws ClassCastException - * if {@link #isSkill()} returns null. - */ - public SkillTemplateID getSkillID() { - return (SkillTemplateID) getTargetID(); - } - - /** - * @return true if the {@link #getTargetID()} returns an {@link ItemID} - */ - public boolean isItem() { - return getID2() instanceof ItemID; - } - - /** - * @return return the {@link #getTargetID()} casted to {@link ItemID} - * @throws ClassCastException - * if {@link #isItem()} returns null. - */ - public ItemID getItemID() { - return (ItemID) getTargetID(); - } -} diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutServiceImpl.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutServiceImpl.java index a01034e1e..57e4b05a8 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutServiceImpl.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/character/ShortcutServiceImpl.java @@ -31,7 +31,6 @@ import com.l2jserver.service.game.world.event.WorldEventDispatcher; /** * @author Rogiel - * */ public class ShortcutServiceImpl extends AbstractService implements ShortcutService { @@ -62,8 +61,8 @@ public class ShortcutServiceImpl extends AbstractService implements 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"); + Preconditions.checkArgument(page >= 0 && page < 10, "0 <= page < 10"); + Preconditions.checkArgument(page >= 0 && slot < 12, "0 <= slot < 12"); if (character.getShortcuts().get(page, slot) != null) throw new ShortcutSlotNotFreeServiceException(); @@ -90,15 +89,15 @@ public class ShortcutServiceImpl extends AbstractService implements 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"); + Preconditions.checkArgument(page >= 0 && page < 10, "0 <= page < 10"); + Preconditions.checkArgument(page >= 0 && slot < 12, "0 <= slot < 12"); final CharacterShortcut shortcut = character.getShortcuts().get(page, slot); if (shortcut == null) throw new ShortcutSlotEmptyServiceException(); - // synchronous delete here - shortcutDao.delete(shortcut); + // asynchronous delete here + shortcutDao.deleteObjectsAsync(shortcut); character.getShortcuts().unregister(shortcut); eventDispatcher.dispatch(new CharacterDeleteShortcutEvent(character,