geforkt von Mirrors/Velocity
Ensure that getting a builder from the ping will produce the same ping.
Dieser Commit ist enthalten in:
Ursprung
68fde1e795
Commit
5cf96aabdd
@ -8,6 +8,7 @@ import com.velocitypowered.api.util.ModInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -73,10 +74,32 @@ public final class ServerPing {
|
||||
+ "version=" + version
|
||||
+ ", players=" + players
|
||||
+ ", description=" + description
|
||||
+ ", favicon='" + favicon + '\''
|
||||
+ ", favicon=" + favicon
|
||||
+ ", modinfo=" + modinfo
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ServerPing ping = (ServerPing) o;
|
||||
return Objects.equals(version, ping.version)
|
||||
&& Objects.equals(players, ping.players)
|
||||
&& Objects.equals(description, ping.description)
|
||||
&& Objects.equals(favicon, ping.favicon)
|
||||
&& Objects.equals(modinfo, ping.modinfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(version, players, description, favicon, modinfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of this {@link ServerPing} instance as a builder so that it can be modified.
|
||||
* @return a copy of this instance as a {@link Builder}
|
||||
@ -281,6 +304,23 @@ public final class ServerPing {
|
||||
+ ", name='" + name + '\''
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Version version = (Version) o;
|
||||
return protocol == version.protocol && Objects.equals(name, version.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(protocol, name);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Players {
|
||||
@ -321,6 +361,24 @@ public final class ServerPing {
|
||||
+ ", sample=" + sample
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Players players = (Players) o;
|
||||
return online == players.online && max == players.max
|
||||
&& Objects.equals(sample, players.sample);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(online, max, sample);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class SamplePlayer {
|
||||
@ -348,5 +406,22 @@ public final class ServerPing {
|
||||
+ ", id=" + id
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SamplePlayer that = (SamplePlayer) o;
|
||||
return Objects.equals(name, that.name) && Objects.equals(id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class ModInfo {
|
||||
|
||||
@ -33,6 +34,23 @@ public final class ModInfo {
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ModInfo modInfo = (ModInfo) o;
|
||||
return type.equals(modInfo.type) && modList.equals(modInfo.modList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(type, modList);
|
||||
}
|
||||
|
||||
public static final class Mod {
|
||||
|
||||
@SerializedName("modid")
|
||||
@ -59,5 +77,22 @@ public final class ModInfo {
|
||||
+ ", version='" + version + '\''
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Mod mod = (Mod) o;
|
||||
return id.equals(mod.id) && version.equals(mod.version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, version);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.velocitypowered.api.proxy.server;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing.Players;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing.SamplePlayer;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing.Version;
|
||||
import java.util.UUID;
|
||||
import net.kyori.text.TextComponent;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ServerPingTest {
|
||||
|
||||
@Test
|
||||
void asBuilderConsistency() {
|
||||
ServerPing ping = new ServerPing(new Version(404, "1.13.2"),
|
||||
new Players(1, 1, ImmutableList.of(new SamplePlayer("tuxed", UUID.randomUUID()))),
|
||||
TextComponent.of("test"), null);
|
||||
assertEquals(ping, ping.asBuilder().build());
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren