mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Attempt to fix command execution.
This commit is contained in:
parent
183d733825
commit
ccd8f2c2a9
@ -83,7 +83,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
}
|
||||
if (PaperLib.isPaper() && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) {
|
||||
new RenderListener(plugin);
|
||||
}
|
||||
}in
|
||||
if (Bukkit.getPluginManager().getPlugin("PlotSquared") != null) {
|
||||
try {
|
||||
WEManager.IMP.managers.add(new PlotSquaredFeature());
|
||||
|
@ -31,7 +31,6 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -177,15 +176,8 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector3 pos, float pitch, float yaw) {
|
||||
if (pos instanceof com.sk89q.worldedit.util.Location) {
|
||||
com.sk89q.worldedit.util.Location loc = (com.sk89q.worldedit.util.Location) pos;
|
||||
Extent extent = loc.getExtent();
|
||||
if (extent instanceof World) {
|
||||
org.bukkit.World world = Bukkit.getWorld(((World) extent).getName());
|
||||
player.teleport(new Location(world, pos.getX(), pos.getY(), pos.getZ(), yaw, pitch));
|
||||
}
|
||||
}
|
||||
player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ(), yaw, pitch));
|
||||
player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(),
|
||||
pos.getZ(), yaw, pitch));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -224,13 +224,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
}
|
||||
}
|
||||
|
||||
// // Register 1.13 Material ids with LegacyMapper
|
||||
// LegacyMapper legacyMapper = LegacyMapper.getInstance();
|
||||
// for (Material m : Material.values()) {
|
||||
// if (!m.isLegacy() && m.isBlock()) {
|
||||
// legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState());
|
||||
// }
|
||||
// }
|
||||
// Enable metrics
|
||||
new Metrics(this);
|
||||
PaperLib.suggestPaper(this);
|
||||
@ -465,7 +458,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
// code of WorldEdit expects it
|
||||
String[] split = new String[args.length + 1];
|
||||
System.arraycopy(args, 0, split, 1, args.length);
|
||||
split[0] = commandLabel;
|
||||
split[0] = "/" + commandLabel;
|
||||
|
||||
CommandEvent event = new CommandEvent(wrapCommandSender(sender), Joiner.on(" ").join(split));
|
||||
getWorldEdit().getEventBus().post(event);
|
||||
|
@ -1,16 +0,0 @@
|
||||
//package com.boydti.fawe.command;
|
||||
//
|
||||
//import com.sk89q.worldedit.WorldEdit;
|
||||
//import com.sk89q.worldedit.util.command.parametric.BindingHelper;
|
||||
//
|
||||
//public class FaweBinding extends BindingHelper {
|
||||
// private final WorldEdit worldEdit;
|
||||
//
|
||||
// public FaweBinding(WorldEdit worldEdit) {
|
||||
// this.worldEdit = worldEdit;
|
||||
// }
|
||||
//
|
||||
// public WorldEdit getWorldEdit() {
|
||||
// return worldEdit;
|
||||
// }
|
||||
//}
|
@ -116,7 +116,7 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
if (!session.getRegionSelector(world).selectPrimary(pos.toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
|
||||
BBC.SELECTOR_ALREADY_SET.send(actor);
|
||||
actor.print(BBC.SELECTOR_ALREADY_SET.s());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
if (!session.getRegionSelector(world).selectSecondary(pos.toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
|
||||
BBC.SELECTOR_ALREADY_SET.send(actor);
|
||||
actor.print(BBC.SELECTOR_ALREADY_SET.s());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -163,14 +163,14 @@ public class SelectionCommands {
|
||||
|
||||
if (pos != null) {
|
||||
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
||||
BBC.SELECTOR_ALREADY_SET.send(player);
|
||||
player.print(BBC.SELECTOR_ALREADY_SET.s());
|
||||
return;
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld())
|
||||
.explainPrimarySelection(player, session, pos.toBlockPoint());
|
||||
} else {
|
||||
BBC.NO_BLOCK.send(player);
|
||||
player.print(BBC.NO_BLOCK.s());
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,14 +185,14 @@ public class SelectionCommands {
|
||||
|
||||
if (pos != null) {
|
||||
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
||||
BBC.SELECTOR_ALREADY_SET.send(player);
|
||||
player.print(BBC.SELECTOR_ALREADY_SET.s());
|
||||
return;
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld())
|
||||
.explainSecondarySelection(player, session, pos.toBlockPoint());
|
||||
} else {
|
||||
BBC.NO_BLOCK.send(player);
|
||||
player.print(BBC.NO_BLOCK.s());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -114,14 +114,17 @@ public abstract class AbstractNonPlayerActor implements Actor {
|
||||
* @param value
|
||||
* @return previous value
|
||||
*/
|
||||
@Override
|
||||
public final void setMeta(String key, Object value) {
|
||||
this.meta.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <T> T getAndSetMeta(String key, T value) {
|
||||
return (T) this.meta.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean hasMeta() {
|
||||
return !meta.isEmpty();
|
||||
}
|
||||
@ -133,6 +136,7 @@ public abstract class AbstractNonPlayerActor implements Actor {
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public final <V> V getMeta(String key) {
|
||||
return (V) this.meta.get(key);
|
||||
}
|
||||
@ -144,6 +148,7 @@ public abstract class AbstractNonPlayerActor implements Actor {
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
@Override
|
||||
public final <V> V deleteMeta(String key) {
|
||||
return (V) this.meta.remove(key);
|
||||
}
|
||||
|
@ -541,7 +541,6 @@ public final class PlatformCommandManager {
|
||||
Request.reset();
|
||||
Actor actor = event.getActor();
|
||||
String args = event.getArguments();
|
||||
System.out.println(1);
|
||||
TaskManager.IMP.taskNow(() -> {
|
||||
int space0 = args.indexOf(' ');
|
||||
String arg0 = space0 == -1 ? args : args.substring(0, space0);
|
||||
@ -596,8 +595,7 @@ public final class PlatformCommandManager {
|
||||
}
|
||||
|
||||
public void handleCommandTask(ThrowableSupplier<Throwable> task, InjectedValueAccess context, @Nullable LocalSession session, CommandEvent event) {
|
||||
Request.reset();
|
||||
Actor actor = context.injectedValue(Key.of(Actor.class)).orElseThrow(() -> new IllegalStateException("No player"));
|
||||
Actor actor = event.getActor();
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
@ -662,7 +660,7 @@ public final class PlatformCommandManager {
|
||||
|
||||
long time = System.currentTimeMillis() - start;
|
||||
if (time > 1000) {
|
||||
BBC.ACTION_COMPLETE.send(actor, time / 1000D);
|
||||
BBC.ACTION_COMPLETE.send(event.getActor(), time / 1000D);
|
||||
}
|
||||
|
||||
worldEdit.flushBlockBag(actor, editSession);
|
||||
|
@ -1,48 +0,0 @@
|
||||
package com.sk89q.worldedit.extension.platform.binding;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.internal.annotation.Validate;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
public class AnnotatedBindings extends Bindings {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
public AnnotatedBindings(WorldEdit worldEdit) {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Validate()
|
||||
public String getText(String argument, Validate modifier) {
|
||||
return validate(argument, modifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a string value using relevant modifiers.
|
||||
*
|
||||
* @param string the string
|
||||
* @param modifiers the list of modifiers to scan
|
||||
* @throws InputParseException on a validation error
|
||||
*/
|
||||
private static String validate(String string, Annotation... modifiers) {
|
||||
if (string != null) {
|
||||
for (Annotation modifier : modifiers) {
|
||||
if (modifier instanceof Validate) {
|
||||
Validate validate = (Validate) modifier;
|
||||
|
||||
if (!validate.value().isEmpty()) {
|
||||
if (!string.matches(validate.value())) {
|
||||
throw new InputParseException(
|
||||
String.format(
|
||||
"The given text doesn't match the right format (technically speaking, the 'format' is %s)",
|
||||
validate.value()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import org.enginehub.piston.CommandParameters;
|
||||
import org.enginehub.piston.exception.CommandException;
|
||||
import org.enginehub.piston.gen.CommandCallListener;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
|
||||
@ -72,15 +73,23 @@ public class CommandLoggingHandler implements CommandCallListener, AutoCloseable
|
||||
logMode = loggingAnnotation.value();
|
||||
}
|
||||
|
||||
Optional<Actor> playerOpt = parameters.injectedValue(Key.of(Actor.class));
|
||||
Optional<World> worldOpt = parameters.injectedValue(Key.of(World.class));
|
||||
Optional<Actor> actorOpt = parameters.injectedValue(Key.of(Actor.class));
|
||||
|
||||
if (!playerOpt.isPresent() || !worldOpt.isPresent()) {
|
||||
if (!actorOpt.isPresent()) {
|
||||
return;
|
||||
}
|
||||
Actor actor = actorOpt.get();
|
||||
|
||||
Actor actor = playerOpt.get();
|
||||
World world = worldOpt.get();
|
||||
World world;
|
||||
try {
|
||||
Optional<World> worldOpt = parameters.injectedValue(Key.of(World.class));
|
||||
if (!worldOpt.isPresent()) {
|
||||
return;
|
||||
}
|
||||
world = worldOpt.get();
|
||||
} catch (CommandException ex) {
|
||||
return;
|
||||
}
|
||||
|
||||
builder.append("WorldEdit: ").append(actor.getName());
|
||||
builder.append(" (in \"").append(world.getName()).append("\")");
|
||||
|
Loading…
Reference in New Issue
Block a user