Add explict this checkstyle rule and fix violations

This commit is contained in:
broccolai 2021-01-28 09:30:10 +00:00 committed by Jason
parent a6eb44376c
commit d5259dfbe4
62 changed files with 195 additions and 192 deletions

View file

@ -207,6 +207,10 @@
<module name="TodoComment"/> <module name="TodoComment"/>
<module name="UpperEll"/> <module name="UpperEll"/>
<module name="RequireThis">
<property name="validateOnlyOverlapping" value="false"/>
</module>
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter --> <!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
<module name="SuppressionXpathFilter"> <module name="SuppressionXpathFilter">
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}" <property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}"

View file

@ -123,7 +123,7 @@ public abstract class CommandManager<C> {
final @NonNull CommandRegistrationHandler commandRegistrationHandler final @NonNull CommandRegistrationHandler commandRegistrationHandler
) { ) {
this.commandTree = CommandTree.newTree(this); this.commandTree = CommandTree.newTree(this);
this.commandExecutionCoordinator = commandExecutionCoordinator.apply(commandTree); this.commandExecutionCoordinator = commandExecutionCoordinator.apply(this.commandTree);
this.commandRegistrationHandler = commandRegistrationHandler; this.commandRegistrationHandler = commandRegistrationHandler;
this.commandSuggestionEngine = new DelegatingCommandSuggestionEngineFactory<>(this).create(); this.commandSuggestionEngine = new DelegatingCommandSuggestionEngineFactory<>(this).create();
/* Register service types */ /* Register service types */
@ -374,7 +374,7 @@ public abstract class CommandManager<C> {
final @NonNull Description description, final @NonNull Description description,
final @NonNull CommandMeta meta final @NonNull CommandMeta meta
) { ) {
return commandBuilder(name, aliases, (ArgumentDescription) description, meta); return this.commandBuilder(name, aliases, (ArgumentDescription) description, meta);
} }
/** /**

View file

@ -240,8 +240,8 @@ public final class CommandTree<C> {
if (root.equals(this.internalTree)) { if (root.equals(this.internalTree)) {
return Pair.of(null, new NoSuchCommandException( return Pair.of(null, new NoSuchCommandException(
commandContext.getSender(), commandContext.getSender(),
getChain(root).stream().map(Node::getValue).collect(Collectors.toList()), this.getChain(root).stream().map(Node::getValue).collect(Collectors.toList()),
stringOrEmpty(commandQueue.peek()) this.stringOrEmpty(commandQueue.peek())
)); ));
} }
/* If we couldn't match a child, check if there's a command attached and execute it */ /* If we couldn't match a child, check if there's a command attached and execute it */
@ -476,7 +476,7 @@ public final class CommandTree<C> {
final @NonNull CommandContext<C> context, final @NonNull CommandContext<C> context,
final @NonNull Queue<@NonNull String> commandQueue final @NonNull Queue<@NonNull String> commandQueue
) { ) {
return getSuggestions(context, commandQueue, this.internalTree); return this.getSuggestions(context, commandQueue, this.internalTree);
} }
@SuppressWarnings("MixedMutabilityReturnType") @SuppressWarnings("MixedMutabilityReturnType")
@ -533,7 +533,7 @@ public final class CommandTree<C> {
/* Calculate suggestions for the literal arguments */ /* Calculate suggestions for the literal arguments */
final List<String> suggestions = new LinkedList<>(); final List<String> suggestions = new LinkedList<>();
if (commandQueue.size() <= 1) { if (commandQueue.size() <= 1) {
final String literalValue = stringOrEmpty(commandQueue.peek()); final String literalValue = this.stringOrEmpty(commandQueue.peek());
for (final Node<CommandArgument<C, ?>> argument : staticArguments) { for (final Node<CommandArgument<C, ?>> argument : staticArguments) {
if (this.isPermitted(commandContext.getSender(), argument) != null) { if (this.isPermitted(commandContext.getSender(), argument) != null) {
continue; continue;
@ -658,7 +658,7 @@ public final class CommandTree<C> {
// Fallback: use suggestion provider of argument // Fallback: use suggestion provider of argument
commandContext.setCurrentArgument(child.getValue()); commandContext.setCurrentArgument(child.getValue());
return child.getValue().getSuggestionsProvider().apply(commandContext, stringOrEmpty(commandQueue.peek())); return child.getValue().getSuggestionsProvider().apply(commandContext, this.stringOrEmpty(commandQueue.peek()));
} }
private @NonNull String stringOrEmpty(final @Nullable String string) { private @NonNull String stringOrEmpty(final @Nullable String string) {
@ -873,7 +873,7 @@ public final class CommandTree<C> {
leaves.add(node); leaves.add(node);
} }
} else { } else {
node.children.forEach(child -> leaves.addAll(getLeavesRaw(child))); node.children.forEach(child -> leaves.addAll(this.getLeavesRaw(child)));
} }
return leaves; return leaves;
} }
@ -887,7 +887,7 @@ public final class CommandTree<C> {
leaves.add(node.getValue()); leaves.add(node.getValue());
} }
} else { } else {
node.children.forEach(child -> leaves.addAll(getLeaves(child))); node.children.forEach(child -> leaves.addAll(this.getLeaves(child)));
} }
return leaves; return leaves;
} }
@ -1024,12 +1024,12 @@ public final class CommandTree<C> {
return false; return false;
} }
final Node<?> node = (Node<?>) o; final Node<?> node = (Node<?>) o;
return Objects.equals(getValue(), node.getValue()); return Objects.equals(this.getValue(), node.getValue());
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(getValue()); return Objects.hash(this.getValue());
} }
/** /**
@ -1052,7 +1052,7 @@ public final class CommandTree<C> {
@Override @Override
public String toString() { public String toString() {
return "Node{value=" + value + '}'; return "Node{value=" + this.value + '}';
} }
} }

View file

@ -46,7 +46,7 @@ final class AnnotatedElementAccessor implements AnnotationAccessor {
final @NonNull Class<A> clazz final @NonNull Class<A> clazz
) { ) {
try { try {
return element.getAnnotation(clazz); return this.element.getAnnotation(clazz);
} catch (final NullPointerException exception) { } catch (final NullPointerException exception) {
return null; return null;
} }

View file

@ -43,7 +43,7 @@ final class MultiDelegateAnnotationAccessor implements AnnotationAccessor {
@Override @Override
public <A extends Annotation> @Nullable A annotation(@NonNull final Class<A> clazz) { public <A extends Annotation> @Nullable A annotation(@NonNull final Class<A> clazz) {
A instance = null; A instance = null;
for (final AnnotationAccessor annotationAccessor : accessors) { for (final AnnotationAccessor annotationAccessor : this.accessors) {
instance = annotationAccessor.annotation(clazz); instance = annotationAccessor.annotation(clazz);
if (instance != null) { if (instance != null) {
break; break;
@ -55,7 +55,7 @@ final class MultiDelegateAnnotationAccessor implements AnnotationAccessor {
@Override @Override
public @NonNull Collection<@NonNull Annotation> annotations() { public @NonNull Collection<@NonNull Annotation> annotations() {
final List<Annotation> annotationList = new LinkedList<>(); final List<Annotation> annotationList = new LinkedList<>();
for (final AnnotationAccessor annotationAccessor : accessors) { for (final AnnotationAccessor annotationAccessor : this.accessors) {
annotationList.addAll(annotationAccessor.annotations()); annotationList.addAll(annotationAccessor.annotations());
} }
return Collections.unmodifiableCollection(annotationList); return Collections.unmodifiableCollection(annotationList);

View file

@ -57,7 +57,7 @@ public final class ParameterInjectorRegistry<C> implements InjectionService<C> {
* Create a new parameter injector registry * Create a new parameter injector registry
*/ */
public ParameterInjectorRegistry() { public ParameterInjectorRegistry() {
servicePipeline.registerServiceType(new TypeToken<InjectionService<C>>() { this.servicePipeline.registerServiceType(new TypeToken<InjectionService<C>>() {
}, this); }, this);
} }

View file

@ -462,12 +462,12 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
return false; return false;
} }
final CommandArgument<?, ?> that = (CommandArgument<?, ?>) o; final CommandArgument<?, ?> that = (CommandArgument<?, ?>) o;
return isRequired() == that.isRequired() && Objects.equals(getName(), that.getName()); return this.isRequired() == that.isRequired() && Objects.equals(this.getName(), that.getName());
} }
@Override @Override
public final int hashCode() { public final int hashCode() {
return Objects.hash(isRequired(), getName()); return Objects.hash(this.isRequired(), this.getName());
} }
@Override @Override
@ -693,7 +693,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
*/ */
public @NonNull CommandArgument<@NonNull C, @NonNull T> build() { public @NonNull CommandArgument<@NonNull C, @NonNull T> build() {
if (this.parser == null && this.manager != null) { if (this.parser == null && this.manager != null) {
this.parser = this.manager.getParserRegistry().createParser(valueType, ParserParameters.empty()) this.parser = this.manager.getParserRegistry().createParser(this.valueType, ParserParameters.empty())
.orElse(null); .orElse(null);
} }
if (this.parser == null) { if (this.parser == null) {

View file

@ -285,7 +285,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
} }
} }
commandContext.store(FLAG_META_KEY, ""); commandContext.store(FLAG_META_KEY, "");
return suggestions(commandContext, input); return this.suggestions(commandContext, input);
} }
/** /**
@ -486,7 +486,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
* @return String value * @return String value
*/ */
public String getInput() { public String getInput() {
return input; return this.input;
} }
} }

