mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 08:39:11 +00:00
Add player menu action events and decoders.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The fifth {@link PlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FifthPlayerActionEvent extends PlayerActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a fifth player action event.
|
||||
*
|
||||
* @param playerIndex The index of the clicked player.
|
||||
*/
|
||||
public FifthPlayerActionEvent(int playerIndex) {
|
||||
super(5, playerIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The first {@link PlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FirstPlayerActionEvent extends PlayerActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a first player action event.
|
||||
*
|
||||
* @param playerIndex The index of the clicked player.
|
||||
*/
|
||||
public FirstPlayerActionEvent(int playerIndex) {
|
||||
super(1, playerIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The fourth {@link PlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FourthPlayerActionEvent extends PlayerActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a fourth player action event.
|
||||
*
|
||||
* @param playerIndex The index of the clicked player.
|
||||
*/
|
||||
public FourthPlayerActionEvent(int playerIndex) {
|
||||
super(4, playerIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent by the client representing the clicking of a player menu action. Note that the actual event
|
||||
* sent by the client is one of the five player action events, but this is the event that should be intercepted (and the
|
||||
* option verified).
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public abstract class PlayerActionEvent extends Event {
|
||||
|
||||
/**
|
||||
* The option number.
|
||||
*/
|
||||
private final int option;
|
||||
|
||||
/**
|
||||
* The index of the clicked player.
|
||||
*/
|
||||
private final int index;
|
||||
|
||||
/**
|
||||
* Creates a player action event.
|
||||
*
|
||||
* @param option The option number.
|
||||
* @param playerIndex The index of the player.
|
||||
*/
|
||||
public PlayerActionEvent(int option, int playerIndex) {
|
||||
this.option = option;
|
||||
this.index = playerIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the menu action number (i.e. the action event 'option') clicked.
|
||||
*
|
||||
* @return The option number.
|
||||
*/
|
||||
public int getOption() {
|
||||
return option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index of the clicked player.
|
||||
*
|
||||
* @return The index.
|
||||
*/
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The second {@link PlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class SecondPlayerActionEvent extends PlayerActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a second player action event.
|
||||
*
|
||||
* @param playerIndex The index of the clicked player.
|
||||
*/
|
||||
public SecondPlayerActionEvent(int playerIndex) {
|
||||
super(2, playerIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The third {@link PlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class ThirdPlayerActionEvent extends PlayerActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a third player action event.
|
||||
*
|
||||
* @param playerIndex The index of the clicked player.
|
||||
*/
|
||||
public ThirdPlayerActionEvent(int playerIndex) {
|
||||
super(3, playerIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.FifthPlayerActionEvent;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link FifthPlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FifthPlayerActionEventDecoder extends EventDecoder<FifthPlayerActionEvent> {
|
||||
|
||||
@Override
|
||||
public FifthPlayerActionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
return new FifthPlayerActionEvent(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.FirstPlayerActionEvent;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link FirstPlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FirstPlayerActionEventDecoder extends EventDecoder<FirstPlayerActionEvent> {
|
||||
|
||||
@Override
|
||||
public FirstPlayerActionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT);
|
||||
return new FirstPlayerActionEvent(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.FourthPlayerActionEvent;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link FourthPlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FourthPlayerActionEventDecoder extends EventDecoder<FourthPlayerActionEvent> {
|
||||
|
||||
@Override
|
||||
public FourthPlayerActionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
return new FourthPlayerActionEvent(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -136,6 +136,7 @@ public final class Release317 extends Release {
|
||||
register(78, spamEventDecoder);
|
||||
register(165, spamEventDecoder);
|
||||
register(189, spamEventDecoder);
|
||||
register(210, spamEventDecoder);
|
||||
register(226, spamEventDecoder);
|
||||
|
||||
register(72, new FirstNpcActionEventDecoder());
|
||||
@@ -144,6 +145,12 @@ public final class Release317 extends Release {
|
||||
register(236, new TakeTileItemEventDecoder());
|
||||
register(192, new ItemOnObjectEventDecoder());
|
||||
|
||||
register(128, new FirstPlayerActionEventDecoder());
|
||||
register(153, new SecondPlayerActionEventDecoder());
|
||||
register(73, new ThirdPlayerActionEventDecoder());
|
||||
register(139, new FourthPlayerActionEventDecoder());
|
||||
register(39, new FifthPlayerActionEventDecoder());
|
||||
|
||||
register(188, new AddFriendEventDecoder());
|
||||
register(133, new AddIgnoreEventDecoder());
|
||||
register(215, new RemoveFriendEventDecoder());
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.SecondPlayerActionEvent;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link SecondPlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class SecondPlayerActionEventDecoder extends EventDecoder<SecondPlayerActionEvent> {
|
||||
|
||||
@Override
|
||||
public SecondPlayerActionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
return new SecondPlayerActionEvent(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.ThirdPlayerActionEvent;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link ThirdPlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class ThirdPlayerActionEventDecoder extends EventDecoder<ThirdPlayerActionEvent> {
|
||||
|
||||
@Override
|
||||
public ThirdPlayerActionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
return new ThirdPlayerActionEvent(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.FifthPlayerActionEvent;
|
||||
import org.apollo.net.codec.game.DataTransformation;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link FifthPlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FifthPlayerActionEventDecoder extends EventDecoder<FifthPlayerActionEvent> {
|
||||
|
||||
@Override
|
||||
public FifthPlayerActionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
return new FifthPlayerActionEvent(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.FirstPlayerActionEvent;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataTransformation;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link FirstPlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FirstPlayerActionEventDecoder extends EventDecoder<FirstPlayerActionEvent> {
|
||||
|
||||
@Override
|
||||
public FirstPlayerActionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
||||
return new FirstPlayerActionEvent(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.FourthPlayerActionEvent;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link FourthPlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FourthPlayerActionEventDecoder extends EventDecoder<FourthPlayerActionEvent> {
|
||||
|
||||
@Override
|
||||
public FourthPlayerActionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
return new FourthPlayerActionEvent(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -141,6 +141,12 @@ public final class Release377 extends Release {
|
||||
register(71, new TakeTileItemEventDecoder());
|
||||
register(152, new ItemOnObjectEventDecoder());
|
||||
|
||||
register(245, new FirstPlayerActionEventDecoder());
|
||||
register(233, new SecondPlayerActionEventDecoder());
|
||||
register(194, new ThirdPlayerActionEventDecoder());
|
||||
register(116, new FourthPlayerActionEventDecoder());
|
||||
register(45, new FifthPlayerActionEventDecoder());
|
||||
|
||||
register(120, new AddFriendEventDecoder());
|
||||
register(217, new AddIgnoreEventDecoder());
|
||||
register(141, new RemoveFriendEventDecoder());
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.SecondPlayerActionEvent;
|
||||
import org.apollo.net.codec.game.DataTransformation;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link SecondPlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class SecondPlayerActionEventDecoder extends EventDecoder<SecondPlayerActionEvent> {
|
||||
|
||||
@Override
|
||||
public SecondPlayerActionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
return new SecondPlayerActionEvent(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.ThirdPlayerActionEvent;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link ThirdPlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class ThirdPlayerActionEventDecoder extends EventDecoder<ThirdPlayerActionEvent> {
|
||||
|
||||
@Override
|
||||
public ThirdPlayerActionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
return new ThirdPlayerActionEvent(index);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user