mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-06 00:38:18 +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;
|
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
|
* @author Kyle Stevenson
|
||||||
* Date: 12/24/13
|
|
||||||
* Time: 2:03 AM
|
|
||||||
*/
|
*/
|
||||||
public class PrivacyOptionEventHandler extends EventHandler<PrivacyOptionEvent> {
|
public class PrivacyOptionEventHandler extends EventHandler<PrivacyOptionEvent> {
|
||||||
@Override
|
|
||||||
public void handle(final EventHandlerContext ctx, final Player player, final PrivacyOptionEvent event) {
|
@Override
|
||||||
player.setPrivacyPublicChat(event.getPrivacyPublicChat());
|
public void handle(EventHandlerContext ctx, Player player, PrivacyOptionEvent event) {
|
||||||
player.setPrivacyPrivateChat(event.getPrivacyPrivateChat());
|
player.setPublicChatPrivacy(event.getPublicChatPrivacy());
|
||||||
player.setPrivacyTradeCompete(event.getPrivacyTradeCompete());
|
player.setPrivateChatPrivacy(event.getPrivateChatPrivacy());
|
||||||
}
|
player.setTradeChatPrivacy(event.getTradeChatPrivacy());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,98 +1,68 @@
|
|||||||
package org.apollo.game.event.impl;
|
package org.apollo.game.event.impl;
|
||||||
|
|
||||||
import org.apollo.game.event.Event;
|
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
|
* An {@link Event} sent by the client or server to update the chat and trade privacy state.
|
||||||
* to the chat and trade privacy options.
|
*
|
||||||
* <br />
|
|
||||||
* See http://rswiki.moparisthebest.com/index.php?title=317:Privacy_options
|
|
||||||
*
|
|
||||||
* @author Kyle Stevenson
|
* @author Kyle Stevenson
|
||||||
* Date: 12/24/13
|
|
||||||
* Time: 1:38 AM
|
|
||||||
*/
|
*/
|
||||||
public class PrivacyOptionEvent extends Event {
|
public class PrivacyOptionEvent extends Event {
|
||||||
/**
|
|
||||||
* Public chat setting
|
|
||||||
*/
|
|
||||||
private final int publicChat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private chat setting
|
* The privacy state of the player's public chat.
|
||||||
*/
|
*/
|
||||||
private final int privateChat;
|
private final PrivacyState publicChatState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trade/compete setting
|
* The privacy state of the player's private chat.
|
||||||
*/
|
*/
|
||||||
private final int tradeCompete;
|
private final PrivacyState privateChatState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a privacy option event.
|
* The privacy state of the player's trade chat.
|
||||||
*
|
*/
|
||||||
* @param publicChat The byte value of the public chat privacy option.
|
private final PrivacyState tradeChatState;
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public chat unsigned byte value.
|
* Creates a privacy option event.
|
||||||
*
|
*
|
||||||
* @return The public chat unsigned byte.
|
* @param publicChatState The privacy state of the player's public chat.
|
||||||
*/
|
* @param privateChatState The privacy state of the player's private chat.
|
||||||
public int getPublicChat() {
|
* @param tradeChatState The privacy state of the player's trade chat.
|
||||||
return publicChat;
|
*/
|
||||||
}
|
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.
|
* Gets the public chat {@link PrivacyState}.
|
||||||
*
|
*
|
||||||
* @return The public chat privacy option.
|
* @return The privacy option.
|
||||||
*/
|
*/
|
||||||
public Player.PrivacyOption getPrivacyPublicChat() {
|
public PrivacyState getPublicChatPrivacy() {
|
||||||
return Player.PrivacyOption.valueOf(publicChat);
|
return publicChatState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private chat unsigned byte value.
|
* Gets the private chat {@link PrivacyState}.
|
||||||
*
|
*
|
||||||
* @return The private chat unsigned byte.
|
* @return The privacy option.
|
||||||
*/
|
*/
|
||||||
public int getPrivateChat() {
|
public PrivacyState getPrivateChatPrivacy() {
|
||||||
return privateChat;
|
return privateChatState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private chat privacy option.
|
* Gets the trade chat {@link PrivacyState}.
|
||||||
*
|
*
|
||||||
* @return The private chat privacy option.
|
* @return The privacy option.
|
||||||
*/
|
*/
|
||||||
public Player.PrivacyOption getPrivacyPrivateChat() {
|
public PrivacyState getTradeChatPrivacy() {
|
||||||
return Player.PrivacyOption.valueOf(privateChat);
|
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);
|
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.
|
* Creates the gender.
|
||||||
*
|
*
|
||||||
* @param intValue The integer representation.
|
* @param value The numerical value.
|
||||||
*/
|
*/
|
||||||
private Gender(int intValue) {
|
private Gender(int value) {
|
||||||
this.intValue = intValue;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts this gender to an integer.
|
* 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() {
|
public int toInteger() {
|
||||||
return intValue;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ public final class Npc extends Mob {
|
|||||||
*/
|
*/
|
||||||
public void transform(int id) {
|
public void transform(int id) {
|
||||||
if (id < 0 || id > NpcDefinition.count()) {
|
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);
|
definition = NpcDefinition.lookup(id);
|
||||||
blockSet.add(SynchronizationBlock.createTransformBlock(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.
|
* Gets the privilege level for the specified numerical level.
|
||||||
*
|
*
|
||||||
* @param numericalLevel The numerical level.
|
* @param value The numerical level.
|
||||||
* @return The privilege level.
|
* @return The privilege level.
|
||||||
* @throws IllegalArgumentException If the numerical level is invalid.
|
* @throws IllegalArgumentException If the numerical level is invalid.
|
||||||
*/
|
*/
|
||||||
public static PrivilegeLevel valueOf(int numericalLevel) {
|
public static PrivilegeLevel valueOf(int value) {
|
||||||
for (PrivilegeLevel level : values()) {
|
PrivilegeLevel[] values = values();
|
||||||
if (level.numericalLevel == numericalLevel) {
|
if (value < 0 || value > values.length) {
|
||||||
return level;
|
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.
|
* 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) {
|
private PrivilegeLevel(int value) {
|
||||||
this.numericalLevel = numericalLevel;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,85 +92,11 @@ public final class Player extends Mob {
|
|||||||
* @return The numerical level used in the protocol.
|
* @return The numerical level used in the protocol.
|
||||||
*/
|
*/
|
||||||
public int toInteger() {
|
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.
|
* The player's appearance.
|
||||||
*/
|
*/
|
||||||
@@ -232,11 +157,21 @@ public final class Player extends Mob {
|
|||||||
*/
|
*/
|
||||||
private int prayerIcon = 0;
|
private int prayerIcon = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The privacy state of this player's private chat.
|
||||||
|
*/
|
||||||
|
private PrivacyState privateChatPrivacy = PrivacyState.ON;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The privilege level.
|
* The privilege level.
|
||||||
*/
|
*/
|
||||||
private PrivilegeLevel privilegeLevel = PrivilegeLevel.STANDARD;
|
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.
|
* A temporary queue of events sent during the login process.
|
||||||
*/
|
*/
|
||||||
@@ -262,6 +197,11 @@ public final class Player extends Mob {
|
|||||||
*/
|
*/
|
||||||
private GameSession session;
|
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.
|
* The current maximum viewing distance of this player.
|
||||||
*/
|
*/
|
||||||
@@ -421,32 +361,14 @@ public final class Player extends Mob {
|
|||||||
return prayerIcon;
|
return prayerIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the privacy option of private chat.
|
* Gets this player's private chat privacy state.
|
||||||
*
|
*
|
||||||
* @return The privacy option.
|
* @return The privacy state.
|
||||||
*/
|
*/
|
||||||
public PrivacyOption getPrivacyPrivateChat() {
|
public PrivacyState getPrivateChatPrivacy() {
|
||||||
return privacyPrivateChat;
|
return privateChatPrivacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 the privilege level.
|
* Gets the privilege level.
|
||||||
@@ -457,6 +379,15 @@ public final class Player extends Mob {
|
|||||||
return privilegeLevel;
|
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.
|
* Gets the player's run energy.
|
||||||
*
|
*
|
||||||
@@ -475,6 +406,15 @@ public final class Player extends Mob {
|
|||||||
return session;
|
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.
|
* Gets this player's viewing distance.
|
||||||
*
|
*
|
||||||
@@ -766,32 +706,32 @@ public final class Player extends Mob {
|
|||||||
this.prayerIcon = prayerIcon;
|
this.prayerIcon = prayerIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the privacy option for private chat.
|
* Sets the private chat {@link PrivacyState}.
|
||||||
*
|
*
|
||||||
* @param privacyPrivateChat The privacy option.
|
* @param privateChatPrivacy The privacy state.
|
||||||
*/
|
*/
|
||||||
public void setPrivacyPrivateChat(final PrivacyOption privacyPrivateChat) {
|
public void setPrivateChatPrivacy(PrivacyState privateChatPrivacy) {
|
||||||
this.privacyPrivateChat = privacyPrivateChat;
|
this.privateChatPrivacy = privateChatPrivacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the privacy option for public chat.
|
* Sets the public chat {@link PrivacyState}.
|
||||||
*
|
*
|
||||||
* @param privacyPublicChat The privacy option.
|
* @param publicChatPrivacy The privacy state.
|
||||||
*/
|
*/
|
||||||
public void setPrivacyPublicChat(final PrivacyOption privacyPublicChat) {
|
public void setPublicChatPrivacy(PrivacyState publicChatPrivacy) {
|
||||||
this.privacyPublicChat = privacyPublicChat;
|
this.publicChatPrivacy = publicChatPrivacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the privacy option for trade/compete.
|
* Sets the trade chat {@link PrivacyState}.
|
||||||
*
|
*
|
||||||
* @param privacyTradeCompete The privacy option.
|
* @param tradeChatPrivacy The privacy state.
|
||||||
*/
|
*/
|
||||||
public void setPrivacyTradeCompete(final PrivacyOption privacyTradeCompete) {
|
public void setTradeChatPrivacy(PrivacyState tradeChatPrivacy) {
|
||||||
this.privacyTradeCompete = privacyTradeCompete;
|
this.tradeChatPrivacy = tradeChatPrivacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the privilege level.
|
* 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;
|
||||||
import org.apollo.game.model.Player.PrivilegeLevel;
|
import org.apollo.game.model.Player.PrivilegeLevel;
|
||||||
import org.apollo.game.model.Position;
|
import org.apollo.game.model.Position;
|
||||||
|
import org.apollo.game.model.PrivacyState;
|
||||||
import org.apollo.game.model.Skill;
|
import org.apollo.game.model.Skill;
|
||||||
import org.apollo.game.model.SkillSet;
|
import org.apollo.game.model.SkillSet;
|
||||||
import org.apollo.io.player.PlayerLoader;
|
import org.apollo.io.player.PlayerLoader;
|
||||||
@@ -54,9 +55,9 @@ public final class BinaryPlayerLoader implements PlayerLoader {
|
|||||||
boolean members = in.readBoolean();
|
boolean members = in.readBoolean();
|
||||||
|
|
||||||
// read settings
|
// read settings
|
||||||
Player.PrivacyOption privacyPublicChat = Player.PrivacyOption.valueOf(in.readByte());
|
PrivacyState privacyPublicChat = PrivacyState.valueOf(in.readByte());
|
||||||
Player.PrivacyOption privacyPrivateChat = Player.PrivacyOption.valueOf(in.readByte());
|
PrivacyState privacyPrivateChat = PrivacyState.valueOf(in.readByte());
|
||||||
Player.PrivacyOption privacyTradeCompete = Player.PrivacyOption.valueOf(in.readByte());
|
PrivacyState privacyTradeCompete = PrivacyState.valueOf(in.readByte());
|
||||||
|
|
||||||
// read position
|
// read position
|
||||||
int x = in.readUnsignedShort();
|
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 player = new Player(credentials, new Position(x, y, height));
|
||||||
player.setPrivilegeLevel(privilegeLevel);
|
player.setPrivilegeLevel(privilegeLevel);
|
||||||
player.setMembers(members);
|
player.setMembers(members);
|
||||||
player.setPrivacyPublicChat(privacyPublicChat);
|
player.setPublicChatPrivacy(privacyPublicChat);
|
||||||
player.setPrivacyPrivateChat(privacyPrivateChat);
|
player.setPrivateChatPrivacy(privacyPrivateChat);
|
||||||
player.setPrivacyTradeCompete(privacyTradeCompete);
|
player.setTradeChatPrivacy(privacyTradeCompete);
|
||||||
player.setDesigned(designed);
|
player.setDesigned(designed);
|
||||||
player.setAppearance(new Appearance(gender, style, colors));
|
player.setAppearance(new Appearance(gender, style, colors));
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ public final class BinaryPlayerSaver implements PlayerSaver {
|
|||||||
out.writeBoolean(player.isMembers());
|
out.writeBoolean(player.isMembers());
|
||||||
|
|
||||||
// write settings
|
// write settings
|
||||||
out.writeByte(player.getPrivacyPublicChat().toInteger());
|
out.writeByte(player.getPublicChatPrivacy().toInteger());
|
||||||
out.writeByte(player.getPrivacyPrivateChat().toInteger());
|
out.writeByte(player.getPrivateChatPrivacy().toInteger());
|
||||||
out.writeByte(player.getPrivacyTradeCompete().toInteger());
|
out.writeByte(player.getTradeChatPrivacy().toInteger());
|
||||||
|
|
||||||
// write position
|
// write position
|
||||||
Position position = player.getPosition();
|
Position position = player.getPosition();
|
||||||
|
|||||||
@@ -8,20 +8,20 @@ import org.apollo.net.release.EventDecoder;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link EventDecoder} for the {@link PrivacyOptionEvent}.
|
* An {@link EventDecoder} for the {@link PrivacyOptionEvent}.
|
||||||
*
|
*
|
||||||
* @author Kyle Stevenson
|
* @author Kyle Stevenson
|
||||||
* Date: 12/24/13
|
|
||||||
* Time: 1:44 AM
|
|
||||||
*/
|
*/
|
||||||
public class PrivacyOptionEventDecoder extends EventDecoder<PrivacyOptionEvent> {
|
public final class PrivacyOptionEventDecoder extends EventDecoder<PrivacyOptionEvent> {
|
||||||
@Override
|
|
||||||
public PrivacyOptionEvent decode(final GamePacket packet) {
|
|
||||||
final GamePacketReader reader = new GamePacketReader(packet);
|
|
||||||
|
|
||||||
final int publicChat = (int) reader.getUnsigned(DataType.BYTE);
|
@Override
|
||||||
final int privateChat = (int) reader.getUnsigned(DataType.BYTE);
|
public PrivacyOptionEvent decode(GamePacket packet) {
|
||||||
final int tradeCompete = (int) reader.getUnsigned(DataType.BYTE);
|
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.DataType;
|
||||||
import org.apollo.net.codec.game.GamePacket;
|
import org.apollo.net.codec.game.GamePacket;
|
||||||
import org.apollo.net.codec.game.GamePacketBuilder;
|
import org.apollo.net.codec.game.GamePacketBuilder;
|
||||||
import org.apollo.net.meta.PacketType;
|
|
||||||
import org.apollo.net.release.EventEncoder;
|
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
|
* @author Kyle Stevenson
|
||||||
* Date: 12/24/13
|
|
||||||
* Time: 1:44 AM
|
|
||||||
*/
|
*/
|
||||||
public class PrivacyOptionEventEncoder extends EventEncoder<PrivacyOptionEvent> {
|
public final class PrivacyOptionEventEncoder extends EventEncoder<PrivacyOptionEvent> {
|
||||||
@Override
|
|
||||||
public GamePacket encode(final PrivacyOptionEvent event) {
|
|
||||||
final GamePacketBuilder builder = new GamePacketBuilder(206, PacketType.FIXED);
|
|
||||||
|
|
||||||
builder.put(DataType.BYTE, event.getPublicChat());
|
@Override
|
||||||
builder.put(DataType.BYTE, event.getPrivateChat());
|
public GamePacket encode(final PrivacyOptionEvent event) {
|
||||||
builder.put(DataType.BYTE, event.getTradeCompete());
|
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(3, new FocusUpdateEventDecoder());
|
||||||
register(241, new MouseClickEventDecoder());
|
register(241, new MouseClickEventDecoder());
|
||||||
register(86, new ArrowKeyEventDecoder());
|
register(86, new ArrowKeyEventDecoder());
|
||||||
|
|
||||||
register(95, new PrivacyOptionEventDecoder());
|
register(95, new PrivacyOptionEventDecoder());
|
||||||
|
|
||||||
SpamPacketEventDecoder spamEventDecoder = new SpamPacketEventDecoder();
|
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.OpenInterfaceSidebarEvent;
|
||||||
import org.apollo.game.event.impl.PlayerSynchronizationEvent;
|
import org.apollo.game.event.impl.PlayerSynchronizationEvent;
|
||||||
import org.apollo.game.event.impl.PositionEvent;
|
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.RegionChangeEvent;
|
||||||
import org.apollo.game.event.impl.ServerMessageEvent;
|
import org.apollo.game.event.impl.ServerMessageEvent;
|
||||||
import org.apollo.game.event.impl.SetTileItemEvent;
|
import org.apollo.game.event.impl.SetTileItemEvent;
|
||||||
@@ -115,6 +116,7 @@ public final class Release377 extends Release {
|
|||||||
register(187, new FocusUpdateEventDecoder());
|
register(187, new FocusUpdateEventDecoder());
|
||||||
register(19, new MouseClickEventDecoder());
|
register(19, new MouseClickEventDecoder());
|
||||||
register(140, new ArrowKeyEventDecoder());
|
register(140, new ArrowKeyEventDecoder());
|
||||||
|
register(176, new PrivacyOptionEventDecoder());
|
||||||
|
|
||||||
SpamPacketEventDecoder spamEventDecoder = new SpamPacketEventDecoder();
|
SpamPacketEventDecoder spamEventDecoder = new SpamPacketEventDecoder();
|
||||||
register(40, spamEventDecoder);
|
register(40, spamEventDecoder);
|
||||||
@@ -151,6 +153,7 @@ public final class Release377 extends Release {
|
|||||||
register(SetTileItemEvent.class, new SetTileItemEventEncoder());
|
register(SetTileItemEvent.class, new SetTileItemEventEncoder());
|
||||||
register(PositionEvent.class, new PositionEventEncoder());
|
register(PositionEvent.class, new PositionEventEncoder());
|
||||||
register(UpdateRunEnergyEvent.class, new UpdateRunEnergyEventEncoder());
|
register(UpdateRunEnergyEvent.class, new UpdateRunEnergyEventEncoder());
|
||||||
|
register(PrivacyOptionEvent.class, new PrivacyOptionEventEncoder());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user