1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-08 08:23:11 +00:00

Implemented ShortcutID and fixed compile warnings

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-06-15 12:26:12 -03:00
parent 0146d1aa82
commit ebb2b2a81a
8 changed files with 122 additions and 7 deletions

View File

@@ -17,6 +17,7 @@
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;
@@ -25,10 +26,9 @@ import com.l2jserver.model.world.L2Character;
/**
* An shortcut in Lineage II game interface
*
* @author <a href="http://www.rogiel.com">Rogiel</a><br />
* TODO create the shortcut id
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class Shortcut extends AbstractModel {
public class Shortcut extends AbstractModel<ShortcutID> {
/**
* The character id
*/

View File

@@ -41,4 +41,18 @@ public class FriendID extends AbstractCompoundID<CharacterID, CharacterID> {
@Assisted("id2") CharacterID id2) {
super(id1, id2);
}
/**
* @return the character ID
*/
public CharacterID getCharacterID() {
return getID1();
}
/**
* @return the friend ID
*/
public CharacterID getFriendID() {
return getID2();
}
}

View File

@@ -0,0 +1,94 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.game.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.template.SkillTemplateID;
/**
* Each {@link Shortcut} is identified by an {@link ID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ShortcutID extends AbstractCompoundID<CharacterID, ID<?>> {
/**
* 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();
}
}