From e2e903ca5ea58e592d2fae3a7230ae35301b7e9b Mon Sep 17 00:00:00 2001 From: wizjany Date: Thu, 9 May 2019 11:14:10 -0400 Subject: [PATCH] Pass service to brush sub-commands too. --- .../com/sk89q/worldedit/command/ApplyBrushCommands.java | 7 +++---- .../com/sk89q/worldedit/command/PaintBrushCommands.java | 7 +++---- .../extension/platform/PlatformCommandManager.java | 5 ++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java index f9ceadd3e..25c1dbdc1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java @@ -39,8 +39,8 @@ import com.sk89q.worldedit.internal.command.CommandRegistrationHandler; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import org.enginehub.piston.CommandManager; +import org.enginehub.piston.CommandManagerService; import org.enginehub.piston.CommandParameters; -import org.enginehub.piston.DefaultCommandManagerService; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; @@ -66,13 +66,12 @@ public class ApplyBrushCommands { .ofTypes(ImmutableList.of(Key.of(double.class))) .build(); - public static void register(CommandManager commandManager, CommandRegistrationHandler registration) { + public static void register(CommandManagerService service, CommandManager commandManager, CommandRegistrationHandler registration) { commandManager.register("apply", builder -> { builder.description(TextComponent.of("Apply brush, apply a function to every block")); builder.action(org.enginehub.piston.Command.Action.NULL_ACTION); - CommandManager manager = DefaultCommandManagerService.getInstance() - .newCommandManager(); + CommandManager manager = service.newCommandManager(); registration.register( manager, ApplyBrushCommandsRegistration.builder(), diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java index cc53ec5b8..e3c92236b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java @@ -39,8 +39,8 @@ import com.sk89q.worldedit.internal.command.CommandRegistrationHandler; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import org.enginehub.piston.CommandManager; +import org.enginehub.piston.CommandManagerService; import org.enginehub.piston.CommandParameters; -import org.enginehub.piston.DefaultCommandManagerService; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; @@ -71,13 +71,12 @@ public class PaintBrushCommands { .ofTypes(ImmutableList.of(Key.of(double.class))) .build(); - public static void register(CommandManager commandManager, CommandRegistrationHandler registration) { + public static void register(CommandManagerService service, CommandManager commandManager, CommandRegistrationHandler registration) { commandManager.register("paint", builder -> { builder.description(TextComponent.of("Paint brush, apply a function to a surface")); builder.action(org.enginehub.piston.Command.Action.NULL_ACTION); - CommandManager manager = DefaultCommandManagerService.getInstance() - .newCommandManager(); + CommandManager manager = service.newCommandManager(); registration.register( manager, PaintBrushCommandsRegistration.builder(), diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index d1a53d763..09f34dbd0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -104,7 +104,6 @@ import com.sk89q.worldedit.world.World; import org.enginehub.piston.ColorConfig; import org.enginehub.piston.Command; import org.enginehub.piston.CommandManager; -import org.enginehub.piston.DefaultCommandManagerService; import org.enginehub.piston.converter.ArgumentConverters; import org.enginehub.piston.exception.CommandException; import org.enginehub.piston.exception.CommandExecutionException; @@ -300,8 +299,8 @@ public final class PlatformCommandManager { BrushCommandsRegistration.builder(), new BrushCommands(worldEdit), manager -> { - PaintBrushCommands.register(manager, registration); - ApplyBrushCommands.register(manager, registration); + PaintBrushCommands.register(commandManagerService, manager, registration); + ApplyBrushCommands.register(commandManagerService, manager, registration); } ); registerSubCommands(