Some small changes

This commit is contained in:
Alexander Söderberg 2020-09-29 21:59:03 +02:00 committed by Alexander Söderberg
parent 26f11e3a7e
commit f7c00244e7
6 changed files with 18 additions and 26 deletions

View file

@ -31,7 +31,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import javax.annotation.Nonnull;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
@ -89,8 +88,8 @@ class CommandHelpHandlerTest {
this.printTopic("vec", query4); this.printTopic("vec", query4);
} }
private void printTopic(@Nonnull final String query, private void printTopic(final String query,
@Nonnull final CommandHelpHandler.HelpTopic<TestCommandSender> helpTopic) { final CommandHelpHandler.HelpTopic<TestCommandSender> helpTopic) {
System.out.printf("Showing results for query: \"/%s\"\n", query); System.out.printf("Showing results for query: \"/%s\"\n", query);
if (helpTopic instanceof CommandHelpHandler.IndexHelpTopic) { if (helpTopic instanceof CommandHelpHandler.IndexHelpTopic) {
this.printIndexHelpTopic((CommandHelpHandler.IndexHelpTopic<TestCommandSender>) helpTopic); this.printIndexHelpTopic((CommandHelpHandler.IndexHelpTopic<TestCommandSender>) helpTopic);
@ -104,7 +103,7 @@ class CommandHelpHandlerTest {
System.out.println(); System.out.println();
} }
private void printIndexHelpTopic(@Nonnull final CommandHelpHandler.IndexHelpTopic<TestCommandSender> helpTopic) { private void printIndexHelpTopic(final CommandHelpHandler.IndexHelpTopic<TestCommandSender> helpTopic) {
System.out.println("└── Available Commands: "); System.out.println("└── Available Commands: ");
final Iterator<CommandHelpHandler.VerboseHelpEntry<TestCommandSender>> iterator = helpTopic.getEntries().iterator(); final Iterator<CommandHelpHandler.VerboseHelpEntry<TestCommandSender>> iterator = helpTopic.getEntries().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -114,7 +113,7 @@ class CommandHelpHandlerTest {
} }
} }
private void printMultiHelpTopic(@Nonnull final CommandHelpHandler.MultiHelpTopic<TestCommandSender> helpTopic) { private void printMultiHelpTopic(final CommandHelpHandler.MultiHelpTopic<TestCommandSender> helpTopic) {
System.out.printf("└── /%s\n", helpTopic.getLongestPath()); System.out.printf("└── /%s\n", helpTopic.getLongestPath());
final int headerIndentation = helpTopic.getLongestPath().length(); final int headerIndentation = helpTopic.getLongestPath().length();
final Iterator<String> iterator = helpTopic.getChildSuggestions().iterator(); final Iterator<String> iterator = helpTopic.getChildSuggestions().iterator();
@ -134,7 +133,7 @@ class CommandHelpHandlerTest {
} }
} }
private void printVerboseHelpTopic(@Nonnull final CommandHelpHandler.VerboseHelpTopic<TestCommandSender> helpTopic) { private void printVerboseHelpTopic(final CommandHelpHandler.VerboseHelpTopic<TestCommandSender> helpTopic) {
System.out.printf("└── Command: /%s\n", manager.getCommandSyntaxFormatter() System.out.printf("└── Command: /%s\n", manager.getCommandSyntaxFormatter()
.apply(helpTopic.getCommand().getArguments(), null)); .apply(helpTopic.getCommand().getArguments(), null));
System.out.printf(" ├── Description: %s\n", helpTopic.getDescription()); System.out.printf(" ├── Description: %s\n", helpTopic.getDescription());

View file

@ -24,8 +24,7 @@
package cloud.commandframework.bukkit; package cloud.commandframework.bukkit;
import cloud.commandframework.meta.SimpleCommandMeta; import cloud.commandframework.meta.SimpleCommandMeta;
import org.checkerframework.checker.nullness.qual.NonNull;
import javax.annotation.Nonnull;
public class BukkitCommandMeta extends SimpleCommandMeta { public class BukkitCommandMeta extends SimpleCommandMeta {
@ -34,7 +33,7 @@ public class BukkitCommandMeta extends SimpleCommandMeta {
* *
* @param simpleCommandMeta Simple command meta data instance that gets mirrored * @param simpleCommandMeta Simple command meta data instance that gets mirrored
*/ */
public BukkitCommandMeta(@Nonnull final SimpleCommandMeta simpleCommandMeta) { public BukkitCommandMeta(@NonNull final SimpleCommandMeta simpleCommandMeta) {
super(simpleCommandMeta.getAll()); super(simpleCommandMeta.getAll());
} }

View file

@ -24,8 +24,7 @@
package cloud.commandframework.bukkit; package cloud.commandframework.bukkit;
import cloud.commandframework.meta.CommandMeta; import cloud.commandframework.meta.CommandMeta;
import org.checkerframework.checker.nullness.qual.NonNull;
import javax.annotation.Nonnull;
public final class BukkitCommandMetaBuilder { public final class BukkitCommandMetaBuilder {
@ -37,8 +36,7 @@ public final class BukkitCommandMetaBuilder {
* *
* @return Builder instance * @return Builder instance
*/ */
@Nonnull public static @NonNull BuilderStage1 builder() {
public static BuilderStage1 builder() {
return new BuilderStage1(); return new BuilderStage1();
} }
@ -54,8 +52,7 @@ public final class BukkitCommandMetaBuilder {
* @param description Command description * @param description Command description
* @return Builder instance * @return Builder instance
*/ */
@Nonnull public @NonNull BuilderStage2 withDescription(@NonNull final String description) {
public BuilderStage2 withDescription(@Nonnull final String description) {
return new BuilderStage2(description); return new BuilderStage2(description);
} }
@ -66,7 +63,7 @@ public final class BukkitCommandMetaBuilder {
private final String description; private final String description;
private BuilderStage2(@Nonnull final String description) { private BuilderStage2(@NonNull final String description) {
this.description = description; this.description = description;
} }
@ -75,8 +72,7 @@ public final class BukkitCommandMetaBuilder {
* *
* @return Meta instance * @return Meta instance
*/ */
@Nonnull public @NonNull BukkitCommandMeta build() {
public BukkitCommandMeta build() {
return new BukkitCommandMeta(CommandMeta.simple().with("description", this.description).build()); return new BukkitCommandMeta(CommandMeta.simple().with("description", this.description).build());
} }

View file

@ -25,8 +25,7 @@ package cloud.commandframework.bukkit;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.checkerframework.checker.nullness.qual.NonNull;
import javax.annotation.Nonnull;
final class BukkitConsoleSender extends BukkitCommandSender { final class BukkitConsoleSender extends BukkitCommandSender {
@ -39,9 +38,8 @@ final class BukkitConsoleSender extends BukkitCommandSender {
return false; return false;
} }
@Nonnull
@Override @Override
public Player asPlayer() { public @NonNull Player asPlayer() {
throw new UnsupportedOperationException("Cannot convert console to player"); throw new UnsupportedOperationException("Cannot convert console to player");
} }

View file

@ -31,8 +31,8 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandMap; import org.bukkit.command.CommandMap;
import org.bukkit.command.SimpleCommandMap; import org.bukkit.command.SimpleCommandMap;
import org.bukkit.help.GenericCommandHelpTopic; import org.bukkit.help.GenericCommandHelpTopic;
import org.checkerframework.checker.nullness.qual.NonNull;
import javax.annotation.Nonnull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Collections; import java.util.Collections;
@ -51,7 +51,7 @@ class BukkitPluginRegistrationHandler<C> implements CommandRegistrationHandler {
BukkitPluginRegistrationHandler() { BukkitPluginRegistrationHandler() {
} }
void initialize(@Nonnull final BukkitCommandManager<C> bukkitCommandManager) throws Exception { void initialize(@NonNull final BukkitCommandManager<C> bukkitCommandManager) throws Exception {
final Method getCommandMap = Bukkit.getServer().getClass().getDeclaredMethod("getCommandMap"); final Method getCommandMap = Bukkit.getServer().getClass().getDeclaredMethod("getCommandMap");
getCommandMap.setAccessible(true); getCommandMap.setAccessible(true);
this.commandMap = (CommandMap) getCommandMap.invoke(Bukkit.getServer()); this.commandMap = (CommandMap) getCommandMap.invoke(Bukkit.getServer());

View file

@ -23,9 +23,9 @@
// //
package cloud.commandframework.services; package cloud.commandframework.services;
import io.leangen.geantyref.TypeToken;
import cloud.commandframework.services.annotations.ServiceImplementation; import cloud.commandframework.services.annotations.ServiceImplementation;
import cloud.commandframework.services.types.Service; import cloud.commandframework.services.types.Service;
import io.leangen.geantyref.TypeToken;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.lang.reflect.Method; import java.lang.reflect.Method;