From ac16c9a2bac79f3e691e7e48591c90cceeb7d525 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 3 Feb 2021 23:08:39 +0100 Subject: [PATCH] Minor upstream merge --- renovate.json | 2 +- .../worldedit/bukkit/BukkitServerInterface.java | 7 +++++++ .../com/sk89q/worldedit/cli/CLIPlatform.java | 7 +++++++ .../sk89q/worldedit/command/BrushCommands.java | 9 +++++++++ .../sk89q/worldedit/command/ToolCommands.java | 11 +++++++++++ .../worldedit/command/WorldEditCommands.java | 6 ++++-- .../worldedit/extension/platform/Platform.java | 17 ++++++++++++++++- .../selector/EllipsoidRegionSelector.java | 2 ++ .../com/sk89q/worldedit/registry/Registry.java | 4 ++++ .../worldedit/util/PropertiesConfiguration.java | 5 +++-- .../src/main/resources/lang/strings.json | 2 ++ .../sk89q/worldedit/fabric/FabricPlatform.java | 7 +++++++ .../sk89q/worldedit/forge/ForgePlatform.java | 7 +++++++ .../sk89q/worldedit/sponge/SpongePlatform.java | 7 +++++++ 14 files changed, 87 insertions(+), 6 deletions(-) diff --git a/renovate.json b/renovate.json index bf4244915..c06f1a6d7 100644 --- a/renovate.json +++ b/renovate.json @@ -2,5 +2,5 @@ "extends": [ "config:base" ], - "ignoreDeps": ["guava", "rhino-runtime", "mockito-core", "antlr4", "antlr4-runtime", "paranamer", "fastutil"] + "ignoreDeps": ["guava", "rhino-runtime", "mockito-core", "antlr4", "antlr4-runtime", "paranamer", "fastutil", "auto-value-annotations", "auto-value"] } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java index 9ffee2d2f..ce2c246e3 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java @@ -213,6 +213,13 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser return plugin.getDescription().getVersion(); } + // FAWE start + @Override + public String getId() { + return "intellectualsites:bukkit"; + } + // FAWE end + @Override public Map getCapabilities() { Map capabilities = new EnumMap<>(Capability.class); diff --git a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIPlatform.java b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIPlatform.java index aebac91f9..5c12cd5d4 100644 --- a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIPlatform.java +++ b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIPlatform.java @@ -145,6 +145,13 @@ class CLIPlatform extends AbstractPlatform { return app.getInternalVersion(); } + // FAWE start + @Override + public String getId() { + return "intellectualsites:cli"; + } + // FAWE end + @Override public Map getCapabilities() { Map capabilities = new EnumMap<>(Capability.class); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 0e173d269..940ca35ed 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -104,8 +104,11 @@ import com.sk89q.worldedit.regions.factory.RegionFactory; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.TreeGenerator; +import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; +import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; +import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -143,6 +146,10 @@ public class BrushCommands { private final WorldEdit worldEdit; + private static final Component UNBIND_COMMAND_COMPONENT = TextComponent.builder("/brush unbind", TextColor.AQUA) + .clickEvent(ClickEvent.suggestCommand("/brush unbind")) + .build(); + /** * Create a new instance. * @@ -1034,6 +1041,7 @@ public class BrushCommands { player.print( Caption.of("fawe.worldedit.brush.brush.equipped", arguments.get().split(" ")[1])); + ToolCommands.sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT); } return settings; } @@ -1267,5 +1275,6 @@ public class BrushCommands { tool.setBrush(new OperationFactoryBrush(factory, shape, session), permission); player.printInfo(TranslatableComponent.of("worldedit.brush.operation.equip", TextComponent.of(factory.toString()))); + ToolCommands.sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java index 8cbeab989..e2eab7d4b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java @@ -53,6 +53,8 @@ import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; +import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; +import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.world.block.BlockStateHolder; import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManagerService; @@ -70,6 +72,10 @@ import java.util.stream.Collectors; @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class ToolCommands { + private static final Component UNBIND_COMMAND_COMPONENT = TextComponent.builder("/tool unbind", TextColor.AQUA) + .clickEvent(ClickEvent.suggestCommand("/tool unbind")) + .build(); + public static void register(CommandRegistrationHandler registration, CommandManager commandManager, CommandManagerService commandManagerService, @@ -142,11 +148,16 @@ public class ToolCommands { player.printInfo(TranslatableComponent.of(isBrush ? "worldedit.brush.none.equip" : "worldedit.tool.none.equip")); } + static void sendUnbindInstruction(Player sender, Component commandComponent) { + sender.printDebug(TranslatableComponent.of("worldedit.tool.unbind-instruction", commandComponent)); + } + private static void setTool(Player player, LocalSession session, Tool tool, String translationKey) throws InvalidToolBindException { BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); session.setTool(itemStack.getType(), tool); player.printInfo(TranslatableComponent.of(translationKey, itemStack.getRichName())); + sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT); } private final WorldEdit we; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index b84c814a6..5da3db6ef 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -40,6 +40,7 @@ import com.sk89q.worldedit.util.formatting.component.TextComponentProducer; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; +import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; @@ -101,7 +102,8 @@ public class WorldEditCommands { for (Platform platform : pm.getPlatforms()) { producer.append( TextComponent.of("* ", TextColor.GRAY) - .append(TextComponent.of(platform.getPlatformName())) + .append(TextComponent.of(platform.getPlatformName()) + .hoverEvent(HoverEvent.showText(TextComponent.of(platform.getId())))) .append(TextComponent.of("(" + platform.getPlatformVersion() + ")")) ).newline(); } @@ -113,7 +115,7 @@ public class WorldEditCommands { producer.append( TextComponent.of(capability.name(), TextColor.GRAY) .append(TextComponent.of(": ") - .append(TextComponent.of(platform != null ? platform.getPlatformName() : "NONE"))) + .append(TextComponent.of(platform != null ? platform.getPlatformName() : "none"))) ).newline(); } actor.print(new MessageBox("Capabilities", producer, TextColor.GRAY).create()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java index 69e01bebb..709492a97 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java @@ -21,6 +21,8 @@ package com.sk89q.worldedit.extension.platform; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility; +import com.sk89q.worldedit.registry.Keyed; import com.sk89q.worldedit.util.SideEffect; import com.sk89q.worldedit.util.io.ResourceLoader; import com.sk89q.worldedit.world.DataFixer; @@ -29,6 +31,7 @@ import com.sk89q.worldedit.world.registry.Registries; import org.enginehub.piston.CommandManager; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import javax.annotation.Nullable; @@ -39,7 +42,7 @@ import javax.annotation.Nullable; *

