mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-15 23:25:32 +01:00
Add fix-edges command and cli-option
This commit is contained in:
parent
d43c7c474f
commit
474c5e27c4
@ -52,6 +52,7 @@
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.map.BmMap;
|
||||
import de.bluecolored.bluemap.core.map.renderstate.TileInfoRegion;
|
||||
import de.bluecolored.bluemap.core.map.renderstate.TileState;
|
||||
import de.bluecolored.bluemap.core.storage.MapStorage;
|
||||
import de.bluecolored.bluemap.core.storage.Storage;
|
||||
import de.bluecolored.bluemap.core.util.Grid;
|
||||
@ -180,6 +181,13 @@ public void init() {
|
||||
this::forceUpdateCommand
|
||||
).build();
|
||||
|
||||
LiteralCommandNode<S> fixEdgesCommand =
|
||||
addRenderArguments(
|
||||
literal("fix-edges")
|
||||
.requires(requirements("bluemap.update.force")),
|
||||
this::fixEdgesCommand
|
||||
).build();
|
||||
|
||||
LiteralCommandNode<S> updateCommand =
|
||||
addRenderArguments(
|
||||
literal("update")
|
||||
@ -235,6 +243,7 @@ public void init() {
|
||||
baseCommand.addChild(freezeCommand);
|
||||
baseCommand.addChild(unfreezeCommand);
|
||||
baseCommand.addChild(forceUpdateCommand);
|
||||
baseCommand.addChild(fixEdgesCommand);
|
||||
baseCommand.addChild(updateCommand);
|
||||
baseCommand.addChild(cancelCommand);
|
||||
baseCommand.addChild(purgeCommand);
|
||||
@ -761,14 +770,18 @@ public int unfreezeCommand(CommandContext<S> context) {
|
||||
}
|
||||
|
||||
public int forceUpdateCommand(CommandContext<S> context) {
|
||||
return updateCommand(context, true);
|
||||
return updateCommand(context, s -> true);
|
||||
}
|
||||
|
||||
public int fixEdgesCommand(CommandContext<S> context) {
|
||||
return updateCommand(context, s -> s == TileState.RENDERED_EDGE);
|
||||
}
|
||||
|
||||
public int updateCommand(CommandContext<S> context) {
|
||||
return updateCommand(context, false);
|
||||
return updateCommand(context, s -> false);
|
||||
}
|
||||
|
||||
public int updateCommand(CommandContext<S> context, boolean force) {
|
||||
public int updateCommand(CommandContext<S> context, Predicate<TileState> force) {
|
||||
final CommandSource source = commandSourceInterface.apply(context.getSource());
|
||||
|
||||
// parse world/map argument
|
||||
@ -795,8 +808,7 @@ public int updateCommand(CommandContext<S> context, boolean force) {
|
||||
mapToRender = null;
|
||||
|
||||
if (worldToRender == null) {
|
||||
source.sendMessage(Text.of(TextColor.RED, "Can't detect a world from this command-source, you'll have to define a world or a map to update!")
|
||||
.setHoverText(Text.of(TextColor.GRAY, "/bluemap " + (force ? "force-update" : "update") + " <world|map>")));
|
||||
source.sendMessage(Text.of(TextColor.RED, "Can't detect a world from this command-source, you'll have to define a world or a map to update!"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -813,8 +825,7 @@ public int updateCommand(CommandContext<S> context, boolean force) {
|
||||
} else {
|
||||
Vector3d position = source.getPosition().orElse(null);
|
||||
if (position == null) {
|
||||
source.sendMessage(Text.of(TextColor.RED, "Can't detect a position from this command-source, you'll have to define x,z coordinates to update with a radius!")
|
||||
.setHoverText(Text.of(TextColor.GRAY, "/bluemap " + (force ? "force-update" : "update") + " <x> <z> " + radius)));
|
||||
source.sendMessage(Text.of(TextColor.RED, "Can't detect a position from this command-source, you'll have to define x,z coordinates to update with a radius!"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -844,7 +855,7 @@ public int updateCommand(CommandContext<S> context, boolean force) {
|
||||
}
|
||||
|
||||
for (BmMap map : maps) {
|
||||
MapUpdateTask updateTask = new MapUpdateTask(map, center, radius, s -> force);
|
||||
MapUpdateTask updateTask = new MapUpdateTask(map, center, radius, force);
|
||||
plugin.getRenderManager().scheduleRenderTask(updateTask);
|
||||
|
||||
source.sendMessage(Text.of(TextColor.GREEN, "Created new Update-Task for map '" + map.getId() + "' ",
|
||||
|
@ -44,6 +44,7 @@
|
||||
import de.bluecolored.bluemap.core.BlueMap;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.map.BmMap;
|
||||
import de.bluecolored.bluemap.core.map.renderstate.TileState;
|
||||
import de.bluecolored.bluemap.core.metrics.Metrics;
|
||||
import de.bluecolored.bluemap.core.storage.MapStorage;
|
||||
import de.bluecolored.bluemap.core.util.FileHelper;
|
||||
@ -71,7 +72,7 @@ public class BlueMapCLI {
|
||||
private String minecraftVersion = null;
|
||||
private Path configFolder = Path.of("config");
|
||||
|
||||
public void renderMaps(BlueMapService blueMap, boolean watch, boolean forceRender, boolean forceGenerateWebapp,
|
||||
public void renderMaps(BlueMapService blueMap, boolean watch, Predicate<TileState> force, boolean forceGenerateWebapp,
|
||||
@Nullable String mapsToRender) throws ConfigurationException, IOException, InterruptedException {
|
||||
|
||||
if (blueMap.getConfig().getWebappConfig().isEnabled())
|
||||
@ -112,7 +113,7 @@ public void renderMaps(BlueMapService blueMap, boolean watch, boolean forceRende
|
||||
//update all maps
|
||||
int totalRegions = 0;
|
||||
for (BmMap map : maps.values()) {
|
||||
MapUpdateTask updateTask = new MapUpdateTask(map, s -> forceRender);
|
||||
MapUpdateTask updateTask = new MapUpdateTask(map, force);
|
||||
renderManager.scheduleRenderTask(updateTask);
|
||||
totalRegions += updateTask.getRegions().size();
|
||||
}
|
||||
@ -355,7 +356,9 @@ public static void main(String[] args) {
|
||||
noActions = false;
|
||||
|
||||
boolean watch = cmd.hasOption("u");
|
||||
boolean force = cmd.hasOption("f");
|
||||
Predicate<TileState> force = t -> false;
|
||||
if (cmd.hasOption("f")) force = t -> true;
|
||||
else if (cmd.hasOption("e")) force = t -> t == TileState.RENDERED_EDGE;
|
||||
boolean generateWebappFiles = cmd.hasOption("g");
|
||||
String mapsToRender = cmd.getOptionValue("m", null);
|
||||
cli.renderMaps(blueMap, watch, force, generateWebappFiles, mapsToRender);
|
||||
@ -453,6 +456,7 @@ private static Options createOptions() {
|
||||
options.addOption("s", "generate-websettings", false, "Updates the settings.json for the web-app");
|
||||
|
||||
options.addOption("r", "render", false, "Renders the maps configured in the 'render.conf' file");
|
||||
options.addOption("e", "fix-edges", false, "Forces rendering the map-edges, instead of only rendering chunks that have been modified since the last render");
|
||||
options.addOption("f", "force-render", false, "Forces rendering everything, instead of only rendering chunks that have been modified since the last render");
|
||||
options.addOption("m", "maps", true, "A comma-separated list of map-id's that should be rendered. Example: 'world,nether'");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user