View file

@ -79,13 +79,13 @@ public class ParserParameter<T> {
return false; return false;
} }
final ParserParameter<?> that = (ParserParameter<?>) o; final ParserParameter<?> that = (ParserParameter<?>) o;
return Objects.equals(key, that.key) return Objects.equals(this.key, that.key)
&& Objects.equals(expectedType, that.expectedType); && Objects.equals(this.expectedType, that.expectedType);
} }
@Override @Override
public final int hashCode() { public final int hashCode() {
return Objects.hash(key, expectedType); return Objects.hash(this.key, this.expectedType);
} }
} }

View file

@ -96,7 +96,7 @@ public final class RegexPreprocessor<C> implements BiFunction<@NonNull CommandCo
context context
)); ));
} }
if (predicate.test(head)) { if (this.predicate.test(head)) {
return ArgumentParseResult.success(true); return ArgumentParseResult.success(true);
} }
return ArgumentParseResult.failure( return ArgumentParseResult.failure(

View file

@ -184,7 +184,7 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
} }
inputQueue.remove(); inputQueue.remove();
if (!liberal) { if (!this.liberal) {
if (input.equalsIgnoreCase("true")) { if (input.equalsIgnoreCase("true")) {
return ArgumentParseResult.success(true); return ArgumentParseResult.success(true);
} }
@ -214,7 +214,7 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
final @NonNull CommandContext<C> commandContext, final @NonNull CommandContext<C> commandContext,
final @NonNull String input final @NonNull String input
) { ) {
if (!liberal) { if (!this.liberal) {
return Arrays.asList("TRUE", "FALSE"); return Arrays.asList("TRUE", "FALSE");
} }
@ -267,7 +267,7 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
* @return String value * @return String value
*/ */
public String getInput() { public String getInput() {
return input; return this.input;
} }
/** /**
@ -276,7 +276,7 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
* @return Liberal value * @return Liberal value
*/ */
public boolean isLiberal() { public boolean isLiberal() {
return liberal; return this.liberal;
} }
} }

View file

@ -183,7 +183,7 @@ public final class CharArgument<C> extends CommandArgument<C, Character> {
* @return Input value * @return Input value
*/ */
public @NonNull String getInput() { public @NonNull String getInput() {
return input; return this.input;
} }
} }

View file

@ -190,7 +190,7 @@ public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
* @return String value * @return String value
*/ */
public String getInput() { public String getInput() {
return input; return this.input;
} }
} }

View file

@ -57,7 +57,7 @@ public final class Caption {
return false; return false;
} }
final Caption caption = (Caption) o; final Caption caption = (Caption) o;
return Objects.equals(key, caption.key); return Objects.equals(this.key, caption.key);
} }
/** /**
@ -71,7 +71,7 @@ public final class Caption {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(key); return Objects.hash(this.key);
} }
@Override @Override

View file

@ -92,9 +92,9 @@ public final class AmbiguousNodeException extends IllegalStateException {
@Override @Override
public String getMessage() { public String getMessage() {
final StringBuilder stringBuilder = new StringBuilder("Ambiguous Node: ") final StringBuilder stringBuilder = new StringBuilder("Ambiguous Node: ")
.append(ambiguousNode.getName()) .append(this.ambiguousNode.getName())
.append(" cannot be added as a child to ") .append(" cannot be added as a child to ")
.append(parentNode == null ? "<root>" : parentNode.getName()) .append(this.parentNode == null ? "<root>" : this.parentNode.getName())
.append(" (All children: "); .append(" (All children: ");
final Iterator<CommandArgument<?, ?>> childIterator = this.children.iterator(); final Iterator<CommandArgument<?, ?>> childIterator = this.children.iterator();
while (childIterator.hasNext()) { while (childIterator.hasNext()) {

View file

@ -88,7 +88,7 @@ public final class InvalidCommandSenderException extends CommandParseException {
return String.format( return String.format(
"%s is not allowed to execute that command. Must be of type %s", "%s is not allowed to execute that command. Must be of type %s",
getCommandSender().getClass().getSimpleName(), getCommandSender().getClass().getSimpleName(),
requiredSender.getSimpleName() this.requiredSender.getSimpleName()
); );
} }

View file

@ -80,7 +80,7 @@ public final class CommandPostprocessingContext<C> {
return false; return false;
} }
final CommandPostprocessingContext<?> that = (CommandPostprocessingContext<?>) o; final CommandPostprocessingContext<?> that = (CommandPostprocessingContext<?>) o;
return Objects.equals(getCommandContext(), that.getCommandContext()) return Objects.equals(this.getCommandContext(), that.getCommandContext())
&& Objects.equals(this.getCommand(), that.getCommand()); && Objects.equals(this.getCommand(), that.getCommand());
} }

View file

@ -81,13 +81,13 @@ public final class CommandPreprocessingContext<C> {
return false; return false;
} }
final CommandPreprocessingContext<?> that = (CommandPreprocessingContext<?>) o; final CommandPreprocessingContext<?> that = (CommandPreprocessingContext<?>) o;
return Objects.equals(getCommandContext(), that.getCommandContext()) return Objects.equals(this.getCommandContext(), that.getCommandContext())
&& Objects.equals(getInputQueue(), that.getInputQueue()); && Objects.equals(this.getInputQueue(), that.getInputQueue());
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(getCommandContext(), getInputQueue()); return Objects.hash(this.getCommandContext(), this.getInputQueue());
} }
} }

View file

@ -182,9 +182,9 @@ public class CommandConfirmationManager<C> {
return; return;
} }
/* Add it to the "queue" */ /* Add it to the "queue" */
addPending(context); CommandConfirmationManager.this.addPending(context);
/* Notify the consumer that a confirmation is required */ /* Notify the consumer that a confirmation is required */
notifyConsumer(context); CommandConfirmationManager.this.notifyConsumer(context);
/* Interrupt */ /* Interrupt */
ConsumerService.interrupt(); ConsumerService.interrupt();
} }

View file

@ -56,12 +56,12 @@ public final class CommandInputTokenizer {
* @return Linked list containing the tokenized input * @return Linked list containing the tokenized input
*/ */
public @NonNull LinkedList<@NonNull String> tokenize() { public @NonNull LinkedList<@NonNull String> tokenize() {
final StringTokenizer stringTokenizer = stringTokenizerFactory.createStringTokenizer(); final StringTokenizer stringTokenizer = this.stringTokenizerFactory.createStringTokenizer();
final LinkedList<String> tokens = new LinkedList<>(); final LinkedList<String> tokens = new LinkedList<>();
while (stringTokenizer.hasMoreElements()) { while (stringTokenizer.hasMoreElements()) {
tokens.add(stringTokenizer.nextToken()); tokens.add(stringTokenizer.nextToken());
} }
if (input.endsWith(DELIMITER)) { if (this.input.endsWith(DELIMITER)) {
tokens.add(EMPTY); tokens.add(EMPTY);
} }
return tokens; return tokens;
@ -74,7 +74,7 @@ public final class CommandInputTokenizer {
private final class StringTokenizerFactory { private final class StringTokenizerFactory {
private @NonNull StringTokenizer createStringTokenizer() { private @NonNull StringTokenizer createStringTokenizer() {
return new StringTokenizer(input, DELIMITER); return new StringTokenizer(CommandInputTokenizer.this.input, DELIMITER);
} }
} }

View file

@ -76,7 +76,7 @@ public final class SimpleCloudKey<@NonNull T> implements CloudKey<T> {
@Override @Override
public @NonNull String getName() { public @NonNull String getName() {
return name; return this.name;
} }
@Override @Override
@ -93,12 +93,12 @@ public final class SimpleCloudKey<@NonNull T> implements CloudKey<T> {
return false; return false;
} }
final SimpleCloudKey<?> key = (SimpleCloudKey<?>) o; final SimpleCloudKey<?> key = (SimpleCloudKey<?>) o;
return name.equals(key.name); return this.name.equals(key.name);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(name); return Objects.hash(this.name);
} }
@Override @Override

View file

@ -97,12 +97,12 @@ public final class Permission implements CommandPermission {
return false; return false;
} }
final Permission that = (Permission) o; final Permission that = (Permission) o;
return Objects.equals(getPermission(), that.getPermission()); return Objects.equals(this.getPermission(), that.getPermission());
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(getPermission()); return Objects.hash(this.getPermission());
} }
} }

View file

@ -89,13 +89,13 @@ public class Pair<U, V> implements Tuple {
return false; return false;
} }
final Pair<?, ?> pair = (Pair<?, ?>) o; final Pair<?, ?> pair = (Pair<?, ?>) o;
return Objects.equals(getFirst(), pair.getFirst()) return Objects.equals(this.getFirst(), pair.getFirst())
&& Objects.equals(getSecond(), pair.getSecond()); && Objects.equals(this.getSecond(), pair.getSecond());
} }
@Override @Override
public final int hashCode() { public final int hashCode() {
return Objects.hash(getFirst(), getSecond()); return Objects.hash(this.getFirst(), this.getSecond());
} }
@Override @Override

