mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-02-03 22:21:28 +01:00
Fix world render argument parsing and catch an uncaught error
This commit is contained in:
parent
f570c2088e
commit
8c90b3a38e
@ -33,6 +33,7 @@
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
@ -44,6 +45,7 @@
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.mca.extensions.BlockStateExtension;
|
||||
@ -196,7 +198,7 @@ public Chunk getChunk(Vector2i chunkPos) throws IOException, ChunkNotGeneratedEx
|
||||
Chunk chunk = CHUNK_CACHE.get(new WorldChunkHash(this, chunkPos), () -> this.loadChunk(chunkPos));
|
||||
if (!chunk.isGenerated()) throw new ChunkNotGeneratedException();
|
||||
return chunk;
|
||||
} catch (ExecutionException e) {
|
||||
} catch (UncheckedExecutionException | ExecutionException e) {
|
||||
Throwable cause = e.getCause();
|
||||
|
||||
if (cause instanceof IOException) {
|
||||
@ -261,6 +263,8 @@ public boolean isChunkGenerated(Vector2i chunkPos) {
|
||||
public Collection<Vector2i> getChunkList(long modifiedSinceMillis){
|
||||
List<Vector2i> chunks = new ArrayList<>(10000);
|
||||
|
||||
if (!getRegionFolder().toFile().isDirectory()) return Collections.emptyList();
|
||||
|
||||
for (File file : getRegionFolder().toFile().listFiles()) {
|
||||
if (!file.getName().endsWith(".mca")) continue;
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
import org.spongepowered.api.text.format.TextColors;
|
||||
import org.spongepowered.api.world.Locatable;
|
||||
import org.spongepowered.api.world.Location;
|
||||
import org.spongepowered.api.world.storage.WorldProperties;
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
@ -150,11 +151,14 @@ public CommandSpec createRenderCommand() {
|
||||
.child(createRemoveTaskCommand(), "remove")
|
||||
.arguments(GenericArguments.optional(GenericArguments.world(Text.of("world"))))
|
||||
.executor((source, args) -> {
|
||||
org.spongepowered.api.world.World spongeWorld = args.<org.spongepowered.api.world.World>getOne("world").orElse(null);
|
||||
WorldProperties spongeWorld = args.<WorldProperties>getOne("world").orElse(null);
|
||||
|
||||
if (spongeWorld == null && source instanceof Locatable) {
|
||||
Location<org.spongepowered.api.world.World> loc = ((Locatable) source).getLocation();
|
||||
spongeWorld = loc.getExtent();
|
||||
} else {
|
||||
spongeWorld = loc.getExtent().getProperties();
|
||||
}
|
||||
|
||||
if (spongeWorld == null){
|
||||
source.sendMessage(Text.of(TextColors.RED, "You have to define a world to render!"));
|
||||
return CommandResult.empty();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user