diff --git a/src/org/apollo/game/message/impl/HintIconMessage.java b/src/org/apollo/game/message/impl/HintIconMessage.java index dff7f252..cbd2167b 100644 --- a/src/org/apollo/game/message/impl/HintIconMessage.java +++ b/src/org/apollo/game/message/impl/HintIconMessage.java @@ -1,5 +1,6 @@ package org.apollo.game.message.impl; +import java.util.NoSuchElementException; import java.util.Optional; import org.apollo.game.message.Message; @@ -15,14 +16,44 @@ public final class HintIconMessage extends Message { // TODO identify the other types and use an enum. /** - * The hint icon type for Npcs. + * The type of a HintIcon. */ - public static final int NPC_TYPE = 1; + public enum Type { - /** - * The hint icon type for Players. - */ - public static final int PLAYER_TYPE = 10; + /** + * A HintIcon that hovers over an Npc. + */ + NPC(1), + + /** + * A HintIcon that hovers over a Player. + */ + PLAYER(10); + + /** + * The integer value of this type. + */ + private final int value; + + /** + * Creates the Type. + * + * @param value The value. + */ + private Type(int value) { + this.value = value; + } + + /** + * Gets the value of this type. + * + * @return The value. + */ + public int getValue() { + return value; + } + + } /** * Creates a HintIconMessage for the Npc with the specified index. @@ -31,7 +62,7 @@ public final class HintIconMessage extends Message { * @return The HintIconMessage. */ public static HintIconMessage forNpc(int index) { - return new HintIconMessage(NPC_TYPE, Optional.of(index), Optional.empty()); + return new HintIconMessage(Type.NPC, Optional.of(index), Optional.empty()); } /** @@ -41,11 +72,11 @@ public final class HintIconMessage extends Message { * @return The HintIconMessage. */ public static HintIconMessage forPlayer(int index) { - return new HintIconMessage(PLAYER_TYPE, Optional.of(index), Optional.empty()); + return new HintIconMessage(Type.PLAYER, Optional.of(index), Optional.empty()); } /** - * The index of the entity, if applicable. + * The index of the Mob, if applicable. */ private final Optional index; @@ -55,18 +86,18 @@ public final class HintIconMessage extends Message { private final Optional position; /** - * The type of entity this HintIconMessage is directed at. + * The Type of entity this HintIconMessage is directed at. */ - private final int type; + private final Type type; /** * Creates the HintIconMessage. * - * @param type The type of entity this HintIconMessage is directed at. - * @param index The index of the entity, if applicable. + * @param type The {@link Type} of this HintIconMessage. + * @param index The index of the Mob, if applicable. * @param position The Position of the tile, if applicable. */ - private HintIconMessage(int type, Optional index, Optional position) { + private HintIconMessage(Type type, Optional index, Optional position) { this.type = type; this.index = index; this.position = position; @@ -76,18 +107,20 @@ public final class HintIconMessage extends Message { * Gets the index of the entity, if applicable. * * @return The index. + * @throws NoSuchElementException If no index is available for this HintIcon. */ - public Optional getIndex() { - return index; + public int getIndex() { + return index.get(); } /** * Gets the {@link Position} of the tile, if applicable. * * @return The Position. + * @throws NoSuchElementException If no Position is available for this HintIcon. */ - public Optional getPosition() { - return position; + public Position getPosition() { + return position.get(); } /** @@ -95,7 +128,7 @@ public final class HintIconMessage extends Message { * * @return The type. */ - public int getType() { + public Type getType() { return type; } diff --git a/src/org/apollo/net/release/r317/HintIconMessageEncoder.java b/src/org/apollo/net/release/r317/HintIconMessageEncoder.java index 036eed4d..e83f281f 100644 --- a/src/org/apollo/net/release/r317/HintIconMessageEncoder.java +++ b/src/org/apollo/net/release/r317/HintIconMessageEncoder.java @@ -16,13 +16,13 @@ public final class HintIconMessageEncoder extends MessageEncoder