3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2025-01-11 23:51:22 +01:00

adding equals and hashcode in ClientSettings, ClientSettingsWrapper and SkinParts (#765)

* adding equals and hashcode in ClientSettings, ClientSettingsWrapper and SkinParts

* fixing format
Dieser Commit ist enthalten in:
foxley 2022-06-23 05:37:38 +02:00 committet von GitHub
Ursprung 93df65fdfb
Commit 86c65f3910
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
3 geänderte Dateien mit 73 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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);
}
}