Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-20 01:40:06 +01:00
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.command.util.CommandPermissions;
|
||||
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.EntityRemover;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
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.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
@ -104,7 +102,7 @@ import org.jetbrains.annotations.Range;
|
||||
/**
|
||||
* Utility commands.
|
||||
*/
|
||||
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class, CommandQueuedConditionGenerator.Registration.class})
|
||||
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class})
|
||||
public class UtilityCommands {
|
||||
|
||||
private final WorldEdit we;
|
||||
@ -185,8 +183,7 @@ public class UtilityCommands {
|
||||
aliases= {"fcancel"},
|
||||
desc = "Cancel your current command"
|
||||
)
|
||||
@CommandPermissions("fawe.cancel")
|
||||
@SkipQueue
|
||||
@CommandPermissions(value = "fawe.cancel", queued = false)
|
||||
public void cancel(Player player) {
|
||||
int cancelled = player.cancel(false);
|
||||
player.print(Caption.of("fawe.cancel.worldedit.cancel.count" , cancelled));
|
||||
@ -704,8 +701,7 @@ public class UtilityCommands {
|
||||
name = "/confirm",
|
||||
desc = "Confirm a command"
|
||||
)
|
||||
@SkipQueue
|
||||
@CommandPermissions("fawe.confirm")
|
||||
@CommandPermissions(value = "fawe.confirm", queued = false)
|
||||
public void confirm(Player fp) throws WorldEditException {
|
||||
if (!fp.confirm()) {
|
||||
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.command.util.CommandPermissions;
|
||||
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.entity.Player;
|
||||
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.Switch;
|
||||
|
||||
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class, CommandQueuedConditionGenerator.Registration.class})
|
||||
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class})
|
||||
public class WorldEditCommands {
|
||||
private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");
|
||||
|
||||
@ -73,7 +71,7 @@ public class WorldEditCommands {
|
||||
aliases = { "ver" },
|
||||
desc = "Get WorldEdit/FAWE version"
|
||||
)
|
||||
@SkipQueue
|
||||
@CommandPermissions(queued = false)
|
||||
public void version(Actor actor) {
|
||||
FaweVersion fVer = Fawe.get().getVersion();
|
||||
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
|
||||
@ -136,8 +134,7 @@ public class WorldEditCommands {
|
||||
aliases = { "debugpaste" },
|
||||
desc = "Writes a report of latest.log, config.yml, message.yml https://athion.net/ISPaster/paste"
|
||||
)
|
||||
@SkipQueue
|
||||
@CommandPermissions({"worldedit.report", "worldedit.debugpaste"})
|
||||
@CommandPermissions(value = {"worldedit.report", "worldedit.debugpaste"}, queued = false)
|
||||
public void report(Actor actor) throws WorldEditException, IOException {
|
||||
String dest = IncendoPaster.debugPaste();
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.report.written", TextComponent.of(dest)));
|
||||
@ -147,8 +144,7 @@ public class WorldEditCommands {
|
||||
name = "threads",
|
||||
desc = "Print all thread stacks"
|
||||
)
|
||||
@SkipQueue
|
||||
@CommandPermissions("worldedit.threads")
|
||||
@CommandPermissions(value = "worldedit.threads", queued = false)
|
||||
public void threads(Actor actor) throws WorldEditException {
|
||||
Map<Thread, StackTraceElement[]> stacks = Thread.getAllStackTraces();
|
||||
for (Map.Entry<Thread, StackTraceElement[]> entry : stacks.entrySet()) {
|
||||
@ -168,6 +164,7 @@ public class WorldEditCommands {
|
||||
name = "cui",
|
||||
desc = "Complete CUI handshake (internal usage)"
|
||||
)
|
||||
@CommandPermissions({})
|
||||
public void cui(Player player, LocalSession session) {
|
||||
session.setCUISupport(true);
|
||||
session.dispatchCUISetup(player);
|
||||
@ -197,8 +194,7 @@ public class WorldEditCommands {
|
||||
name = "help",
|
||||
desc = "Displays help for WorldEdit commands"
|
||||
)
|
||||
@SkipQueue
|
||||
@CommandPermissions("worldedit.help")
|
||||
@CommandPermissions(value = "worldedit.help", queued = false)
|
||||
public void help(Actor actor,
|
||||
@Switch(name = 's', desc = "List sub-commands of the given command, if applicable")
|
||||
boolean listSubCommands,
|
||||
|
@ -34,6 +34,7 @@ public @interface CommandPermissions {
|
||||
*
|
||||
* @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;
|
||||
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.enginehub.piston.Command;
|
||||
import org.enginehub.piston.gen.CommandConditionGenerator;
|
||||
@ -41,6 +42,6 @@ public final class CommandPermissionsConditionGenerator implements CommandCondit
|
||||
CommandPermissions annotation = commandMethod.getAnnotation(CommandPermissions.class);
|
||||
checkNotNull(annotation, "Annotation is missing from commandMethod");
|
||||
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;
|
||||
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import org.enginehub.piston.Command;
|
||||
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 final Set<String> permissions;
|
||||
private final boolean queued;
|
||||
|
||||
public PermissionCondition(Set<String> permissions) {
|
||||
this(permissions, true);
|
||||
}
|
||||
|
||||
public PermissionCondition(Set<String> permissions, boolean queued) {
|
||||
this.permissions = permissions;
|
||||
this.queued = queued;
|
||||
}
|
||||
|
||||
public Set<String> getPermissions() {
|
||||
@ -47,4 +54,8 @@ public class PermissionCondition implements Command.Condition {
|
||||
.map(actor -> permissions.stream().anyMatch(actor::hasPermission))
|
||||
.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.WorldConverter;
|
||||
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.PrintCommandHelp;
|
||||
import com.sk89q.worldedit.command.util.SubCommandPermissionCondition;
|
||||
@ -652,7 +651,7 @@ public final class PlatformCommandManager {
|
||||
return;
|
||||
}
|
||||
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()) {
|
||||
handleCommandOnCurrentThread(event);
|
||||
return;
|
||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.internal.command;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.CommandQueuedConditionGenerator;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.gen.CommandCallListener;
|
||||
import org.enginehub.piston.gen.CommandRegistration;
|
||||
@ -31,7 +30,6 @@ import java.util.List;
|
||||
public class CommandRegistrationHandler {
|
||||
|
||||
private static final CommandPermissionsConditionGenerator PERM_GEN = new CommandPermissionsConditionGenerator();
|
||||
private static final CommandQueuedConditionGenerator QUEUED_GEN = new CommandQueuedConditionGenerator();
|
||||
|
||||
|
||||
private final List<CommandCallListener> callListeners;
|
||||
@ -49,11 +47,6 @@ public class CommandRegistrationHandler {
|
||||
PERM_GEN
|
||||
);
|
||||
}
|
||||
if (registration instanceof CommandQueuedConditionGenerator.Registration) {
|
||||
((CommandQueuedConditionGenerator.Registration) registration).commandQueuedConditionGenerator(
|
||||
QUEUED_GEN
|
||||
);
|
||||
}
|
||||
registration.build();
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren