use of baritone.api.event.events.TabCompleteEvent in project Spark-Client by Spark-Client-Development.
the class MixinTabCompleter method onRequestCompletions.
@Inject(method = "requestCompletions", at = @At("HEAD"), cancellable = true)
private void onRequestCompletions(String prefix, CallbackInfo ci) {
if (!((Object) this instanceof GuiChat.ChatTabCompleter)) {
return;
}
IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone();
TabCompleteEvent event = new TabCompleteEvent(prefix);
baritone.getGameEventHandler().onPreTabComplete(event);
if (event.isCancelled()) {
ci.cancel();
return;
}
if (event.completions != null) {
ci.cancel();
this.dontComplete = true;
try {
this.requestedCompletions = true;
setCompletions(event.completions);
} finally {
this.dontComplete = false;
}
}
}
use of baritone.api.event.events.TabCompleteEvent in project Spark-Client by Spark-Client-Development.
the class ExampleBaritoneControl method onPreTabComplete.
@Override
public void onPreTabComplete(TabCompleteEvent event) {
if (!settings.prefixControl.getValue()) {
return;
}
String prefix = event.prefix;
String commandPrefix = settings.prefix.getValue();
if (!prefix.startsWith(commandPrefix)) {
return;
}
String msg = prefix.substring(commandPrefix.length());
List<ICommandArgument> args = CommandArguments.from(msg, true);
Stream<String> stream = tabComplete(msg);
if (args.size() == 1) {
stream = stream.map(x -> commandPrefix + x);
}
event.completions = stream.toArray(String[]::new);
}
use of baritone.api.event.events.TabCompleteEvent in project baritone by cabaletta.
the class ExampleBaritoneControl method onPreTabComplete.
@Override
public void onPreTabComplete(TabCompleteEvent event) {
if (!settings.prefixControl.value) {
return;
}
String prefix = event.prefix;
String commandPrefix = settings.prefix.value;
if (!prefix.startsWith(commandPrefix)) {
return;
}
String msg = prefix.substring(commandPrefix.length());
List<ICommandArgument> args = CommandArguments.from(msg, true);
Stream<String> stream = tabComplete(msg);
if (args.size() == 1) {
stream = stream.map(x -> commandPrefix + x);
}
event.completions = stream.toArray(String[]::new);
}
use of baritone.api.event.events.TabCompleteEvent in project baritone by cabaletta.
the class MixinTabCompleter method onRequestCompletions.
@Inject(method = "requestCompletions", at = @At("HEAD"), cancellable = true)
private void onRequestCompletions(String prefix, CallbackInfo ci) {
if (!((Object) this instanceof GuiChat.ChatTabCompleter)) {
return;
}
IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone();
TabCompleteEvent event = new TabCompleteEvent(prefix);
baritone.getGameEventHandler().onPreTabComplete(event);
if (event.isCancelled()) {
ci.cancel();
return;
}
if (event.completions != null) {
ci.cancel();
this.dontComplete = true;
try {
this.requestedCompletions = true;
setCompletions(event.completions);
} finally {
this.dontComplete = false;
}
}
}
Aggregations