mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 08:39:11 +00:00
Fix poor conventions from pull request.
This commit is contained in:
@@ -6,17 +6,17 @@ import org.apollo.game.event.impl.PrivacyOptionEvent;
|
||||
import org.apollo.game.model.Player;
|
||||
|
||||
/**
|
||||
* Handles {@link PrivacyOptionEvent} from the client to the server.
|
||||
*
|
||||
* Handles {@link PrivacyOptionEvent}s from the client.
|
||||
*
|
||||
* @author Kyle Stevenson
|
||||
* Date: 12/24/13
|
||||
* Time: 2:03 AM
|
||||
*/
|
||||
public class PrivacyOptionEventHandler extends EventHandler<PrivacyOptionEvent> {
|
||||
@Override
|
||||
public void handle(final EventHandlerContext ctx, final Player player, final PrivacyOptionEvent event) {
|
||||
player.setPrivacyPublicChat(event.getPrivacyPublicChat());
|
||||
player.setPrivacyPrivateChat(event.getPrivacyPrivateChat());
|
||||
player.setPrivacyTradeCompete(event.getPrivacyTradeCompete());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, PrivacyOptionEvent event) {
|
||||
player.setPublicChatPrivacy(event.getPublicChatPrivacy());
|
||||
player.setPrivateChatPrivacy(event.getPrivateChatPrivacy());
|
||||
player.setTradeChatPrivacy(event.getTradeChatPrivacy());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,98 +1,68 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
import org.apollo.game.model.Player;
|
||||
import org.apollo.game.model.PrivacyState;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent by the client or server to specify the options at the bottom of the game screen relating
|
||||
* to the chat and trade privacy options.
|
||||
* <br />
|
||||
* See http://rswiki.moparisthebest.com/index.php?title=317:Privacy_options
|
||||
*
|
||||
* An {@link Event} sent by the client or server to update the chat and trade privacy state.
|
||||
*
|
||||
* @author Kyle Stevenson
|
||||
* Date: 12/24/13
|
||||
* Time: 1:38 AM
|
||||
*/
|
||||
public class PrivacyOptionEvent extends Event {
|
||||
/**
|
||||
* Public chat setting
|
||||
*/
|
||||
private final int publicChat;
|
||||
|
||||
/**
|
||||
* Private chat setting
|
||||
*/
|
||||
private final int privateChat;
|
||||
/**
|
||||
* The privacy state of the player's public chat.
|
||||
*/
|
||||
private final PrivacyState publicChatState;
|
||||
|
||||
/**
|
||||
* Trade/compete setting
|
||||
*/
|
||||
private final int tradeCompete;
|
||||
/**
|
||||
* The privacy state of the player's private chat.
|
||||
*/
|
||||
private final PrivacyState privateChatState;
|
||||
|
||||
/**
|
||||
* Creates a privacy option event.
|
||||
*
|
||||
* @param publicChat The byte value of the public chat privacy option.
|
||||
* @param privateChat The byte value of the private chat privacy option.
|
||||
* @param tradeCompete The byte value of the trade/compete privacy option.
|
||||
*/
|
||||
public PrivacyOptionEvent(final int publicChat, final int privateChat, final int tradeCompete) {
|
||||
this.publicChat = publicChat & 0xFF;
|
||||
this.privateChat = privateChat & 0xFF;
|
||||
this.tradeCompete = tradeCompete & 0xFF;
|
||||
}
|
||||
/**
|
||||
* The privacy state of the player's trade chat.
|
||||
*/
|
||||
private final PrivacyState tradeChatState;
|
||||
|
||||
/**
|
||||
* Public chat unsigned byte value.
|
||||
*
|
||||
* @return The public chat unsigned byte.
|
||||
*/
|
||||
public int getPublicChat() {
|
||||
return publicChat;
|
||||
}
|
||||
/**
|
||||
* Creates a privacy option event.
|
||||
*
|
||||
* @param publicChatState The privacy state of the player's public chat.
|
||||
* @param privateChatState The privacy state of the player's private chat.
|
||||
* @param tradeChatState The privacy state of the player's trade chat.
|
||||
*/
|
||||
public PrivacyOptionEvent(int publicChatState, int privateChatState, int tradeChatState) {
|
||||
this.publicChatState = PrivacyState.valueOf(publicChatState);
|
||||
this.privateChatState = PrivacyState.valueOf(privateChatState);
|
||||
this.tradeChatState = PrivacyState.valueOf(tradeChatState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Public chat privacy option.
|
||||
*
|
||||
* @return The public chat privacy option.
|
||||
*/
|
||||
public Player.PrivacyOption getPrivacyPublicChat() {
|
||||
return Player.PrivacyOption.valueOf(publicChat);
|
||||
}
|
||||
/**
|
||||
* Gets the public chat {@link PrivacyState}.
|
||||
*
|
||||
* @return The privacy option.
|
||||
*/
|
||||
public PrivacyState getPublicChatPrivacy() {
|
||||
return publicChatState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private chat unsigned byte value.
|
||||
*
|
||||
* @return The private chat unsigned byte.
|
||||
*/
|
||||
public int getPrivateChat() {
|
||||
return privateChat;
|
||||
}
|
||||
/**
|
||||
* Gets the private chat {@link PrivacyState}.
|
||||
*
|
||||
* @return The privacy option.
|
||||
*/
|
||||
public PrivacyState getPrivateChatPrivacy() {
|
||||
return privateChatState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private chat privacy option.
|
||||
*
|
||||
* @return The private chat privacy option.
|
||||
*/
|
||||
public Player.PrivacyOption getPrivacyPrivateChat() {
|
||||
return Player.PrivacyOption.valueOf(privateChat);
|
||||
}
|
||||
/**
|
||||
* Gets the trade chat {@link PrivacyState}.
|
||||
*
|
||||
* @return The privacy option.
|
||||
*/
|
||||
public PrivacyState getTradeChatPrivacy() {
|
||||
return tradeChatState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trade/compete unsigned byte value.
|
||||
*
|
||||
* @return The trade/compete unsigned byte.
|
||||
*/
|
||||
public int getTradeCompete() {
|
||||
return tradeCompete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trade/compete privacy option.
|
||||
*
|
||||
* @return The trade/compete privacy option.
|
||||
*/
|
||||
public Player.PrivacyOption getPrivacyTradeCompete() {
|
||||
return Player.PrivacyOption.valueOf(tradeCompete);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,26 +18,26 @@ public enum Gender {
|
||||
FEMALE(1);
|
||||
|
||||
/**
|
||||
* An integer representation used by the client.
|
||||
* The numerical value used by the client.
|
||||
*/
|
||||
private final int intValue;
|
||||
private final int value;
|
||||
|
||||
/**
|
||||
* Creates the gender.
|
||||
*
|
||||
* @param intValue The integer representation.
|
||||
* @param value The numerical value.
|
||||
*/
|
||||
private Gender(int intValue) {
|
||||
this.intValue = intValue;
|
||||
private Gender(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this gender to an integer.
|
||||
*
|
||||
* @return The integer representation used by the client.
|
||||
* @return The numerical value used by the client.
|
||||
*/
|
||||
public int toInteger() {
|
||||
return intValue;
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public final class Npc extends Mob {
|
||||
*/
|
||||
public void transform(int id) {
|
||||
if (id < 0 || id > NpcDefinition.count()) {
|
||||
throw new IllegalArgumentException("id to transform to is out of bounds");
|
||||
throw new IllegalArgumentException("Id to transform to is out of bounds");
|
||||
}
|
||||
definition = NpcDefinition.lookup(id);
|
||||
blockSet.add(SynchronizationBlock.createTransformBlock(id));
|
||||
|
||||
@@ -60,31 +60,30 @@ public final class Player extends Mob {
|
||||
/**
|
||||
* Gets the privilege level for the specified numerical level.
|
||||
*
|
||||
* @param numericalLevel The numerical level.
|
||||
* @param value The numerical level.
|
||||
* @return The privilege level.
|
||||
* @throws IllegalArgumentException If the numerical level is invalid.
|
||||
*/
|
||||
public static PrivilegeLevel valueOf(int numericalLevel) {
|
||||
for (PrivilegeLevel level : values()) {
|
||||
if (level.numericalLevel == numericalLevel) {
|
||||
return level;
|
||||
}
|
||||
public static PrivilegeLevel valueOf(int value) {
|
||||
PrivilegeLevel[] values = values();
|
||||
if (value < 0 || value > values.length) {
|
||||
throw new IndexOutOfBoundsException("Invalid privilege level integer value supplied");
|
||||
}
|
||||
throw new IllegalArgumentException("invalid numerical level");
|
||||
return values[value];
|
||||
}
|
||||
|
||||
/**
|
||||
* The numerical level used in the protocol.
|
||||
*/
|
||||
private final int numericalLevel;
|
||||
private final int value;
|
||||
|
||||
/**
|
||||
* Creates a privilege level.
|
||||
* Creates the privilege level.
|
||||
*
|
||||
* @param numericalLevel The numerical level.
|
||||
* @param value The numerical level.
|
||||
*/
|
||||
private PrivilegeLevel(int numericalLevel) {
|
||||
this.numericalLevel = numericalLevel;
|
||||
private PrivilegeLevel(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,85 +92,11 @@ public final class Player extends Mob {
|
||||
* @return The numerical level used in the protocol.
|
||||
*/
|
||||
public int toInteger() {
|
||||
return numericalLevel;
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An enumeration representing the different states for chat and trade options in the protocol.
|
||||
*
|
||||
* @author Kyle Stevenson
|
||||
*/
|
||||
public enum PrivacyOption {
|
||||
|
||||
/**
|
||||
* Represents the on-state which displays all messages.
|
||||
*/
|
||||
ON(0),
|
||||
|
||||
/**
|
||||
* Represents the friends-state which only displays messages from friends and staff members.
|
||||
*/
|
||||
FRIENDS(1),
|
||||
|
||||
/**
|
||||
* Represents the off-state which displays no messages except those of moderators and staff members.
|
||||
*/
|
||||
OFF(2),
|
||||
|
||||
/**
|
||||
* Represents the hidden-state which displays text over player's heads but not in the chat box.
|
||||
* This only applies to the "public" option.
|
||||
*/
|
||||
HIDE(3);
|
||||
|
||||
/**
|
||||
* Gets the privacy option for the specified numerical value.
|
||||
*
|
||||
* @param numericalValue The numerical level.
|
||||
* @return The privilege level.
|
||||
* @throws IllegalArgumentException If the numerical level is invalid.
|
||||
*/
|
||||
public static PrivacyOption valueOf(final int numericalValue) {
|
||||
for (final PrivacyOption option : values()) {
|
||||
if (option.numericalOption == numericalValue) {
|
||||
return option;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("invalid numerical level");
|
||||
}
|
||||
|
||||
/**
|
||||
* The numerical level used in the protocol.
|
||||
*/
|
||||
private final int numericalOption;
|
||||
|
||||
/**
|
||||
* Creates a privacy option.
|
||||
*
|
||||
* @param numericalValue The numerical value.
|
||||
*/
|
||||
private PrivacyOption(final int numericalValue) {
|
||||
this.numericalOption = numericalValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the numerical option.
|
||||
*
|
||||
* @return The numerical option used in the protocol.
|
||||
*/
|
||||
public int toInteger() {
|
||||
return numericalOption;
|
||||
}
|
||||
}
|
||||
|
||||
private PrivacyOption privacyPublicChat = PrivacyOption.ON;
|
||||
|
||||
private PrivacyOption privacyPrivateChat = PrivacyOption.ON;
|
||||
|
||||
private PrivacyOption privacyTradeCompete = PrivacyOption.ON;
|
||||
|
||||
/**
|
||||
* The player's appearance.
|
||||
*/
|
||||
@@ -232,11 +157,21 @@ public final class Player extends Mob {
|
||||
*/
|
||||
private int prayerIcon = 0;
|
||||
|
||||
/**
|
||||
* The privacy state of this player's private chat.
|
||||
*/
|
||||
private PrivacyState privateChatPrivacy = PrivacyState.ON;
|
||||
|
||||
/**
|
||||
* The privilege level.
|
||||
*/
|
||||
private PrivilegeLevel privilegeLevel = PrivilegeLevel.STANDARD;
|
||||
|
||||
/**
|
||||
* The privacy state of this player's public chat.
|
||||
*/
|
||||
private PrivacyState publicChatPrivacy = PrivacyState.ON;
|
||||
|
||||
/**
|
||||
* A temporary queue of events sent during the login process.
|
||||
*/
|
||||
@@ -262,6 +197,11 @@ public final class Player extends Mob {
|
||||
*/
|
||||
private GameSession session;
|
||||
|
||||
/**
|
||||
* The privacy state of this player's trade chat.
|
||||
*/
|
||||
private PrivacyState tradeChatPrivacy = PrivacyState.ON;
|
||||
|
||||
/**
|
||||
* The current maximum viewing distance of this player.
|
||||
*/
|
||||
@@ -421,32 +361,14 @@ public final class Player extends Mob {
|
||||
return prayerIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the privacy option of private chat.
|
||||
*
|
||||
* @return The privacy option.
|
||||
*/
|
||||
public PrivacyOption getPrivacyPrivateChat() {
|
||||
return privacyPrivateChat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the privacy option of public chat.
|
||||
*
|
||||
* @return The privacy option.
|
||||
*/
|
||||
public PrivacyOption getPrivacyPublicChat() {
|
||||
return privacyPublicChat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the privacy option of trade/compete.
|
||||
*
|
||||
* @return The privacy option.
|
||||
*/
|
||||
public PrivacyOption getPrivacyTradeCompete() {
|
||||
return privacyTradeCompete;
|
||||
}
|
||||
/**
|
||||
* Gets this player's private chat privacy state.
|
||||
*
|
||||
* @return The privacy state.
|
||||
*/
|
||||
public PrivacyState getPrivateChatPrivacy() {
|
||||
return privateChatPrivacy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the privilege level.
|
||||
@@ -457,6 +379,15 @@ public final class Player extends Mob {
|
||||
return privilegeLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets this player's public chat privacy state.
|
||||
*
|
||||
* @return The privacy state.
|
||||
*/
|
||||
public PrivacyState getPublicChatPrivacy() {
|
||||
return publicChatPrivacy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player's run energy.
|
||||
*
|
||||
@@ -475,6 +406,15 @@ public final class Player extends Mob {
|
||||
return session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets this player's trade chat privacy state.
|
||||
*
|
||||
* @return The privacy state.
|
||||
*/
|
||||
public PrivacyState getTradeChatPrivacy() {
|
||||
return tradeChatPrivacy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets this player's viewing distance.
|
||||
*
|
||||
@@ -766,32 +706,32 @@ public final class Player extends Mob {
|
||||
this.prayerIcon = prayerIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the privacy option for private chat.
|
||||
*
|
||||
* @param privacyPrivateChat The privacy option.
|
||||
*/
|
||||
public void setPrivacyPrivateChat(final PrivacyOption privacyPrivateChat) {
|
||||
this.privacyPrivateChat = privacyPrivateChat;
|
||||
}
|
||||
/**
|
||||
* Sets the private chat {@link PrivacyState}.
|
||||
*
|
||||
* @param privateChatPrivacy The privacy state.
|
||||
*/
|
||||
public void setPrivateChatPrivacy(PrivacyState privateChatPrivacy) {
|
||||
this.privateChatPrivacy = privateChatPrivacy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the privacy option for public chat.
|
||||
*
|
||||
* @param privacyPublicChat The privacy option.
|
||||
*/
|
||||
public void setPrivacyPublicChat(final PrivacyOption privacyPublicChat) {
|
||||
this.privacyPublicChat = privacyPublicChat;
|
||||
}
|
||||
/**
|
||||
* Sets the public chat {@link PrivacyState}.
|
||||
*
|
||||
* @param publicChatPrivacy The privacy state.
|
||||
*/
|
||||
public void setPublicChatPrivacy(PrivacyState publicChatPrivacy) {
|
||||
this.publicChatPrivacy = publicChatPrivacy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the privacy option for trade/compete.
|
||||
*
|
||||
* @param privacyTradeCompete The privacy option.
|
||||
*/
|
||||
public void setPrivacyTradeCompete(final PrivacyOption privacyTradeCompete) {
|
||||
this.privacyTradeCompete = privacyTradeCompete;
|
||||
}
|
||||
/**
|
||||
* Sets the trade chat {@link PrivacyState}.
|
||||
*
|
||||
* @param tradeChatPrivacy The privacy state.
|
||||
*/
|
||||
public void setTradeChatPrivacy(PrivacyState tradeChatPrivacy) {
|
||||
this.tradeChatPrivacy = tradeChatPrivacy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the privilege level.
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package org.apollo.game.model;
|
||||
|
||||
/**
|
||||
* An enumeration representing the different privacy states for public, private and trade chat.
|
||||
*
|
||||
* @author Kyle Stevenson
|
||||
*/
|
||||
public enum PrivacyState {
|
||||
|
||||
/**
|
||||
* Represents the 'friends' state, when only messages from friends and moderators are displayed.
|
||||
*/
|
||||
FRIENDS(2),
|
||||
|
||||
/**
|
||||
* Represents the 'hidden' state, when all public chat text is displayed over the heads of players, but not in the
|
||||
* chat interface. This state only applies to public chat.
|
||||
*/
|
||||
HIDE(1),
|
||||
|
||||
/**
|
||||
* Represents the 'off' state, when only messages from moderators are displayed.
|
||||
*/
|
||||
OFF(3),
|
||||
|
||||
/**
|
||||
* Represents the 'on' state, when all messages are displayed.
|
||||
*/
|
||||
ON(0);
|
||||
|
||||
/**
|
||||
* Gets the privacy state for the specified numerical value.
|
||||
*
|
||||
* @param value The numerical value.
|
||||
* @return The privacy state.
|
||||
* @throws IllegalArgumentException If the numerical value is invalid.
|
||||
*/
|
||||
public static PrivacyState valueOf(int value) {
|
||||
PrivacyState[] values = values();
|
||||
if (value < 0 || value >= values.length) {
|
||||
throw new IllegalArgumentException("Invalid privacy option integer value specified");
|
||||
}
|
||||
return values[value];
|
||||
}
|
||||
|
||||
/**
|
||||
* The numerical value used by the client.
|
||||
*/
|
||||
private final int value;
|
||||
|
||||
/**
|
||||
* Creates the privacy state.
|
||||
*
|
||||
* @param value The numerical value.
|
||||
*/
|
||||
private PrivacyState(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this privacy state to an integer.
|
||||
*
|
||||
* @return The numerical value used by the client.
|
||||
*/
|
||||
public int toInteger() {
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import org.apollo.game.model.Item;
|
||||
import org.apollo.game.model.Player;
|
||||
import org.apollo.game.model.Player.PrivilegeLevel;
|
||||
import org.apollo.game.model.Position;
|
||||
import org.apollo.game.model.PrivacyState;
|
||||
import org.apollo.game.model.Skill;
|
||||
import org.apollo.game.model.SkillSet;
|
||||
import org.apollo.io.player.PlayerLoader;
|
||||
@@ -54,9 +55,9 @@ public final class BinaryPlayerLoader implements PlayerLoader {
|
||||
boolean members = in.readBoolean();
|
||||
|
||||
// read settings
|
||||
Player.PrivacyOption privacyPublicChat = Player.PrivacyOption.valueOf(in.readByte());
|
||||
Player.PrivacyOption privacyPrivateChat = Player.PrivacyOption.valueOf(in.readByte());
|
||||
Player.PrivacyOption privacyTradeCompete = Player.PrivacyOption.valueOf(in.readByte());
|
||||
PrivacyState privacyPublicChat = PrivacyState.valueOf(in.readByte());
|
||||
PrivacyState privacyPrivateChat = PrivacyState.valueOf(in.readByte());
|
||||
PrivacyState privacyTradeCompete = PrivacyState.valueOf(in.readByte());
|
||||
|
||||
// read position
|
||||
int x = in.readUnsignedShort();
|
||||
@@ -80,9 +81,9 @@ public final class BinaryPlayerLoader implements PlayerLoader {
|
||||
Player player = new Player(credentials, new Position(x, y, height));
|
||||
player.setPrivilegeLevel(privilegeLevel);
|
||||
player.setMembers(members);
|
||||
player.setPrivacyPublicChat(privacyPublicChat);
|
||||
player.setPrivacyPrivateChat(privacyPrivateChat);
|
||||
player.setPrivacyTradeCompete(privacyTradeCompete);
|
||||
player.setPublicChatPrivacy(privacyPublicChat);
|
||||
player.setPrivateChatPrivacy(privacyPrivateChat);
|
||||
player.setTradeChatPrivacy(privacyTradeCompete);
|
||||
player.setDesigned(designed);
|
||||
player.setAppearance(new Appearance(gender, style, colors));
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ public final class BinaryPlayerSaver implements PlayerSaver {
|
||||
out.writeBoolean(player.isMembers());
|
||||
|
||||
// write settings
|
||||
out.writeByte(player.getPrivacyPublicChat().toInteger());
|
||||
out.writeByte(player.getPrivacyPrivateChat().toInteger());
|
||||
out.writeByte(player.getPrivacyTradeCompete().toInteger());
|
||||
out.writeByte(player.getPublicChatPrivacy().toInteger());
|
||||
out.writeByte(player.getPrivateChatPrivacy().toInteger());
|
||||
out.writeByte(player.getTradeChatPrivacy().toInteger());
|
||||
|
||||
// write position
|
||||
Position position = player.getPosition();
|
||||
|
||||
@@ -8,20 +8,20 @@ import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link PrivacyOptionEvent}.
|
||||
*
|
||||
*
|
||||
* @author Kyle Stevenson
|
||||
* Date: 12/24/13
|
||||
* Time: 1:44 AM
|
||||
*/
|
||||
public class PrivacyOptionEventDecoder extends EventDecoder<PrivacyOptionEvent> {
|
||||
@Override
|
||||
public PrivacyOptionEvent decode(final GamePacket packet) {
|
||||
final GamePacketReader reader = new GamePacketReader(packet);
|
||||
public final class PrivacyOptionEventDecoder extends EventDecoder<PrivacyOptionEvent> {
|
||||
|
||||
final int publicChat = (int) reader.getUnsigned(DataType.BYTE);
|
||||
final int privateChat = (int) reader.getUnsigned(DataType.BYTE);
|
||||
final int tradeCompete = (int) reader.getUnsigned(DataType.BYTE);
|
||||
@Override
|
||||
public PrivacyOptionEvent decode(GamePacket packet) {
|
||||
final GamePacketReader reader = new GamePacketReader(packet);
|
||||
|
||||
return new PrivacyOptionEvent(publicChat, privateChat, tradeCompete);
|
||||
}
|
||||
}
|
||||
final int publicChatState = (int) reader.getUnsigned(DataType.BYTE);
|
||||
final int privateChatState = (int) reader.getUnsigned(DataType.BYTE);
|
||||
final int tradeChatState = (int) reader.getUnsigned(DataType.BYTE);
|
||||
|
||||
return new PrivacyOptionEvent(publicChatState, privateChatState, tradeChatState);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,25 +4,24 @@ import org.apollo.game.event.impl.PrivacyOptionEvent;
|
||||
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.meta.PacketType;
|
||||
import org.apollo.net.release.EventEncoder;
|
||||
|
||||
/**
|
||||
* An {@link org.apollo.net.release.EventEncoder} for the {@link PrivacyOptionEvent}.
|
||||
*
|
||||
* An {@link EventEncoder} for the {@link PrivacyOptionEvent}.
|
||||
*
|
||||
* @author Kyle Stevenson
|
||||
* Date: 12/24/13
|
||||
* Time: 1:44 AM
|
||||
*/
|
||||
public class PrivacyOptionEventEncoder extends EventEncoder<PrivacyOptionEvent> {
|
||||
@Override
|
||||
public GamePacket encode(final PrivacyOptionEvent event) {
|
||||
final GamePacketBuilder builder = new GamePacketBuilder(206, PacketType.FIXED);
|
||||
public final class PrivacyOptionEventEncoder extends EventEncoder<PrivacyOptionEvent> {
|
||||
|
||||
builder.put(DataType.BYTE, event.getPublicChat());
|
||||
builder.put(DataType.BYTE, event.getPrivateChat());
|
||||
builder.put(DataType.BYTE, event.getTradeCompete());
|
||||
@Override
|
||||
public GamePacket encode(final PrivacyOptionEvent event) {
|
||||
final GamePacketBuilder builder = new GamePacketBuilder(206);
|
||||
|
||||
return builder.toGamePacket();
|
||||
}
|
||||
}
|
||||
builder.put(DataType.BYTE, event.getPublicChatPrivacy().ordinal());
|
||||
builder.put(DataType.BYTE, event.getPrivateChatPrivacy().ordinal());
|
||||
builder.put(DataType.BYTE, event.getTradeChatPrivacy().ordinal());
|
||||
|
||||
return builder.toGamePacket();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -116,7 +116,6 @@ public final class Release317 extends Release {
|
||||
register(3, new FocusUpdateEventDecoder());
|
||||
register(241, new MouseClickEventDecoder());
|
||||
register(86, new ArrowKeyEventDecoder());
|
||||
|
||||
register(95, new PrivacyOptionEventDecoder());
|
||||
|
||||
SpamPacketEventDecoder spamEventDecoder = new SpamPacketEventDecoder();
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.PrivacyOptionEvent;
|
||||
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 PrivacyOptionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class PrivacyOptionEventDecoder extends EventDecoder<PrivacyOptionEvent> {
|
||||
|
||||
@Override
|
||||
public PrivacyOptionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
|
||||
int publicChatState = (int) reader.getUnsigned(DataType.BYTE);
|
||||
int privateChatState = (int) reader.getUnsigned(DataType.BYTE);
|
||||
int tradeChatState = (int) reader.getUnsigned(DataType.BYTE);
|
||||
|
||||
return new PrivacyOptionEvent(publicChatState, privateChatState, tradeChatState);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.PrivacyOptionEvent;
|
||||
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.EventEncoder;
|
||||
|
||||
/**
|
||||
* An {@link EventEncoder} for the {@link PrivacyOptionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class PrivacyOptionEventEncoder extends EventEncoder<PrivacyOptionEvent> {
|
||||
|
||||
@Override
|
||||
public GamePacket encode(final PrivacyOptionEvent event) {
|
||||
GamePacketBuilder builder = new GamePacketBuilder(201);
|
||||
|
||||
builder.put(DataType.BYTE, event.getPublicChatPrivacy().ordinal());
|
||||
builder.put(DataType.BYTE, event.getPrivateChatPrivacy().ordinal());
|
||||
builder.put(DataType.BYTE, event.getTradeChatPrivacy().ordinal());
|
||||
|
||||
return builder.toGamePacket();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import org.apollo.game.event.impl.OpenInterfaceEvent;
|
||||
import org.apollo.game.event.impl.OpenInterfaceSidebarEvent;
|
||||
import org.apollo.game.event.impl.PlayerSynchronizationEvent;
|
||||
import org.apollo.game.event.impl.PositionEvent;
|
||||
import org.apollo.game.event.impl.PrivacyOptionEvent;
|
||||
import org.apollo.game.event.impl.RegionChangeEvent;
|
||||
import org.apollo.game.event.impl.ServerMessageEvent;
|
||||
import org.apollo.game.event.impl.SetTileItemEvent;
|
||||
@@ -115,6 +116,7 @@ public final class Release377 extends Release {
|
||||
register(187, new FocusUpdateEventDecoder());
|
||||
register(19, new MouseClickEventDecoder());
|
||||
register(140, new ArrowKeyEventDecoder());
|
||||
register(176, new PrivacyOptionEventDecoder());
|
||||
|
||||
SpamPacketEventDecoder spamEventDecoder = new SpamPacketEventDecoder();
|
||||
register(40, spamEventDecoder);
|
||||
@@ -151,6 +153,7 @@ public final class Release377 extends Release {
|
||||
register(SetTileItemEvent.class, new SetTileItemEventEncoder());
|
||||
register(PositionEvent.class, new PositionEventEncoder());
|
||||
register(UpdateRunEnergyEvent.class, new UpdateRunEnergyEventEncoder());
|
||||
register(PrivacyOptionEvent.class, new PrivacyOptionEventEncoder());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user