mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-13 11:41:52 +01:00
Fix player settings (#620)
This commit is contained in:
parent
fb81578028
commit
f1ca048eb6
@ -2024,6 +2024,8 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
private boolean chatColors;
|
||||
private byte displayedSkinParts;
|
||||
private MainHand mainHand;
|
||||
private boolean enableTextFiltering;
|
||||
private boolean allowServerListings;
|
||||
|
||||
public PlayerSettings() {
|
||||
viewDistance = 2;
|
||||
@ -2078,6 +2080,10 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
return mainHand;
|
||||
}
|
||||
|
||||
public boolean enableTextFiltering() { return enableTextFiltering; }
|
||||
|
||||
public boolean allowServerListings() { return allowServerListings; }
|
||||
|
||||
/**
|
||||
* Changes the player settings internally.
|
||||
* <p>
|
||||
@ -2091,13 +2097,15 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
* @param mainHand the player main hand
|
||||
*/
|
||||
public void refresh(String locale, byte viewDistance, ChatMessageType chatMessageType, boolean chatColors,
|
||||
byte displayedSkinParts, MainHand mainHand) {
|
||||
byte displayedSkinParts, MainHand mainHand, boolean enableTextFiltering, boolean allowServerListings) {
|
||||
this.locale = locale;
|
||||
this.viewDistance = viewDistance;
|
||||
this.chatMessageType = chatMessageType;
|
||||
this.chatColors = chatColors;
|
||||
this.displayedSkinParts = displayedSkinParts;
|
||||
this.mainHand = mainHand;
|
||||
this.enableTextFiltering = enableTextFiltering;
|
||||
this.allowServerListings = allowServerListings;
|
||||
|
||||
// TODO: Use the metadata object here
|
||||
metadata.setIndex((byte) 17, Metadata.Byte(displayedSkinParts));
|
||||
|
@ -9,7 +9,7 @@ public final class SettingsListener {
|
||||
public static void listener(ClientSettingsPacket packet, Player player) {
|
||||
Player.PlayerSettings settings = player.getSettings();
|
||||
final byte viewDistance = (byte) Math.abs(packet.viewDistance());
|
||||
settings.refresh(packet.locale(), viewDistance, packet.chatMessageType(), packet.chatColors(), packet.displayedSkinParts(), packet.mainHand());
|
||||
settings.refresh(packet.locale(), viewDistance, packet.chatMessageType(), packet.chatColors(), packet.displayedSkinParts(), packet.mainHand(), packet.enableTextFiltering(), packet.allowsListing());
|
||||
EventDispatcher.call(new PlayerSettingsChangeEvent(player));
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public record ClientSettingsPacket(@NotNull String locale, byte viewDistance,
|
||||
@NotNull ChatMessageType chatMessageType, boolean chatColors,
|
||||
byte displayedSkinParts, @NotNull Player.MainHand mainHand,
|
||||
boolean disableTextFiltering, boolean allowsListing) implements ClientPacket {
|
||||
boolean enableTextFiltering, boolean allowsListing) implements ClientPacket {
|
||||
public ClientSettingsPacket {
|
||||
if (locale.length() > 128)
|
||||
throw new IllegalArgumentException("Locale cannot be longer than 128 characters.");
|
||||
@ -31,7 +31,7 @@ public record ClientSettingsPacket(@NotNull String locale, byte viewDistance,
|
||||
writer.writeBoolean(chatColors);
|
||||
writer.writeByte(displayedSkinParts);
|
||||
writer.writeVarInt(mainHand.ordinal());
|
||||
writer.writeBoolean(disableTextFiltering);
|
||||
writer.writeBoolean(enableTextFiltering);
|
||||
writer.writeBoolean(allowsListing);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user