mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-10 06:28:36 +00:00
Don't confirm twice every time
- I channelled my inner Jesse on this one.
This commit is contained in:
@ -609,7 +609,7 @@ public final class PlatformCommandManager {
|
||||
if (actor == null) {
|
||||
context = globalInjectedValues;
|
||||
} else {
|
||||
context = initializeInjectedValues(args::toString, actor, null);
|
||||
context = initializeInjectedValues(args::toString, actor, null, false);
|
||||
}
|
||||
return parseCommand(args, context);
|
||||
}
|
||||
@ -688,7 +688,7 @@ public final class PlatformCommandManager {
|
||||
}
|
||||
}
|
||||
|
||||
MemoizingValueAccess context = initializeInjectedValues(event::getArguments, actor, event);
|
||||
MemoizingValueAccess context = initializeInjectedValues(event::getArguments, actor, event, false);
|
||||
|
||||
ThrowableSupplier<Throwable> task = () -> commandManager.execute(context, ImmutableList.copyOf(split));
|
||||
|
||||
@ -800,7 +800,7 @@ public final class PlatformCommandManager {
|
||||
getCommandManager(), actor, "//help");
|
||||
}
|
||||
|
||||
private MemoizingValueAccess initializeInjectedValues(Arguments arguments, Actor actor, Event event) {
|
||||
private MemoizingValueAccess initializeInjectedValues(Arguments arguments, Actor actor, Event event, boolean isSuggestions) {
|
||||
InjectedValueStore store = MapBackedValueStore.create();
|
||||
store.injectValue(Key.of(Actor.class), ValueProvider.constant(actor));
|
||||
if (actor instanceof Player) {
|
||||
@ -817,6 +817,7 @@ public final class PlatformCommandManager {
|
||||
localSession.tellVersion(actor);
|
||||
return Optional.of(localSession);
|
||||
});
|
||||
store.injectValue(Key.of(boolean.class), context -> Optional.of(isSuggestions));
|
||||
store.injectValue(Key.of(InjectedValueStore.class), ValueProvider.constant(store));
|
||||
store.injectValue(Key.of(Event.class), ValueProvider.constant(event));
|
||||
return MemoizingValueAccess.wrap(
|
||||
@ -841,7 +842,7 @@ public final class PlatformCommandManager {
|
||||
List<String> argStrings = split.stream()
|
||||
.map(Substring::getSubstring)
|
||||
.collect(Collectors.toList());
|
||||
MemoizingValueAccess access = initializeInjectedValues(() -> arguments, event.getActor(), event);
|
||||
MemoizingValueAccess access = initializeInjectedValues(() -> arguments, event.getActor(), event, true);
|
||||
ImmutableSet<Suggestion> suggestions;
|
||||
try {
|
||||
suggestions = commandManager.getSuggestions(access, argStrings);
|
||||
|
@ -7,7 +7,9 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.converter.ArgumentConverter;
|
||||
import org.enginehub.piston.converter.ConversionResult;
|
||||
import org.enginehub.piston.converter.FailedConversion;
|
||||
import org.enginehub.piston.converter.SuccessfulConversion;
|
||||
import org.enginehub.piston.exception.StopExecutionException;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import org.enginehub.piston.inject.InjectedValueStore;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
@ -97,7 +99,11 @@ public class Bindings {
|
||||
|
||||
@Override
|
||||
public ConversionResult<Object> convert(String s, InjectedValueAccess access) {
|
||||
return SuccessfulConversion.fromSingle(invoke(s, argsFunc, access, method));
|
||||
Object o = invoke(s, argsFunc, access, method);
|
||||
if (o == null) {
|
||||
return FailedConversion.from(new NullPointerException());
|
||||
}
|
||||
return SuccessfulConversion.fromSingle(o);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -118,7 +124,10 @@ public class Bindings {
|
||||
}
|
||||
return method.invoke(this, args);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
if (!(e.getCause() instanceof StopExecutionException)) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user