mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Add HintIconMessage, FourthNpcActionMessage, and FifthNpcActionMessage.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package org.apollo.game.message.impl;
|
||||
|
||||
/**
|
||||
* The fifth {@link NpcActionMessage}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FifthNpcActionMessage extends NpcActionMessage {
|
||||
|
||||
/**
|
||||
* Creates a new fifth npc action message.
|
||||
*
|
||||
* @param index The index of the npc.
|
||||
*/
|
||||
public FifthNpcActionMessage(int index) {
|
||||
super(5, index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.apollo.game.message.impl;
|
||||
|
||||
/**
|
||||
* The fourth {@link NpcActionMessage}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FourthNpcActionMessage extends NpcActionMessage {
|
||||
|
||||
/**
|
||||
* Creates a new fourth npc action message.
|
||||
*
|
||||
* @param index The index of the npc.
|
||||
*/
|
||||
public FourthNpcActionMessage(int index) {
|
||||
super(4, index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package org.apollo.game.message.impl;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apollo.game.message.Message;
|
||||
import org.apollo.game.model.Position;
|
||||
|
||||
/**
|
||||
* A {@link Message} that displays a hint icon over an Npc, tile, or player.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class HintIconMessage extends Message {
|
||||
|
||||
// TODO identify the other types and use an enum.
|
||||
|
||||
/**
|
||||
* The hint icon type for Npcs.
|
||||
*/
|
||||
public static final int NPC_TYPE = 1;
|
||||
|
||||
/**
|
||||
* The hint icon type for Players.
|
||||
*/
|
||||
public static final int PLAYER_TYPE = 10;
|
||||
|
||||
/**
|
||||
* Creates a HintIconMessage for the Npc with the specified index.
|
||||
*
|
||||
* @param index The index of the Npc.
|
||||
* @return The HintIconMessage.
|
||||
*/
|
||||
public static HintIconMessage forNpc(int index) {
|
||||
return new HintIconMessage(NPC_TYPE, Optional.of(index), Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a HintIconMessage for the Player with the specified index.
|
||||
*
|
||||
* @param index The index of the Player.
|
||||
* @return The HintIconMessage.
|
||||
*/
|
||||
public static HintIconMessage forPlayer(int index) {
|
||||
return new HintIconMessage(PLAYER_TYPE, Optional.of(index), Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* The index of the entity, if applicable.
|
||||
*/
|
||||
private final Optional<Integer> index;
|
||||
|
||||
/**
|
||||
* The Position of the tile, if applicable.
|
||||
*/
|
||||
private final Optional<Position> position;
|
||||
|
||||
/**
|
||||
* The type of entity this HintIconMessage is directed at.
|
||||
*/
|
||||
private final int 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 position The Position of the tile, if applicable.
|
||||
*/
|
||||
private HintIconMessage(int type, Optional<Integer> index, Optional<Position> position) {
|
||||
this.type = type;
|
||||
this.index = index;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index of the entity, if applicable.
|
||||
*
|
||||
* @return The index.
|
||||
*/
|
||||
public Optional<Integer> getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Position} of the tile, if applicable.
|
||||
*
|
||||
* @return The Position.
|
||||
*/
|
||||
public Optional<Position> getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type this HintIconMessage is directed at.
|
||||
*
|
||||
* @return The type.
|
||||
*/
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.message.impl.HintIconMessage;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketBuilder;
|
||||
import org.apollo.net.release.MessageEncoder;
|
||||
|
||||
/**
|
||||
* A {@link MessageEncoder} for the {@link HintIconMessage}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class HintIconMessageEncoder extends MessageEncoder<HintIconMessage> {
|
||||
|
||||
@Override
|
||||
public GamePacket encode(HintIconMessage message) {
|
||||
GamePacketBuilder builder = new GamePacketBuilder(254);
|
||||
int type = message.getType();
|
||||
builder.put(DataType.BYTE, type);
|
||||
|
||||
switch (type) {
|
||||
case HintIconMessage.NPC_TYPE:
|
||||
case HintIconMessage.PLAYER_TYPE:
|
||||
builder.put(DataType.SHORT, message.getIndex().get());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported hint icon type " + type + ".");
|
||||
}
|
||||
|
||||
return builder.toGamePacket();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import org.apollo.game.message.impl.DisplayTabInterfaceMessage;
|
||||
import org.apollo.game.message.impl.EnterAmountMessage;
|
||||
import org.apollo.game.message.impl.ForwardPrivateChatMessage;
|
||||
import org.apollo.game.message.impl.FriendServerStatusMessage;
|
||||
import org.apollo.game.message.impl.HintIconMessage;
|
||||
import org.apollo.game.message.impl.IdAssignmentMessage;
|
||||
import org.apollo.game.message.impl.IgnoreListMessage;
|
||||
import org.apollo.game.message.impl.LogoutMessage;
|
||||
@@ -145,6 +146,7 @@ public final class Release317 extends Release {
|
||||
register(155, new FirstNpcActionMessageDecoder());
|
||||
register(17, new SecondNpcActionMessageDecoder());
|
||||
register(21, new ThirdNpcActionMessageDecoder());
|
||||
|
||||
register(236, new TakeTileItemMessageDecoder());
|
||||
register(192, new ItemOnObjectMessageDecoder());
|
||||
|
||||
@@ -201,6 +203,7 @@ public final class Release317 extends Release {
|
||||
register(FriendServerStatusMessage.class, new FriendServerStatusMessageEncoder());
|
||||
register(IgnoreListMessage.class, new IgnoreListMessageEncoder());
|
||||
register(SendFriendMessage.class, new SendFriendMessageEncoder());
|
||||
register(HintIconMessage.class, new HintIconMessageEncoder());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.message.impl.HintIconMessage;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketBuilder;
|
||||
import org.apollo.net.release.MessageEncoder;
|
||||
|
||||
/**
|
||||
* A {@link MessageEncoder} for the {@link HintIconMessage}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class HintIconMessageEncoder extends MessageEncoder<HintIconMessage> {
|
||||
|
||||
@Override
|
||||
public GamePacket encode(HintIconMessage message) {
|
||||
GamePacketBuilder builder = new GamePacketBuilder(199);
|
||||
int type = message.getType();
|
||||
builder.put(DataType.BYTE, type);
|
||||
|
||||
switch (type) {
|
||||
case HintIconMessage.NPC_TYPE:
|
||||
case HintIconMessage.PLAYER_TYPE:
|
||||
builder.put(DataType.SHORT, message.getIndex().get());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported hint icon type " + type + ".");
|
||||
}
|
||||
|
||||
return builder.toGamePacket();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import org.apollo.game.message.impl.DisplayTabInterfaceMessage;
|
||||
import org.apollo.game.message.impl.EnterAmountMessage;
|
||||
import org.apollo.game.message.impl.ForwardPrivateChatMessage;
|
||||
import org.apollo.game.message.impl.FriendServerStatusMessage;
|
||||
import org.apollo.game.message.impl.HintIconMessage;
|
||||
import org.apollo.game.message.impl.IdAssignmentMessage;
|
||||
import org.apollo.game.message.impl.IgnoreListMessage;
|
||||
import org.apollo.game.message.impl.LogoutMessage;
|
||||
@@ -19,8 +20,8 @@ import org.apollo.game.message.impl.OpenInterfaceSidebarMessage;
|
||||
import org.apollo.game.message.impl.PlayerSynchronizationMessage;
|
||||
import org.apollo.game.message.impl.PositionMessage;
|
||||
import org.apollo.game.message.impl.PrivacyOptionMessage;
|
||||
import org.apollo.game.message.impl.SectorChangeMessage;
|
||||
import org.apollo.game.message.impl.RemoveTileItemMessage;
|
||||
import org.apollo.game.message.impl.SectorChangeMessage;
|
||||
import org.apollo.game.message.impl.SendFriendMessage;
|
||||
import org.apollo.game.message.impl.SendObjectMessage;
|
||||
import org.apollo.game.message.impl.ServerChatMessage;
|
||||
@@ -40,6 +41,7 @@ import org.apollo.game.message.impl.UpdateTileItemMessage;
|
||||
import org.apollo.game.message.impl.UpdateWeightMessage;
|
||||
import org.apollo.net.meta.PacketMetaDataGroup;
|
||||
import org.apollo.net.release.Release;
|
||||
import org.apollo.net.release.r317.HintIconMessageEncoder;
|
||||
|
||||
/**
|
||||
* A {@link Release} implementation for the 377 protocol.
|
||||
@@ -128,7 +130,7 @@ public final class Release377 extends Release {
|
||||
register(36, new MagicOnItemMessageDecoder());
|
||||
|
||||
register(187, new FocusUpdateMessageDecoder());
|
||||
register(19, new MouseClickedMessageDecoder());
|
||||
register(19, new MouseClickedMessageDecoder());
|
||||
register(171, new FlaggedMouseEventMessageDecoder());
|
||||
register(140, new ArrowKeyMessageDecoder());
|
||||
register(176, new PrivacyOptionMessageDecoder());
|
||||
@@ -196,6 +198,7 @@ public final class Release377 extends Release {
|
||||
register(FriendServerStatusMessage.class, new FriendServerStatusMessageEncoder());
|
||||
register(IgnoreListMessage.class, new IgnoreListMessageEncoder());
|
||||
register(SendFriendMessage.class, new SendFriendMessageEncoder());
|
||||
register(HintIconMessage.class, new HintIconMessageEncoder());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user