Merge branch 'mc/1.13'
This commit is contained in:
commit
8b4e6a3a32
|
@ -150,6 +150,14 @@ public class BukkitPlugin extends JavaPlugin implements ServerInterface {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorldName(UUID worldUUID) {
|
||||
World world = getServer().getWorld(worldUUID);
|
||||
if (world != null) return world.getName();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private UUID getUUIDForWorldSync (File worldFolder) throws IOException {
|
||||
for (World world : getServer().getWorlds()) {
|
||||
if (worldFolder.equals(world.getWorldFolder().getCanonicalFile())) return world.getUID();
|
||||
|
|
|
@ -3,7 +3,6 @@ description: "A 3d-map of your Minecraft worlds view-able in your browser using
|
|||
main: de.bluecolored.bluemap.bukkit.BukkitPlugin
|
||||
version: ${version}
|
||||
author: "Blue (TBlueF / Lukas Rieger)"
|
||||
authors: [Blue (TBlueF / Lukas Rieger)]
|
||||
website: "https://github.com/BlueMap-Minecraft"
|
||||
commands:
|
||||
permissions:
|
||||
|
@ -15,6 +14,7 @@ permissions:
|
|||
bluemap.resume: true
|
||||
bluemap.render: true
|
||||
bluemap.debug: true
|
||||
bluemap.marker: true
|
||||
default: op
|
||||
bluemap.status:
|
||||
default: op
|
||||
|
@ -27,4 +27,6 @@ permissions:
|
|||
bluemap.render:
|
||||
default: op
|
||||
bluemap.debug:
|
||||
default: op
|
||||
bluemap.marker:
|
||||
default: op
|
|
@ -189,7 +189,7 @@ public class Plugin {
|
|||
World world = worlds.get(worldUUID);
|
||||
if (world == null) {
|
||||
try {
|
||||
world = MCAWorld.load(worldFolder.toPath(), worldUUID, configManager.getBlockIdConfig(), configManager.getBlockPropertiesConfig(), configManager.getBiomeConfig());
|
||||
world = MCAWorld.load(worldFolder.toPath(), worldUUID, configManager.getBlockIdConfig(), configManager.getBlockPropertiesConfig(), configManager.getBiomeConfig(), serverInterface.getWorldName(worldUUID));
|
||||
worlds.put(worldUUID, world);
|
||||
} catch (IOException e) {
|
||||
Logger.global.logError("Failed to load map '" + id + "': Failed to read level.dat", e);
|
||||
|
|
|
@ -27,6 +27,7 @@ package de.bluecolored.bluemap.common.plugin.commands;
|
|||
import java.util.Collection;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
||||
|
@ -34,7 +35,7 @@ import com.mojang.brigadier.suggestion.Suggestions;
|
|||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
|
||||
public abstract class AbstractSuggestionProvider<S> implements SuggestionProvider<S> {
|
||||
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Suggestions> getSuggestions(CommandContext<S> context, SuggestionsBuilder builder) throws CommandSyntaxException {
|
||||
Collection<String> possibleValues = getPossibleValues();
|
||||
|
@ -43,7 +44,7 @@ public abstract class AbstractSuggestionProvider<S> implements SuggestionProvide
|
|||
String remaining = builder.getRemaining().toLowerCase();
|
||||
for (String str : possibleValues) {
|
||||
if (str.toLowerCase().startsWith(remaining)) {
|
||||
builder.suggest(str);
|
||||
builder.suggest(str = StringArgumentType.escapeIfRequired(str));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,11 @@ import com.mojang.brigadier.context.CommandContext;
|
|||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
|
||||
import de.bluecolored.bluemap.api.BlueMapAPI;
|
||||
import de.bluecolored.bluemap.api.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.marker.MarkerAPI;
|
||||
import de.bluecolored.bluemap.api.marker.MarkerSet;
|
||||
import de.bluecolored.bluemap.api.marker.POIMarker;
|
||||
import de.bluecolored.bluemap.common.MapType;
|
||||
import de.bluecolored.bluemap.common.RenderTask;
|
||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
||||
|
@ -59,6 +64,8 @@ import de.bluecolored.bluemap.core.world.Block;
|
|||
import de.bluecolored.bluemap.core.world.World;
|
||||
|
||||
public class Commands<S> {
|
||||
|
||||
public static final String DEFAULT_MARKER_SET_ID = "markers";
|
||||
|
||||
private final Plugin plugin;
|
||||
private final CommandDispatcher<S> dispatcher;
|
||||
|
@ -95,15 +102,11 @@ public class Commands<S> {
|
|||
.requires(requirements("bluemap.debug"))
|
||||
.executes(this::debugCommand)
|
||||
|
||||
.then(argument("world", StringArgumentType.word()).suggests(new WorldSuggestionProvider<>(plugin))
|
||||
.then(argument("world", StringArgumentType.string()).suggests(new WorldSuggestionProvider<>(plugin))
|
||||
.then(argument("x", DoubleArgumentType.doubleArg())
|
||||
.then(argument("y", DoubleArgumentType.doubleArg())
|
||||
.then(argument("z", DoubleArgumentType.doubleArg())
|
||||
.executes(this::debugCommand)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.executes(this::debugCommand)))))
|
||||
.build();
|
||||
|
||||
LiteralCommandNode<S> pauseCommand =
|
||||
|
@ -124,45 +127,74 @@ public class Commands<S> {
|
|||
.executes(this::renderCommand) // /bluemap render
|
||||
|
||||
.then(argument("radius", IntegerArgumentType.integer())
|
||||
.executes(this::renderCommand) // /bluemap render <radius>
|
||||
)
|
||||
.executes(this::renderCommand)) // /bluemap render <radius>
|
||||
|
||||
.then(argument("x", DoubleArgumentType.doubleArg())
|
||||
.then(argument("z", DoubleArgumentType.doubleArg())
|
||||
.then(argument("radius", IntegerArgumentType.integer())
|
||||
.executes(this::renderCommand) // /bluemap render <x> <z> <radius>
|
||||
)
|
||||
)
|
||||
)
|
||||
.executes(this::renderCommand)))) // /bluemap render <x> <z> <radius>
|
||||
|
||||
.then(argument("world|map", StringArgumentType.word()).suggests(new WorldOrMapSuggestionProvider<>(plugin))
|
||||
.then(argument("world|map", StringArgumentType.string()).suggests(new WorldOrMapSuggestionProvider<>(plugin))
|
||||
.executes(this::renderCommand) // /bluemap render <world|map>
|
||||
|
||||
.then(argument("x", DoubleArgumentType.doubleArg())
|
||||
.then(argument("z", DoubleArgumentType.doubleArg())
|
||||
.then(argument("radius", IntegerArgumentType.integer())
|
||||
.executes(this::renderCommand) // /bluemap render <world|map> <x> <z> <radius>
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
.executes(this::renderCommand))))) // /bluemap render <world|map> <x> <z> <radius>
|
||||
.build();
|
||||
|
||||
LiteralCommandNode<S> prioRenderCommand =
|
||||
literal("prioritize")
|
||||
.requires(requirements("bluemap.render"))
|
||||
.then(argument("uuid", StringArgumentType.word())
|
||||
.executes(this::prioritizeRenderTaskCommand)
|
||||
)
|
||||
.then(argument("uuid", StringArgumentType.string())
|
||||
.executes(this::prioritizeRenderTaskCommand))
|
||||
.build();
|
||||
|
||||
LiteralCommandNode<S> cancelRenderCommand =
|
||||
literal("cancel")
|
||||
.requires(requirements("bluemap.render"))
|
||||
.then(argument("uuid", StringArgumentType.word())
|
||||
.executes(this::cancelRenderTaskCommand)
|
||||
)
|
||||
.then(argument("uuid", StringArgumentType.string())
|
||||
.executes(this::cancelRenderTaskCommand))
|
||||
.build();
|
||||
|
||||
LiteralCommandNode<S> worldsCommand =
|
||||
literal("worlds")
|
||||
.requires(requirements("bluemap.status"))
|
||||
.executes(this::worldsCommand)
|
||||
.build();
|
||||
|
||||
LiteralCommandNode<S> mapsCommand =
|
||||
literal("maps")
|
||||
.requires(requirements("bluemap.status"))
|
||||
.executes(this::mapsCommand)
|
||||
.build();
|
||||
|
||||
LiteralCommandNode<S> markerCommand =
|
||||
literal("marker")
|
||||
.requires(requirements("bluemap.marker"))
|
||||
.build();
|
||||
|
||||
LiteralCommandNode<S> createMarkerCommand =
|
||||
literal("create")
|
||||
.requires(requirements("bluemap.marker"))
|
||||
.then(argument("id", StringArgumentType.word())
|
||||
.then(argument("map", StringArgumentType.string()).suggests(new MapSuggestionProvider<>(plugin))
|
||||
|
||||
.then(argument("label", StringArgumentType.string())
|
||||
.executes(this::createMarkerCommand))
|
||||
|
||||
.then(argument("x", DoubleArgumentType.doubleArg())
|
||||
.then(argument("y", DoubleArgumentType.doubleArg())
|
||||
.then(argument("z", DoubleArgumentType.doubleArg())
|
||||
.then(argument("label", StringArgumentType.string())
|
||||
.executes(this::createMarkerCommand)))))))
|
||||
.build();
|
||||
|
||||
LiteralCommandNode<S> removeMarkerCommand =
|
||||
literal("remove")
|
||||
.requires(requirements("bluemap.marker"))
|
||||
.then(argument("id", StringArgumentType.word()).suggests(MarkerIdSuggestionProvider.getInstance())
|
||||
.executes(this::removeMarkerCommand))
|
||||
.build();
|
||||
|
||||
// command tree
|
||||
|
@ -174,6 +206,11 @@ public class Commands<S> {
|
|||
baseCommand.addChild(renderCommand);
|
||||
renderCommand.addChild(prioRenderCommand);
|
||||
renderCommand.addChild(cancelRenderCommand);
|
||||
baseCommand.addChild(worldsCommand);
|
||||
baseCommand.addChild(mapsCommand);
|
||||
baseCommand.addChild(markerCommand);
|
||||
markerCommand.addChild(createMarkerCommand);
|
||||
markerCommand.addChild(removeMarkerCommand);
|
||||
}
|
||||
|
||||
private Predicate<S> requirements(String permission){
|
||||
|
@ -454,4 +491,135 @@ public class Commands<S> {
|
|||
source.sendMessage(Text.of(TextColor.RED, "There is no render-task with this UUID: " + uuidString));
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int worldsCommand(CommandContext<S> context) {
|
||||
CommandSource source = commandSourceInterface.apply(context.getSource());
|
||||
|
||||
source.sendMessage(Text.of(TextColor.BLUE, "Worlds loaded by BlueMap:"));
|
||||
for (World world : plugin.getWorlds()) {
|
||||
source.sendMessage(Text.of(TextColor.GRAY, " - ", TextColor.WHITE, world.getName()).setHoverText(Text.of(TextColor.GRAY, world.getUUID())));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int mapsCommand(CommandContext<S> context) {
|
||||
CommandSource source = commandSourceInterface.apply(context.getSource());
|
||||
|
||||
source.sendMessage(Text.of(TextColor.BLUE, "Maps loaded by BlueMap:"));
|
||||
for (MapType map : plugin.getMapTypes()) {
|
||||
source.sendMessage(Text.of(TextColor.GRAY, " - ", TextColor.WHITE, map.getId(), TextColor.GRAY, " (" + map.getName() + ")").setHoverText(Text.of(TextColor.WHITE, "World: ", TextColor.GRAY, map.getWorld().getName())));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int createMarkerCommand(CommandContext<S> context) {
|
||||
CommandSource source = commandSourceInterface.apply(context.getSource());
|
||||
|
||||
String markerId = context.getArgument("id", String.class);
|
||||
String markerLabel = context.getArgument("label", String.class)
|
||||
.replace("<", "<")
|
||||
.replace(">", ">"); //no html via commands
|
||||
|
||||
// parse world/map argument
|
||||
String mapString = context.getArgument("map", String.class);
|
||||
MapType map = parseMap(mapString).orElse(null);
|
||||
|
||||
if (map == null) {
|
||||
source.sendMessage(Text.of(TextColor.RED, "There is no ", helper.mapHelperHover(), " with this name: ", TextColor.WHITE, mapString));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// parse position
|
||||
Optional<Double> x = getOptionalArgument(context, "x", Double.class);
|
||||
Optional<Double> y = getOptionalArgument(context, "y", Double.class);
|
||||
Optional<Double> z = getOptionalArgument(context, "z", Double.class);
|
||||
|
||||
Vector3d position;
|
||||
|
||||
if (x.isPresent() && y.isPresent() && z.isPresent()) {
|
||||
position = new Vector3d(x.get(), y.get(), z.get());
|
||||
} else {
|
||||
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 the x,y,z coordinates for the marker!").setHoverText(Text.of(TextColor.GRAY, "/bluemap marker create " + markerId + " " + "[world|map] <x> <y> <z> <label>")));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// get api
|
||||
BlueMapAPI api = BlueMapAPI.getInstance().orElse(null);
|
||||
if (api == null) {
|
||||
source.sendMessage(Text.of(TextColor.RED, "MarkerAPI is not available, try ", TextColor.GRAY, "/bluemap reload"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// resolve api-map
|
||||
Optional<BlueMapMap> apiMap = api.getMap(map.getId());
|
||||
if (!apiMap.isPresent()) {
|
||||
source.sendMessage(Text.of(TextColor.RED, "Failed to get map from API, try ", TextColor.GRAY, "/bluemap reload"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// add marker
|
||||
try {
|
||||
MarkerAPI markerApi = api.getMarkerAPI();
|
||||
|
||||
MarkerSet set = markerApi.getMarkerSet(DEFAULT_MARKER_SET_ID).orElse(null);
|
||||
if (set == null) {
|
||||
set = markerApi.createMarkerSet(DEFAULT_MARKER_SET_ID);
|
||||
set.setLabel("Markers");
|
||||
}
|
||||
|
||||
if (set.getMarker(markerId).isPresent()) {
|
||||
source.sendMessage(Text.of(TextColor.RED, "There already is a marker with this id: ", TextColor.WHITE, markerId));
|
||||
return 0;
|
||||
}
|
||||
|
||||
POIMarker marker = set.createPOIMarker(markerId, apiMap.get(), position);
|
||||
marker.setLabel(markerLabel);
|
||||
|
||||
markerApi.save();
|
||||
MarkerIdSuggestionProvider.getInstance().forceUpdate();
|
||||
} catch (IOException e) {
|
||||
source.sendMessage(Text.of(TextColor.RED, "There was an error trying to add the marker, please check the console for details!"));
|
||||
Logger.global.logError("Exception trying to add a marker!", e);
|
||||
}
|
||||
|
||||
source.sendMessage(Text.of(TextColor.GREEN, "Marker added!"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int removeMarkerCommand(CommandContext<S> context) {
|
||||
CommandSource source = commandSourceInterface.apply(context.getSource());
|
||||
|
||||
String markerId = context.getArgument("id", String.class);
|
||||
|
||||
BlueMapAPI api = BlueMapAPI.getInstance().orElse(null);
|
||||
if (api == null) {
|
||||
source.sendMessage(Text.of(TextColor.RED, "MarkerAPI is not available, try ", TextColor.GRAY, "/bluemap reload"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
MarkerAPI markerApi = api.getMarkerAPI();
|
||||
|
||||
MarkerSet set = markerApi.createMarkerSet("markers");
|
||||
if (!set.removeMarker(markerId)) {
|
||||
source.sendMessage(Text.of(TextColor.RED, "There is no marker with this id: ", TextColor.WHITE, markerId));
|
||||
}
|
||||
|
||||
markerApi.save();
|
||||
MarkerIdSuggestionProvider.getInstance().forceUpdate();
|
||||
} catch (IOException e) {
|
||||
source.sendMessage(Text.of(TextColor.RED, "There was an error trying to remove the marker, please check the console for details!"));
|
||||
Logger.global.logError("Exception trying to remove a marker!", e);
|
||||
}
|
||||
|
||||
source.sendMessage(Text.of(TextColor.GREEN, "Marker removed!"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package de.bluecolored.bluemap.common.plugin.commands;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
|
||||
import de.bluecolored.bluemap.api.BlueMapAPI;
|
||||
import de.bluecolored.bluemap.api.marker.Marker;
|
||||
import de.bluecolored.bluemap.api.marker.MarkerAPI;
|
||||
import de.bluecolored.bluemap.api.marker.MarkerSet;
|
||||
import de.bluecolored.bluemap.api.marker.POIMarker;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
|
||||
public class MarkerIdSuggestionProvider<S> extends AbstractSuggestionProvider<S> {
|
||||
|
||||
private static MarkerIdSuggestionProvider<?> instance;
|
||||
|
||||
private MarkerAPI markerApi;
|
||||
private long lastUpdate = -1;
|
||||
|
||||
private MarkerIdSuggestionProvider() {}
|
||||
|
||||
@Override
|
||||
public Collection<String> getPossibleValues() {
|
||||
Collection<String> values = new HashSet<>();
|
||||
|
||||
if (markerApi == null || lastUpdate + 1000 * 60 < System.currentTimeMillis()) { // only (re)load marker-values max every minute
|
||||
lastUpdate = System.currentTimeMillis();
|
||||
|
||||
Optional<BlueMapAPI> api = BlueMapAPI.getInstance();
|
||||
if (!api.isPresent()) return values;
|
||||
|
||||
try {
|
||||
markerApi = api.get().getMarkerAPI();
|
||||
} catch (IOException e) {
|
||||
Logger.global.noFloodError("0FEz5tm345rf", "Failed to load MarkerAPI!", e);
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
MarkerSet set = markerApi.getMarkerSet(Commands.DEFAULT_MARKER_SET_ID).orElse(null);
|
||||
if (set != null) {
|
||||
for (Marker marker : set.getMarkers()) {
|
||||
if (marker instanceof POIMarker) {
|
||||
values.add(marker.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
public void forceUpdate() {
|
||||
lastUpdate = -1;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <S> MarkerIdSuggestionProvider<S> getInstance(){
|
||||
if (instance == null) {
|
||||
instance = new MarkerIdSuggestionProvider<>();
|
||||
}
|
||||
|
||||
return (MarkerIdSuggestionProvider<S>) instance;
|
||||
}
|
||||
|
||||
}
|
|
@ -50,6 +50,17 @@ public interface ServerInterface {
|
|||
*/
|
||||
UUID getUUIDForWorld(File worldFolder) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the name of the world with that UUID, the name is used in commands and should therefore be unique.<br>
|
||||
* A return-value of <code>null</code> makes bluemap load the world-name from the level.dat and dimension-folder.
|
||||
*
|
||||
* @param worldUUID the uuid of the world
|
||||
* @return the worlds name
|
||||
*/
|
||||
default String getWorldName(UUID worldUUID) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Folder containing the configurations for the plugin
|
||||
*/
|
||||
|
|
|
@ -377,11 +377,18 @@ public class MCAWorld implements World {
|
|||
private Path getMCAFilePath(Vector2i region) {
|
||||
return getRegionFolder().resolve(MCAUtil.createNameFromRegionLocation(region.getX(), region.getY()));
|
||||
}
|
||||
|
||||
|
||||
public static MCAWorld load(Path worldFolder, UUID uuid, BlockIdMapper blockIdMapper, BlockPropertiesMapper blockPropertiesMapper, BiomeMapper biomeIdMapper) throws IOException {
|
||||
return load(worldFolder, uuid, blockIdMapper, blockPropertiesMapper, biomeIdMapper, null);
|
||||
}
|
||||
|
||||
public static MCAWorld load(Path worldFolder, UUID uuid, BlockIdMapper blockIdMapper, BlockPropertiesMapper blockPropertiesMapper, BiomeMapper biomeIdMapper, String name) throws IOException {
|
||||
try {
|
||||
boolean subDimension = false;
|
||||
|
||||
File levelFile = new File(worldFolder.toFile(), "level.dat");
|
||||
if (!levelFile.exists()) {
|
||||
subDimension = true;
|
||||
levelFile = new File(worldFolder.toFile().getParentFile(), "level.dat");
|
||||
if (!levelFile.exists()) {
|
||||
throw new FileNotFoundException("Could not find a level.dat file for this world!");
|
||||
|
@ -391,7 +398,11 @@ public class MCAWorld implements World {
|
|||
CompoundTag level = (CompoundTag) NBTUtil.readTag(levelFile);
|
||||
CompoundTag levelData = level.getCompoundTag("Data");
|
||||
|
||||
String name = levelData.getString("LevelName");
|
||||
if (name == null) {
|
||||
name = levelData.getString("LevelName");
|
||||
if (subDimension) name += "/" + worldFolder.toFile().getName();
|
||||
}
|
||||
|
||||
int worldHeight = 255;
|
||||
int seaLevel = 63;
|
||||
Vector3i spawnPoint = new Vector3i(
|
||||
|
|
|
@ -24,15 +24,28 @@
|
|||
*/
|
||||
package de.bluecolored.bluemap.forge;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.flowpowered.math.vector.Vector3d;
|
||||
|
||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
||||
import de.bluecolored.bluemap.common.plugin.serverinterface.CommandSource;
|
||||
import de.bluecolored.bluemap.common.plugin.text.Text;
|
||||
import de.bluecolored.bluemap.core.world.World;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
public class ForgeCommandSource implements CommandSource {
|
||||
|
||||
private ForgeMod mod;
|
||||
private Plugin plugin;
|
||||
private net.minecraft.command.CommandSource delegate;
|
||||
|
||||
public ForgeCommandSource(net.minecraft.command.CommandSource delegate) {
|
||||
public ForgeCommandSource(ForgeMod mod, Plugin plugin, net.minecraft.command.CommandSource delegate) {
|
||||
this.mod = mod;
|
||||
this.plugin = plugin;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
|
@ -46,4 +59,26 @@ public class ForgeCommandSource implements CommandSource {
|
|||
return delegate.hasPermissionLevel(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Vector3d> getPosition() {
|
||||
Vec3d pos = delegate.getPos();
|
||||
if (pos != null) {
|
||||
return Optional.of(new Vector3d(pos.x, pos.y, pos.z));
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<World> getWorld() {
|
||||
try {
|
||||
ServerWorld world = delegate.getWorld();
|
||||
if (world != null) {
|
||||
return Optional.ofNullable(plugin.getWorld(mod.getUUIDForWorld(world)));
|
||||
}
|
||||
} catch (IOException ignore) {}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public class ForgeMod implements ServerInterface {
|
|||
}
|
||||
|
||||
//register commands
|
||||
this.commands = new Commands<>(bluemap, event.getCommandDispatcher(), ForgeCommandSource::new);
|
||||
this.commands = new Commands<>(bluemap, event.getCommandDispatcher(), forgeSource -> new ForgeCommandSource(this, bluemap, forgeSource));
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
|
|
|
@ -27,6 +27,7 @@ package de.bluecolored.bluemap.sponge;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -39,6 +40,7 @@ import org.spongepowered.api.event.game.GameReloadEvent;
|
|||
import org.spongepowered.api.event.game.state.GameStartingServerEvent;
|
||||
import org.spongepowered.api.event.game.state.GameStoppingEvent;
|
||||
import org.spongepowered.api.scheduler.SpongeExecutorService;
|
||||
import org.spongepowered.api.world.World;
|
||||
import org.spongepowered.api.world.storage.WorldProperties;
|
||||
|
||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
||||
|
@ -145,6 +147,14 @@ public class SpongePlugin implements ServerInterface {
|
|||
throw new IOException("Failed to read level_sponge.dat", t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorldName(UUID worldUUID) {
|
||||
Optional<World> world = Sponge.getServer().getWorld(worldUUID);
|
||||
if (world.isPresent()) return world.get().getName();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getConfigFolder() {
|
||||
|
|
Loading…
Reference in New Issue