Merge branch 'wip/v5' into feat/events

This commit is contained in:
Lukas Rieger (Blue) 2024-05-20 21:45:01 +02:00
commit c91f991dc9
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6
8 changed files with 38 additions and 25 deletions

View File

@ -39,7 +39,6 @@
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
public class BlueMapAPIImpl extends BlueMapAPI {
@ -107,8 +106,7 @@ public Optional<BlueMapWorld> getWorldUncached(Object world) {
if (coreWorld != null) world = coreWorld;
}
if (world instanceof World) {
var coreWorld = (World) world;
if (world instanceof World coreWorld) {
return Optional.of(new BlueMapWorldImpl(plugin, coreWorld));
}
@ -146,7 +144,7 @@ public String getBlueMapVersion() {
public void register() {
try {
BlueMapAPI.registerInstance(this);
} catch (ExecutionException ex) {
} catch (Exception ex) {
Logger.global.logError("BlueMapAPI: A BlueMapAPI listener threw an exception (onEnable)!", ex.getCause());
}
}
@ -154,7 +152,7 @@ public void register() {
public void unregister() {
try {
BlueMapAPI.unregisterInstance(this);
} catch (ExecutionException ex) {
} catch (Exception ex) {
Logger.global.logError("BlueMapAPI: A BlueMapAPI listener threw an exception (onDisable)!", ex.getCause());
}
}

View File

@ -31,7 +31,6 @@
import de.bluecolored.bluemap.common.rendermanager.MapPurgeTask;
import de.bluecolored.bluemap.common.rendermanager.MapUpdateTask;
import java.io.IOException;
import java.util.Collection;
public class RenderManagerImpl implements RenderManager {
@ -59,7 +58,7 @@ public boolean scheduleMapUpdateTask(BlueMapMap map, Collection<Vector2i> region
}
@Override
public boolean scheduleMapPurgeTask(BlueMapMap map) throws IOException {
public boolean scheduleMapPurgeTask(BlueMapMap map) {
BlueMapMapImpl cmap = castMap(map);
return renderManager.scheduleRenderTask(new MapPurgeTask(cmap.getBmMap()));
}

View File

@ -29,11 +29,15 @@
import de.bluecolored.bluemap.common.web.http.HttpResponse;
import de.bluecolored.bluemap.common.web.http.HttpStatusCode;
import de.bluecolored.bluemap.core.BlueMap;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
@Getter @Setter
public class BlueMapResponseModifier implements HttpRequestHandler {
private final HttpRequestHandler delegate;
private final String serverName;
private @NonNull HttpRequestHandler delegate;
private @NonNull String serverName;
public BlueMapResponseModifier(HttpRequestHandler delegate) {
this.delegate = delegate;

View File

@ -25,6 +25,9 @@
package de.bluecolored.bluemap.common.web;
import de.bluecolored.bluemap.common.web.http.*;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.io.File;
@ -38,9 +41,10 @@
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
@Getter @Setter
public class FileRequestHandler implements HttpRequestHandler {
private final Path webRoot;
private @NonNull Path webRoot;
public FileRequestHandler(Path webRoot) {
this.webRoot = webRoot.normalize();

View File

@ -28,12 +28,16 @@
import de.bluecolored.bluemap.common.web.http.HttpRequestHandler;
import de.bluecolored.bluemap.common.web.http.HttpResponse;
import de.bluecolored.bluemap.common.web.http.HttpStatusCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import java.util.function.Supplier;
@Getter @Setter
public class JsonDataRequestHandler implements HttpRequestHandler {
private final Supplier<String> dataSupplier;
private @NonNull Supplier<String> dataSupplier;
public JsonDataRequestHandler(Supplier<String> dataSupplier) {
this.dataSupplier = dataSupplier;

View File

@ -26,14 +26,18 @@
import de.bluecolored.bluemap.common.web.http.*;
import de.bluecolored.bluemap.core.logger.Logger;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
@Getter
@Getter @Setter
@AllArgsConstructor
public class LoggingRequestHandler implements HttpRequestHandler {
private final HttpRequestHandler delegate;
private final Logger logger;
private final String format;
private @NonNull HttpRequestHandler delegate;
private @NonNull String format;
private @NonNull Logger logger;
public LoggingRequestHandler(HttpRequestHandler delegate) {
this(delegate, Logger.global);
@ -47,12 +51,6 @@ public LoggingRequestHandler(HttpRequestHandler delegate, String format) {
this(delegate, format, Logger.global);
}
public LoggingRequestHandler(HttpRequestHandler delegate, String format, Logger logger) {
this.delegate = delegate;
this.format = format;
this.logger = logger;
}
@Override
public HttpResponse handle(HttpRequest request) {

View File

@ -34,7 +34,10 @@
import de.bluecolored.bluemap.core.storage.MapStorage;
import de.bluecolored.bluemap.core.storage.compression.CompressedInputStream;
import de.bluecolored.bluemap.core.storage.compression.Compression;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import org.apache.commons.io.IOUtils;
import java.io.ByteArrayInputStream;
@ -47,11 +50,12 @@
import java.util.regex.Pattern;
@RequiredArgsConstructor
@Getter @Setter
public class MapStorageRequestHandler implements HttpRequestHandler {
private static final Pattern TILE_PATTERN = Pattern.compile("tiles/([\\d/]+)/x(-?[\\d/]+)z(-?[\\d/]+).*");
private final MapStorage mapStorage;
private @NonNull MapStorage mapStorage;
@SuppressWarnings("resource")
@Override

View File

@ -34,16 +34,18 @@
import lombok.Setter;
import org.intellij.lang.annotations.Language;
import java.util.LinkedList;
import java.util.Deque;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Getter
public class RoutingRequestHandler implements HttpRequestHandler {
public final LinkedList<Route> routes;
private final Deque<Route> routes;
public RoutingRequestHandler() {
this.routes = new LinkedList<>();
this.routes = new ConcurrentLinkedDeque<>();
}
public void register(@Language("RegExp") String pattern, HttpRequestHandler handler) {