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:
Ursprung
93df65fdfb
Commit
86c65f3910
@ -7,6 +7,9 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.proxy.player;
|
package com.velocitypowered.api.proxy.player;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public final class SkinParts {
|
public final class SkinParts {
|
||||||
|
|
||||||
private final byte bitmask;
|
private final byte bitmask;
|
||||||
@ -42,4 +45,21 @@ public final class SkinParts {
|
|||||||
public boolean hasHat() {
|
public boolean hasHat() {
|
||||||
return ((bitmask >> 6) & 1) == 1;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import com.velocitypowered.api.proxy.player.PlayerSettings;
|
|||||||
import com.velocitypowered.api.proxy.player.SkinParts;
|
import com.velocitypowered.api.proxy.player.SkinParts;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ClientSettings;
|
import com.velocitypowered.proxy.protocol.packet.ClientSettings;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Objects;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class ClientSettingsWrapper implements PlayerSettings {
|
public class ClientSettingsWrapper implements PlayerSettings {
|
||||||
@ -79,4 +80,21 @@ public class ClientSettingsWrapper implements PlayerSettings {
|
|||||||
return settings.isClientListingAllowed();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
|||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import java.util.Objects;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class ClientSettings implements MinecraftPacket {
|
public class ClientSettings implements MinecraftPacket {
|
||||||
@ -190,4 +191,38 @@ public class ClientSettings implements MinecraftPacket {
|
|||||||
public boolean handle(MinecraftSessionHandler handler) {
|
public boolean handle(MinecraftSessionHandler handler) {
|
||||||
return handler.handle(this);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren