added Arena appliances for fights on a separate server

This commit is contained in:
MineTec committed 2026-10-15 22:33:48 +02:00
1 parent c6bf0b0163
commit 8b616ba2a2
37 files changed
+2945 -2

No files matched your search

@@ -49,6 +49,19 @@ public abstract class HttpRepository extends Repository {
return this.execute(request, outputType, data);
}
/**
* Like {@link #post(String, Object, Class)}, but the request fails with an exception once the timeout has passed.
*/
protected <TInput, TOutput> ReqResp<TOutput> post(String command, Duration timeout, TInput data, Class<TOutput> outputType) {
HttpRequest request = this.getRequestBuilder(this.getUri(command, parameters -> {
}))
.timeout(timeout)
.POST(HttpRequest.BodyPublishers.ofString(this.gson.toJson(data)))
.build();
return this.execute(request, outputType, data);
}
protected <TInput, TOutput> ReqResp<TOutput> put(String command, TInput data, Class<TOutput> outputType) {
return this.put(command, parameters -> {
}, data, outputType);
@@ -117,12 +130,19 @@ public abstract class HttpRepository extends Repository {
return builder;
}
/**
* Whether request bodies are written to the log. Turn off for large or sensitive payloads.
*/
protected boolean logRequestData() {
return true;
}
private <TResponse> ReqResp<TResponse> execute(HttpRequest request, Class<TResponse> clazz, Object original) {
ReqResp<String> rawResponse = this.sendHttp(request);
Main.logger().info(String.format(
"Request: %s\nRequest-Data: %s\nResponse: %s",
request,
this.gson.toJson(original),
this.logRequestData() ? this.gson.toJson(original) : "<not logged>",
rawResponse
));
return new ReqResp<>(rawResponse.status(), this.gson.fromJson(rawResponse.data(), clazz));
@@ -4,6 +4,7 @@ import com.google.gson.Gson;
import eu.mhsl.craftattack.spawn.core.Main;
import eu.mhsl.craftattack.spawn.core.api.server.hooks.HttpHook;
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
import eu.mhsl.craftattack.spawn.core.config.Configuration;
import org.bukkit.configuration.ConfigurationSection;
import spark.Request;
import spark.Spark;
@@ -19,7 +20,7 @@ public class HttpServer {
public static Object nothing = null;
public HttpServer() {
Spark.port(8080);
Spark.port(Configuration.pluginConfig.getInt("httpPort", 8080));
Spark.get("/ping", (request, response) -> System.currentTimeMillis());
+38
View File
@@ -1,5 +1,6 @@
plugin:
httpServerEnabled: true
httpPort: 8080
disabledAppliances:
- NameOfApplianceClass
@@ -34,6 +35,43 @@ worldMuseum:
yaw: 0
pitch: 0
arenaPortal:
api: http://127.0.0.1:8081/
connect-server-name: arena
uuid:
villagerLocation:
world: world
x: 0
y: 0
z: 0
yaw: 0
pitch: 0
arena:
connect-server-name: craftattack
fightMinutes: 10
countdownSeconds: 5
resetBlocksPerTick: 20000
uuid:
villagerLocation:
world: arena
x: 0
y: 64
z: 0
yaw: 0
pitch: 0
tribuneSpawn:
world: arena
x: 0.5
y: 64
z: 0.5
yaw: 0
pitch: 0
# alles Weitere setzt /arenasetup auf dem Arena-Server
syncRegion: {}
pads: {}
arenas: {}
adminMarker:
permission: admin
color: AQUA