geforkt von Mirrors/FastAsyncWorldEdit
Remove SkipQueue annotation, and combine with perm condition
it seems piston only generates one condition, idk why
Dieser Commit ist enthalten in:
Ursprung
27ec3cdc66
Commit
39b698f67d
@ -40,12 +40,10 @@ 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.CommandPermissions;
|
||||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||||
import com.sk89q.worldedit.command.util.CommandQueuedConditionGenerator;
|
|
||||||
import com.sk89q.worldedit.command.util.CreatureButcher;
|
import com.sk89q.worldedit.command.util.CreatureButcher;
|
||||||
import com.sk89q.worldedit.command.util.EntityRemover;
|
import com.sk89q.worldedit.command.util.EntityRemover;
|
||||||
import com.sk89q.worldedit.command.util.Logging;
|
import com.sk89q.worldedit.command.util.Logging;
|
||||||
import com.sk89q.worldedit.command.util.PrintCommandHelp;
|
import com.sk89q.worldedit.command.util.PrintCommandHelp;
|
||||||
import com.sk89q.worldedit.command.util.annotation.SkipQueue;
|
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
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;
|
||||||
@ -104,7 +102,7 @@ import org.jetbrains.annotations.Range;
|
|||||||
/**
|
/**
|
||||||
* Utility commands.
|
* Utility commands.
|
||||||
*/
|
*/
|
||||||
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class, CommandQueuedConditionGenerator.Registration.class})
|
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class})
|
||||||
public class UtilityCommands {
|
public class UtilityCommands {
|
||||||
|
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
@ -185,8 +183,7 @@ public class UtilityCommands {
|
|||||||
aliases= {"fcancel"},
|
aliases= {"fcancel"},
|
||||||
desc = "Cancel your current command"
|
desc = "Cancel your current command"
|
||||||
)
|
)
|
||||||
@CommandPermissions("fawe.cancel")
|
@CommandPermissions(value = "fawe.cancel", queued = false)
|
||||||
@SkipQueue
|
|
||||||
public void cancel(Player player) {
|
public void cancel(Player player) {
|
||||||
int cancelled = player.cancel(false);
|
int cancelled = player.cancel(false);
|
||||||
player.print(Caption.of("fawe.cancel.worldedit.cancel.count" , cancelled));
|
player.print(Caption.of("fawe.cancel.worldedit.cancel.count" , cancelled));
|
||||||
@ -704,8 +701,7 @@ public class UtilityCommands {
|
|||||||
name = "/confirm",
|
name = "/confirm",
|
||||||
desc = "Confirm a command"
|
desc = "Confirm a command"
|
||||||
)
|
)
|
||||||
@SkipQueue
|
@CommandPermissions(value = "fawe.confirm", queued = false)
|
||||||
@CommandPermissions("fawe.confirm")
|
|
||||||
public void confirm(Player fp) throws WorldEditException {
|
public void confirm(Player fp) throws WorldEditException {
|
||||||
if (!fp.confirm()) {
|
if (!fp.confirm()) {
|
||||||
fp.print(TranslatableComponent.of("fawe.worldedit.utility.nothing.confirmed"));
|
fp.print(TranslatableComponent.of("fawe.worldedit.utility.nothing.confirmed"));
|
||||||
|
@ -29,8 +29,6 @@ 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.CommandPermissions;
|
||||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||||
import com.sk89q.worldedit.command.util.annotation.SkipQueue;
|
|
||||||
import com.sk89q.worldedit.command.util.CommandQueuedConditionGenerator;
|
|
||||||
import com.sk89q.worldedit.command.util.PrintCommandHelp;
|
import com.sk89q.worldedit.command.util.PrintCommandHelp;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
|
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
|
||||||
@ -58,7 +56,7 @@ import org.enginehub.piston.annotation.param.Arg;
|
|||||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||||
import org.enginehub.piston.annotation.param.Switch;
|
import org.enginehub.piston.annotation.param.Switch;
|
||||||
|
|
||||||
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class, CommandQueuedConditionGenerator.Registration.class})
|
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class})
|
||||||
public class WorldEditCommands {
|
public class WorldEditCommands {
|
||||||
private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");
|
private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");
|
||||||
|
|
||||||
@ -73,7 +71,7 @@ public class WorldEditCommands {
|
|||||||
aliases = { "ver" },
|
aliases = { "ver" },
|
||||||
desc = "Get WorldEdit/FAWE version"
|
desc = "Get WorldEdit/FAWE version"
|
||||||
)
|
)
|
||||||
@SkipQueue
|
@CommandPermissions(queued = false)
|
||||||
public void version(Actor actor) {
|
public void version(Actor actor) {
|
||||||
FaweVersion fVer = Fawe.get().getVersion();
|
FaweVersion fVer = Fawe.get().getVersion();
|
||||||
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
|
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
|
||||||
@ -136,8 +134,7 @@ public class WorldEditCommands {
|
|||||||
aliases = { "debugpaste" },
|
aliases = { "debugpaste" },
|
||||||
desc = "Writes a report of latest.log, config.yml, message.yml https://athion.net/ISPaster/paste"
|
desc = "Writes a report of latest.log, config.yml, message.yml https://athion.net/ISPaster/paste"
|
||||||
)
|
)
|
||||||
@SkipQueue
|
@CommandPermissions(value = {"worldedit.report", "worldedit.debugpaste"}, queued = false)
|
||||||
@CommandPermissions({"worldedit.report", "worldedit.debugpaste"})
|
|
||||||
public void report(Actor actor) throws WorldEditException, IOException {
|
public void report(Actor actor) throws WorldEditException, IOException {
|
||||||
String dest = IncendoPaster.debugPaste();
|
String dest = IncendoPaster.debugPaste();
|
||||||
actor.printInfo(TranslatableComponent.of("worldedit.report.written", TextComponent.of(dest)));
|
actor.printInfo(TranslatableComponent.of("worldedit.report.written", TextComponent.of(dest)));
|
||||||
@ -147,8 +144,7 @@ public class WorldEditCommands {
|
|||||||
name = "threads",
|
name = "threads",
|
||||||
desc = "Print all thread stacks"
|
desc = "Print all thread stacks"
|
||||||
)
|
)
|
||||||
@SkipQueue
|
@CommandPermissions(value = "worldedit.threads", queued = false)
|
||||||
@CommandPermissions("worldedit.threads")
|
|
||||||
public void threads(Actor actor) throws WorldEditException {
|
public void threads(Actor actor) throws WorldEditException {
|
||||||
Map<Thread, StackTraceElement[]> stacks = Thread.getAllStackTraces();
|
Map<Thread, StackTraceElement[]> stacks = Thread.getAllStackTraces();
|
||||||
for (Map.Entry<Thread, StackTraceElement[]> entry : stacks.entrySet()) {
|
for (Map.Entry<Thread, StackTraceElement[]> entry : stacks.entrySet()) {
|
||||||
@ -168,6 +164,7 @@ public class WorldEditCommands {
|
|||||||
name = "cui",
|
name = "cui",
|
||||||
desc = "Complete CUI handshake (internal usage)"
|
desc = "Complete CUI handshake (internal usage)"
|
||||||
)
|
)
|
||||||
|
@CommandPermissions({})
|
||||||
public void cui(Player player, LocalSession session) {
|
public void cui(Player player, LocalSession session) {
|
||||||
session.setCUISupport(true);
|
session.setCUISupport(true);
|
||||||
session.dispatchCUISetup(player);
|
session.dispatchCUISetup(player);
|
||||||
@ -197,8 +194,7 @@ public class WorldEditCommands {
|
|||||||
name = "help",
|
name = "help",
|
||||||
desc = "Displays help for WorldEdit commands"
|
desc = "Displays help for WorldEdit commands"
|
||||||
)
|
)
|
||||||
@SkipQueue
|
@CommandPermissions(value = "worldedit.help", queued = false)
|
||||||
@CommandPermissions("worldedit.help")
|
|
||||||
public void help(Actor actor,
|
public void help(Actor actor,
|
||||||
@Switch(name = 's', desc = "List sub-commands of the given command, if applicable")
|
@Switch(name = 's', desc = "List sub-commands of the given command, if applicable")
|
||||||
boolean listSubCommands,
|
boolean listSubCommands,
|
||||||
|
@ -34,6 +34,7 @@ public @interface CommandPermissions {
|
|||||||
*
|
*
|
||||||
* @return a list of permissions strings
|
* @return a list of permissions strings
|
||||||
*/
|
*/
|
||||||
String[] value();
|
String[] value() default {};
|
||||||
|
|
||||||
|
boolean queued() default true;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.util;
|
package com.sk89q.worldedit.command.util;
|
||||||
|
|
||||||
|
import com.boydti.fawe.util.StringMan;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.enginehub.piston.Command;
|
import org.enginehub.piston.Command;
|
||||||
import org.enginehub.piston.gen.CommandConditionGenerator;
|
import org.enginehub.piston.gen.CommandConditionGenerator;
|
||||||
@ -41,6 +42,6 @@ public final class CommandPermissionsConditionGenerator implements CommandCondit
|
|||||||
CommandPermissions annotation = commandMethod.getAnnotation(CommandPermissions.class);
|
CommandPermissions annotation = commandMethod.getAnnotation(CommandPermissions.class);
|
||||||
checkNotNull(annotation, "Annotation is missing from commandMethod");
|
checkNotNull(annotation, "Annotation is missing from commandMethod");
|
||||||
Set<String> permissions = ImmutableSet.copyOf(annotation.value());
|
Set<String> permissions = ImmutableSet.copyOf(annotation.value());
|
||||||
return new PermissionCondition(permissions);
|
return new PermissionCondition(permissions, annotation.queued());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
package com.sk89q.worldedit.command.util;
|
|
||||||
|
|
||||||
import org.enginehub.piston.Command;
|
|
||||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dummy class
|
|
||||||
*/
|
|
||||||
public class CommandQueuedCondition implements Command.Condition {
|
|
||||||
private final boolean isQueued;
|
|
||||||
|
|
||||||
public CommandQueuedCondition(boolean isQueued) {
|
|
||||||
this.isQueued = isQueued;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isQueued() {
|
|
||||||
return isQueued;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean satisfied(InjectedValueAccess injectedValueAccess) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.sk89q.worldedit.command.util;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.command.util.annotation.SkipQueue;
|
|
||||||
import org.enginehub.piston.Command;
|
|
||||||
import org.enginehub.piston.gen.CommandConditionGenerator;
|
|
||||||
import org.enginehub.piston.util.NonnullByDefault;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
@NonnullByDefault
|
|
||||||
public final class CommandQueuedConditionGenerator implements CommandConditionGenerator {
|
|
||||||
|
|
||||||
public interface Registration {
|
|
||||||
Registration commandQueuedConditionGenerator(CommandQueuedConditionGenerator generator);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Command.Condition generateCondition(Method commandMethod) {
|
|
||||||
SkipQueue skip = commandMethod.getAnnotation(SkipQueue.class);
|
|
||||||
if (skip == null) {
|
|
||||||
return Command.Condition.TRUE;
|
|
||||||
}
|
|
||||||
return new CommandQueuedCondition(!skip.value());
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.util;
|
package com.sk89q.worldedit.command.util;
|
||||||
|
|
||||||
|
import com.boydti.fawe.util.StringMan;
|
||||||
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.inject.InjectedValueAccess;
|
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||||
@ -31,9 +32,15 @@ public class PermissionCondition implements Command.Condition {
|
|||||||
private static final Key<Actor> ACTOR_KEY = Key.of(Actor.class);
|
private static final Key<Actor> ACTOR_KEY = Key.of(Actor.class);
|
||||||
|
|
||||||
private final Set<String> permissions;
|
private final Set<String> permissions;
|
||||||
|
private final boolean queued;
|
||||||
|
|
||||||
public PermissionCondition(Set<String> permissions) {
|
public PermissionCondition(Set<String> permissions) {
|
||||||
|
this(permissions, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PermissionCondition(Set<String> permissions, boolean queued) {
|
||||||
this.permissions = permissions;
|
this.permissions = permissions;
|
||||||
|
this.queued = queued;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getPermissions() {
|
public Set<String> getPermissions() {
|
||||||
@ -47,4 +54,8 @@ public class PermissionCondition implements Command.Condition {
|
|||||||
.map(actor -> permissions.stream().anyMatch(actor::hasPermission))
|
.map(actor -> permissions.stream().anyMatch(actor::hasPermission))
|
||||||
.orElse(false);
|
.orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isQueued() {
|
||||||
|
return queued;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package com.sk89q.worldedit.command.util.annotation;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.command.util.CommandQueuedConditionGenerator;
|
|
||||||
import org.enginehub.piston.annotation.CommandCondition;
|
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a command to be queued
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@CommandCondition(CommandQueuedConditionGenerator.class)
|
|
||||||
public @interface SkipQueue {
|
|
||||||
boolean value() default true;
|
|
||||||
}
|
|
@ -107,7 +107,6 @@ import com.sk89q.worldedit.command.argument.RegistryConverter;
|
|||||||
import com.sk89q.worldedit.command.argument.VectorConverter;
|
import com.sk89q.worldedit.command.argument.VectorConverter;
|
||||||
import com.sk89q.worldedit.command.argument.WorldConverter;
|
import com.sk89q.worldedit.command.argument.WorldConverter;
|
||||||
import com.sk89q.worldedit.command.argument.ZonedDateTimeConverter;
|
import com.sk89q.worldedit.command.argument.ZonedDateTimeConverter;
|
||||||
import com.sk89q.worldedit.command.util.CommandQueuedCondition;
|
|
||||||
import com.sk89q.worldedit.command.util.PermissionCondition;
|
import com.sk89q.worldedit.command.util.PermissionCondition;
|
||||||
import com.sk89q.worldedit.command.util.PrintCommandHelp;
|
import com.sk89q.worldedit.command.util.PrintCommandHelp;
|
||||||
import com.sk89q.worldedit.command.util.SubCommandPermissionCondition;
|
import com.sk89q.worldedit.command.util.SubCommandPermissionCondition;
|
||||||
@ -652,7 +651,7 @@ public final class PlatformCommandManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Command cmd = optional.get();
|
Command cmd = optional.get();
|
||||||
CommandQueuedCondition queued = cmd.getCondition().as(CommandQueuedCondition.class).orElse(null);
|
PermissionCondition queued = cmd.getCondition().as(PermissionCondition.class).orElse(null);
|
||||||
if (queued != null && !queued.isQueued()) {
|
if (queued != null && !queued.isQueued()) {
|
||||||
handleCommandOnCurrentThread(event);
|
handleCommandOnCurrentThread(event);
|
||||||
return;
|
return;
|
||||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.internal.command;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||||
import com.sk89q.worldedit.command.util.CommandQueuedConditionGenerator;
|
|
||||||
import org.enginehub.piston.CommandManager;
|
import org.enginehub.piston.CommandManager;
|
||||||
import org.enginehub.piston.gen.CommandCallListener;
|
import org.enginehub.piston.gen.CommandCallListener;
|
||||||
import org.enginehub.piston.gen.CommandRegistration;
|
import org.enginehub.piston.gen.CommandRegistration;
|
||||||
@ -31,7 +30,6 @@ import java.util.List;
|
|||||||
public class CommandRegistrationHandler {
|
public class CommandRegistrationHandler {
|
||||||
|
|
||||||
private static final CommandPermissionsConditionGenerator PERM_GEN = new CommandPermissionsConditionGenerator();
|
private static final CommandPermissionsConditionGenerator PERM_GEN = new CommandPermissionsConditionGenerator();
|
||||||
private static final CommandQueuedConditionGenerator QUEUED_GEN = new CommandQueuedConditionGenerator();
|
|
||||||
|
|
||||||
|
|
||||||
private final List<CommandCallListener> callListeners;
|
private final List<CommandCallListener> callListeners;
|
||||||
@ -49,11 +47,6 @@ public class CommandRegistrationHandler {
|
|||||||
PERM_GEN
|
PERM_GEN
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (registration instanceof CommandQueuedConditionGenerator.Registration) {
|
|
||||||
((CommandQueuedConditionGenerator.Registration) registration).commandQueuedConditionGenerator(
|
|
||||||
QUEUED_GEN
|
|
||||||
);
|
|
||||||
}
|
|
||||||
registration.build();
|
registration.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren