mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-23 02:55:19 +01:00
Merge branch 'wip/v5' into feat/events
This commit is contained in:
commit
c91f991dc9
@ -39,7 +39,6 @@
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class BlueMapAPIImpl extends BlueMapAPI {
|
public class BlueMapAPIImpl extends BlueMapAPI {
|
||||||
@ -107,8 +106,7 @@ public Optional<BlueMapWorld> getWorldUncached(Object world) {
|
|||||||
if (coreWorld != null) world = coreWorld;
|
if (coreWorld != null) world = coreWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world instanceof World) {
|
if (world instanceof World coreWorld) {
|
||||||
var coreWorld = (World) world;
|
|
||||||
return Optional.of(new BlueMapWorldImpl(plugin, coreWorld));
|
return Optional.of(new BlueMapWorldImpl(plugin, coreWorld));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +144,7 @@ public String getBlueMapVersion() {
|
|||||||
public void register() {
|
public void register() {
|
||||||
try {
|
try {
|
||||||
BlueMapAPI.registerInstance(this);
|
BlueMapAPI.registerInstance(this);
|
||||||
} catch (ExecutionException ex) {
|
} catch (Exception ex) {
|
||||||
Logger.global.logError("BlueMapAPI: A BlueMapAPI listener threw an exception (onEnable)!", ex.getCause());
|
Logger.global.logError("BlueMapAPI: A BlueMapAPI listener threw an exception (onEnable)!", ex.getCause());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,7 +152,7 @@ public void register() {
|
|||||||
public void unregister() {
|
public void unregister() {
|
||||||
try {
|
try {
|
||||||
BlueMapAPI.unregisterInstance(this);
|
BlueMapAPI.unregisterInstance(this);
|
||||||
} catch (ExecutionException ex) {
|
} catch (Exception ex) {
|
||||||
Logger.global.logError("BlueMapAPI: A BlueMapAPI listener threw an exception (onDisable)!", ex.getCause());
|
Logger.global.logError("BlueMapAPI: A BlueMapAPI listener threw an exception (onDisable)!", ex.getCause());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
import de.bluecolored.bluemap.common.rendermanager.MapPurgeTask;
|
import de.bluecolored.bluemap.common.rendermanager.MapPurgeTask;
|
||||||
import de.bluecolored.bluemap.common.rendermanager.MapUpdateTask;
|
import de.bluecolored.bluemap.common.rendermanager.MapUpdateTask;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class RenderManagerImpl implements RenderManager {
|
public class RenderManagerImpl implements RenderManager {
|
||||||
@ -59,7 +58,7 @@ public boolean scheduleMapUpdateTask(BlueMapMap map, Collection<Vector2i> region
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean scheduleMapPurgeTask(BlueMapMap map) throws IOException {
|
public boolean scheduleMapPurgeTask(BlueMapMap map) {
|
||||||
BlueMapMapImpl cmap = castMap(map);
|
BlueMapMapImpl cmap = castMap(map);
|
||||||
return renderManager.scheduleRenderTask(new MapPurgeTask(cmap.getBmMap()));
|
return renderManager.scheduleRenderTask(new MapPurgeTask(cmap.getBmMap()));
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,15 @@
|
|||||||
import de.bluecolored.bluemap.common.web.http.HttpResponse;
|
import de.bluecolored.bluemap.common.web.http.HttpResponse;
|
||||||
import de.bluecolored.bluemap.common.web.http.HttpStatusCode;
|
import de.bluecolored.bluemap.common.web.http.HttpStatusCode;
|
||||||
import de.bluecolored.bluemap.core.BlueMap;
|
import de.bluecolored.bluemap.core.BlueMap;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
public class BlueMapResponseModifier implements HttpRequestHandler {
|
public class BlueMapResponseModifier implements HttpRequestHandler {
|
||||||
|
|
||||||
private final HttpRequestHandler delegate;
|
private @NonNull HttpRequestHandler delegate;
|
||||||
private final String serverName;
|
private @NonNull String serverName;
|
||||||
|
|
||||||
public BlueMapResponseModifier(HttpRequestHandler delegate) {
|
public BlueMapResponseModifier(HttpRequestHandler delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
package de.bluecolored.bluemap.common.web;
|
package de.bluecolored.bluemap.common.web;
|
||||||
|
|
||||||
import de.bluecolored.bluemap.common.web.http.*;
|
import de.bluecolored.bluemap.common.web.http.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import lombok.Setter;
|
||||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -38,9 +41,10 @@
|
|||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
public class FileRequestHandler implements HttpRequestHandler {
|
public class FileRequestHandler implements HttpRequestHandler {
|
||||||
|
|
||||||
private final Path webRoot;
|
private @NonNull Path webRoot;
|
||||||
|
|
||||||
public FileRequestHandler(Path webRoot) {
|
public FileRequestHandler(Path webRoot) {
|
||||||
this.webRoot = webRoot.normalize();
|
this.webRoot = webRoot.normalize();
|
||||||
|
@ -28,12 +28,16 @@
|
|||||||
import de.bluecolored.bluemap.common.web.http.HttpRequestHandler;
|
import de.bluecolored.bluemap.common.web.http.HttpRequestHandler;
|
||||||
import de.bluecolored.bluemap.common.web.http.HttpResponse;
|
import de.bluecolored.bluemap.common.web.http.HttpResponse;
|
||||||
import de.bluecolored.bluemap.common.web.http.HttpStatusCode;
|
import de.bluecolored.bluemap.common.web.http.HttpStatusCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
public class JsonDataRequestHandler implements HttpRequestHandler {
|
public class JsonDataRequestHandler implements HttpRequestHandler {
|
||||||
|
|
||||||
private final Supplier<String> dataSupplier;
|
private @NonNull Supplier<String> dataSupplier;
|
||||||
|
|
||||||
public JsonDataRequestHandler(Supplier<String> dataSupplier) {
|
public JsonDataRequestHandler(Supplier<String> dataSupplier) {
|
||||||
this.dataSupplier = dataSupplier;
|
this.dataSupplier = dataSupplier;
|
||||||
|
@ -26,14 +26,18 @@
|
|||||||
|
|
||||||
import de.bluecolored.bluemap.common.web.http.*;
|
import de.bluecolored.bluemap.common.web.http.*;
|
||||||
import de.bluecolored.bluemap.core.logger.Logger;
|
import de.bluecolored.bluemap.core.logger.Logger;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
@Getter
|
@Getter @Setter
|
||||||
|
@AllArgsConstructor
|
||||||
public class LoggingRequestHandler implements HttpRequestHandler {
|
public class LoggingRequestHandler implements HttpRequestHandler {
|
||||||
|
|
||||||
private final HttpRequestHandler delegate;
|
private @NonNull HttpRequestHandler delegate;
|
||||||
private final Logger logger;
|
private @NonNull String format;
|
||||||
private final String format;
|
private @NonNull Logger logger;
|
||||||
|
|
||||||
public LoggingRequestHandler(HttpRequestHandler delegate) {
|
public LoggingRequestHandler(HttpRequestHandler delegate) {
|
||||||
this(delegate, Logger.global);
|
this(delegate, Logger.global);
|
||||||
@ -47,12 +51,6 @@ public LoggingRequestHandler(HttpRequestHandler delegate, String format) {
|
|||||||
this(delegate, format, Logger.global);
|
this(delegate, format, Logger.global);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoggingRequestHandler(HttpRequestHandler delegate, String format, Logger logger) {
|
|
||||||
this.delegate = delegate;
|
|
||||||
this.format = format;
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpResponse handle(HttpRequest request) {
|
public HttpResponse handle(HttpRequest request) {
|
||||||
|
|
||||||
|
@ -34,7 +34,10 @@
|
|||||||
import de.bluecolored.bluemap.core.storage.MapStorage;
|
import de.bluecolored.bluemap.core.storage.MapStorage;
|
||||||
import de.bluecolored.bluemap.core.storage.compression.CompressedInputStream;
|
import de.bluecolored.bluemap.core.storage.compression.CompressedInputStream;
|
||||||
import de.bluecolored.bluemap.core.storage.compression.Compression;
|
import de.bluecolored.bluemap.core.storage.compression.Compression;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@ -47,11 +50,12 @@
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@Getter @Setter
|
||||||
public class MapStorageRequestHandler implements HttpRequestHandler {
|
public class MapStorageRequestHandler implements HttpRequestHandler {
|
||||||
|
|
||||||
private static final Pattern TILE_PATTERN = Pattern.compile("tiles/([\\d/]+)/x(-?[\\d/]+)z(-?[\\d/]+).*");
|
private static final Pattern TILE_PATTERN = Pattern.compile("tiles/([\\d/]+)/x(-?[\\d/]+)z(-?[\\d/]+).*");
|
||||||
|
|
||||||
private final MapStorage mapStorage;
|
private @NonNull MapStorage mapStorage;
|
||||||
|
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,16 +34,18 @@
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.intellij.lang.annotations.Language;
|
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.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public class RoutingRequestHandler implements HttpRequestHandler {
|
public class RoutingRequestHandler implements HttpRequestHandler {
|
||||||
|
|
||||||
public final LinkedList<Route> routes;
|
private final Deque<Route> routes;
|
||||||
|
|
||||||
public RoutingRequestHandler() {
|
public RoutingRequestHandler() {
|
||||||
this.routes = new LinkedList<>();
|
this.routes = new ConcurrentLinkedDeque<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(@Language("RegExp") String pattern, HttpRequestHandler handler) {
|
public void register(@Language("RegExp") String pattern, HttpRequestHandler handler) {
|
||||||
|
Loading…
Reference in New Issue
Block a user