use of com.sk89q.worldedit.command.argument.Arguments in project FastAsyncWorldEdit by IntellectualSites.
the class HistorySubCommands method list.
@Command(name = "list", desc = "List your history")
@CommandPermissions("worldedit.history.list")
public void list(Player player, LocalSession session, RollbackDatabase database, Arguments arguments, @Arg(desc = "Player uuid/name") UUID other, @ArgFlag(name = 'p', desc = "Page to view.", def = "") Integer page) {
int index = session.getHistoryIndex();
List<Supplier<? extends ChangeSet>> history = Lists.transform(session.getHistory(), (Function<ChangeSet, Supplier<ChangeSet>>) input -> () -> input);
Location origin = player.getLocation();
String pageCommand = "/" + arguments.get().replaceAll("-p [0-9]+", "").trim();
Reference<PaginationBox> cached = player.getMeta(pageCommand);
PaginationBox pages = cached == null ? null : cached.get();
if (page == null || pages == null) {
pages = list(database, pageCommand, history, origin.toBlockPoint());
page = 1;
}
player.print(pages.create(page));
}
use of com.sk89q.worldedit.command.argument.Arguments in project FastAsyncWorldEdit by IntellectualSites.
the class PlatformCommandManager method initializeInjectedValues.
// FAWE end
// FAWE start - Event & suggestions, make method public
public MemoizingValueAccess initializeInjectedValues(Arguments arguments, Actor actor, Event event, boolean isSuggestions) {
// FAWE end
InjectedValueStore store = MapBackedValueStore.create();
store.injectValue(Key.of(Actor.class), ValueProvider.constant(actor));
if (actor instanceof Player) {
store.injectValue(Key.of(Player.class), ValueProvider.constant((Player) actor));
} else {
store.injectValue(Key.of(Player.class), context -> {
throw new CommandException(Caption.of("worldedit.command.player-only"), ImmutableList.of());
});
}
store.injectValue(Key.of(Arguments.class), ValueProvider.constant(arguments));
store.injectValue(Key.of(LocalSession.class), context -> {
LocalSession localSession = worldEdit.getSessionManager().get(actor);
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));
// 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));
}
use of com.sk89q.worldedit.command.argument.Arguments in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCommands method set.
public BrushSettings set(InjectedValueAccess context, Brush brush, String permission) throws InvalidToolBindException {
Player player = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"));
LocalSession session = player.getSession();
BrushSettings bs = new BrushSettings();
BrushTool tool = session.getBrushTool(player, false);
if (tool != null) {
BrushSettings currentContext = tool.getContext();
if (currentContext != null) {
Brush currentBrush = currentContext.getBrush();
if (currentBrush != null && currentBrush.getClass() == brush.getClass()) {
bs = currentContext;
}
}
}
Arguments arguments = context.injectedValue(Key.of(Arguments.class)).orElse(null);
if (arguments != null) {
String args = arguments.get();
bs.addSetting(BrushSettings.SettingType.BRUSH, args.substring(args.indexOf(' ') + 1));
}
bs.addPermission(permission);
bs.setBrush(brush);
return process(player, arguments, bs);
}
Aggregations