geforkt von Mirrors/FastAsyncWorldEdit
Port ClipboardCommands, update to new Key
Dieser Commit ist enthalten in:
Ursprung
f33140b327
Commit
37c993be16
@ -20,7 +20,6 @@
|
|||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.sk89q.bukkit.util.CommandInspector;
|
import com.sk89q.bukkit.util.CommandInspector;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -28,6 +27,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.enginehub.piston.CommandManager;
|
import org.enginehub.piston.CommandManager;
|
||||||
import org.enginehub.piston.CommandParameters;
|
import org.enginehub.piston.CommandParameters;
|
||||||
import org.enginehub.piston.NoInputCommandParameters;
|
import org.enginehub.piston.NoInputCommandParameters;
|
||||||
|
import org.enginehub.piston.inject.Key;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ class BukkitCommandInspector implements CommandInspector {
|
|||||||
if (mapping.isPresent()) {
|
if (mapping.isPresent()) {
|
||||||
CommandParameters parameters = NoInputCommandParameters.builder()
|
CommandParameters parameters = NoInputCommandParameters.builder()
|
||||||
.injectedValues(ImmutableMap.of(
|
.injectedValues(ImmutableMap.of(
|
||||||
Key.get(Actor.class), plugin.wrapCommandSender(sender)
|
Key.of(Actor.class), plugin.wrapCommandSender(sender)
|
||||||
))
|
))
|
||||||
.build();
|
.build();
|
||||||
return mapping.get().getCondition().satisfied(parameters);
|
return mapping.get().getCondition().satisfied(parameters);
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.sk89q.util.StringUtil;
|
import com.sk89q.util.StringUtil;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
@ -43,6 +42,7 @@ import org.bukkit.inventory.EquipmentSlot;
|
|||||||
import org.enginehub.piston.CommandManager;
|
import org.enginehub.piston.CommandManager;
|
||||||
import org.enginehub.piston.CommandParameters;
|
import org.enginehub.piston.CommandParameters;
|
||||||
import org.enginehub.piston.NoInputCommandParameters;
|
import org.enginehub.piston.NoInputCommandParameters;
|
||||||
|
import org.enginehub.piston.inject.Key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles all events thrown in relation to a Player
|
* Handles all events thrown in relation to a Player
|
||||||
@ -110,7 +110,7 @@ public class WorldEditListener implements Listener {
|
|||||||
public void onPlayerCommand(PlayerCommandSendEvent event) {
|
public void onPlayerCommand(PlayerCommandSendEvent event) {
|
||||||
CommandParameters parameters = NoInputCommandParameters.builder()
|
CommandParameters parameters = NoInputCommandParameters.builder()
|
||||||
.injectedValues(ImmutableMap.of(
|
.injectedValues(ImmutableMap.of(
|
||||||
Key.get(Actor.class), plugin.wrapCommandSender(event.getPlayer())
|
Key.of(Actor.class), plugin.wrapCommandSender(event.getPlayer())
|
||||||
))
|
))
|
||||||
.build();
|
.build();
|
||||||
CommandManager commandManager = plugin.getWorldEdit().getPlatformManager().getPlatformCommandMananger().getCommandManager();
|
CommandManager commandManager = plugin.getWorldEdit().getPlatformManager().getPlatformCommandMananger().getCommandManager();
|
||||||
|
@ -19,16 +19,11 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
|
|
||||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||||
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||||
import com.sk89q.worldedit.command.util.Logging;
|
import com.sk89q.worldedit.command.util.Logging;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
@ -48,42 +43,38 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
import org.enginehub.piston.annotation.Command;
|
||||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
import org.enginehub.piston.annotation.CommandContainer;
|
||||||
|
import org.enginehub.piston.annotation.param.Arg;
|
||||||
|
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||||
|
import org.enginehub.piston.annotation.param.Switch;
|
||||||
|
|
||||||
|
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
|
||||||
|
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clipboard commands.
|
* Clipboard commands.
|
||||||
*/
|
*/
|
||||||
|
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||||
public class ClipboardCommands {
|
public class ClipboardCommands {
|
||||||
|
|
||||||
private final WorldEdit worldEdit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
|
||||||
* @param worldEdit reference to WorldEdit
|
|
||||||
*/
|
*/
|
||||||
public ClipboardCommands(WorldEdit worldEdit) {
|
public ClipboardCommands() {
|
||||||
checkNotNull(worldEdit);
|
|
||||||
this.worldEdit = worldEdit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/copy" },
|
name = "/copy",
|
||||||
flags = "em",
|
desc = "Copy the selection to the clipboard"
|
||||||
desc = "Copy the selection to the clipboard",
|
|
||||||
help = "Copy the selection to the clipboard\n" +
|
|
||||||
"Flags:\n" +
|
|
||||||
" -e will also copy entities\n" +
|
|
||||||
" -m sets a source mask so that excluded blocks become air",
|
|
||||||
min = 0,
|
|
||||||
max = 0
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.copy")
|
@CommandPermissions("worldedit.clipboard.copy")
|
||||||
public void copy(Player player, LocalSession session, EditSession editSession,
|
public void copy(Player player, LocalSession session, EditSession editSession,
|
||||||
@Selection Region region, @Switch('e') boolean copyEntities,
|
@Selection Region region,
|
||||||
@Switch('m') Mask mask) throws WorldEditException {
|
@Switch(name = 'e', desc = "Also copy entities")
|
||||||
|
boolean copyEntities,
|
||||||
|
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
|
||||||
|
Mask mask) throws WorldEditException {
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
||||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||||
@ -98,22 +89,20 @@ public class ClipboardCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/cut" },
|
name = "/cut",
|
||||||
flags = "em",
|
|
||||||
usage = "[leave-id]",
|
|
||||||
desc = "Cut the selection to the clipboard",
|
desc = "Cut the selection to the clipboard",
|
||||||
help = "Copy the selection to the clipboard\n" +
|
descFooter = "WARNING: Cutting and pasting entities cannot be undone!"
|
||||||
"Flags:\n" +
|
|
||||||
" -e will also cut entities\n" +
|
|
||||||
" -m sets a source mask so that excluded blocks become air\n" +
|
|
||||||
"WARNING: Cutting and pasting entities cannot yet be undone!",
|
|
||||||
max = 1
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.cut")
|
@CommandPermissions("worldedit.clipboard.cut")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void cut(Player player, LocalSession session, EditSession editSession,
|
public void cut(Player player, LocalSession session, EditSession editSession,
|
||||||
@Selection Region region, @Optional("air") Pattern leavePattern, @Switch('e') boolean copyEntities,
|
@Selection Region region,
|
||||||
@Switch('m') Mask mask) throws WorldEditException {
|
@Arg(desc = "Pattern to leave in place of the selection", def = "air")
|
||||||
|
Pattern leavePattern,
|
||||||
|
@Switch(name = 'e', desc = "Also cut entities")
|
||||||
|
boolean copyEntities,
|
||||||
|
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
|
||||||
|
Mask mask) throws WorldEditException {
|
||||||
|
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
||||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||||
@ -131,24 +120,18 @@ public class ClipboardCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/paste" },
|
name = "/paste",
|
||||||
usage = "",
|
desc = "Paste the clipboard's contents"
|
||||||
flags = "sao",
|
|
||||||
desc = "Paste the clipboard's contents",
|
|
||||||
help =
|
|
||||||
"Pastes the clipboard's contents.\n" +
|
|
||||||
"Flags:\n" +
|
|
||||||
" -a skips air blocks\n" +
|
|
||||||
" -o pastes at the original position\n" +
|
|
||||||
" -s selects the region after pasting",
|
|
||||||
min = 0,
|
|
||||||
max = 0
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.paste")
|
@CommandPermissions("worldedit.clipboard.paste")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
public void paste(Player player, LocalSession session, EditSession editSession,
|
public void paste(Player player, LocalSession session, EditSession editSession,
|
||||||
@Switch('a') boolean ignoreAirBlocks, @Switch('o') boolean atOrigin,
|
@Switch(name = 'a', desc = "Skip air blocks")
|
||||||
@Switch('s') boolean selectPasted) throws WorldEditException {
|
boolean ignoreAirBlocks,
|
||||||
|
@Switch(name = 'o', desc = "Paste at the original position")
|
||||||
|
boolean atOrigin,
|
||||||
|
@Switch(name = 's', desc = "Select the region after pasting")
|
||||||
|
boolean selectPasted) throws WorldEditException {
|
||||||
|
|
||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
Clipboard clipboard = holder.getClipboard();
|
Clipboard clipboard = holder.getClipboard();
|
||||||
@ -176,42 +159,43 @@ public class ClipboardCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/rotate" },
|
name = "/rotate",
|
||||||
usage = "<y-axis> [<x-axis>] [<z-axis>]",
|
|
||||||
desc = "Rotate the contents of the clipboard",
|
desc = "Rotate the contents of the clipboard",
|
||||||
help = "Non-destructively rotate the contents of the clipboard.\n" +
|
descFooter = "Non-destructively rotate the contents of the clipboard.\n" +
|
||||||
"Angles are provided in degrees and a positive angle will result in a clockwise rotation. " +
|
"Angles are provided in degrees and a positive angle will result in a clockwise rotation. " +
|
||||||
"Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.\n"
|
"Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.\n"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.rotate")
|
@CommandPermissions("worldedit.clipboard.rotate")
|
||||||
public void rotate(Player player, LocalSession session, Double yRotate, @Optional Double xRotate, @Optional Double zRotate) throws WorldEditException {
|
public void rotate(Player player, LocalSession session,
|
||||||
if ((yRotate != null && Math.abs(yRotate % 90) > 0.001) ||
|
@Arg(desc = "Amount to rotate on the y-axis")
|
||||||
xRotate != null && Math.abs(xRotate % 90) > 0.001 ||
|
double yRotate,
|
||||||
zRotate != null && Math.abs(zRotate % 90) > 0.001) {
|
@Arg(desc = "Amount to rotate on the x-axis", def = "0")
|
||||||
|
double xRotate,
|
||||||
|
@Arg(desc = "Amount to rotate on the z-axis", def = "0")
|
||||||
|
double zRotate) throws WorldEditException {
|
||||||
|
if (Math.abs(yRotate % 90) > 0.001 ||
|
||||||
|
Math.abs(xRotate % 90) > 0.001 ||
|
||||||
|
Math.abs(zRotate % 90) > 0.001) {
|
||||||
player.printDebug("Note: Interpolation is not yet supported, so angles that are multiples of 90 is recommended.");
|
player.printDebug("Note: Interpolation is not yet supported, so angles that are multiples of 90 is recommended.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
AffineTransform transform = new AffineTransform();
|
AffineTransform transform = new AffineTransform();
|
||||||
transform = transform.rotateY(-(yRotate != null ? yRotate : 0));
|
transform = transform.rotateY(-yRotate);
|
||||||
transform = transform.rotateX(-(xRotate != null ? xRotate : 0));
|
transform = transform.rotateX(-xRotate);
|
||||||
transform = transform.rotateZ(-(zRotate != null ? zRotate : 0));
|
transform = transform.rotateZ(-zRotate);
|
||||||
holder.setTransform(holder.getTransform().combine(transform));
|
holder.setTransform(holder.getTransform().combine(transform));
|
||||||
player.print("The clipboard copy has been rotated.");
|
player.print("The clipboard copy has been rotated.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/flip" },
|
name = "/flip",
|
||||||
usage = "[<direction>]",
|
desc = "Flip the contents of the clipboard across the origin"
|
||||||
desc = "Flip the contents of the clipboard",
|
|
||||||
help =
|
|
||||||
"Flips the contents of the clipboard across the point from which the copy was made.\n",
|
|
||||||
min = 0,
|
|
||||||
max = 1
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.flip")
|
@CommandPermissions("worldedit.clipboard.flip")
|
||||||
public void flip(Player player, LocalSession session,
|
public void flip(Player player, LocalSession session,
|
||||||
@Optional(Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException {
|
@Arg(desc = "The direction to flip, defaults to look direction.", def = Direction.AIM)
|
||||||
|
@Direction BlockVector3 direction) throws WorldEditException {
|
||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
AffineTransform transform = new AffineTransform();
|
AffineTransform transform = new AffineTransform();
|
||||||
transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3());
|
transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3());
|
||||||
@ -220,11 +204,8 @@ public class ClipboardCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "clearclipboard" },
|
name = "clearclipboard",
|
||||||
usage = "",
|
desc = "Clear your clipboard"
|
||||||
desc = "Clear your clipboard",
|
|
||||||
min = 0,
|
|
||||||
max = 0
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.clear")
|
@CommandPermissions("worldedit.clipboard.clear")
|
||||||
public void clearClipboard(Player player, LocalSession session) throws WorldEditException {
|
public void clearClipboard(Player player, LocalSession session) throws WorldEditException {
|
||||||
|
@ -19,16 +19,16 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.util;
|
package com.sk89q.worldedit.command.util;
|
||||||
|
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import org.enginehub.piston.Command;
|
import org.enginehub.piston.Command;
|
||||||
import org.enginehub.piston.CommandParameters;
|
import org.enginehub.piston.CommandParameters;
|
||||||
|
import org.enginehub.piston.inject.Key;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public final class PermissionCondition implements Command.Condition {
|
public final class PermissionCondition implements Command.Condition {
|
||||||
|
|
||||||
private static final Key<Actor> ACTOR_KEY = Key.get(Actor.class);
|
private static final Key<Actor> ACTOR_KEY = Key.of(Actor.class);
|
||||||
|
|
||||||
private final Set<String> permissions;
|
private final Set<String> permissions;
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package com.sk89q.worldedit.extension.platform;
|
package com.sk89q.worldedit.extension.platform;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -31,10 +30,11 @@ import com.sk89q.worldedit.command.BrushCommands;
|
|||||||
import com.sk89q.worldedit.command.BrushCommandsRegistration;
|
import com.sk89q.worldedit.command.BrushCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.ChunkCommands;
|
import com.sk89q.worldedit.command.ChunkCommands;
|
||||||
import com.sk89q.worldedit.command.ChunkCommandsRegistration;
|
import com.sk89q.worldedit.command.ChunkCommandsRegistration;
|
||||||
|
import com.sk89q.worldedit.command.ClipboardCommands;
|
||||||
|
import com.sk89q.worldedit.command.ClipboardCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.SchematicCommands;
|
import com.sk89q.worldedit.command.SchematicCommands;
|
||||||
import com.sk89q.worldedit.command.SchematicCommandsRegistration;
|
import com.sk89q.worldedit.command.SchematicCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.argument.Arguments;
|
import com.sk89q.worldedit.command.argument.Arguments;
|
||||||
import com.sk89q.worldedit.command.argument.EditSessionHolder;
|
|
||||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||||
import com.sk89q.worldedit.command.util.PermissionCondition;
|
import com.sk89q.worldedit.command.util.PermissionCondition;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
@ -47,7 +47,6 @@ import com.sk89q.worldedit.internal.command.CommandLoggingHandler;
|
|||||||
import com.sk89q.worldedit.internal.command.UserCommandCompleter;
|
import com.sk89q.worldedit.internal.command.UserCommandCompleter;
|
||||||
import com.sk89q.worldedit.internal.command.WorldEditBinding;
|
import com.sk89q.worldedit.internal.command.WorldEditBinding;
|
||||||
import com.sk89q.worldedit.internal.command.WorldEditExceptionConverter;
|
import com.sk89q.worldedit.internal.command.WorldEditExceptionConverter;
|
||||||
import com.sk89q.worldedit.session.SessionOwner;
|
|
||||||
import com.sk89q.worldedit.session.request.Request;
|
import com.sk89q.worldedit.session.request.Request;
|
||||||
import com.sk89q.worldedit.util.command.parametric.ExceptionConverter;
|
import com.sk89q.worldedit.util.command.parametric.ExceptionConverter;
|
||||||
import com.sk89q.worldedit.util.command.parametric.LegacyCommandsHandler;
|
import com.sk89q.worldedit.util.command.parametric.LegacyCommandsHandler;
|
||||||
@ -65,8 +64,8 @@ import org.enginehub.piston.exception.ConditionFailedException;
|
|||||||
import org.enginehub.piston.exception.UsageException;
|
import org.enginehub.piston.exception.UsageException;
|
||||||
import org.enginehub.piston.gen.CommandCallListener;
|
import org.enginehub.piston.gen.CommandCallListener;
|
||||||
import org.enginehub.piston.gen.CommandRegistration;
|
import org.enginehub.piston.gen.CommandRegistration;
|
||||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
|
||||||
import org.enginehub.piston.inject.InjectedValueStore;
|
import org.enginehub.piston.inject.InjectedValueStore;
|
||||||
|
import org.enginehub.piston.inject.Key;
|
||||||
import org.enginehub.piston.inject.MapBackedValueStore;
|
import org.enginehub.piston.inject.MapBackedValueStore;
|
||||||
import org.enginehub.piston.inject.MemoizingValueAccess;
|
import org.enginehub.piston.inject.MemoizingValueAccess;
|
||||||
import org.enginehub.piston.part.SubCommandPart;
|
import org.enginehub.piston.part.SubCommandPart;
|
||||||
@ -200,13 +199,17 @@ public final class PlatformCommandMananger {
|
|||||||
ChunkCommandsRegistration.builder(),
|
ChunkCommandsRegistration.builder(),
|
||||||
new ChunkCommands(worldEdit)
|
new ChunkCommands(worldEdit)
|
||||||
);
|
);
|
||||||
|
register(
|
||||||
|
commandManager,
|
||||||
|
ClipboardCommandsRegistration.builder(),
|
||||||
|
new ClipboardCommands()
|
||||||
|
);
|
||||||
|
|
||||||
// Unported commands are below. Delete once they're added to the main manager above.
|
// Unported commands are below. Delete once they're added to the main manager above.
|
||||||
/*
|
/*
|
||||||
dispatcher = new CommandGraph()
|
dispatcher = new CommandGraph()
|
||||||
.builder(builder)
|
.builder(builder)
|
||||||
.commands()
|
.commands()
|
||||||
.registerMethods(new ClipboardCommands(worldEdit))
|
|
||||||
.registerMethods(new GeneralCommands(worldEdit))
|
.registerMethods(new GeneralCommands(worldEdit))
|
||||||
.registerMethods(new GenerationCommands(worldEdit))
|
.registerMethods(new GenerationCommands(worldEdit))
|
||||||
.registerMethods(new HistoryCommands(worldEdit))
|
.registerMethods(new HistoryCommands(worldEdit))
|
||||||
@ -334,22 +337,22 @@ public final class PlatformCommandMananger {
|
|||||||
LocalConfiguration config = worldEdit.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
|
|
||||||
InjectedValueStore store = MapBackedValueStore.create();
|
InjectedValueStore store = MapBackedValueStore.create();
|
||||||
store.injectValue(Key.get(Actor.class), ValueProvider.constant(actor));
|
store.injectValue(Key.of(Actor.class), ValueProvider.constant(actor));
|
||||||
if (actor instanceof Player) {
|
if (actor instanceof Player) {
|
||||||
store.injectValue(Key.get(Player.class), ValueProvider.constant((Player) actor));
|
store.injectValue(Key.of(Player.class), ValueProvider.constant((Player) actor));
|
||||||
}
|
}
|
||||||
store.injectValue(Key.get(Arguments.class), ValueProvider.constant(event::getArguments));
|
store.injectValue(Key.of(Arguments.class), ValueProvider.constant(event::getArguments));
|
||||||
store.injectValue(Key.get(LocalSession.class),
|
store.injectValue(Key.of(LocalSession.class),
|
||||||
context -> {
|
context -> {
|
||||||
LocalSession localSession = worldEdit.getSessionManager().get(actor);
|
LocalSession localSession = worldEdit.getSessionManager().get(actor);
|
||||||
localSession.tellVersion(actor);
|
localSession.tellVersion(actor);
|
||||||
return Optional.of(localSession);
|
return Optional.of(localSession);
|
||||||
});
|
});
|
||||||
store.injectValue(Key.get(EditSession.class),
|
store.injectValue(Key.of(EditSession.class),
|
||||||
context -> {
|
context -> {
|
||||||
LocalSession localSession = context.injectedValue(Key.get(LocalSession.class))
|
LocalSession localSession = context.injectedValue(Key.of(LocalSession.class))
|
||||||
.orElseThrow(() -> new IllegalStateException("No LocalSession"));
|
.orElseThrow(() -> new IllegalStateException("No LocalSession"));
|
||||||
return context.injectedValue(Key.get(Player.class))
|
return context.injectedValue(Key.of(Player.class))
|
||||||
.map(player -> {
|
.map(player -> {
|
||||||
EditSession editSession = localSession.createEditSession(player);
|
EditSession editSession = localSession.createEditSession(player);
|
||||||
editSession.enableStandardMode();
|
editSession.enableStandardMode();
|
||||||
@ -401,7 +404,7 @@ public final class PlatformCommandMananger {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Optional<EditSession> editSessionOpt =
|
Optional<EditSession> editSessionOpt =
|
||||||
context.injectedValueIfMemoized(Key.get(EditSession.class));
|
context.injectedValueIfMemoized(Key.of(EditSession.class));
|
||||||
|
|
||||||
if (editSessionOpt.isPresent()) {
|
if (editSessionOpt.isPresent()) {
|
||||||
EditSession editSession = editSessionOpt.get();
|
EditSession editSession = editSessionOpt.get();
|
||||||
@ -432,8 +435,8 @@ public final class PlatformCommandMananger {
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void handleCommandSuggestion(CommandSuggestionEvent event) {
|
public void handleCommandSuggestion(CommandSuggestionEvent event) {
|
||||||
try {
|
try {
|
||||||
commandManager.injectValue(Key.get(Actor.class), ValueProvider.constant(event.getActor()));
|
commandManager.injectValue(Key.of(Actor.class), ValueProvider.constant(event.getActor()));
|
||||||
commandManager.injectValue(Key.get(Arguments.class), ValueProvider.constant(event::getArguments));
|
commandManager.injectValue(Key.of(Arguments.class), ValueProvider.constant(event::getArguments));
|
||||||
// TODO suggestions
|
// TODO suggestions
|
||||||
} catch (CommandException e) {
|
} catch (CommandException e) {
|
||||||
event.getActor().printError(e.getMessage());
|
event.getActor().printError(e.getMessage());
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.annotation;
|
package com.sk89q.worldedit.internal.annotation;
|
||||||
|
|
||||||
|
import org.enginehub.piston.inject.InjectAnnotation;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
@ -29,6 +31,6 @@ import java.lang.annotation.Target;
|
|||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.PARAMETER)
|
@Target(ElementType.PARAMETER)
|
||||||
|
@InjectAnnotation
|
||||||
public @interface Selection {
|
public @interface Selection {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,16 +19,16 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.command;
|
package com.sk89q.worldedit.internal.command;
|
||||||
|
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.sk89q.worldedit.command.util.Logging;
|
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.command.util.Logging;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import org.enginehub.piston.CommandParameters;
|
import org.enginehub.piston.CommandParameters;
|
||||||
import org.enginehub.piston.gen.CommandCallListener;
|
import org.enginehub.piston.gen.CommandCallListener;
|
||||||
|
import org.enginehub.piston.inject.Key;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -72,7 +72,7 @@ public class CommandLoggingHandler implements CommandCallListener, AutoCloseable
|
|||||||
logMode = loggingAnnotation.value();
|
logMode = loggingAnnotation.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Player> playerOpt = parameters.injectedValue(Key.get(Actor.class))
|
Optional<Player> playerOpt = parameters.injectedValue(Key.of(Actor.class))
|
||||||
.filter(Player.class::isInstance)
|
.filter(Player.class::isInstance)
|
||||||
.map(Player.class::cast);
|
.map(Player.class::cast);
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren