Skip to content

Commit

Permalink
Construct endpoint urls
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Oct 17, 2023
1 parent cf67f50 commit 937cd66
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# gradle
# Gradle Properties
org.gradle.jvmargs=-Xmx8G
org.gradle.parallel=true

# project
# Project Details
maven_name=Classic4J
maven_version=2.0.2-SNAPSHOT
maven_group=de.florianmichael
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
* This class provides methods to interact with the BetaCraft API. These API methods are used to request the Multiplayer Pass for a server.
*/
public class BetaCraftHandler {
public final static URI GET_MP_PASS = URI.create("http://api.betacraft.uk/getmppass.jsp");
public final static URI BETACRAFT_ROOT_URI = URI.create("https://api.betacraft.uk");

public final static URI GET_MP_PASS = BETACRAFT_ROOT_URI.resolve("/getmppass.jsp");

/**
* Requests the Multiplayer Pass for a server from the BetaCraft API.
Expand Down Expand Up @@ -66,6 +68,8 @@ public static String requestMPPass(final String username, final String ip, final

joinServerInterface.sendAuthRequest(sha1(server.getBytes()));

System.out.println(GET_MP_PASS + "?user=" + username + "&server=" + server);

final InputStream connection = new URL(GET_MP_PASS + "?user=" + username + "&server=" + server).openStream();
Scanner scanner = new Scanner(connection);
StringBuilder response = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ public static void requestAuthentication(final CCAccount account, final String l
return;
}
if (loginResponse.shouldError()) {
final String errorDisplay = loginResponse.getErrorDisplay();
processHandler.handleException(new LoginException(errorDisplay));
processHandler.handleException(new LoginException(loginResponse.getErrorDisplay()));
return;
}
processHandler.handleSuccessfulLogin(account);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package de.florianmichael.classic4j.request.betacraft;

import com.google.gson.Gson;
import de.florianmichael.classic4j.BetaCraftHandler;
import de.florianmichael.classic4j.model.betacraft.BCServerInfoSpec;
import de.florianmichael.classic4j.model.betacraft.BCServerList;
import de.florianmichael.classic4j.model.betacraft.impl.BCServerInfov1;
Expand All @@ -28,8 +29,8 @@
import java.util.concurrent.CompletableFuture;

public enum BCServerListRequest {
V1(URI.create("https://api.betacraft.uk/server_list.jsp"), BCServerInfov1.class),
V2(URI.create("https://api.betacraft.uk/v2/server_list"), BCServerInfov2.class);
V1(BetaCraftHandler.BETACRAFT_ROOT_URI.resolve("/server_list.jsp"), BCServerInfov1.class),
V2(BetaCraftHandler.BETACRAFT_ROOT_URI.resolve("/v2/server_list"), BCServerInfov2.class);

private final URI uri;
private final Class<? extends BCServerInfoSpec> infoSpec;
Expand Down

0 comments on commit 937cd66

Please sign in to comment.