View file

@ -121,15 +121,15 @@ public class Quartet<U, V, W, X> implements Tuple {
return false; return false;
} }
final Quartet<?, ?, ?, ?> quartet = (Quartet<?, ?, ?, ?>) o; final Quartet<?, ?, ?, ?> quartet = (Quartet<?, ?, ?, ?>) o;
return Objects.equals(getFirst(), quartet.getFirst()) return Objects.equals(this.getFirst(), quartet.getFirst())
&& Objects.equals(getSecond(), quartet.getSecond()) && Objects.equals(this.getSecond(), quartet.getSecond())
&& Objects.equals(getThird(), quartet.getThird()) && Objects.equals(this.getThird(), quartet.getThird())
&& Objects.equals(getFourth(), quartet.getFourth()); && Objects.equals(this.getFourth(), quartet.getFourth());
} }
@Override @Override
public final int hashCode() { public final int hashCode() {
return Objects.hash(getFirst(), getSecond(), getThird(), getFourth()); return Objects.hash(this.getFirst(), this.getSecond(), this.getThird(), this.getFourth());
} }
@Override @Override

View file

@ -137,16 +137,16 @@ public class Quintet<U, V, W, X, Y> implements Tuple {
return false; return false;
} }
final Quintet<?, ?, ?, ?, ?> quintet = (Quintet<?, ?, ?, ?, ?>) o; final Quintet<?, ?, ?, ?, ?> quintet = (Quintet<?, ?, ?, ?, ?>) o;
return Objects.equals(getFirst(), quintet.getFirst()) return Objects.equals(this.getFirst(), quintet.getFirst())
&& Objects.equals(getSecond(), quintet.getSecond()) && Objects.equals(this.getSecond(), quintet.getSecond())
&& Objects.equals(getThird(), quintet.getThird()) && Objects.equals(this.getThird(), quintet.getThird())
&& Objects.equals(getFourth(), quintet.getFourth()) && Objects.equals(this.getFourth(), quintet.getFourth())
&& Objects.equals(getFifth(), quintet.getFifth()); && Objects.equals(this.getFifth(), quintet.getFifth());
} }
@Override @Override
public final int hashCode() { public final int hashCode() {
return Objects.hash(getFirst(), getSecond(), getThird(), getFourth(), getFifth()); return Objects.hash(this.getFirst(), this.getSecond(), this.getThird(), this.getFourth(), this.getFifth());
} }
@Override @Override

View file

@ -153,17 +153,17 @@ public class Sextet<U, V, W, X, Y, Z> implements Tuple {
return false; return false;
} }
final Sextet<?, ?, ?, ?, ?, ?> sextet = (Sextet<?, ?, ?, ?, ?, ?>) o; final Sextet<?, ?, ?, ?, ?, ?> sextet = (Sextet<?, ?, ?, ?, ?, ?>) o;
return Objects.equals(getFirst(), sextet.getFirst()) return Objects.equals(this.getFirst(), sextet.getFirst())
&& Objects.equals(getSecond(), sextet.getSecond()) && Objects.equals(this.getSecond(), sextet.getSecond())
&& Objects.equals(getThird(), sextet.getThird()) && Objects.equals(this.getThird(), sextet.getThird())
&& Objects.equals(getFourth(), sextet.getFourth()) && Objects.equals(this.getFourth(), sextet.getFourth())
&& Objects.equals(getFifth(), sextet.getFifth()) && Objects.equals(this.getFifth(), sextet.getFifth())
&& Objects.equals(getSixth(), sextet.getSixth()); && Objects.equals(this.getSixth(), sextet.getSixth());
} }
@Override @Override
public final int hashCode() { public final int hashCode() {
return Objects.hash(getFirst(), getSecond(), getThird(), getFourth(), getFifth(), getSixth()); return Objects.hash(this.getFirst(), this.getSecond(), this.getThird(), this.getFourth(), this.getFifth(), this.getSixth());
} }
@Override @Override

View file

@ -105,14 +105,14 @@ public class Triplet<U, V, W> implements Tuple {
return false; return false;
} }
final Triplet<?, ?, ?> triplet = (Triplet<?, ?, ?>) o; final Triplet<?, ?, ?> triplet = (Triplet<?, ?, ?>) o;
return Objects.equals(getFirst(), triplet.getFirst()) return Objects.equals(this.getFirst(), triplet.getFirst())
&& Objects.equals(getSecond(), triplet.getSecond()) && Objects.equals(this.getSecond(), triplet.getSecond())
&& Objects.equals(getThird(), triplet.getThird()); && Objects.equals(this.getThird(), triplet.getThird());
} }
@Override @Override
public final int hashCode() { public final int hashCode() {
return Objects.hash(getFirst(), getSecond(), getThird()); return Objects.hash(this.getFirst(), this.getSecond(), this.getThird());
} }
@Override @Override

View file

