geforkt von Mirrors/FastAsyncWorldEdit
Fix intialization, rework registration
Dieser Commit ist enthalten in:
Ursprung
7ff537138a
Commit
23279c007e
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.command;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@ -5,9 +24,9 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.command.factory.TreeGeneratorFactory;
|
|
||||||
import com.sk89q.worldedit.command.factory.ItemUseFactory;
|
import com.sk89q.worldedit.command.factory.ItemUseFactory;
|
||||||
import com.sk89q.worldedit.command.factory.ReplaceFactory;
|
import com.sk89q.worldedit.command.factory.ReplaceFactory;
|
||||||
|
import com.sk89q.worldedit.command.factory.TreeGeneratorFactory;
|
||||||
import com.sk89q.worldedit.command.util.PermissionCondition;
|
import com.sk89q.worldedit.command.util.PermissionCondition;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.function.Contextual;
|
import com.sk89q.worldedit.function.Contextual;
|
||||||
@ -16,7 +35,7 @@ import com.sk89q.worldedit.function.factory.Apply;
|
|||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.util.command.CommandUtil;
|
import com.sk89q.worldedit.util.command.CommandRegistrationHandler;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import org.enginehub.piston.CommandManager;
|
import org.enginehub.piston.CommandManager;
|
||||||
@ -47,14 +66,14 @@ public class ApplyBrushCommands {
|
|||||||
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static void register(CommandManager commandManager) {
|
public static void register(CommandManager commandManager, CommandRegistrationHandler registration) {
|
||||||
commandManager.register("apply", builder -> {
|
commandManager.register("apply", builder -> {
|
||||||
builder.description(TextComponent.of("Apply brush, apply a function to every block"));
|
builder.description(TextComponent.of("Apply brush, apply a function to every block"));
|
||||||
builder.action(org.enginehub.piston.Command.Action.NULL_ACTION);
|
builder.action(org.enginehub.piston.Command.Action.NULL_ACTION);
|
||||||
|
|
||||||
CommandManager manager = DefaultCommandManagerService.getInstance()
|
CommandManager manager = DefaultCommandManagerService.getInstance()
|
||||||
.newCommandManager();
|
.newCommandManager();
|
||||||
CommandUtil.register(
|
registration.register(
|
||||||
manager,
|
manager,
|
||||||
ApplyBrushCommandsRegistration.builder(),
|
ApplyBrushCommandsRegistration.builder(),
|
||||||
new ApplyBrushCommands()
|
new ApplyBrushCommands()
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.command;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@ -5,9 +24,9 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.command.factory.TreeGeneratorFactory;
|
|
||||||
import com.sk89q.worldedit.command.factory.ItemUseFactory;
|
import com.sk89q.worldedit.command.factory.ItemUseFactory;
|
||||||
import com.sk89q.worldedit.command.factory.ReplaceFactory;
|
import com.sk89q.worldedit.command.factory.ReplaceFactory;
|
||||||
|
import com.sk89q.worldedit.command.factory.TreeGeneratorFactory;
|
||||||
import com.sk89q.worldedit.command.util.PermissionCondition;
|
import com.sk89q.worldedit.command.util.PermissionCondition;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.function.Contextual;
|
import com.sk89q.worldedit.function.Contextual;
|
||||||
@ -16,7 +35,7 @@ import com.sk89q.worldedit.function.factory.Paint;
|
|||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.util.command.CommandUtil;
|
import com.sk89q.worldedit.util.command.CommandRegistrationHandler;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import org.enginehub.piston.CommandManager;
|
import org.enginehub.piston.CommandManager;
|
||||||
@ -52,14 +71,14 @@ public class PaintBrushCommands {
|
|||||||
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static void register(CommandManager commandManager) {
|
public static void register(CommandManager commandManager, CommandRegistrationHandler registration) {
|
||||||
commandManager.register("paint", builder -> {
|
commandManager.register("paint", builder -> {
|
||||||
builder.description(TextComponent.of("Paint brush, apply a function to a surface"));
|
builder.description(TextComponent.of("Paint brush, apply a function to a surface"));
|
||||||
builder.action(org.enginehub.piston.Command.Action.NULL_ACTION);
|
builder.action(org.enginehub.piston.Command.Action.NULL_ACTION);
|
||||||
|
|
||||||
CommandManager manager = DefaultCommandManagerService.getInstance()
|
CommandManager manager = DefaultCommandManagerService.getInstance()
|
||||||
.newCommandManager();
|
.newCommandManager();
|
||||||
CommandUtil.register(
|
registration.register(
|
||||||
manager,
|
manager,
|
||||||
PaintBrushCommandsRegistration.builder(),
|
PaintBrushCommandsRegistration.builder(),
|
||||||
new PaintBrushCommands()
|
new PaintBrushCommands()
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.command.factory;
|
package com.sk89q.worldedit.command.factory;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.command.factory;
|
package com.sk89q.worldedit.command.factory;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.NullExtent;
|
import com.sk89q.worldedit.extent.NullExtent;
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.command.factory;
|
package com.sk89q.worldedit.command.factory;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
@ -84,9 +84,11 @@ import com.sk89q.worldedit.event.platform.CommandEvent;
|
|||||||
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
|
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||||
|
import com.sk89q.worldedit.internal.command.CommandLoggingHandler;
|
||||||
import com.sk89q.worldedit.internal.command.WorldEditExceptionConverter;
|
import com.sk89q.worldedit.internal.command.WorldEditExceptionConverter;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.session.request.Request;
|
import com.sk89q.worldedit.session.request.Request;
|
||||||
|
import com.sk89q.worldedit.util.command.CommandRegistrationHandler;
|
||||||
import com.sk89q.worldedit.util.command.parametric.ExceptionConverter;
|
import com.sk89q.worldedit.util.command.parametric.ExceptionConverter;
|
||||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
@ -124,8 +126,6 @@ import java.util.regex.Pattern;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.sk89q.worldedit.util.command.CommandUtil.COMMAND_LOG;
|
|
||||||
import static com.sk89q.worldedit.util.command.CommandUtil.register;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the registration and invocation of commands.
|
* Handles the registration and invocation of commands.
|
||||||
@ -136,6 +136,8 @@ public final class PlatformCommandManager {
|
|||||||
|
|
||||||
public static final Pattern COMMAND_CLEAN_PATTERN = Pattern.compile("^[/]+");
|
public static final Pattern COMMAND_CLEAN_PATTERN = Pattern.compile("^[/]+");
|
||||||
private static final Logger log = LoggerFactory.getLogger(PlatformCommandManager.class);
|
private static final Logger log = LoggerFactory.getLogger(PlatformCommandManager.class);
|
||||||
|
private static final java.util.logging.Logger COMMAND_LOG =
|
||||||
|
java.util.logging.Logger.getLogger("com.sk89q.worldedit.CommandLog");
|
||||||
private static final Pattern numberFormatExceptionPattern = Pattern.compile("^For input string: \"(.*)\"$");
|
private static final Pattern numberFormatExceptionPattern = Pattern.compile("^For input string: \"(.*)\"$");
|
||||||
|
|
||||||
private final WorldEdit worldEdit;
|
private final WorldEdit worldEdit;
|
||||||
@ -144,6 +146,7 @@ public final class PlatformCommandManager {
|
|||||||
private final InjectedValueStore globalInjectedValues;
|
private final InjectedValueStore globalInjectedValues;
|
||||||
private final DynamicStreamHandler dynamicHandler = new DynamicStreamHandler();
|
private final DynamicStreamHandler dynamicHandler = new DynamicStreamHandler();
|
||||||
private final WorldEditExceptionConverter exceptionConverter;
|
private final WorldEditExceptionConverter exceptionConverter;
|
||||||
|
private final CommandRegistrationHandler registration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
@ -159,6 +162,10 @@ public final class PlatformCommandManager {
|
|||||||
this.commandManager = DefaultCommandManagerService.getInstance()
|
this.commandManager = DefaultCommandManagerService.getInstance()
|
||||||
.newCommandManager();
|
.newCommandManager();
|
||||||
this.globalInjectedValues = MapBackedValueStore.create();
|
this.globalInjectedValues = MapBackedValueStore.create();
|
||||||
|
this.registration = new CommandRegistrationHandler(
|
||||||
|
ImmutableList.of(
|
||||||
|
new CommandLoggingHandler(worldEdit, COMMAND_LOG)
|
||||||
|
));
|
||||||
// setup separate from main constructor
|
// setup separate from main constructor
|
||||||
// ensures that everything is definitely assigned
|
// ensures that everything is definitely assigned
|
||||||
initialize();
|
initialize();
|
||||||
@ -239,7 +246,7 @@ public final class PlatformCommandManager {
|
|||||||
|
|
||||||
CommandManager manager = DefaultCommandManagerService.getInstance()
|
CommandManager manager = DefaultCommandManagerService.getInstance()
|
||||||
.newCommandManager();
|
.newCommandManager();
|
||||||
register(
|
this.registration.register(
|
||||||
manager,
|
manager,
|
||||||
registration,
|
registration,
|
||||||
instance
|
instance
|
||||||
@ -282,8 +289,8 @@ public final class PlatformCommandManager {
|
|||||||
BrushCommandsRegistration.builder(),
|
BrushCommandsRegistration.builder(),
|
||||||
new BrushCommands(worldEdit),
|
new BrushCommands(worldEdit),
|
||||||
manager -> {
|
manager -> {
|
||||||
PaintBrushCommands.register(manager);
|
PaintBrushCommands.register(manager, registration);
|
||||||
ApplyBrushCommands.register(manager);
|
ApplyBrushCommands.register(manager, registration);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
registerSubCommands(
|
registerSubCommands(
|
||||||
@ -293,72 +300,72 @@ public final class PlatformCommandManager {
|
|||||||
WorldEditCommandsRegistration.builder(),
|
WorldEditCommandsRegistration.builder(),
|
||||||
new WorldEditCommands(worldEdit)
|
new WorldEditCommands(worldEdit)
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
BiomeCommandsRegistration.builder(),
|
BiomeCommandsRegistration.builder(),
|
||||||
new BiomeCommands()
|
new BiomeCommands()
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
ChunkCommandsRegistration.builder(),
|
ChunkCommandsRegistration.builder(),
|
||||||
new ChunkCommands(worldEdit)
|
new ChunkCommands(worldEdit)
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
ClipboardCommandsRegistration.builder(),
|
ClipboardCommandsRegistration.builder(),
|
||||||
new ClipboardCommands()
|
new ClipboardCommands()
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
GeneralCommandsRegistration.builder(),
|
GeneralCommandsRegistration.builder(),
|
||||||
new GeneralCommands(worldEdit)
|
new GeneralCommands(worldEdit)
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
GenerationCommandsRegistration.builder(),
|
GenerationCommandsRegistration.builder(),
|
||||||
new GenerationCommands(worldEdit)
|
new GenerationCommands(worldEdit)
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
HistoryCommandsRegistration.builder(),
|
HistoryCommandsRegistration.builder(),
|
||||||
new HistoryCommands(worldEdit)
|
new HistoryCommands(worldEdit)
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
NavigationCommandsRegistration.builder(),
|
NavigationCommandsRegistration.builder(),
|
||||||
new NavigationCommands(worldEdit)
|
new NavigationCommands(worldEdit)
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
RegionCommandsRegistration.builder(),
|
RegionCommandsRegistration.builder(),
|
||||||
new RegionCommands()
|
new RegionCommands()
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
ScriptingCommandsRegistration.builder(),
|
ScriptingCommandsRegistration.builder(),
|
||||||
new ScriptingCommands(worldEdit)
|
new ScriptingCommands(worldEdit)
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
SelectionCommandsRegistration.builder(),
|
SelectionCommandsRegistration.builder(),
|
||||||
new SelectionCommands(worldEdit)
|
new SelectionCommands(worldEdit)
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
SnapshotUtilCommandsRegistration.builder(),
|
SnapshotUtilCommandsRegistration.builder(),
|
||||||
new SnapshotUtilCommands(worldEdit)
|
new SnapshotUtilCommands(worldEdit)
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
ToolCommandsRegistration.builder(),
|
ToolCommandsRegistration.builder(),
|
||||||
new ToolCommands(worldEdit)
|
new ToolCommands(worldEdit)
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
ToolUtilCommandsRegistration.builder(),
|
ToolUtilCommandsRegistration.builder(),
|
||||||
new ToolUtilCommands(worldEdit)
|
new ToolUtilCommands(worldEdit)
|
||||||
);
|
);
|
||||||
register(
|
this.registration.register(
|
||||||
commandManager,
|
commandManager,
|
||||||
UtilityCommandsRegistration.builder(),
|
UtilityCommandsRegistration.builder(),
|
||||||
new UtilityCommands(worldEdit)
|
new UtilityCommands(worldEdit)
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.function;
|
package com.sk89q.worldedit.function;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit.util.command;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||||
|
import com.sk89q.worldedit.internal.command.CommandLoggingHandler;
|
||||||
|
import org.enginehub.piston.CommandManager;
|
||||||
|
import org.enginehub.piston.gen.CommandCallListener;
|
||||||
|
import org.enginehub.piston.gen.CommandRegistration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class CommandRegistrationHandler {
|
||||||
|
|
||||||
|
private static final CommandPermissionsConditionGenerator PERM_GEN = new CommandPermissionsConditionGenerator();
|
||||||
|
|
||||||
|
private final List<CommandCallListener> callListeners;
|
||||||
|
|
||||||
|
public CommandRegistrationHandler(List<CommandCallListener> callListeners) {
|
||||||
|
this.callListeners = ImmutableList.copyOf(callListeners);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <CI> void register(CommandManager manager, CommandRegistration<CI> registration, CI instance) {
|
||||||
|
registration.containerInstance(instance)
|
||||||
|
.commandManager(manager)
|
||||||
|
.listeners(callListeners);
|
||||||
|
if (registration instanceof CommandPermissionsConditionGenerator.Registration) {
|
||||||
|
((CommandPermissionsConditionGenerator.Registration) registration).commandPermissionsConditionGenerator(
|
||||||
|
PERM_GEN
|
||||||
|
);
|
||||||
|
}
|
||||||
|
registration.build();
|
||||||
|
}
|
||||||
|
}
|
@ -19,22 +19,13 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.util.command;
|
package com.sk89q.worldedit.util.command;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
|
||||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||||
import com.sk89q.worldedit.internal.command.CommandLoggingHandler;
|
|
||||||
import org.enginehub.piston.Command;
|
import org.enginehub.piston.Command;
|
||||||
import org.enginehub.piston.CommandManager;
|
|
||||||
import org.enginehub.piston.gen.CommandCallListener;
|
|
||||||
import org.enginehub.piston.gen.CommandRegistration;
|
|
||||||
import org.enginehub.piston.part.SubCommandPart;
|
import org.enginehub.piston.part.SubCommandPart;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CommandUtil {
|
public class CommandUtil {
|
||||||
@ -57,26 +48,6 @@ public class CommandUtil {
|
|||||||
return BY_CLEAN_NAME;
|
return BY_CLEAN_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final CommandPermissionsConditionGenerator PERM_GEN = new CommandPermissionsConditionGenerator();
|
|
||||||
|
|
||||||
public static final Logger COMMAND_LOG =
|
|
||||||
Logger.getLogger("com.sk89q.worldedit.CommandLog");
|
|
||||||
private static final List<CommandCallListener> CALL_LISTENERS = ImmutableList.of(
|
|
||||||
new CommandLoggingHandler(WorldEdit.getInstance(), COMMAND_LOG)
|
|
||||||
);
|
|
||||||
|
|
||||||
public static <CI> void register(CommandManager manager, CommandRegistration<CI> registration, CI instance) {
|
|
||||||
registration.containerInstance(instance)
|
|
||||||
.commandManager(manager)
|
|
||||||
.listeners(CALL_LISTENERS);
|
|
||||||
if (registration instanceof CommandPermissionsConditionGenerator.Registration) {
|
|
||||||
((CommandPermissionsConditionGenerator.Registration) registration).commandPermissionsConditionGenerator(
|
|
||||||
PERM_GEN
|
|
||||||
);
|
|
||||||
}
|
|
||||||
registration.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private CommandUtil() {
|
private CommandUtil() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren