Scattercommand should use the same editsession for all commands, make it "silent" by default and allow players to see output if wanted.

This commit is contained in:
dordsor21
2021-09-18 17:42:40 +01:00
parent 34301b446a
commit 7d032ba69f
5 changed files with 88 additions and 10 deletions

View File

@ -795,7 +795,8 @@ public final class PlatformCommandManager {
}
Optional<EditSession> editSessionOpt = context.injectedValue(Key.of(EditSession.class));
if (editSessionOpt.isPresent()) {
// Require null CommandEvent#getSession as it means the editsession is being handled somewhere else.
if (editSessionOpt.isPresent() && event.getSession() == null) {
EditSession editSession = editSessionOpt.get();
editSession.flushQueue();
session.remember(editSession);
@ -866,6 +867,14 @@ public final class PlatformCommandManager {
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));
//FAWE start - allow giving editsessions
if (event instanceof CommandEvent) {
EditSession session = ((CommandEvent) event).getSession();
if (session != null) {
store.injectValue(Key.of(EditSession.class), context -> Optional.of(session));
}
}
//FAWE end
return MemoizingValueAccess.wrap(
MergedValueAccess.of(store, globalInjectedValues)
);