-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16510d1
commit ad3316f
Showing
26 changed files
with
791 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
- Add option to use own credits to Server.start() | ||
- Use JSON body instead of form data | ||
- Update dependencies | ||
- Add endpoints for the server config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/com/exaroton/api/request/server/files/FileRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.exaroton.api.request.server.files; | ||
|
||
import com.exaroton.api.APIRequest; | ||
import com.exaroton.api.ExarotonClient; | ||
|
||
import java.util.HashMap; | ||
|
||
public abstract class FileRequest<T> extends APIRequest<T> { | ||
protected final String serverId; | ||
protected final String path; | ||
|
||
public FileRequest(ExarotonClient client, String serverId, String path) { | ||
super(client); | ||
this.serverId = serverId; | ||
this.path = path; | ||
} | ||
|
||
@Override | ||
protected HashMap<String, String> getData() { | ||
HashMap<String, String> map = super.getData(); | ||
map.put("server", this.serverId); | ||
map.put("path", this.path); | ||
return map; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/exaroton/api/request/server/files/GetConfigOptionsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.exaroton.api.request.server.files; | ||
|
||
import com.exaroton.api.APIResponse; | ||
import com.exaroton.api.ExarotonClient; | ||
import com.exaroton.api.server.config.ConfigOption; | ||
import com.google.gson.reflect.TypeToken; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
public class GetConfigOptionsRequest extends FileRequest<ConfigOption[]> { | ||
|
||
public GetConfigOptionsRequest(ExarotonClient client, String serverId, String path) { | ||
super(client, serverId, path); | ||
} | ||
|
||
|
||
@Override | ||
protected String getEndpoint() { | ||
return "servers/{server}/files/config/{path}"; | ||
} | ||
|
||
@Override | ||
protected Type getType() { | ||
return new TypeToken<APIResponse<ConfigOption[]>>(){}.getType(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/exaroton/api/request/server/files/UpdateConfigOptionsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.exaroton.api.request.server.files; | ||
|
||
import com.exaroton.api.APIResponse; | ||
import com.exaroton.api.ExarotonClient; | ||
import com.exaroton.api.server.config.ConfigOption; | ||
import com.google.gson.reflect.TypeToken; | ||
|
||
import java.lang.reflect.Type; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class UpdateConfigOptionsRequest extends FileRequest<ConfigOption[]> { | ||
private final Map<String, Object> options; | ||
|
||
public UpdateConfigOptionsRequest(ExarotonClient client, String serverId, String path, Map<String, Object> options) { | ||
super(client, serverId, path); | ||
this.options = options; | ||
} | ||
|
||
@Override | ||
protected String getEndpoint() { | ||
return "servers/{server}/files/config/{path}"; | ||
} | ||
|
||
@Override | ||
protected Type getType() { | ||
return new TypeToken<APIResponse<ConfigOption[]>>(){}.getType(); | ||
} | ||
|
||
@Override | ||
protected String getMethod() { | ||
return "POST"; | ||
} | ||
|
||
@Override | ||
protected Object getBody() { | ||
return client.getGson().toJson(this.options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/com/exaroton/api/server/config/ConfigOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.exaroton.api.server.config; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
public abstract class ConfigOption { | ||
private final String key; | ||
private final String label; | ||
private final OptionType type; | ||
private final String[] options; | ||
|
||
protected ConfigOption(String key, String label, OptionType type, String[] options) { | ||
this.key = key; | ||
this.label = label; | ||
this.type = type; | ||
this.options = options; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public @Nullable String[] getOptions() { | ||
return options; | ||
} | ||
|
||
abstract public @Nullable Object getValue(); | ||
|
||
public OptionType getType() { | ||
return type; | ||
} | ||
} |
Oops, something went wrong.