It is strongly recommended that implementations extend from * {@link AbstractPlatform}.

*/ -public interface Platform { +public interface Platform extends Keyed { /** * Return the resource loader. @@ -176,6 +179,18 @@ public interface Platform { */ String getPlatformVersion(); + /** + * {@inheritDoc} + * @return an id + * @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility} + * for details + */ + @NonAbstractForCompatibility(delegateName = "getPlatformName", delegateParams = {}) + @Override + default String getId() { + return "legacy:" + getPlatformName().toLowerCase(Locale.ROOT).replaceAll("[^a-z_.-]", "_"); + } + /** * Get a map of advertised capabilities of this platform, where each key * in the given map is a supported capability and the respective value diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java index 93b0cf8b2..8d7a87a14 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java @@ -79,6 +79,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion { final EllipsoidRegionSelector ellipsoidRegionSelector = (EllipsoidRegionSelector) oldSelector; region = new EllipsoidRegion(ellipsoidRegionSelector.getIncompleteRegion()); + started = ellipsoidRegionSelector.started; } else { Region oldRegion; try { @@ -93,6 +94,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion { BlockVector3 center = pos1.add(pos2).divide(2).floor(); region.setCenter(center); region.setRadius(pos2.subtract(center).toVector3()); + started = true; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java index ff2527dbb..b4c4a800f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java @@ -62,6 +62,10 @@ public class Registry implements Iterable { return value; } + public void clear() { + this.map.clear(); + } + public Set keySet() { return Collections.unmodifiableSet(this.map.keySet()); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java index 82130682b..5a4b4cadb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java @@ -39,6 +39,7 @@ import java.io.OutputStream; import java.nio.file.Path; import java.util.Arrays; import java.util.HashSet; +import java.util.Locale; import java.util.Properties; import java.util.Set; @@ -107,7 +108,7 @@ public class PropertiesConfiguration extends LocalConfiguration { logFile = getString("log-file", logFile); logFormat = getString("log-format", logFormat); registerHelp = getBool("register-help", registerHelp); - wandItem = getString("wand-item", wandItem); + wandItem = getString("wand-item", wandItem).toLowerCase(Locale.ROOT); try { wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId(); } catch (Throwable ignored) { @@ -117,7 +118,7 @@ public class PropertiesConfiguration extends LocalConfiguration { useInventory = getBool("use-inventory", useInventory); useInventoryOverride = getBool("use-inventory-override", useInventoryOverride); useInventoryCreativeOverride = getBool("use-inventory-creative-override", useInventoryCreativeOverride); - navigationWand = getString("nav-wand-item", navigationWand); + navigationWand = getString("nav-wand-item", navigationWand).toLowerCase(Locale.ROOT); try { navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).getId(); } catch (Throwable ignored) { diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index 586c1dca8..b778c31ed 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -447,6 +447,8 @@ "worldedit.tool.lrbuild.set": "Left-click set to {0}; right-click set to {1}.", "worldedit.tool.stack.equip": "Stack tool bound to {0}.", + "worldedit.tool.unbind-instruction": "Run {0} while holding the item to unbind it.", + "worldedit.tool.superpickaxe.mode.single": "Mode is now single. Left click with a pickaxe. // to disable.", "worldedit.tool.superpickaxe.mode.area": "Mode is now area. Left click with a pickaxe. // to disable.", "worldedit.tool.superpickaxe.mode.recursive": "Mode is now recursive. Left click with a pickaxe. // to disable.", diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlatform.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlatform.java index 299f1596a..c466cba48 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlatform.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlatform.java @@ -189,6 +189,13 @@ class FabricPlatform extends AbstractPlatform implements MultiUserPlatform { return mod.getInternalVersion(); } + // FAWE start + @Override + public String getId() { + return "intellectualsites:fabric"; + } + // FAWE end + @Override public Map getCapabilities() { Map capabilities = new EnumMap<>(Capability.class); diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java index 051ff0d33..dd55d77d2 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java @@ -195,6 +195,13 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform { return mod.getInternalVersion(); } + // FAWE start + @Override + public String getId() { + return "intellectualsites:forge"; + } + // FAWE end + @Override public Map getCapabilities() { Map capabilities = new EnumMap<>(Capability.class); diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlatform.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlatform.java index a90170c77..370fddbe9 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlatform.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlatform.java @@ -184,6 +184,13 @@ class SpongePlatform extends AbstractPlatform implements MultiUserPlatform { return mod.getInternalVersion(); } + // FAWE start + @Override + public String getId() { + return "intellectualsites:sponge"; + } + // FAWE end + @Override public Map getCapabilities() { Map capabilities = new EnumMap<>(Capability.class);