Skip to content

Commit

Permalink
feat: allow changing TWIN instance URL on config
Browse files Browse the repository at this point in the history
Backport of 57dd1b0 to v3
  • Loading branch information
diogotcorreia committed Jul 15, 2024
1 parent 4b0e03e commit cb59870
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public class MainConfig implements TritonConfig {
private long databaseMysqlPoolConnTimeout;
private Map<String, String> databaseMysqlPoolProperties;
private boolean iKnowWhatIAmDoing;
private String twinInstance;

public MainConfig(Triton main) {
this.main = main;
Expand Down Expand Up @@ -183,6 +184,7 @@ private void setup(Configuration section) {
setupLanguageCreation(languageCreation);

this.iKnowWhatIAmDoing = section.getBoolean("i-know-what-i-am-doing", false);
this.twinInstance = section.getString("twin-instance", "https://twin.rexcantor64.com");
}

public void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class TwinManager {
.registerTypeAdapter(LanguageSign.class, new LanguageSignSerializer())
.create();
private static final int TWIN_VERSION = 6;
private static final String BASE_URL = "https://twin.rexcantor64.com";
private final Triton main;

public TwinManager(Triton main) {
Expand Down Expand Up @@ -120,7 +119,7 @@ public HttpResponse upload(List<String> allowedCollections, List<String> allowed
}

val encodedData = data.toString();
val u = new URL(BASE_URL + "/api/v1/upload");
val u = new URL(getBaseUrl() + "/api/v1/upload");
val conn = (HttpURLConnection) u.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
Expand Down Expand Up @@ -163,7 +162,7 @@ public HttpResponse download(String id) {
if (Triton.isSpigot() && main.getConf().isBungeecord())
return null;

URL u = new URL(BASE_URL + "/api/v1/get/" + id);
URL u = new URL(getBaseUrl() + "/api/v1/get/" + id);
HttpURLConnection conn = (HttpURLConnection) u.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("GET");
Expand Down Expand Up @@ -197,7 +196,7 @@ public HttpResponse download(String id) {
}

public static String getBaseUrl() {
return BASE_URL;
return Triton.get().getConfig().getTwinInstance();
}

public static class HttpResponse {
Expand Down

0 comments on commit cb59870

Please sign in to comment.