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