@ -75,24 +75,24 @@ public class JavacordCommand<C> implements MessageCreateListener {
commandSender = new JavacordCommandSender(event); commandSender = new JavacordCommandSender(event);
} }
C sender = manager.getCommandSenderMapper().apply(commandSender); C sender = this.manager.getCommandSenderMapper().apply(commandSender);
String messageContent = event.getMessageContent(); String messageContent = event.getMessageContent();
String commandPrefix = manager.getCommandPrefix(sender); String commandPrefix = this.manager.getCommandPrefix(sender);
if (!messageContent.startsWith(commandPrefix)) { if (!messageContent.startsWith(commandPrefix)) {
return; return;
} }
messageContent = messageContent.replaceFirst(commandPrefix, ""); messageContent = messageContent.replaceFirst(commandPrefix, "");
final String finalContent = messageContent; final String finalContent = messageContent;
if (((StaticArgument<C>) command).getAliases() if (((StaticArgument<C>) this.command).getAliases()
.stream() .stream()
.map(String::toLowerCase) .map(String::toLowerCase)
.noneMatch(commandAlias -> finalContent.toLowerCase().startsWith(commandAlias))) { .noneMatch(commandAlias -> finalContent.toLowerCase().startsWith(commandAlias))) {
return; return;
} }
manager.executeCommand(sender, finalContent) this.manager.executeCommand(sender, finalContent)
.whenComplete((commandResult, throwable) -> { .whenComplete((commandResult, throwable) -> {
if (throwable == null) { if (throwable == null) {
return; return;
@ -109,7 +109,7 @@ public class JavacordCommand<C> implements MessageCreateListener {
} }
if (throwable instanceof InvalidSyntaxException) { if (throwable instanceof InvalidSyntaxException) {
manager.handleException( this.manager.handleException(
sender, sender,
InvalidSyntaxException.class, InvalidSyntaxException.class,
(InvalidSyntaxException) throwable, (InvalidSyntaxException) throwable,
@ -123,7 +123,7 @@ public class JavacordCommand<C> implements MessageCreateListener {
} }
if (throwable instanceof InvalidCommandSenderException) { if (throwable instanceof InvalidCommandSenderException) {
manager.handleException( this.manager.handleException(
sender, sender,
InvalidCommandSenderException.class, InvalidCommandSenderException.class,
(InvalidCommandSenderException) throwable, (InvalidCommandSenderException) throwable,
@ -134,7 +134,7 @@ public class JavacordCommand<C> implements MessageCreateListener {
} }
if (throwable instanceof NoPermissionException) { if (throwable instanceof NoPermissionException) {
manager.handleException( this.manager.handleException(
sender, sender,
NoPermissionException.class, NoPermissionException.class,
(NoPermissionException) throwable, (NoPermissionException) throwable,
@ -145,7 +145,7 @@ public class JavacordCommand<C> implements MessageCreateListener {
} }
if (throwable instanceof ArgumentParseException) { if (throwable instanceof ArgumentParseException) {
manager.handleException( this.manager.handleException(
sender, sender,
ArgumentParseException.class, ArgumentParseException.class,
(ArgumentParseException) throwable, (ArgumentParseException) throwable,
@ -157,7 +157,7 @@ public class JavacordCommand<C> implements MessageCreateListener {
} }
if (throwable instanceof CommandExecutionException) { if (throwable instanceof CommandExecutionException) {
manager.handleException( this.manager.handleException(
sender, sender,
CommandExecutionException.class, CommandExecutionException.class,
(CommandExecutionException) throwable, (CommandExecutionException) throwable,

View file

@ -104,7 +104,7 @@ public class JavacordCommandSender {
*/ */
@NonNull @NonNull
public CompletableFuture<Message> sendErrorMessage(final @Nullable String message) { public CompletableFuture<Message> sendErrorMessage(final @Nullable String message) {
return sendMessage(":x: " + message); return this.sendMessage(":x: " + message);
} }
/** /**
@ -115,7 +115,7 @@ public class JavacordCommandSender {
*/ */
@NonNull @NonNull
public CompletableFuture<Message> sendSuccessMessage(final @Nullable String message) { public CompletableFuture<Message> sendSuccessMessage(final @Nullable String message) {
return sendMessage(":white_check_mark: " + message); return this.sendMessage(":white_check_mark: " + message);
} }
} }

View file

@ -77,7 +77,7 @@ public class JDACommandListener<C> extends ListenerAdapter {
content = content.substring(prefix.length()); content = content.substring(prefix.length());
commandManager.executeCommand(sender, content) this.commandManager.executeCommand(sender, content)
.whenComplete((commandResult, throwable) -> { .whenComplete((commandResult, throwable) -> {
if (throwable == null) { if (throwable == null) {
return; return;

View file

@ -126,7 +126,7 @@ public class JDACommandManager<C> extends CommandManager<C> {
* @return JDA instance * @return JDA instance
*/ */
public final @NonNull JDA getJDA() { public final @NonNull JDA getJDA() {
return jda; return this.jda;
} }
/** /**

View file

@ -96,7 +96,7 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
* @return List of Modes * @return List of Modes
*/ */
public @NotNull Set<ParserMode> getModes() { public @NotNull Set<ParserMode> getModes() {
return modes; return this.modes;
} }
@ -133,7 +133,7 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
*/ */
@Override @Override
public @NonNull ChannelArgument<C> build() { public @NonNull ChannelArgument<C> build() {
return new ChannelArgument<>(this.isRequired(), this.getName(), modes); return new ChannelArgument<>(this.isRequired(), this.getName(), this.modes);
} }
} }
@ -183,7 +183,7 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
return ArgumentParseResult.failure(new IllegalArgumentException("Channel arguments can only be parsed in guilds")); return ArgumentParseResult.failure(new IllegalArgumentException("Channel arguments can only be parsed in guilds"));
} }
if (modes.contains(ParserMode.MENTION)) { if (this.modes.contains(ParserMode.MENTION)) {
if (input.startsWith("<#") && input.endsWith(">")) { if (input.startsWith("<#") && input.endsWith(">")) {
final String id = input.substring(2, input.length() - 1); final String id = input.substring(2, input.length() - 1);
@ -201,7 +201,7 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
} }
} }
if (modes.contains(ParserMode.ID)) { if (this.modes.contains(ParserMode.ID)) {
try { try {
final ArgumentParseResult<MessageChannel> result = this.channelFromId(event, input, input); final ArgumentParseResult<MessageChannel> result = this.channelFromId(event, input, input);
inputQueue.remove(); inputQueue.remove();
@ -211,7 +211,7 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
} }
} }
if (modes.contains(ParserMode.NAME)) { if (this.modes.contains(ParserMode.NAME)) {
final List<TextChannel> channels = event.getGuild().getTextChannelsByName(input, true); final List<TextChannel> channels = event.getGuild().getTextChannelsByName(input, true);
if (channels.size() == 0) { if (channels.size() == 0) {
@ -271,7 +271,7 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
* @return users input * @return users input
*/ */
public final @NonNull String getInput() { public final @NonNull String getInput() {
return input; return this.input;
} }
} }

View file

@ -96,7 +96,7 @@ public final class RoleArgument<C> extends CommandArgument<C, Role> {
* @return List of Modes * @return List of Modes
*/ */
public @NotNull Set<ParserMode> getModes() { public @NotNull Set<ParserMode> getModes() {
return modes; return this.modes;
} }
@ -133,7 +133,7 @@ public final class RoleArgument<C> extends CommandArgument<C, Role> {
*/ */
@Override @Override
public @NonNull RoleArgument<C> build() { public @NonNull RoleArgument<C> build() {
return new RoleArgument<>(this.isRequired(), this.getName(), modes); return new RoleArgument<>(this.isRequired(), this.getName(), this.modes);
} }
} }
@ -183,7 +183,7 @@ public final class RoleArgument<C> extends CommandArgument<C, Role> {
return ArgumentParseResult.failure(new IllegalArgumentException("Role arguments can only be parsed in guilds")); return ArgumentParseResult.failure(new IllegalArgumentException("Role arguments can only be parsed in guilds"));
} }
if (modes.contains(ParserMode.MENTION)) { if (this.modes.contains(ParserMode.MENTION)) {
if (input.startsWith("<@&") && input.endsWith(">")) { if (input.startsWith("<@&") && input.endsWith(">")) {
final String id = input.substring(3, input.length() - 1); final String id = input.substring(3, input.length() - 1);
@ -201,7 +201,7 @@ public final class RoleArgument<C> extends CommandArgument<C, Role> {
} }
} }
if (modes.contains(ParserMode.ID)) { if (this.modes.contains(ParserMode.ID)) {
try { try {
final ArgumentParseResult<Role> result = this.roleFromId(event, input, input); final ArgumentParseResult<Role> result = this.roleFromId(event, input, input);
inputQueue.remove(); inputQueue.remove();
@ -211,7 +211,7 @@ public final class RoleArgument<C> extends CommandArgument<C, Role> {
} }
} }
if (modes.contains(ParserMode.NAME)) { if (this.modes.contains(ParserMode.NAME)) {
final List<Role> roles = event.getGuild().getRolesByName(input, true); final List<Role> roles = event.getGuild().getRolesByName(input, true);
if (roles.size() == 0) { if (roles.size() == 0) {
@ -271,7 +271,7 @@ public final class RoleArgument<C> extends CommandArgument<C, Role> {
* @return users input * @return users input
*/ */
public final @NonNull String getInput() { public final @NonNull String getInput() {
return input; return this.input;
} }
} }

View file

@ -102,7 +102,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
* @return List of Modes * @return List of Modes
*/ */
public @NotNull Set<ParserMode> getModes() { public @NotNull Set<ParserMode> getModes() {
return modes; return this.modes;
} }
@ -167,7 +167,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
*/ */
@Override @Override
public @NonNull UserArgument<C> build() { public @NonNull UserArgument<C> build() {
return new UserArgument<>(this.isRequired(), this.getName(), modes, isolationLevel); return new UserArgument<>(this.isRequired(), this.getName(), this.modes, this.isolationLevel);
} }
} }
@ -228,7 +228,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
final MessageReceivedEvent event = commandContext.get("MessageReceivedEvent"); final MessageReceivedEvent event = commandContext.get("MessageReceivedEvent");
Exception exception = null; Exception exception = null;
if (modes.contains(ParserMode.MENTION)) { if (this.modes.contains(ParserMode.MENTION)) {
if (input.startsWith("<@") && input.endsWith(">")) { if (input.startsWith("<@") && input.endsWith(">")) {
final String id; final String id;
if (input.startsWith("<@!")) { if (input.startsWith("<@!")) {
@ -251,7 +251,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
} }
} }
if (modes.contains(ParserMode.ID)) { if (this.modes.contains(ParserMode.ID)) {
try { try {
final ArgumentParseResult<User> result = this.userFromId(event, input, input); final ArgumentParseResult<User> result = this.userFromId(event, input, input);
inputQueue.remove(); inputQueue.remove();
@ -261,10 +261,10 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
} }
} }
if (modes.contains(ParserMode.NAME)) { if (this.modes.contains(ParserMode.NAME)) {
final List<User> users; final List<User> users;
if (isolationLevel == Isolation.GLOBAL) { if (this.isolationLevel == Isolation.GLOBAL) {
users = event.getJDA().getUsersByName(input, true); users = event.getJDA().getUsersByName(input, true);
} else if (event.isFromGuild()) { } else if (event.isFromGuild()) {
users = event.getGuild().getMembersByEffectiveName(input, true) users = event.getGuild().getMembersByEffectiveName(input, true)
@ -302,7 +302,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
) )
throws UserNotFoundParseException, NumberFormatException { throws UserNotFoundParseException, NumberFormatException {
final User user; final User user;
if (isolationLevel == Isolation.GLOBAL) { if (this.isolationLevel == Isolation.GLOBAL) {
user = event.getJDA().getUserById(id); user = event.getJDA().getUserById(id);
} else if (event.isFromGuild()) { } else if (event.isFromGuild()) {
Member member = event.getGuild().getMemberById(id); Member member = event.getGuild().getMemberById(id);
@ -344,7 +344,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
* @return Users input * @return Users input
*/ */
public final @NonNull String getInput() { public final @NonNull String getInput() {
return input; return this.input;
} }
} }

View file

@ -54,7 +54,7 @@ final class CloudListenerAdapter<C> extends ListenerAdapter {
return; return;
} }
final C sender = this.manager.getUserMapper().apply(event.getUser()); final C sender = this.manager.getUserMapper().apply(event.getUser());
manager.executeCommand(sender, message.substring(this.manager.getCommandPrefix().length())) this.manager.executeCommand(sender, message.substring(this.manager.getCommandPrefix().length()))
.whenComplete((commandResult, throwable) -> { .whenComplete((commandResult, throwable) -> {
if (throwable == null) { if (throwable == null) {
return; return;

View file

@ -488,7 +488,7 @@ public final class CloudBrigadierManager<C, S> {
for (final CommandTree.Node<CommandArgument<C, ?>> node : root.getChildren()) { for (final CommandTree.Node<CommandArgument<C, ?>> node : root.getChildren()) {
argumentBuilders[parsers.length - 1] argumentBuilders[parsers.length - 1]
.then(constructCommandNode(forceExecutor, node, permissionChecker, executor, suggestionProvider)); .then(this.constructCommandNode(forceExecutor, node, permissionChecker, executor, suggestionProvider));
} }
return argumentBuilders[0]; return argumentBuilders[0];
@ -536,7 +536,7 @@ public final class CloudBrigadierManager<C, S> {
argumentBuilder.executes(executor); argumentBuilder.executes(executor);
} }
for (final CommandTree.Node<CommandArgument<C, ?>> node : root.getChildren()) { for (final CommandTree.Node<CommandArgument<C, ?>> node : root.getChildren()) {
argumentBuilder.then(constructCommandNode(forceExecutor, node, permissionChecker, executor, suggestionProvider)); argumentBuilder.then(this.constructCommandNode(forceExecutor, node, permissionChecker, executor, suggestionProvider));
} }
return argumentBuilder; return argumentBuilder;
} }

View file

@ -72,7 +72,7 @@ public final class BukkitBrigadierMapper<C> {
/* Detect Minecraft Version Metadata */ /* Detect Minecraft Version Metadata */
final String version = Bukkit.getServer().getClass().getPackage().getName(); final String version = Bukkit.getServer().getClass().getPackage().getName();
this.nmsVersion = version.substring(version.lastIndexOf(".") + 1); this.nmsVersion = version.substring(version.lastIndexOf(".") + 1);
final int majorMinecraftVersion = Integer.parseInt(nmsVersion.split("_")[1]); final int majorMinecraftVersion = Integer.parseInt(this.nmsVersion.split("_")[1]);
try { try {
/* UUID nms argument is a 1.16+ feature */ /* UUID nms argument is a 1.16+ feature */

View file

@ -52,9 +52,9 @@ final class BukkitCommandPreprocessor<C> implements CommandPreprocessor<C> {
*/ */
@Override @Override
public void accept(final @NonNull CommandPreprocessingContext<C> context) { public void accept(final @NonNull CommandPreprocessingContext<C> context) {
context.getCommandContext().store("BukkitCommandSender", mgr.getBackwardsCommandSenderMapper().apply( context.getCommandContext().store("BukkitCommandSender", this.mgr.getBackwardsCommandSenderMapper().apply(
context.getCommandContext().getSender())); context.getCommandContext().getSender()));
context.getCommandContext().store("CloudBukkitCapabilities", mgr.queryCapabilities()); context.getCommandContext().store("CloudBukkitCapabilities", this.mgr.queryCapabilities());
} }
} }

View file

@ -84,12 +84,12 @@ public abstract class BukkitCommandSender {
return false; return false;
} }
final BukkitCommandSender that = (BukkitCommandSender) o; final BukkitCommandSender that = (BukkitCommandSender) o;
return Objects.equal(internalSender, that.internalSender); return Objects.equal(this.internalSender, that.internalSender);
} }
@Override @Override
public final int hashCode() { public final int hashCode() {
return Objects.hashCode(internalSender); return Objects.hashCode(this.internalSender);
} }
/** /**

View file

@ -64,7 +64,7 @@ public class BukkitPluginRegistrationHandler<C> implements CommandRegistrationHa
final Field knownCommands = SimpleCommandMap.class.getDeclaredField("knownCommands"); final Field knownCommands = SimpleCommandMap.class.getDeclaredField("knownCommands");
knownCommands.setAccessible(true); knownCommands.setAccessible(true);
@SuppressWarnings("unchecked") final Map<String, org.bukkit.command.Command> bukkitCommands = @SuppressWarnings("unchecked") final Map<String, org.bukkit.command.Command> bukkitCommands =
(Map<String, org.bukkit.command.Command>) knownCommands.get(commandMap); (Map<String, org.bukkit.command.Command>) knownCommands.get(this.commandMap);
this.bukkitCommands = bukkitCommands; this.bukkitCommands = bukkitCommands;
this.bukkitCommandManager = bukkitCommandManager; this.bukkitCommandManager = bukkitCommandManager;
Bukkit.getHelpMap().registerHelpTopicFactory(BukkitCommand.class, GenericCommandHelpTopic::new); Bukkit.getHelpMap().registerHelpTopicFactory(BukkitCommand.class, GenericCommandHelpTopic::new);

View file

@ -60,7 +60,7 @@ class CloudCommodoreManager<C> extends BukkitPluginRegistrationHandler<C> {
)); ));
this.brigadierManager.brigadierSenderMapper( this.brigadierManager.brigadierSenderMapper(
sender -> this.commandManager.getCommandSenderMapper().apply( sender -> this.commandManager.getCommandSenderMapper().apply(
commodore.getBukkitSender(sender) this.commodore.getBukkitSender(sender)
) )
); );
new BukkitBrigadierMapper<>(this.commandManager, this.brigadierManager); new BukkitBrigadierMapper<>(this.commandManager, this.brigadierManager);

View file

@ -51,7 +51,7 @@ public class MultiplePlayerSelector extends MultipleEntitySelector {
if (e.getType() != EntityType.PLAYER) { if (e.getType() != EntityType.PLAYER) {
throw new IllegalArgumentException("Non-players selected in player selector."); throw new IllegalArgumentException("Non-players selected in player selector.");
} else { } else {
players.add((Player) e); this.players.add((Player) e);
} }
}); });
} }

View file

@ -219,7 +219,7 @@ public final class OfflinePlayerArgument<C> extends CommandArgument<C, OfflinePl
* @return String value * @return String value
*/ */
public @NonNull String getInput() { public @NonNull String getInput() {
return input; return this.input;
} }
} }

View file

@ -211,7 +211,7 @@ public final class PlayerArgument<C> extends CommandArgument<C, Player> {
* @return String value * @return String value
*/ */
public @NonNull String getInput() { public @NonNull String getInput() {
return input; return this.input;
} }
} }

View file

@ -86,13 +86,13 @@ public final class LocationCoordinate {
return false; return false;
} }
final LocationCoordinate that = (LocationCoordinate) o; final LocationCoordinate that = (LocationCoordinate) o;
return Double.compare(that.coordinate, coordinate) == 0 return Double.compare(that.coordinate, this.coordinate) == 0
&& type == that.type; && this.type == that.type;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(type, coordinate); return Objects.hash(this.type, this.coordinate);
} }
@Override @Override

View file

@ -69,7 +69,7 @@ public final class SelectorParseException extends ParserException {
* @return String value * @return String value
*/ */
public @NonNull String getInput() { public @NonNull String getInput() {
return input; return this.input;
} }
/** /**

View file

@ -49,7 +49,7 @@ final class BungeeCommandPreprocessor<C> implements CommandPreprocessor<C> {
@Override @Override
public void accept(final @NonNull CommandPreprocessingContext<C> context) { public void accept(final @NonNull CommandPreprocessingContext<C> context) {
context.getCommandContext().store(BungeeContextKeys.PROXY_SERVER_KEY, mgr.getOwningPlugin().getProxy()); context.getCommandContext().store(BungeeContextKeys.PROXY_SERVER_KEY, this.mgr.getOwningPlugin().getProxy());
} }
} }

View file

@ -132,7 +132,7 @@ final class CloudburstCommand<C> extends PluginCommand<Plugin> {
CommandExecutionException.class, CommandExecutionException.class,
(CommandExecutionException) throwable, (c, e) -> { (CommandExecutionException) throwable, (c, e) -> {
commandSender.sendMessage(MESSAGE_INTERNAL_ERROR); commandSender.sendMessage(MESSAGE_INTERNAL_ERROR);
manager.getOwningPlugin().getLogger().error( this.manager.getOwningPlugin().getLogger().error(
"Exception executing command handler", "Exception executing command handler",
finalThrowable.getCause() finalThrowable.getCause()
); );
@ -140,7 +140,7 @@ final class CloudburstCommand<C> extends PluginCommand<Plugin> {
); );
} else { } else {
commandSender.sendMessage(MESSAGE_INTERNAL_ERROR); commandSender.sendMessage(MESSAGE_INTERNAL_ERROR);
manager.getOwningPlugin().getLogger().error( this.manager.getOwningPlugin().getLogger().error(
"An unhandled exception was thrown during command execution", "An unhandled exception was thrown during command execution",
throwable throwable
); );

View file

@ -57,7 +57,7 @@ final class Pagination<T> {
) { ) {
final int pages = (int) Math.ceil(content.size() / (itemsPerPage * 1.00)); final int pages = (int) Math.ceil(content.size() / (itemsPerPage * 1.00));
if (page < 1 || page > pages) { if (page < 1 || page > pages) {
return Collections.singletonList(outOfRangeRenderer.apply(page, pages)); return Collections.singletonList(this.outOfRangeRenderer.apply(page, pages));
} }
final List<Component> renderedContent = new ArrayList<>(this.headerRenderer.apply(page, pages)); final List<Component> renderedContent = new ArrayList<>(this.headerRenderer.apply(page, pages));

View file

@ -51,7 +51,7 @@ final class VelocityCommandPreprocessor<C> implements CommandPreprocessor<C> {
public void accept(final @NonNull CommandPreprocessingContext<C> context) { public void accept(final @NonNull CommandPreprocessingContext<C> context) {
context.getCommandContext().store( context.getCommandContext().store(
VelocityContextKeys.PROXY_SERVER_KEY, VelocityContextKeys.PROXY_SERVER_KEY,
mgr.getProxyServer() this.mgr.getProxyServer()
); );
} }

View file

@ -71,7 +71,7 @@ final class VelocityPluginRegistrationHandler<C> implements CommandRegistrationH
p p
), ),
true, true,
new VelocityExecutor<>(manager) new VelocityExecutor<>(this.manager)
) )
); );
final CommandMeta commandMeta = this.manager.getProxyServer().getCommandManager() final CommandMeta commandMeta = this.manager.getProxyServer().getCommandManager()

View file

@ -69,7 +69,7 @@ class AnnotatedMethodService<Context, Result> implements Service<Context, Result
} catch (final Throwable throwable) { } catch (final Throwable throwable) {
new IllegalStateException(String new IllegalStateException(String
.format("Failed to call method service implementation '%s' in class '%s'", .format("Failed to call method service implementation '%s' in class '%s'",
method.getName(), instance.getClass().getCanonicalName() this.method.getName(), this.instance.getClass().getCanonicalName()
), throwable) ), throwable)
.printStackTrace(); .printStackTrace();
} }

View file

@ -76,7 +76,7 @@ public final class ServicePipeline {
final @NonNull Service<@NonNull Context, @NonNull Result> defaultImplementation final @NonNull Service<@NonNull Context, @NonNull Result> defaultImplementation
) { ) {
synchronized (this.lock) { synchronized (this.lock) {
if (repositories.containsKey(type.getType())) { if (this.repositories.containsKey(type.getType())) {
throw new IllegalArgumentException(String throw new IllegalArgumentException(String
.format( .format(
"Service of type '%s' has already been registered", "Service of type '%s' has already been registered",
@ -151,7 +151,7 @@ public final class ServicePipeline {
final @NonNull Collection<Predicate<Context>> filters final @NonNull Collection<Predicate<Context>> filters
) { ) {
synchronized (this.lock) { synchronized (this.lock) {
final ServiceRepository<Context, Result> repository = getRepository(type); final ServiceRepository<Context, Result> repository = this.getRepository(type);
repository.registerImplementation(implementation, filters); repository.registerImplementation(implementation, filters);
} }
return this; return this;
@ -175,7 +175,7 @@ public final class ServicePipeline {
final @NonNull Service<Context, Result> implementation, final @NonNull Service<Context, Result> implementation,
final @NonNull Collection<Predicate<Context>> filters final @NonNull Collection<Predicate<Context>> filters
) { ) {
return registerServiceImplementation(TypeToken.get(type), implementation, filters); return this.registerServiceImplementation(TypeToken.get(type), implementation, filters);
} }
/** /**
@ -229,7 +229,7 @@ public final class ServicePipeline {
public <Context, Result, S extends Service<Context, Result>> Collection<TypeToken<? extends S>> getImplementations( public <Context, Result, S extends Service<Context, Result>> Collection<TypeToken<? extends S>> getImplementations(
final @NonNull TypeToken<S> type final @NonNull TypeToken<S> type
) { ) {
ServiceRepository<Context, Result> repository = getRepository(type); ServiceRepository<Context, Result> repository = this.getRepository(type);
List<TypeToken<? extends S>> collection = new LinkedList<>(); List<TypeToken<? extends S>> collection = new LinkedList<>();
final LinkedList<? extends ServiceRepository<Context, Result>.ServiceWrapper<? extends Service<Context, Result>>> final LinkedList<? extends ServiceRepository<Context, Result>.ServiceWrapper<? extends Service<Context, Result>>>
queue = repository.getQueue(); queue = repository.getQueue();

View file

@ -107,7 +107,7 @@ public final class ServiceRepository<Context, Response> {
final @NonNull T implementation, final @NonNull T implementation,
final @NonNull Collection<Predicate<Context>> filters final @NonNull Collection<Predicate<Context>> filters
) { ) {
this.defaultImplementation = implementations.isEmpty(); this.defaultImplementation = ServiceRepository.this.implementations.isEmpty();
this.implementation = implementation; this.implementation = implementation;
this.filters = filters; this.filters = filters;
ExecutionOrder executionOrder = implementation.order(); ExecutionOrder executionOrder = implementation.order();
@ -139,8 +139,8 @@ public final class ServiceRepository<Context, Response> {
@Override @Override
public String toString() { public String toString() {
return String return String
.format("ServiceWrapper{type=%s,implementation=%s}", serviceType.toString(), .format("ServiceWrapper{type=%s,implementation=%s}", ServiceRepository.this.serviceType.toString(),
TypeToken.get(implementation.getClass()).toString() TypeToken.get(this.implementation.getClass()).toString()
); );
} }

View file

@ -133,7 +133,7 @@ public final class ServiceSpigot<Context, Result> {
*/ */
public void getResult(final @NonNull BiConsumer<Result, Throwable> consumer) { public void getResult(final @NonNull BiConsumer<Result, Throwable> consumer) {
try { try {
consumer.accept(getResult(), null); consumer.accept(this.getResult(), null);
} catch (final PipelineException pipelineException) { } catch (final PipelineException pipelineException) {
consumer.accept(null, pipelineException.getCause()); consumer.accept(null, pipelineException.getCause());
} catch (final Exception e) { } catch (final Exception e) {
@ -167,7 +167,7 @@ public final class ServiceSpigot<Context, Result> {
* @return New pump, for the result of this request * @return New pump, for the result of this request
*/ */
public @NonNull CompletableFuture<ServicePump<Result>> forwardAsynchronously() { public @NonNull CompletableFuture<ServicePump<Result>> forwardAsynchronously() {
return this.getResultAsynchronously().thenApply(pipeline::pump); return this.getResultAsynchronously().thenApply(this.pipeline::pump);
} }
} }

View file

@ -127,7 +127,7 @@ public final class TaskRecipe {
* @return New task recipe component * @return New task recipe component
*/ */
public <T> TaskRecipeComponentOutputting<O, T> synchronous(final @NonNull TaskFunction<O, T> function) { public <T> TaskRecipeComponentOutputting<O, T> synchronous(final @NonNull TaskFunction<O, T> function) {
addSynchronous(function); TaskRecipe.this.addSynchronous(function);
return new TaskRecipeComponentOutputting<>(this.initialInput); return new TaskRecipeComponentOutputting<>(this.initialInput);
} }
@ -139,7 +139,7 @@ public final class TaskRecipe {
* @return New task recipe component * @return New task recipe component
*/ */
public <T> TaskRecipeComponentOutputting<O, T> asynchronous(final @NonNull TaskFunction<O, T> function) { public <T> TaskRecipeComponentOutputting<O, T> asynchronous(final @NonNull TaskFunction<O, T> function) {
addAsynchronous(function); TaskRecipe.this.addAsynchronous(function);
return new TaskRecipeComponentOutputting<>(this.initialInput); return new TaskRecipeComponentOutputting<>(this.initialInput);
} }
@ -150,8 +150,8 @@ public final class TaskRecipe {
* @return New task recipe component * @return New task recipe component
*/ */
public TaskRecipeComponentVoid<O> synchronous(final @NonNull TaskConsumer<O> consumer) { public TaskRecipeComponentVoid<O> synchronous(final @NonNull TaskConsumer<O> consumer) {
addSynchronous(consumer); TaskRecipe.this.addSynchronous(consumer);
return new TaskRecipeComponentVoid<>(initialInput); return new TaskRecipeComponentVoid<>(this.initialInput);
} }
/** /**
@ -161,8 +161,8 @@ public final class TaskRecipe {
* @return New task recipe component * @return New task recipe component
*/ */
public TaskRecipeComponentVoid<O> asynchronous(final @NonNull TaskConsumer<O> consumer) { public TaskRecipeComponentVoid<O> asynchronous(final @NonNull TaskConsumer<O> consumer) {
addAsynchronous(consumer); TaskRecipe.this.addAsynchronous(consumer);
return new TaskRecipeComponentVoid<>(initialInput); return new TaskRecipeComponentVoid<>(this.initialInput);
} }
/** /**
@ -171,7 +171,7 @@ public final class TaskRecipe {
* @param callback Callback function * @param callback Callback function
*/ */
public void execute(final @NonNull Runnable callback) { public void execute(final @NonNull Runnable callback) {
TaskRecipe.this.execute(initialInput, callback); TaskRecipe.this.execute(this.initialInput, callback);
} }
/** /**
@ -204,8 +204,8 @@ public final class TaskRecipe {
* @return New task recipe component * @return New task recipe component
*/ */
public TaskRecipeComponentVoid<I> synchronous(final @NonNull TaskConsumer<I> consumer) { public TaskRecipeComponentVoid<I> synchronous(final @NonNull TaskConsumer<I> consumer) {
addSynchronous(consumer); TaskRecipe.this.addSynchronous(consumer);
return new TaskRecipeComponentVoid<>(initialInput); return new TaskRecipeComponentVoid<>(this.initialInput);
} }
/** /**
@ -215,8 +215,8 @@ public final class TaskRecipe {
* @return New task recipe component * @return New task recipe component
*/ */
public TaskRecipeComponentVoid<I> asynchronous(final @NonNull TaskConsumer<I> consumer) { public TaskRecipeComponentVoid<I> asynchronous(final @NonNull TaskConsumer<I> consumer) {
addSynchronous(consumer); TaskRecipe.this.addSynchronous(consumer);
return new TaskRecipeComponentVoid<>(initialInput); return new TaskRecipeComponentVoid<>(this.initialInput);
} }
/** /**
@ -225,7 +225,7 @@ public final class TaskRecipe {
* @param callback Callback function * @param callback Callback function
*/ */
public void execute(final @NonNull Runnable callback) { public void execute(final @NonNull Runnable callback) {
TaskRecipe.this.execute(initialInput, callback); TaskRecipe.this.execute(this.initialInput, callback);
} }
/** /**

View file

@ -26,7 +26,6 @@ package cloud.commandframework.examples.bukkit;
import cloud.commandframework.ArgumentDescription; import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.Command; import cloud.commandframework.Command;
import cloud.commandframework.CommandTree; import cloud.commandframework.CommandTree;
import cloud.commandframework.Description;
import cloud.commandframework.keys.SimpleCloudKey; import cloud.commandframework.keys.SimpleCloudKey;
import cloud.commandframework.minecraft.extras.MinecraftExceptionHandler; import cloud.commandframework.minecraft.extras.MinecraftExceptionHandler;
import cloud.commandframework.minecraft.extras.MinecraftHelp; import cloud.commandframework.minecraft.extras.MinecraftHelp;
@ -138,7 +137,7 @@ public final class ExamplePlugin extends JavaPlugin {
/* C -> Command Sender */ mapperFunction /* C -> Command Sender */ mapperFunction
); );
} catch (final Exception e) { } catch (final Exception e) {
this.getLogger().severe("Failed to initialize the command manager"); this.getLogger().severe("Failed to initialize the command this.manager");
/* Disable the plugin */ /* Disable the plugin */
this.getServer().getPluginManager().disablePlugin(this); this.getServer().getPluginManager().disablePlugin(this);
return; return;
@ -159,17 +158,17 @@ public final class ExamplePlugin extends JavaPlugin {
// //
// Register Brigadier mappings // Register Brigadier mappings
// //
if (manager.queryCapability(CloudBukkitCapabilities.BRIGADIER)) { if (this.manager.queryCapability(CloudBukkitCapabilities.BRIGADIER)) {
manager.registerBrigadier(); this.manager.registerBrigadier();
} }
// //
// Register asynchronous completions // Register asynchronous completions
// //
if (manager.queryCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) { if (this.manager.queryCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) {
((PaperCommandManager<CommandSender>) this.manager).registerAsynchronousCompletions(); ((PaperCommandManager<CommandSender>) this.manager).registerAsynchronousCompletions();
} }
// //
// Create the confirmation manager. This allows us to require certain commands to be // Create the confirmation this.manager. This allows us to require certain commands to be
// confirmed before they can be executed // confirmed before they can be executed
// //
this.confirmationManager = new CommandConfirmationManager<>( this.confirmationManager = new CommandConfirmationManager<>(
@ -183,7 +182,7 @@ public final class ExamplePlugin extends JavaPlugin {
// //
// Register the confirmation processor. This will enable confirmations for commands that require it // Register the confirmation processor. This will enable confirmations for commands that require it
// //
this.confirmationManager.registerConfirmationProcessor(manager); this.confirmationManager.registerConfirmationProcessor(this.manager);
// //
// Create the annotation parser. This allows you to define commands using methods annotated with // Create the annotation parser. This allows you to define commands using methods annotated with
// @CommandMethod // @CommandMethod
@ -213,7 +212,7 @@ public final class ExamplePlugin extends JavaPlugin {
.append(text("Example", NamedTextColor.GOLD)) .append(text("Example", NamedTextColor.GOLD))
.append(text("] ", NamedTextColor.DARK_GRAY)) .append(text("] ", NamedTextColor.DARK_GRAY))
.append(component).build() .append(component).build()
).apply(manager, bukkitAudiences::sender); ).apply(this.manager, this.bukkitAudiences::sender);
// //
// Create the commands // Create the commands
// //
@ -266,7 +265,7 @@ public final class ExamplePlugin extends JavaPlugin {
), ),
ArgumentDescription.of("Coordinates") ArgumentDescription.of("Coordinates")
) )
.handler(context -> manager.taskRecipe().begin(context) .handler(context -> this.manager.taskRecipe().begin(context)
.synchronous(commandContext -> { .synchronous(commandContext -> {
final Player player = (Player) commandContext.getSender(); final Player player = (Player) commandContext.getSender();
final World world = commandContext.get(worldArgument); final World world = commandContext.get(worldArgument);
@ -283,7 +282,7 @@ public final class ExamplePlugin extends JavaPlugin {
) )
.literal("here") .literal("here")
.handler( .handler(
context -> manager.taskRecipe().begin(context) context -> this.manager.taskRecipe().begin(context)
.synchronous(commandContext -> { .synchronous(commandContext -> {
final Player player = (Player) commandContext.getSender(); final Player player = (Player) commandContext.getSender();
final SingleEntitySelector singleEntitySelector = commandContext final SingleEntitySelector singleEntitySelector = commandContext
@ -299,13 +298,13 @@ public final class ExamplePlugin extends JavaPlugin {
.command(builder.literal("teleport") .command(builder.literal("teleport")
.meta(CommandMeta.DESCRIPTION, "Teleport to a world") .meta(CommandMeta.DESCRIPTION, "Teleport to a world")
.argument(WorldArgument.of("world"), ArgumentDescription.of("World to teleport to")) .argument(WorldArgument.of("world"), ArgumentDescription.of("World to teleport to"))
.handler(context -> manager.taskRecipe().begin(context).synchronous(ctx -> { .handler(context -> this.manager.taskRecipe().begin(context).synchronous(ctx -> {
final Player player = (Player) ctx.getSender(); final Player player = (Player) ctx.getSender();
player.teleport(ctx.<World>get("world").getSpawnLocation()); player.teleport(ctx.<World>get("world").getSpawnLocation());
player.sendMessage(ChatColor.GREEN + "You have been teleported!"); player.sendMessage(ChatColor.GREEN + "You have been teleported!");
}).execute())); }).execute()));
manager.command(builder.literal("tasktest") this.manager.command(builder.literal("tasktest")
.handler(context -> manager.taskRecipe() .handler(context -> this.manager.taskRecipe()
.begin(context) .begin(context)
.asynchronous(c -> { .asynchronous(c -> {
c.getSender().sendMessage("ASYNC: " + !Bukkit.isPrimaryThread()); c.getSender().sendMessage("ASYNC: " + !Bukkit.isPrimaryThread());
@ -316,7 +315,7 @@ public final class ExamplePlugin extends JavaPlugin {
}) })
.execute(() -> context.getSender().sendMessage("DONE!")) .execute(() -> context.getSender().sendMessage("DONE!"))
)); ));
manager.command(manager.commandBuilder("give") this.manager.command(this.manager.commandBuilder("give")
.senderType(Player.class) .senderType(Player.class)
.argument(MaterialArgument.of("material")) .argument(MaterialArgument.of("material"))
.argument(IntegerArgument.of("amount")) .argument(IntegerArgument.of("amount"))
@ -327,18 +326,18 @@ public final class ExamplePlugin extends JavaPlugin {
((Player) c.getSender()).getInventory().addItem(itemStack); ((Player) c.getSender()).getInventory().addItem(itemStack);
c.getSender().sendMessage("You've been given stuff, bro."); c.getSender().sendMessage("You've been given stuff, bro.");
})); }));
manager.command(builder.literal("summon") this.manager.command(builder.literal("summon")
.senderType(Player.class) .senderType(Player.class)
.argument(EnumArgument.of(EntityType.class, "type")) .argument(EnumArgument.of(EntityType.class, "type"))
.handler(c -> manager.taskRecipe().begin(c).synchronous(ctx -> { .handler(c -> this.manager.taskRecipe().begin(c).synchronous(ctx -> {
final Location loc = ((Player) ctx.getSender()).getLocation(); final Location loc = ((Player) ctx.getSender()).getLocation();
loc.getWorld().spawnEntity(loc, ctx.get("type")); loc.getWorld().spawnEntity(loc, ctx.get("type"));
}).execute())); }).execute()));
manager.command(builder.literal("enchant") this.manager.command(builder.literal("enchant")
.senderType(Player.class) .senderType(Player.class)
.argument(EnchantmentArgument.of("enchant")) .argument(EnchantmentArgument.of("enchant"))
.argument(IntegerArgument.of("level")) .argument(IntegerArgument.of("level"))
.handler(c -> manager.taskRecipe().begin(c).synchronous(ctx -> { .handler(c -> this.manager.taskRecipe().begin(c).synchronous(ctx -> {
final Player player = ((Player) ctx.getSender()); final Player player = ((Player) ctx.getSender());
player.getInventory().getItemInHand().addEnchantment(ctx.get("enchant"), ctx.get("level")); player.getInventory().getItemInHand().addEnchantment(ctx.get("enchant"), ctx.get("level"));
}).execute())); }).execute()));
@ -346,7 +345,7 @@ public final class ExamplePlugin extends JavaPlugin {
// //
// A command to change the color scheme for the help command // A command to change the color scheme for the help command
// //
manager.command(builder this.manager.command(builder
.meta(CommandMeta.DESCRIPTION, "Sets the color scheme for '/example help'") .meta(CommandMeta.DESCRIPTION, "Sets the color scheme for '/example help'")
.literal("helpcolors") .literal("helpcolors")
.argument( .argument(
@ -369,7 +368,7 @@ public final class ExamplePlugin extends JavaPlugin {
TextColorArgument.of("accent"), TextColorArgument.of("accent"),
RichDescription.of(text("The color used for accents and symbols")) RichDescription.of(text("The color used for accents and symbols"))
) )
.handler(c -> minecraftHelp.setHelpColors(MinecraftHelp.HelpColors.of( .handler(c -> this.minecraftHelp.setHelpColors(MinecraftHelp.HelpColors.of(
c.get("primary"), c.get("primary"),
c.get("highlight"), c.get("highlight"),
c.get("alternate_highlight"), c.get("alternate_highlight"),
@ -381,8 +380,8 @@ public final class ExamplePlugin extends JavaPlugin {
// //
// Create a Bukkit-like command // Create a Bukkit-like command
// //
manager.command( this.manager.command(
manager.commandBuilder( this.manager.commandBuilder(
"arraycommand", "arraycommand",
ArgumentDescription.of("Bukkit-esque cmmand") ArgumentDescription.of("Bukkit-esque cmmand")
).argument( ).argument(
@ -405,8 +404,8 @@ public final class ExamplePlugin extends JavaPlugin {
/* Register a custom regex caption */ /* Register a custom regex caption */
final Caption moneyCaption = Caption.of("regex.money"); final Caption moneyCaption = Caption.of("regex.money");
if (manager.getCaptionRegistry() instanceof SimpleCaptionRegistry) { if (this.manager.getCaptionRegistry() instanceof SimpleCaptionRegistry) {
((SimpleCaptionRegistry<CommandSender>) manager.getCaptionRegistry()).registerMessageFactory( ((SimpleCaptionRegistry<CommandSender>) this.manager.getCaptionRegistry()).registerMessageFactory(
moneyCaption, moneyCaption,
(sender, key) -> "'{input}' is not very cash money of you" (sender, key) -> "'{input}' is not very cash money of you"
); );
@ -471,7 +470,7 @@ public final class ExamplePlugin extends JavaPlugin {
final @Argument("money") @Regex(value = "(?=.*?\\d)^\\$?(([1-9]\\d{0,2}(,\\d{3})*)|\\d+)?(\\.\\d{1,2})?$", final @Argument("money") @Regex(value = "(?=.*?\\d)^\\$?(([1-9]\\d{0,2}(,\\d{3})*)|\\d+)?(\\.\\d{1,2})?$",
failureCaption = "regex.money") String money failureCaption = "regex.money") String money
) { ) {
bukkitAudiences.sender(sender).sendMessage( this.bukkitAudiences.sender(sender).sendMessage(
Identity.nil(), Identity.nil(),
text().append(text("You have been given ", NamedTextColor.AQUA)) text().append(text("You have been given ", NamedTextColor.AQUA))
.append(text(money, NamedTextColor.GOLD)) .append(text(money, NamedTextColor.GOLD))

View file

@ -70,7 +70,7 @@ public final class ExamplePlugin extends Plugin {
mapperFunction mapperFunction
); );
} catch (final Exception e) { } catch (final Exception e) {
this.getLogger().severe("Failed to initialize the command manager"); this.getLogger().severe("Failed to initialize the command this.manager");
return; return;
} }
@ -79,14 +79,14 @@ public final class ExamplePlugin extends Plugin {
this.confirmationManager = new CommandConfirmationManager<>( this.confirmationManager = new CommandConfirmationManager<>(
30L, 30L,
TimeUnit.SECONDS, TimeUnit.SECONDS,
context -> bungeeAudiences.sender(context.getCommandContext().getSender()).sendMessage( context -> this.bungeeAudiences.sender(context.getCommandContext().getSender()).sendMessage(
text( text(
"Confirmation required. Confirm using /example confirm.", NamedTextColor.RED)), "Confirmation required. Confirm using /example confirm.", NamedTextColor.RED)),
sender -> bungeeAudiences.sender(sender).sendMessage( sender -> this.bungeeAudiences.sender(sender).sendMessage(
text("You do not have any pending commands.", NamedTextColor.RED)) text("You do not have any pending commands.", NamedTextColor.RED))
); );
this.confirmationManager.registerConfirmationProcessor(manager); this.confirmationManager.registerConfirmationProcessor(this.manager);
new MinecraftExceptionHandler<CommandSender>() new MinecraftExceptionHandler<CommandSender>()
.withInvalidSyntaxHandler() .withInvalidSyntaxHandler()
@ -98,7 +98,7 @@ public final class ExamplePlugin extends Plugin {
.append(text("Example", NamedTextColor.GOLD)) .append(text("Example", NamedTextColor.GOLD))
.append(text("] ", NamedTextColor.DARK_GRAY)) .append(text("] ", NamedTextColor.DARK_GRAY))
.append(component).build() .append(component).build()
).apply(manager, bungeeAudiences::sender); ).apply(this.manager, this.bungeeAudiences::sender);
this.constructCommands(); this.constructCommands();
} }
@ -121,12 +121,12 @@ public final class ExamplePlugin extends Plugin {
// Create a player command // Create a player command
// //
this.manager.command( this.manager.command(
manager.commandBuilder("player") this.manager.commandBuilder("player")
.senderType(ProxiedPlayer.class) .senderType(ProxiedPlayer.class)
.argument(playerArgument, RichDescription.of(text("Player ").append(text("name", NamedTextColor.GOLD)))) .argument(playerArgument, RichDescription.of(text("Player ").append(text("name", NamedTextColor.GOLD))))
.handler(context -> { .handler(context -> {
final ProxiedPlayer player = context.get("player"); final ProxiedPlayer player = context.get("player");
bungeeAudiences.sender(context.getSender()).sendMessage( this.bungeeAudiences.sender(context.getSender()).sendMessage(
text("Selected ", NamedTextColor.GOLD) text("Selected ", NamedTextColor.GOLD)
.append(text(player.getDisplayName(), NamedTextColor.AQUA)) .append(text(player.getDisplayName(), NamedTextColor.AQUA))
); );
@ -142,7 +142,7 @@ public final class ExamplePlugin extends Plugin {
.argument(serverArgument, ArgumentDescription.of("Server name")) .argument(serverArgument, ArgumentDescription.of("Server name"))
.handler(context -> { .handler(context -> {
final ServerInfo server = context.get("server"); final ServerInfo server = context.get("server");
bungeeAudiences.sender(context.getSender()).sendMessage( this.bungeeAudiences.sender(context.getSender()).sendMessage(
text("Selected ", NamedTextColor.GOLD) text("Selected ", NamedTextColor.GOLD)
.append(text(server.getName(), NamedTextColor.AQUA)) .append(text(server.getName(), NamedTextColor.AQUA))
); );

View file

@ -69,7 +69,7 @@ public abstract class CustomUser {
* @return Sending user * @return Sending user
*/ */
public final @NonNull User getUser() { public final @NonNull User getUser() {
return user; return this.user;
} }
/** /**
@ -78,7 +78,7 @@ public abstract class CustomUser {
* @return Message channel * @return Message channel
*/ */
public final @NonNull MessageChannel getChannel() { public final @NonNull MessageChannel getChannel() {
return channel; return this.channel;
} }
} }

View file

@ -53,7 +53,7 @@ public final class GuildUser extends CustomUser {
* @return Sending member * @return Sending member
*/ */
public @NonNull Member getMember() { public @NonNull Member getMember() {
return member; return this.member;
} }
/** /**
@ -62,7 +62,7 @@ public final class GuildUser extends CustomUser {
* @return Message channel * @return Message channel
*/ */
public @NonNull TextChannel getTextChannel() { public @NonNull TextChannel getTextChannel() {
return channel; return this.channel;
} }
} }

View file

@ -51,7 +51,7 @@ public final class PrivateUser extends CustomUser {
* @return Private channel * @return Private channel
*/ */
public @NonNull PrivateChannel getPrivateChannel() { public @NonNull PrivateChannel getPrivateChannel() {
return privateChannel; return this.privateChannel;
} }
} }

View file

@ -62,7 +62,7 @@ public final class ExampleVelocityPlugin {
*/ */
@Subscribe @Subscribe
public void onProxyInitialization(final @NonNull ProxyInitializeEvent event) { public void onProxyInitialization(final @NonNull ProxyInitializeEvent event) {
final Injector childInjector = injector.createChildInjector( final Injector childInjector = this.injector.createChildInjector(
new CloudInjectionModule<>( new CloudInjectionModule<>(
CommandSource.class, CommandSource.class,
CommandExecutionCoordinator.simpleCoordinator(), CommandExecutionCoordinator.simpleCoordinator(),