mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 08:39:11 +00:00
Fix bug where incorrect privacy state would be retrieved.
This commit is contained in:
@@ -34,9 +34,9 @@ public final class PrivacyOptionEvent extends Event {
|
||||
* @param tradePrivacy The privacy state of the player's trade chat.
|
||||
*/
|
||||
public PrivacyOptionEvent(int chatPrivacy, int friendPrivacy, int tradePrivacy) {
|
||||
this.chatPrivacy = PrivacyState.valueOf(chatPrivacy);
|
||||
this.friendPrivacy = PrivacyState.valueOf(friendPrivacy);
|
||||
this.tradePrivacy = PrivacyState.valueOf(tradePrivacy);
|
||||
this.chatPrivacy = PrivacyState.valueOf(chatPrivacy, true);
|
||||
this.friendPrivacy = PrivacyState.valueOf(friendPrivacy, false);
|
||||
this.tradePrivacy = PrivacyState.valueOf(tradePrivacy, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,11 +35,15 @@ public enum PrivacyState {
|
||||
* @return The privacy state.
|
||||
* @throws IllegalArgumentException If the specified value is out of bounds.
|
||||
*/
|
||||
public static PrivacyState valueOf(int value) {
|
||||
public static PrivacyState valueOf(int value, boolean chat) {
|
||||
PrivacyState[] values = values();
|
||||
if (!chat && value != 0) {
|
||||
value++;
|
||||
}
|
||||
if (value < 0 || value >= values.length) {
|
||||
throw new IllegalArgumentException("Invalid privacy option integer value specified: " + value + ".");
|
||||
}
|
||||
|
||||
return values[value];
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public final class PluginMetaDataParser {
|
||||
String id = idNode.getValue();
|
||||
String name = nameNode.getValue();
|
||||
String description = descriptionNode.getValue();
|
||||
int version = Integer.parseInt(versionNode.getValue());
|
||||
double version = Double.parseDouble(versionNode.getValue());
|
||||
|
||||
if (id == null || name == null || description == null) {
|
||||
throw new IOException("Id, name and description must have values.");
|
||||
|
||||
@@ -57,9 +57,9 @@ public final class BinaryPlayerLoader implements PlayerLoader {
|
||||
boolean members = in.readBoolean();
|
||||
|
||||
// read settings
|
||||
PrivacyState privacyPublicChat = PrivacyState.valueOf(in.readByte());
|
||||
PrivacyState privacyPrivateChat = PrivacyState.valueOf(in.readByte());
|
||||
PrivacyState privacyTradeCompete = PrivacyState.valueOf(in.readByte());
|
||||
PrivacyState chatPrivacy = PrivacyState.valueOf(in.readByte(), true);
|
||||
PrivacyState friendPrivacy = PrivacyState.valueOf(in.readByte(), false);
|
||||
PrivacyState tradePrivacy = PrivacyState.valueOf(in.readByte(), false);
|
||||
int runEnergy = in.readByte();
|
||||
ScreenBrightness brightness = ScreenBrightness.valueOf(in.readByte());
|
||||
|
||||
@@ -85,9 +85,9 @@ public final class BinaryPlayerLoader implements PlayerLoader {
|
||||
Player player = new Player(credentials, new Position(x, y, height));
|
||||
player.setPrivilegeLevel(privilegeLevel);
|
||||
player.setMembers(members);
|
||||
player.setChatPrivacy(privacyPublicChat);
|
||||
player.setFriendPrivacy(privacyPrivateChat);
|
||||
player.setTradePrivacy(privacyTradeCompete);
|
||||
player.setChatPrivacy(chatPrivacy);
|
||||
player.setFriendPrivacy(friendPrivacy);
|
||||
player.setTradePrivacy(tradePrivacy);
|
||||
player.setRunEnergy(runEnergy);
|
||||
player.setScreenBrightness(brightness);
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@ public final class PrivacyOptionEventDecoder extends EventDecoder<PrivacyOptionE
|
||||
|
||||
@Override
|
||||
public PrivacyOptionEvent decode(GamePacket packet) {
|
||||
final GamePacketReader reader = new GamePacketReader(packet);
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
|
||||
final int publicChatState = (int) reader.getUnsigned(DataType.BYTE);
|
||||
final int privateChatState = (int) reader.getUnsigned(DataType.BYTE);
|
||||
final int tradeChatState = (int) reader.getUnsigned(DataType.BYTE);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ public final class PrivacyOptionEventEncoder extends EventEncoder<PrivacyOptionE
|
||||
public GamePacket encode(final PrivacyOptionEvent event) {
|
||||
final GamePacketBuilder builder = new GamePacketBuilder(206);
|
||||
|
||||
builder.put(DataType.BYTE, event.getChatPrivacy().ordinal());
|
||||
builder.put(DataType.BYTE, event.getFriendPrivacy().ordinal());
|
||||
builder.put(DataType.BYTE, event.getTradePrivacy().ordinal());
|
||||
builder.put(DataType.BYTE, event.getChatPrivacy().toInteger());
|
||||
builder.put(DataType.BYTE, event.getFriendPrivacy().toInteger());
|
||||
builder.put(DataType.BYTE, event.getTradePrivacy().toInteger());
|
||||
|
||||
return builder.toGamePacket();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user