diff --git a/api/src/main/java/com/velocitypowered/api/proxy/player/SkinParts.java b/api/src/main/java/com/velocitypowered/api/proxy/player/SkinParts.java index e897dd0f..eb32c846 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/player/SkinParts.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/player/SkinParts.java @@ -7,6 +7,9 @@ package com.velocitypowered.api.proxy.player; +import java.util.Objects; +import org.checkerframework.checker.nullness.qual.Nullable; + public final class SkinParts { private final byte bitmask; @@ -42,4 +45,21 @@ public final class SkinParts { public boolean hasHat() { return ((bitmask >> 6) & 1) == 1; } + + @Override + public boolean equals(@Nullable final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final SkinParts skinParts = (SkinParts) o; + return bitmask == skinParts.bitmask; + } + + @Override + public int hashCode() { + return Objects.hash(bitmask); + } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientSettingsWrapper.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientSettingsWrapper.java index 402ef78d..36f906b5 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientSettingsWrapper.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientSettingsWrapper.java @@ -21,6 +21,7 @@ import com.velocitypowered.api.proxy.player.PlayerSettings; import com.velocitypowered.api.proxy.player.SkinParts; import com.velocitypowered.proxy.protocol.packet.ClientSettings; import java.util.Locale; +import java.util.Objects; import org.checkerframework.checker.nullness.qual.Nullable; public class ClientSettingsWrapper implements PlayerSettings { @@ -79,4 +80,21 @@ public class ClientSettingsWrapper implements PlayerSettings { return settings.isClientListingAllowed(); } + @Override + public boolean equals(@Nullable final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClientSettingsWrapper that = (ClientSettingsWrapper) o; + return Objects.equals(settings, that.settings) && Objects.equals(parts, that.parts) + && Objects.equals(locale, that.locale); + } + + @Override + public int hashCode() { + return Objects.hash(settings, parts, locale); + } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ClientSettings.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ClientSettings.java index f1e7d038..c193e682 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ClientSettings.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ClientSettings.java @@ -22,6 +22,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.ProtocolUtils; import io.netty.buffer.ByteBuf; +import java.util.Objects; import org.checkerframework.checker.nullness.qual.Nullable; public class ClientSettings implements MinecraftPacket { @@ -190,4 +191,38 @@ public class ClientSettings implements MinecraftPacket { public boolean handle(MinecraftSessionHandler handler) { return handler.handle(this); } + + @Override + public boolean equals(@Nullable final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ClientSettings that = (ClientSettings) o; + return viewDistance == that.viewDistance + && chatVisibility == that.chatVisibility + && chatColors == that.chatColors + && difficulty == that.difficulty + && skinParts == that.skinParts + && mainHand == that.mainHand + && chatFilteringEnabled == that.chatFilteringEnabled + && clientListingAllowed == that.clientListingAllowed + && Objects.equals(locale, that.locale); + } + + @Override + public int hashCode() { + return Objects.hash( + locale, + viewDistance, + chatVisibility, + chatColors, + difficulty, + skinParts, + mainHand, + chatFilteringEnabled, + clientListingAllowed); + } }