mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-22 16:48:25 +01:00
refactored some parts of the PR
This commit is contained in:
parent
8ea2e6922f
commit
67e6be3788
@ -24,6 +24,7 @@ import de.florianmichael.viafabricplus.definition.ItemReleaseVersionDefinition;
|
||||
import de.florianmichael.viafabricplus.definition.PackFormatsDefinition;
|
||||
import de.florianmichael.viafabricplus.definition.bedrock.BedrockAccountHandler;
|
||||
import de.florianmichael.viafabricplus.definition.c0_30.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.definition.c0_30.classicube.ClassiCubeAccountHandler;
|
||||
import de.florianmichael.viafabricplus.definition.c0_30.protocol.CustomClassicProtocolExtensions;
|
||||
import de.florianmichael.viafabricplus.definition.c0_30.command.ClassicProtocolCommands;
|
||||
import de.florianmichael.viafabricplus.definition.v1_8_x.ArmorPointsDefinition;
|
||||
@ -52,6 +53,7 @@ public class ViaFabricPlus {
|
||||
ClassicItemSelectionScreen.create();
|
||||
ChatLengthDefinition.create();
|
||||
ClassicProtocolCommands.create();
|
||||
ClassiCubeAccountHandler.create();
|
||||
|
||||
new ProtocolHack();
|
||||
|
||||
|
@ -43,8 +43,7 @@ public class ClassiCubeAccount {
|
||||
|
||||
public void login(ILoginProcessHandler processHandler) throws LoginException {
|
||||
final ClassiCubeAuthenticationTokenRequest initialTokenRequest = new ClassiCubeAuthenticationTokenRequest();
|
||||
final ClassiCubeAuthenticationResponse initialTokenResponse = initialTokenRequest.send()
|
||||
.join();
|
||||
final ClassiCubeAuthenticationResponse initialTokenResponse = initialTokenRequest.send().join();
|
||||
|
||||
// There should NEVER be any errors on the initial token response!
|
||||
if (initialTokenResponse.shouldError()) {
|
||||
@ -54,8 +53,7 @@ public class ClassiCubeAccount {
|
||||
}
|
||||
|
||||
final ClassiCubeAuthenticationLoginRequest loginRequest = new ClassiCubeAuthenticationLoginRequest(initialTokenResponse, this.username, this.password);
|
||||
final ClassiCubeAuthenticationResponse loginResponse = loginRequest.send()
|
||||
.join();
|
||||
final ClassiCubeAuthenticationResponse loginResponse = loginRequest.send().join();
|
||||
|
||||
if (loginResponse.shouldError()) {
|
||||
final String errorDisplay = loginResponse.getErrorDisplay();
|
||||
|
@ -28,8 +28,7 @@ public class ClassiCubeAuthenticationData {
|
||||
}
|
||||
|
||||
public String getRequestBody() {
|
||||
final StringBuilder builder = new StringBuilder("username=")
|
||||
.append(username);
|
||||
final StringBuilder builder = new StringBuilder("username=").append(username);
|
||||
|
||||
builder.append("&password=");
|
||||
builder.append(password);
|
||||
|
@ -3,6 +3,7 @@ package de.florianmichael.viafabricplus.definition.c0_30.classicube.auth.process
|
||||
import de.florianmichael.viafabricplus.definition.c0_30.classicube.auth.ClassiCubeAccount;
|
||||
|
||||
public interface ILoginProcessHandler {
|
||||
|
||||
void handleMfa(final ClassiCubeAccount account);
|
||||
void handleSuccessfulLogin(final ClassiCubeAccount account);
|
||||
}
|
||||
|
@ -2,33 +2,17 @@ package de.florianmichael.viafabricplus.definition.c0_30.classicube.data;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class ClassiCubeServerInfo {
|
||||
public final String hash;
|
||||
public final int maxplayers;
|
||||
public final String name;
|
||||
public final int players;
|
||||
public final String software;
|
||||
public final long uptime;
|
||||
@SerializedName("country_abbr")
|
||||
public final String countryCode;
|
||||
public final boolean web;
|
||||
public final boolean featured;
|
||||
public final String ip;
|
||||
public final int port;
|
||||
public final String mppass;
|
||||
|
||||
public ClassiCubeServerInfo(String hash, int maxplayers, String name, int players, String software, long uptime, String countryCode, boolean web, boolean featured, String ip, int port, String mppass) {
|
||||
this.hash = hash;
|
||||
this.maxplayers = maxplayers;
|
||||
this.name = name;
|
||||
this.players = players;
|
||||
this.software = software;
|
||||
this.uptime = uptime;
|
||||
this.countryCode = countryCode;
|
||||
this.web = web;
|
||||
this.featured = featured;
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
this.mppass = mppass;
|
||||
}
|
||||
public record ClassiCubeServerInfo(
|
||||
String hash,
|
||||
@SerializedName("maxplayers") int maxPlayers,
|
||||
String name,
|
||||
int players,
|
||||
String software,
|
||||
long uptime,
|
||||
@SerializedName("country_abbr") String countryCode,
|
||||
boolean web,
|
||||
boolean featured,
|
||||
String ip,
|
||||
int port,
|
||||
String mppass) {
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import java.net.http.HttpRequest;
|
||||
public abstract class ClassiCubeRequest {
|
||||
|
||||
private final static URI CLASSICUBE_ROOT_URI = URI.create("https://www.classicube.net");
|
||||
|
||||
protected final static URI AUTHENTICATION_URI = CLASSICUBE_ROOT_URI.resolve("/api/login/");
|
||||
protected final static URI SERVER_INFO_URI = CLASSICUBE_ROOT_URI.resolve("/api/server/");
|
||||
protected final static URI SERVER_LIST_INFO_URI = CLASSICUBE_ROOT_URI.resolve("/api/servers/");
|
||||
|
@ -12,6 +12,10 @@ public class ClassiCubeServerInfoResponse extends ClassiCubeResponse {
|
||||
this.servers = servers;
|
||||
}
|
||||
|
||||
public Set<ClassiCubeServerInfo> getServers() {
|
||||
return servers;
|
||||
}
|
||||
|
||||
public static ClassiCubeServerInfoResponse fromJson(final String json) {
|
||||
return GSON.fromJson(json, ClassiCubeServerInfoResponse.class);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user