This commit is contained in:
2023-04-16 09:31:37 +08:00
parent c534b9508b
commit 31109849fe
30 changed files with 369 additions and 144 deletions
@@ -1,7 +1,6 @@
package cc.maxmc.msm.api;
import cc.maxmc.msm.api.misc.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import cc.maxmc.msm.api.misc.MatchInfo;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -9,12 +8,12 @@ import java.util.List;
@SuppressWarnings("unused") // API
public interface MultiServerManAPI {
@NotNull
ServerInfo getServer(@NotNull String type, @NotNull List<String> players);
MatchInfo getServer(@NotNull String type, @NotNull List<String> players);
void informEnd(int id);
@NotNull
ServerInfo getPlayerServer(@NotNull String player);
MatchInfo getPlayerServer(@NotNull String player);
Boolean containPlayer(@NotNull String player);
@@ -0,0 +1,42 @@
package cc.maxmc.msm.api.misc;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public class MatchInfo {
private final int id;
@NotNull
private final ServerInfo info;
public MatchInfo() {
id = -1;
info = new ServerInfo();
}
public MatchInfo(int id, @NotNull ServerInfo info) {
this.id = id;
this.info = info;
}
public int getId() {
return id;
}
public ServerInfo getServer() {
return info;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MatchInfo matchInfo = (MatchInfo) o;
return id == matchInfo.id && Objects.equals(info, matchInfo.info);
}
@Override
public int hashCode() {
return Objects.hash(id, info);
}
}
@@ -1,15 +1,34 @@
package cc.maxmc.msm.api.misc;
import com.google.common.net.HostAndPort;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
import java.util.UUID;
@SuppressWarnings("unused") // API
public class ServerInfo {
@NotNull
private final UUID uid;
@Nullable
private final HostAndPort server;
private final int id;
private final String server;
private boolean available;
public ServerInfo() {
uid = UUID.fromString("00000000-0000-0000-0000-000000000000");
server = null;
}
public ServerInfo(@NotNull UUID uid, @Nullable String server) {
this.uid = uid;
this.server = server;
}
@NotNull
public UUID getUid() {
return uid;
}
public boolean isAvailable() {
return available;
}
@@ -18,22 +37,21 @@ public class ServerInfo {
this.available = available;
}
public ServerInfo() {
server = HostAndPort.fromString("127.0.0.1");
id = -1;
}
public ServerInfo(@Nullable HostAndPort server, int id) {
this.server = server;
this.id = id;
}
@Nullable
public HostAndPort getServer() {
public String getServer() {
return server;
}
public int getId() {
return id;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ServerInfo that = (ServerInfo) o;
return Objects.equals(server, that.server) && Objects.equals(uid, that.uid);
}
@Override
public int hashCode() {
return Objects.hash(server, uid);
}
}