diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/Command.java b/cloud-core/src/main/java/com/intellectualsites/commands/Command.java index e3fe2682..701b84a8 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/Command.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/Command.java @@ -27,7 +27,6 @@ import com.intellectualsites.commands.arguments.CommandArgument; import com.intellectualsites.commands.arguments.StaticArgument; import com.intellectualsites.commands.execution.CommandExecutionHandler; import com.intellectualsites.commands.meta.CommandMeta; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -45,7 +44,7 @@ import java.util.function.Consumer; * @param Command meta type */ @SuppressWarnings("unused") -public class Command { +public class Command { @Nonnull private final List> arguments; @Nonnull private final CommandExecutionHandler commandExecutionHandler; @@ -132,7 +131,7 @@ public class Command { * @return Command builder */ @Nonnull - public static Builder newBuilder(@Nonnull final String commandName, + public static Builder newBuilder(@Nonnull final String commandName, @Nonnull final M commandMeta, @Nonnull final String... aliases) { return new Builder<>(null, commandMeta, null, @@ -217,7 +216,7 @@ public class Command { * @param Command sender type * @param Command meta type */ - public static final class Builder { + public static final class Builder { @Nonnull private final M commandMeta; @Nonnull private final List> commandArguments; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/CommandManager.java b/cloud-core/src/main/java/com/intellectualsites/commands/CommandManager.java index 047dc955..c19bb20e 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/CommandManager.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/CommandManager.java @@ -41,7 +41,6 @@ import com.intellectualsites.commands.execution.preprocessor.CommandPreprocessin import com.intellectualsites.commands.execution.preprocessor.CommandPreprocessor; import com.intellectualsites.commands.internal.CommandRegistrationHandler; import com.intellectualsites.commands.meta.CommandMeta; -import com.intellectualsites.commands.sender.CommandSender; import com.intellectualsites.services.ServicePipeline; import com.intellectualsites.services.State; @@ -61,7 +60,7 @@ import java.util.function.Function; * @param Command meta type */ @SuppressWarnings("unused") -public abstract class CommandManager { +public abstract class CommandManager { private final CommandContextFactory commandContextFactory = new StandardCommandContextFactory<>(); private final ServicePipeline servicePipeline = ServicePipeline.builder().build(); @@ -194,6 +193,15 @@ public abstract class CommandManager Command sender type * @param Command meta type */ -public final class CommandTree { +public final class CommandTree { private final Object commandLock = new Object(); @@ -83,7 +82,7 @@ public final class CommandTree { * @return New command tree */ @Nonnull - public static CommandTree newTree( + public static CommandTree newTree( @Nonnull final CommandManager commandManager, @Nonnull final CommandRegistrationHandler commandRegistrationHandler) { return new CommandTree<>(commandManager, commandRegistrationHandler); @@ -369,10 +368,10 @@ public final class CommandTree { private String isPermitted(@Nonnull final C sender, @Nonnull final Node> node) { final String permission = node.nodeMeta.get("permission"); if (permission != null) { - return sender.hasPermission(permission) ? null : permission; + return this.commandManager.hasPermission(sender, permission) ? null : permission; } if (node.isLeaf()) { - return sender.hasPermission( + return this.commandManager.hasPermission(sender, Objects.requireNonNull(Objects.requireNonNull(node.value, "node.value").getOwningCommand(), "owning command").getCommandPermission()) ? null : Objects.requireNonNull(node.value.getOwningCommand(), "owning command").getCommandPermission(); diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/CommandArgument.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/CommandArgument.java index 295a63e0..73353caf 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/CommandArgument.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/CommandArgument.java @@ -29,7 +29,6 @@ import com.intellectualsites.commands.CommandManager; import com.intellectualsites.commands.arguments.parser.ArgumentParseResult; import com.intellectualsites.commands.arguments.parser.ArgumentParser; import com.intellectualsites.commands.arguments.parser.ParserParameters; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -43,7 +42,7 @@ import java.util.regex.Pattern; * @param The type that the argument parses into */ @SuppressWarnings("unused") -public class CommandArgument implements Comparable> { +public class CommandArgument implements Comparable> { /** * Pattern for command argument names @@ -128,7 +127,7 @@ public class CommandArgument implements Comparable CommandArgument.Builder ofType(@Nonnull final Class clazz, + public static CommandArgument.Builder ofType(@Nonnull final Class clazz, @Nonnull final String name) { return new Builder<>(clazz, name); } @@ -261,7 +260,7 @@ public class CommandArgument implements Comparable Command sender type * @param Argument value type */ - public static class Builder { + public static class Builder { private final Class valueType; private final String name; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/CommandSyntaxFormatter.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/CommandSyntaxFormatter.java index a9a779e5..2a150be0 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/CommandSyntaxFormatter.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/CommandSyntaxFormatter.java @@ -23,8 +23,6 @@ // package com.intellectualsites.commands.arguments; -import com.intellectualsites.commands.sender.CommandSender; - import javax.annotation.Nonnull; import java.util.List; import java.util.function.Function; @@ -35,7 +33,7 @@ import java.util.function.Function; * @param Command sender type */ @FunctionalInterface -public interface CommandSyntaxFormatter extends Function>, String> { +public interface CommandSyntaxFormatter extends Function>, String> { @Override @Nonnull diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/StandardCommandSyntaxFormatter.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/StandardCommandSyntaxFormatter.java index 49703011..b8cc903b 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/StandardCommandSyntaxFormatter.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/StandardCommandSyntaxFormatter.java @@ -23,8 +23,6 @@ // package com.intellectualsites.commands.arguments; -import com.intellectualsites.commands.sender.CommandSender; - import javax.annotation.Nonnull; import java.util.Iterator; import java.util.List; @@ -39,7 +37,7 @@ import java.util.List; * * @param Command sender type */ -public class StandardCommandSyntaxFormatter implements CommandSyntaxFormatter { +public class StandardCommandSyntaxFormatter implements CommandSyntaxFormatter { @Nonnull @Override diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/StaticArgument.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/StaticArgument.java index eb76661a..f4c6f62f 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/StaticArgument.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/StaticArgument.java @@ -26,7 +26,6 @@ package com.intellectualsites.commands.arguments; import com.intellectualsites.commands.arguments.parser.ArgumentParseResult; import com.intellectualsites.commands.arguments.parser.ArgumentParser; import com.intellectualsites.commands.context.CommandContext; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.Arrays; @@ -41,7 +40,7 @@ import java.util.Set; * * @param Command sender type */ -public final class StaticArgument extends CommandArgument { +public final class StaticArgument extends CommandArgument { private StaticArgument(final boolean required, @Nonnull final String name, @Nonnull final String... aliases) { super(required, name, new StaticArgumentParser<>(name, aliases), String.class); @@ -56,7 +55,7 @@ public final class StaticArgument extends CommandArgume * @return Constructed argument */ @Nonnull - public static StaticArgument required(@Nonnull final String name, + public static StaticArgument required(@Nonnull final String name, @Nonnull final String... aliases) { return new StaticArgument<>(true, name, aliases); } @@ -70,7 +69,7 @@ public final class StaticArgument extends CommandArgume * @return Constructed argument */ @Nonnull - public static StaticArgument optional(@Nonnull final String name, + public static StaticArgument optional(@Nonnull final String name, @Nonnull final String... aliases) { return new StaticArgument<>(false, name, aliases); } @@ -95,7 +94,7 @@ public final class StaticArgument extends CommandArgume } - private static final class StaticArgumentParser implements ArgumentParser { + private static final class StaticArgumentParser implements ArgumentParser { private final String name; private final Set acceptedStrings = new HashSet<>(); diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/parser/ArgumentParser.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/parser/ArgumentParser.java index 3740abb7..76acee4a 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/parser/ArgumentParser.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/parser/ArgumentParser.java @@ -24,7 +24,6 @@ package com.intellectualsites.commands.arguments.parser; import com.intellectualsites.commands.context.CommandContext; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.Collections; @@ -38,7 +37,7 @@ import java.util.Queue; * @param Value type */ @FunctionalInterface -public interface ArgumentParser { +public interface ArgumentParser { /** * Parse command input into a command result diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/parser/ParserRegistry.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/parser/ParserRegistry.java index 65d39f16..9e2f6e0f 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/parser/ParserRegistry.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/parser/ParserRegistry.java @@ -24,7 +24,6 @@ package com.intellectualsites.commands.arguments.parser; import com.google.common.reflect.TypeToken; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.lang.annotation.Annotation; @@ -40,7 +39,7 @@ import java.util.function.Function; * * @param Command sender type */ -public interface ParserRegistry { +public interface ParserRegistry { /** * Register a parser supplier diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/parser/StandardParserRegistry.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/parser/StandardParserRegistry.java index 86710be6..ebda7564 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/parser/StandardParserRegistry.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/parser/StandardParserRegistry.java @@ -35,7 +35,6 @@ import com.intellectualsites.commands.arguments.standard.FloatArgument; import com.intellectualsites.commands.arguments.standard.IntegerArgument; import com.intellectualsites.commands.arguments.standard.ShortArgument; import com.intellectualsites.commands.arguments.standard.StringArgument; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.lang.annotation.Annotation; @@ -52,7 +51,7 @@ import java.util.function.Function; * * @param Command sender type */ -public final class StandardParserRegistry implements ParserRegistry { +public final class StandardParserRegistry implements ParserRegistry { private static final Map, Class> PRIMITIVE_MAPPINGS = ImmutableMap., Class>builder() .put(char.class, Character.class) diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/BooleanArgument.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/BooleanArgument.java index 85738733..cd302044 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/BooleanArgument.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/BooleanArgument.java @@ -27,7 +27,6 @@ import com.intellectualsites.commands.arguments.CommandArgument; import com.intellectualsites.commands.arguments.parser.ArgumentParseResult; import com.intellectualsites.commands.arguments.parser.ArgumentParser; import com.intellectualsites.commands.context.CommandContext; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.Arrays; @@ -35,7 +34,7 @@ import java.util.List; import java.util.Queue; @SuppressWarnings("unused") -public final class BooleanArgument extends CommandArgument { +public final class BooleanArgument extends CommandArgument { private final boolean liberal; private BooleanArgument(final boolean required, @Nonnull final String name, @@ -52,7 +51,7 @@ public final class BooleanArgument extends CommandArgum * @return Created builder */ @Nonnull - public static Builder newBuilder(@Nonnull final String name) { + public static Builder newBuilder(@Nonnull final String name) { return new Builder<>(name); } @@ -64,7 +63,7 @@ public final class BooleanArgument extends CommandArgum * @return Created argument */ @Nonnull - public static CommandArgument required(@Nonnull final String name) { + public static CommandArgument required(@Nonnull final String name) { return BooleanArgument.newBuilder(name).asRequired().build(); } @@ -76,7 +75,7 @@ public final class BooleanArgument extends CommandArgum * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name) { + public static CommandArgument optional(@Nonnull final String name) { return BooleanArgument.newBuilder(name).asOptional().build(); } @@ -89,13 +88,13 @@ public final class BooleanArgument extends CommandArgum * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name, + public static CommandArgument optional(@Nonnull final String name, final String defaultNum) { return BooleanArgument.newBuilder(name).asOptionalWithDefault(defaultNum).build(); } - public static final class Builder extends CommandArgument.Builder { + public static final class Builder extends CommandArgument.Builder { private boolean liberal = false; @@ -138,7 +137,7 @@ public final class BooleanArgument extends CommandArgum } - public static final class BooleanParser implements ArgumentParser { + public static final class BooleanParser implements ArgumentParser { private static final List LIBERAL = Arrays.asList("TRUE", "YES", "ON", "FALSE", "NO", "OFF"); private static final List LIBERAL_TRUE = Arrays.asList("TRUE", "YES", "ON"); diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/ByteArgument.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/ByteArgument.java index 22cbd10f..90f7bf69 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/ByteArgument.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/ByteArgument.java @@ -28,13 +28,12 @@ import com.intellectualsites.commands.arguments.parser.ArgumentParseResult; import com.intellectualsites.commands.arguments.parser.ArgumentParser; import com.intellectualsites.commands.context.CommandContext; import com.intellectualsites.commands.exceptions.parsing.NumberParseException; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.Queue; @SuppressWarnings("unused") -public final class ByteArgument extends CommandArgument { +public final class ByteArgument extends CommandArgument { private final byte min; private final byte max; @@ -54,7 +53,7 @@ public final class ByteArgument extends CommandArgument * @return Created builder */ @Nonnull - public static Builder newBuilder(@Nonnull final String name) { + public static Builder newBuilder(@Nonnull final String name) { return new Builder<>(name); } @@ -66,7 +65,7 @@ public final class ByteArgument extends CommandArgument * @return Created argument */ @Nonnull - public static CommandArgument required(@Nonnull final String name) { + public static CommandArgument required(@Nonnull final String name) { return ByteArgument.newBuilder(name).asRequired().build(); } @@ -78,7 +77,7 @@ public final class ByteArgument extends CommandArgument * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name) { + public static CommandArgument optional(@Nonnull final String name) { return ByteArgument.newBuilder(name).asOptional().build(); } @@ -90,13 +89,13 @@ public final class ByteArgument extends CommandArgument * @param Command sender type * @return Created argument */ - @Nonnull public static CommandArgument optional(@Nonnull final String name, + @Nonnull public static CommandArgument optional(@Nonnull final String name, final byte defaultNum) { return ByteArgument.newBuilder(name).asOptionalWithDefault(Byte.toString(defaultNum)).build(); } - public static final class Builder extends CommandArgument.Builder { + public static final class Builder extends CommandArgument.Builder { private byte min = Byte.MIN_VALUE; private byte max = Byte.MAX_VALUE; @@ -162,7 +161,7 @@ public final class ByteArgument extends CommandArgument } - public static final class ByteParser implements ArgumentParser { + public static final class ByteParser implements ArgumentParser { private final byte min; private final byte max; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/CharArgument.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/CharArgument.java index 75143f3d..2003a34c 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/CharArgument.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/CharArgument.java @@ -27,13 +27,12 @@ import com.intellectualsites.commands.arguments.CommandArgument; import com.intellectualsites.commands.arguments.parser.ArgumentParseResult; import com.intellectualsites.commands.arguments.parser.ArgumentParser; import com.intellectualsites.commands.context.CommandContext; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.Queue; @SuppressWarnings("unused") -public final class CharArgument extends CommandArgument { +public final class CharArgument extends CommandArgument { private CharArgument(final boolean required, @Nonnull final String name, @Nonnull final String defaultValue) { @@ -48,7 +47,7 @@ public final class CharArgument extends CommandArgument * @return Created builder */ @Nonnull - public static CharArgument.Builder newBuilder(@Nonnull final String name) { + public static CharArgument.Builder newBuilder(@Nonnull final String name) { return new CharArgument.Builder<>(name); } @@ -60,7 +59,7 @@ public final class CharArgument extends CommandArgument * @return Created argument */ @Nonnull - public static CommandArgument required(@Nonnull final String name) { + public static CommandArgument required(@Nonnull final String name) { return CharArgument.newBuilder(name).asRequired().build(); } @@ -72,7 +71,7 @@ public final class CharArgument extends CommandArgument * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name) { + public static CommandArgument optional(@Nonnull final String name) { return CharArgument.newBuilder(name).asOptional().build(); } @@ -85,13 +84,13 @@ public final class CharArgument extends CommandArgument * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name, + public static CommandArgument optional(@Nonnull final String name, final String defaultNum) { return CharArgument.newBuilder(name).asOptionalWithDefault(defaultNum).build(); } - public static final class Builder extends CommandArgument.Builder { + public static final class Builder extends CommandArgument.Builder { protected Builder(@Nonnull final String name) { super(Character.class, name); @@ -111,7 +110,7 @@ public final class CharArgument extends CommandArgument } - public static final class CharacterParser implements ArgumentParser { + public static final class CharacterParser implements ArgumentParser { @Nonnull @Override diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/DoubleArgument.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/DoubleArgument.java index 763ee99c..8a5a2be8 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/DoubleArgument.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/DoubleArgument.java @@ -28,13 +28,12 @@ import com.intellectualsites.commands.arguments.parser.ArgumentParseResult; import com.intellectualsites.commands.arguments.parser.ArgumentParser; import com.intellectualsites.commands.context.CommandContext; import com.intellectualsites.commands.exceptions.parsing.NumberParseException; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.Queue; @SuppressWarnings("unused") -public final class DoubleArgument extends CommandArgument { +public final class DoubleArgument extends CommandArgument { private final double min; private final double max; @@ -57,7 +56,7 @@ public final class DoubleArgument extends CommandArgume * @return Created builder */ @Nonnull - public static Builder newBuilder(@Nonnull final String name) { + public static Builder newBuilder(@Nonnull final String name) { return new Builder<>(name); } @@ -69,7 +68,7 @@ public final class DoubleArgument extends CommandArgume * @return Created argument */ @Nonnull - public static CommandArgument required(@Nonnull final String name) { + public static CommandArgument required(@Nonnull final String name) { return DoubleArgument.newBuilder(name).asRequired().build(); } @@ -81,7 +80,7 @@ public final class DoubleArgument extends CommandArgume * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name) { + public static CommandArgument optional(@Nonnull final String name) { return DoubleArgument.newBuilder(name).asOptional().build(); } @@ -94,13 +93,13 @@ public final class DoubleArgument extends CommandArgume * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name, + public static CommandArgument optional(@Nonnull final String name, final double defaultNum) { return DoubleArgument.newBuilder(name).asOptionalWithDefault(Double.toString(defaultNum)).build(); } - public static final class Builder extends CommandArgument.Builder { + public static final class Builder extends CommandArgument.Builder { private double min = Double.MIN_VALUE; private double max = Double.MAX_VALUE; @@ -166,7 +165,7 @@ public final class DoubleArgument extends CommandArgume } - public static final class DoubleParser implements ArgumentParser { + public static final class DoubleParser implements ArgumentParser { private final double min; private final double max; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/EnumArgument.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/EnumArgument.java index 81dabb92..03e6b8fd 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/EnumArgument.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/EnumArgument.java @@ -27,7 +27,6 @@ import com.intellectualsites.commands.arguments.CommandArgument; import com.intellectualsites.commands.arguments.parser.ArgumentParseResult; import com.intellectualsites.commands.arguments.parser.ArgumentParser; import com.intellectualsites.commands.context.CommandContext; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.EnumSet; @@ -42,7 +41,7 @@ import java.util.stream.Collectors; * @param Enum type */ @SuppressWarnings("unused") -public class EnumArgument> extends CommandArgument { +public class EnumArgument> extends CommandArgument { protected EnumArgument(@Nonnull final Class enumClass, final boolean required, @@ -61,7 +60,7 @@ public class EnumArgument> extends Co * @return Created builder */ @Nonnull - public static > EnumArgument.Builder newBuilder( + public static > EnumArgument.Builder newBuilder( @Nonnull final Class enumClass, @Nonnull final String name) { return new EnumArgument.Builder<>(name, enumClass); } @@ -76,7 +75,7 @@ public class EnumArgument> extends Co * @return Created argument */ @Nonnull - public static > CommandArgument required( + public static > CommandArgument required( @Nonnull final Class enumClass, @Nonnull final String name) { return EnumArgument.newBuilder(enumClass, name).asRequired().build(); } @@ -91,7 +90,7 @@ public class EnumArgument> extends Co * @return Created argument */ @Nonnull - public static > CommandArgument optional( + public static > CommandArgument optional( @Nonnull final Class enumClass, @Nonnull final String name) { return EnumArgument.newBuilder(enumClass, name).asOptional().build(); } @@ -107,13 +106,13 @@ public class EnumArgument> extends Co * @return Created argument */ @Nonnull - public static > CommandArgument optional( + public static > CommandArgument optional( @Nonnull final Class enumClass, @Nonnull final String name, @Nonnull final E defaultValue) { return EnumArgument.newBuilder(enumClass, name).asOptionalWithDefault(defaultValue.name().toLowerCase()).build(); } - public static final class Builder> extends CommandArgument.Builder { + public static final class Builder> extends CommandArgument.Builder { private final Class enumClass; @@ -130,7 +129,7 @@ public class EnumArgument> extends Co } - public static final class EnumParser> implements ArgumentParser { + public static final class EnumParser> implements ArgumentParser { private final Class enumClass; private final EnumSet allowedValues; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/FloatArgument.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/FloatArgument.java index 37ada15e..e5499570 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/FloatArgument.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/FloatArgument.java @@ -28,13 +28,12 @@ import com.intellectualsites.commands.arguments.parser.ArgumentParseResult; import com.intellectualsites.commands.arguments.parser.ArgumentParser; import com.intellectualsites.commands.context.CommandContext; import com.intellectualsites.commands.exceptions.parsing.NumberParseException; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.Queue; @SuppressWarnings("unused") -public final class FloatArgument extends CommandArgument { +public final class FloatArgument extends CommandArgument { private final float min; private final float max; @@ -57,7 +56,7 @@ public final class FloatArgument extends CommandArgumen * @return Created builder */ @Nonnull - public static Builder newBuilder(@Nonnull final String name) { + public static Builder newBuilder(@Nonnull final String name) { return new Builder<>(name); } @@ -69,7 +68,7 @@ public final class FloatArgument extends CommandArgumen * @return Created argument */ @Nonnull - public static CommandArgument required(@Nonnull final String name) { + public static CommandArgument required(@Nonnull final String name) { return FloatArgument.newBuilder(name).asRequired().build(); } @@ -81,7 +80,7 @@ public final class FloatArgument extends CommandArgumen * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name) { + public static CommandArgument optional(@Nonnull final String name) { return FloatArgument.newBuilder(name).asOptional().build(); } @@ -94,13 +93,13 @@ public final class FloatArgument extends CommandArgumen * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name, + public static CommandArgument optional(@Nonnull final String name, final float defaultNum) { return FloatArgument.newBuilder(name).asOptionalWithDefault(Float.toString(defaultNum)).build(); } - public static final class Builder extends CommandArgument.Builder { + public static final class Builder extends CommandArgument.Builder { private float min = Float.MIN_VALUE; private float max = Float.MAX_VALUE; @@ -166,7 +165,7 @@ public final class FloatArgument extends CommandArgumen } - public static final class FloatParser implements ArgumentParser { + public static final class FloatParser implements ArgumentParser { private final float min; private final float max; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/IntegerArgument.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/IntegerArgument.java index c457b884..4dd9b5cf 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/IntegerArgument.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/IntegerArgument.java @@ -28,13 +28,12 @@ import com.intellectualsites.commands.arguments.parser.ArgumentParseResult; import com.intellectualsites.commands.arguments.parser.ArgumentParser; import com.intellectualsites.commands.context.CommandContext; import com.intellectualsites.commands.exceptions.parsing.NumberParseException; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.Queue; @SuppressWarnings("unused") -public final class IntegerArgument extends CommandArgument { +public final class IntegerArgument extends CommandArgument { private final int min; private final int max; @@ -57,7 +56,7 @@ public final class IntegerArgument extends CommandArgum * @return Created builder */ @Nonnull - public static Builder newBuilder(@Nonnull final String name) { + public static Builder newBuilder(@Nonnull final String name) { return new Builder<>(name); } @@ -69,7 +68,7 @@ public final class IntegerArgument extends CommandArgum * @return Created argument */ @Nonnull - public static CommandArgument required(@Nonnull final String name) { + public static CommandArgument required(@Nonnull final String name) { return IntegerArgument.newBuilder(name).asRequired().build(); } @@ -81,7 +80,7 @@ public final class IntegerArgument extends CommandArgum * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name) { + public static CommandArgument optional(@Nonnull final String name) { return IntegerArgument.newBuilder(name).asOptional().build(); } @@ -94,13 +93,13 @@ public final class IntegerArgument extends CommandArgum * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name, + public static CommandArgument optional(@Nonnull final String name, final int defaultNum) { return IntegerArgument.newBuilder(name).asOptionalWithDefault(Integer.toString(defaultNum)).build(); } - public static final class Builder extends CommandArgument.Builder { + public static final class Builder extends CommandArgument.Builder { private int min = Integer.MIN_VALUE; private int max = Integer.MAX_VALUE; @@ -166,7 +165,7 @@ public final class IntegerArgument extends CommandArgum } - public static final class IntegerParser implements ArgumentParser { + public static final class IntegerParser implements ArgumentParser { private final int min; private final int max; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/LongArgument.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/LongArgument.java index 545c01e4..f60a859f 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/LongArgument.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/LongArgument.java @@ -28,13 +28,12 @@ import com.intellectualsites.commands.arguments.parser.ArgumentParseResult; import com.intellectualsites.commands.arguments.parser.ArgumentParser; import com.intellectualsites.commands.context.CommandContext; import com.intellectualsites.commands.exceptions.parsing.NumberParseException; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.Queue; @SuppressWarnings("unused") -public final class LongArgument extends CommandArgument { +public final class LongArgument extends CommandArgument { private final long min; private final long max; @@ -57,7 +56,7 @@ public final class LongArgument extends CommandArgument * @return Created builder */ @Nonnull - public static LongArgument.Builder newBuilder(@Nonnull final String name) { + public static LongArgument.Builder newBuilder(@Nonnull final String name) { return new Builder<>(name); } @@ -69,7 +68,7 @@ public final class LongArgument extends CommandArgument * @return Created argument */ @Nonnull - public static CommandArgument required(@Nonnull final String name) { + public static CommandArgument required(@Nonnull final String name) { return LongArgument.newBuilder(name).asRequired().build(); } @@ -81,7 +80,7 @@ public final class LongArgument extends CommandArgument * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name) { + public static CommandArgument optional(@Nonnull final String name) { return LongArgument.newBuilder(name).asOptional().build(); } @@ -94,13 +93,13 @@ public final class LongArgument extends CommandArgument * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name, + public static CommandArgument optional(@Nonnull final String name, final long defaultNum) { return LongArgument.newBuilder(name).asOptionalWithDefault(Long.toString(defaultNum)).build(); } - public static final class Builder extends CommandArgument.Builder { + public static final class Builder extends CommandArgument.Builder { private long min = Long.MIN_VALUE; private long max = Long.MAX_VALUE; @@ -166,7 +165,7 @@ public final class LongArgument extends CommandArgument } - private static final class LongParser implements ArgumentParser { + private static final class LongParser implements ArgumentParser { private final long min; private final long max; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/ShortArgument.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/ShortArgument.java index 983af5c7..5f6950df 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/ShortArgument.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/ShortArgument.java @@ -28,13 +28,12 @@ import com.intellectualsites.commands.arguments.parser.ArgumentParseResult; import com.intellectualsites.commands.arguments.parser.ArgumentParser; import com.intellectualsites.commands.context.CommandContext; import com.intellectualsites.commands.exceptions.parsing.NumberParseException; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.Queue; @SuppressWarnings("unused") -public final class ShortArgument extends CommandArgument { +public final class ShortArgument extends CommandArgument { private final short min; private final short max; @@ -57,7 +56,7 @@ public final class ShortArgument extends CommandArgumen * @return Created builder */ @Nonnull - public static ShortArgument.Builder newBuilder(@Nonnull final String name) { + public static ShortArgument.Builder newBuilder(@Nonnull final String name) { return new Builder<>(name); } @@ -69,7 +68,7 @@ public final class ShortArgument extends CommandArgumen * @return Created argument */ @Nonnull - public static CommandArgument required(@Nonnull final String name) { + public static CommandArgument required(@Nonnull final String name) { return ShortArgument.newBuilder(name).asRequired().build(); } @@ -81,7 +80,7 @@ public final class ShortArgument extends CommandArgumen * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name) { + public static CommandArgument optional(@Nonnull final String name) { return ShortArgument.newBuilder(name).asOptional().build(); } @@ -94,13 +93,13 @@ public final class ShortArgument extends CommandArgumen * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name, + public static CommandArgument optional(@Nonnull final String name, final short defaultNum) { return ShortArgument.newBuilder(name).asOptionalWithDefault(Short.toString(defaultNum)).build(); } - public static final class Builder extends CommandArgument.Builder { + public static final class Builder extends CommandArgument.Builder { private short min = Short.MIN_VALUE; private short max = Short.MAX_VALUE; @@ -166,7 +165,7 @@ public final class ShortArgument extends CommandArgumen } - public static final class ShortParser implements ArgumentParser { + public static final class ShortParser implements ArgumentParser { private final short min; private final short max; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/StringArgument.java b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/StringArgument.java index 7f18d73c..94fa6f3e 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/StringArgument.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/arguments/standard/StringArgument.java @@ -27,7 +27,6 @@ import com.intellectualsites.commands.arguments.CommandArgument; import com.intellectualsites.commands.arguments.parser.ArgumentParseResult; import com.intellectualsites.commands.arguments.parser.ArgumentParser; import com.intellectualsites.commands.context.CommandContext; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.Collections; @@ -37,7 +36,7 @@ import java.util.StringJoiner; import java.util.function.BiFunction; @SuppressWarnings("unused") -public final class StringArgument extends CommandArgument { +public final class StringArgument extends CommandArgument { private final StringMode stringMode; @@ -58,7 +57,7 @@ public final class StringArgument extends CommandArgume * @return Created builder */ @Nonnull - public static StringArgument.Builder newBuilder(@Nonnull final String name) { + public static StringArgument.Builder newBuilder(@Nonnull final String name) { return new StringArgument.Builder<>(name); } @@ -70,7 +69,7 @@ public final class StringArgument extends CommandArgume * @return Created argument */ @Nonnull - public static CommandArgument required(@Nonnull final String name) { + public static CommandArgument required(@Nonnull final String name) { return StringArgument.newBuilder(name).asRequired().build(); } @@ -82,7 +81,7 @@ public final class StringArgument extends CommandArgume * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name) { + public static CommandArgument optional(@Nonnull final String name) { return StringArgument.newBuilder(name).asOptional().build(); } @@ -95,7 +94,7 @@ public final class StringArgument extends CommandArgume * @return Created argument */ @Nonnull - public static CommandArgument optional(@Nonnull final String name, + public static CommandArgument optional(@Nonnull final String name, final String defaultNum) { return StringArgument.newBuilder(name).asOptionalWithDefault(defaultNum).build(); } @@ -118,7 +117,7 @@ public final class StringArgument extends CommandArgume } - public static final class Builder extends CommandArgument.Builder { + public static final class Builder extends CommandArgument.Builder { private StringMode stringMode = StringMode.SINGLE; private BiFunction, String, List> suggestionsProvider = (v1, v2) -> Collections.emptyList(); @@ -188,7 +187,7 @@ public final class StringArgument extends CommandArgume } - public static final class StringParser implements ArgumentParser { + public static final class StringParser implements ArgumentParser { private final StringMode stringMode; private final BiFunction, String, List> suggestionsProvider; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/context/CommandContext.java b/cloud-core/src/main/java/com/intellectualsites/commands/context/CommandContext.java index 6657efe4..53b6c7c7 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/context/CommandContext.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/context/CommandContext.java @@ -23,8 +23,6 @@ // package com.intellectualsites.commands.context; -import com.intellectualsites.commands.sender.CommandSender; - import javax.annotation.Nonnull; import java.util.HashMap; import java.util.Map; @@ -35,7 +33,7 @@ import java.util.Optional; * * @param Command sender type */ -public final class CommandContext { +public final class CommandContext { private final Map internalStorage = new HashMap<>(); private final C commandSender; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/context/CommandContextFactory.java b/cloud-core/src/main/java/com/intellectualsites/commands/context/CommandContextFactory.java index bf83c3f2..c4a84b7c 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/context/CommandContextFactory.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/context/CommandContextFactory.java @@ -23,8 +23,6 @@ // package com.intellectualsites.commands.context; -import com.intellectualsites.commands.sender.CommandSender; - import javax.annotation.Nonnull; /** @@ -32,7 +30,7 @@ import javax.annotation.Nonnull; * * @param Command sender */ -public interface CommandContextFactory { +public interface CommandContextFactory { /** * Create a new command context diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/context/StandardCommandContextFactory.java b/cloud-core/src/main/java/com/intellectualsites/commands/context/StandardCommandContextFactory.java index 047b6843..6b3ffedd 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/context/StandardCommandContextFactory.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/context/StandardCommandContextFactory.java @@ -23,11 +23,9 @@ // package com.intellectualsites.commands.context; -import com.intellectualsites.commands.sender.CommandSender; - import javax.annotation.Nonnull; -public final class StandardCommandContextFactory implements CommandContextFactory { +public final class StandardCommandContextFactory implements CommandContextFactory { /** * Construct a new command context diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/context/package-info.java b/cloud-core/src/main/java/com/intellectualsites/commands/context/package-info.java index 971b0e96..c65d0f9f 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/context/package-info.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/context/package-info.java @@ -23,7 +23,7 @@ // /** - * Command context stores values for a {@link com.intellectualsites.commands.sender.CommandSender} + * Command context stores values for a command sender * before and during command execution and parsing */ package com.intellectualsites.commands.context; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/ArgumentParseException.java b/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/ArgumentParseException.java index dcee2c7b..3ab28627 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/ArgumentParseException.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/ArgumentParseException.java @@ -24,7 +24,6 @@ package com.intellectualsites.commands.exceptions; import com.intellectualsites.commands.arguments.CommandArgument; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.List; @@ -41,7 +40,7 @@ public class ArgumentParseException extends CommandParseException { * @param currentChain Chain leading up to the exception */ public ArgumentParseException(@Nonnull final Throwable throwable, - @Nonnull final CommandSender commandSender, + @Nonnull final Object commandSender, @Nonnull final List> currentChain) { super(commandSender, currentChain); this.cause = throwable; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/CommandParseException.java b/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/CommandParseException.java index d6a0561c..9829d35e 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/CommandParseException.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/CommandParseException.java @@ -24,7 +24,6 @@ package com.intellectualsites.commands.exceptions; import com.intellectualsites.commands.arguments.CommandArgument; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.Collections; @@ -36,7 +35,7 @@ import java.util.List; @SuppressWarnings("unused") public class CommandParseException extends IllegalArgumentException { - private final CommandSender commandSender; + private final Object commandSender; private final List> currentChain; /** @@ -45,7 +44,7 @@ public class CommandParseException extends IllegalArgumentException { * @param commandSender Sender who executed the command * @param currentChain Chain leading up to the exception */ - protected CommandParseException(@Nonnull final CommandSender commandSender, + protected CommandParseException(@Nonnull final Object commandSender, @Nonnull final List> currentChain) { this.commandSender = commandSender; this.currentChain = currentChain; @@ -57,7 +56,7 @@ public class CommandParseException extends IllegalArgumentException { * @return Command sender */ @Nonnull - public CommandSender getCommandSender() { + public Object getCommandSender() { return this.commandSender; } diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/InvalidCommandSenderException.java b/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/InvalidCommandSenderException.java index fb8c9a53..662606e2 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/InvalidCommandSenderException.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/InvalidCommandSenderException.java @@ -24,7 +24,6 @@ package com.intellectualsites.commands.exceptions; import com.intellectualsites.commands.arguments.CommandArgument; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.List; @@ -43,7 +42,7 @@ public final class InvalidCommandSenderException extends CommandParseException { * @param requiredSender The sender type that is required * @param currentChain Chain leading up to the exception */ - public InvalidCommandSenderException(@Nonnull final CommandSender commandSender, + public InvalidCommandSenderException(@Nonnull final Object commandSender, @Nonnull final Class requiredSender, @Nonnull final List> currentChain) { super(commandSender, currentChain); diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/InvalidSyntaxException.java b/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/InvalidSyntaxException.java index d6065162..1831362f 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/InvalidSyntaxException.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/InvalidSyntaxException.java @@ -24,13 +24,12 @@ package com.intellectualsites.commands.exceptions; import com.intellectualsites.commands.arguments.CommandArgument; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.List; /** - * Exception sent when a {@link CommandSender} inputs invalid command syntax + * Exception sent when a command sender inputs invalid command syntax */ @SuppressWarnings("unused") public class InvalidSyntaxException extends CommandParseException { @@ -45,7 +44,7 @@ public class InvalidSyntaxException extends CommandParseException { * @param currentChain Chain leading up to issue */ public InvalidSyntaxException(@Nonnull final String correctSyntax, - @Nonnull final CommandSender commandSender, + @Nonnull final Object commandSender, @Nonnull final List> currentChain) { super(commandSender, currentChain); this.correctSyntax = correctSyntax; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/NoPermissionException.java b/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/NoPermissionException.java index a1146d1b..cb69b053 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/NoPermissionException.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/NoPermissionException.java @@ -24,13 +24,12 @@ package com.intellectualsites.commands.exceptions; import com.intellectualsites.commands.arguments.CommandArgument; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.List; /** - * Exception thrown when a {@link CommandSender} misses a permission required + * Exception thrown when a command sender misses a permission required * to execute a {@link com.intellectualsites.commands.Command} */ @SuppressWarnings("unused") @@ -46,7 +45,7 @@ public class NoPermissionException extends CommandParseException { * @param currentChain Chain leading up to the exception */ public NoPermissionException(@Nonnull final String missingPermission, - @Nonnull final CommandSender commandSender, + @Nonnull final Object commandSender, @Nonnull final List> currentChain) { super(commandSender, currentChain); this.missingPermission = missingPermission; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/NoSuchCommandException.java b/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/NoSuchCommandException.java index 39d760a7..0bb5a6bd 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/NoSuchCommandException.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/exceptions/NoSuchCommandException.java @@ -24,7 +24,6 @@ package com.intellectualsites.commands.exceptions; import com.intellectualsites.commands.arguments.CommandArgument; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.List; @@ -45,7 +44,7 @@ public final class NoSuchCommandException extends CommandParseException { * @param currentChain Chain leading up to the exception * @param command Entered command (following the command chain) */ - public NoSuchCommandException(@Nonnull final CommandSender commandSender, + public NoSuchCommandException(@Nonnull final Object commandSender, @Nonnull final List> currentChain, @Nonnull final String command) { super(commandSender, currentChain); diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandExecutionCoordinator.java b/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandExecutionCoordinator.java index f672f9d9..bd8a1851 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandExecutionCoordinator.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandExecutionCoordinator.java @@ -26,7 +26,6 @@ package com.intellectualsites.commands.execution; import com.intellectualsites.commands.CommandTree; import com.intellectualsites.commands.context.CommandContext; import com.intellectualsites.commands.meta.CommandMeta; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.Queue; @@ -42,7 +41,7 @@ import java.util.function.Function; * @param Command sender type * @param Command meta type */ -public abstract class CommandExecutionCoordinator { +public abstract class CommandExecutionCoordinator { private final CommandTree commandTree; @@ -62,7 +61,7 @@ public abstract class CommandExecutionCoordinator Command meta type * @return New coordinator instance */ - public static Function, + public static Function, CommandExecutionCoordinator> simpleCoordinator() { return SimpleCoordinator::new; } @@ -94,7 +93,7 @@ public abstract class CommandExecutionCoordinator Command sender type * @param Command meta type */ - public static final class SimpleCoordinator extends + public static final class SimpleCoordinator extends CommandExecutionCoordinator { private SimpleCoordinator(@Nonnull final CommandTree commandTree) { diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandExecutionHandler.java b/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandExecutionHandler.java index c3a38572..5facaef2 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandExecutionHandler.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandExecutionHandler.java @@ -24,18 +24,17 @@ package com.intellectualsites.commands.execution; import com.intellectualsites.commands.context.CommandContext; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; /** * Handler that is invoked whenever a {@link com.intellectualsites.commands.Command} is executed - * by a {@link com.intellectualsites.commands.sender.CommandSender} + * by a command sender * * @param Command sender type */ @FunctionalInterface -public interface CommandExecutionHandler { +public interface CommandExecutionHandler { /** * Handle command execution @@ -50,7 +49,7 @@ public interface CommandExecutionHandler { * * @param Command sender type */ - class NullCommandExecutionHandler implements CommandExecutionHandler { + class NullCommandExecutionHandler implements CommandExecutionHandler { @Override public void execute(@Nonnull final CommandContext commandContext) { diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandResult.java b/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandResult.java index 5c085bc5..2ebec0af 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandResult.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandResult.java @@ -24,7 +24,6 @@ package com.intellectualsites.commands.execution; import com.intellectualsites.commands.context.CommandContext; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; @@ -33,7 +32,7 @@ import javax.annotation.Nonnull; * * @param Command sender type */ -public class CommandResult { +public class CommandResult { private final CommandContext commandContext; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandSuggestionProcessor.java b/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandSuggestionProcessor.java index 79bb374a..428ecd8c 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandSuggestionProcessor.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/execution/CommandSuggestionProcessor.java @@ -24,7 +24,6 @@ package com.intellectualsites.commands.execution; import com.intellectualsites.commands.execution.preprocessor.CommandPreprocessingContext; -import com.intellectualsites.commands.sender.CommandSender; import java.util.List; import java.util.function.BiFunction; @@ -34,7 +33,7 @@ import java.util.function.BiFunction; * * @param Command sender type */ -public interface CommandSuggestionProcessor extends +public interface CommandSuggestionProcessor extends BiFunction, List, List> { } diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/execution/FilteringCommandSuggestionProcessor.java b/cloud-core/src/main/java/com/intellectualsites/commands/execution/FilteringCommandSuggestionProcessor.java index 97429140..85f79264 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/execution/FilteringCommandSuggestionProcessor.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/execution/FilteringCommandSuggestionProcessor.java @@ -24,7 +24,6 @@ package com.intellectualsites.commands.execution; import com.intellectualsites.commands.execution.preprocessor.CommandPreprocessingContext; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.LinkedList; @@ -35,7 +34,7 @@ import java.util.List; * * @param Command sender type */ -public final class FilteringCommandSuggestionProcessor implements CommandSuggestionProcessor { +public final class FilteringCommandSuggestionProcessor implements CommandSuggestionProcessor { @Nonnull @Override diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/execution/preprocessor/AcceptingCommandPreprocessor.java b/cloud-core/src/main/java/com/intellectualsites/commands/execution/preprocessor/AcceptingCommandPreprocessor.java index 4dbe5b62..1def0070 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/execution/preprocessor/AcceptingCommandPreprocessor.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/execution/preprocessor/AcceptingCommandPreprocessor.java @@ -23,8 +23,6 @@ // package com.intellectualsites.commands.execution.preprocessor; -import com.intellectualsites.commands.sender.CommandSender; - import javax.annotation.Nonnull; /** @@ -33,7 +31,7 @@ import javax.annotation.Nonnull; * * @param Command sender type */ -public final class AcceptingCommandPreprocessor implements CommandPreprocessor { +public final class AcceptingCommandPreprocessor implements CommandPreprocessor { /** * Key used to access the context meta that indicates that the context has been fully processed diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/execution/preprocessor/CommandPreprocessingContext.java b/cloud-core/src/main/java/com/intellectualsites/commands/execution/preprocessor/CommandPreprocessingContext.java index 3616f216..815eac2e 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/execution/preprocessor/CommandPreprocessingContext.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/execution/preprocessor/CommandPreprocessingContext.java @@ -24,7 +24,6 @@ package com.intellectualsites.commands.execution.preprocessor; import com.intellectualsites.commands.context.CommandContext; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; import java.util.LinkedList; @@ -35,7 +34,7 @@ import java.util.Objects; * * @param Command sender type */ -public final class CommandPreprocessingContext { +public final class CommandPreprocessingContext { private final CommandContext commandContext; private final LinkedList inputQueue; diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/execution/preprocessor/CommandPreprocessor.java b/cloud-core/src/main/java/com/intellectualsites/commands/execution/preprocessor/CommandPreprocessor.java index a94904ed..0174da3e 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/execution/preprocessor/CommandPreprocessor.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/execution/preprocessor/CommandPreprocessor.java @@ -23,7 +23,6 @@ // package com.intellectualsites.commands.execution.preprocessor; -import com.intellectualsites.commands.sender.CommandSender; import com.intellectualsites.services.types.ConsumerService; /** @@ -36,5 +35,5 @@ import com.intellectualsites.services.types.ConsumerService; * @param Command sender type * {@inheritDoc} */ -public interface CommandPreprocessor extends ConsumerService> { +public interface CommandPreprocessor extends ConsumerService> { } diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/sender/CommandSender.java b/cloud-core/src/main/java/com/intellectualsites/commands/sender/CommandSender.java deleted file mode 100644 index 87844df9..00000000 --- a/cloud-core/src/main/java/com/intellectualsites/commands/sender/CommandSender.java +++ /dev/null @@ -1,38 +0,0 @@ -// -// MIT License -// -// Copyright (c) 2020 Alexander Söderberg -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// -package com.intellectualsites.commands.sender; - -import javax.annotation.Nonnull; - -public interface CommandSender { - - /** - * Check if the command sender has a given permission node - * - * @param permission Permission node - * @return {@code true} if the sender has the given permission node, else {@code false} - */ - boolean hasPermission(@Nonnull String permission); - -} diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/sender/package-info.java b/cloud-core/src/main/java/com/intellectualsites/commands/sender/package-info.java deleted file mode 100644 index 752d5a8b..00000000 --- a/cloud-core/src/main/java/com/intellectualsites/commands/sender/package-info.java +++ /dev/null @@ -1,28 +0,0 @@ -// -// MIT License -// -// Copyright (c) 2020 Alexander Söderberg -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// - -/** - * Command sender related classes - */ -package com.intellectualsites.commands.sender; diff --git a/cloud-core/src/test/java/com/intellectualsites/commands/CommandPreProcessorTest.java b/cloud-core/src/test/java/com/intellectualsites/commands/CommandPreProcessorTest.java index 762a83ca..a1521063 100644 --- a/cloud-core/src/test/java/com/intellectualsites/commands/CommandPreProcessorTest.java +++ b/cloud-core/src/test/java/com/intellectualsites/commands/CommandPreProcessorTest.java @@ -27,7 +27,6 @@ import com.intellectualsites.commands.arguments.standard.EnumArgument; import com.intellectualsites.commands.execution.preprocessor.CommandPreprocessingContext; import com.intellectualsites.commands.execution.preprocessor.CommandPreprocessor; import com.intellectualsites.commands.meta.SimpleCommandMeta; -import com.intellectualsites.commands.sender.CommandSender; import com.intellectualsites.services.types.ConsumerService; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -37,7 +36,7 @@ import javax.annotation.Nonnull; public class CommandPreProcessorTest { - private static CommandManager manager; + private static CommandManager manager; @BeforeAll static void newTree() { @@ -70,10 +69,10 @@ public class CommandPreProcessorTest { } - static final class SamplePreprocessor implements CommandPreprocessor { + static final class SamplePreprocessor implements CommandPreprocessor { @Override - public void accept(@Nonnull final CommandPreprocessingContext context) { + public void accept(@Nonnull final CommandPreprocessingContext context) { try { final int num = Integer.parseInt(context.getInputQueue().removeFirst()); context.getCommandContext().store("int", num); diff --git a/cloud-core/src/test/java/com/intellectualsites/commands/CommandSuggestionsTest.java b/cloud-core/src/test/java/com/intellectualsites/commands/CommandSuggestionsTest.java index e918fb9b..34529523 100644 --- a/cloud-core/src/test/java/com/intellectualsites/commands/CommandSuggestionsTest.java +++ b/cloud-core/src/test/java/com/intellectualsites/commands/CommandSuggestionsTest.java @@ -27,7 +27,6 @@ import com.intellectualsites.commands.arguments.StaticArgument; import com.intellectualsites.commands.arguments.standard.EnumArgument; import com.intellectualsites.commands.arguments.standard.StringArgument; import com.intellectualsites.commands.meta.SimpleCommandMeta; -import com.intellectualsites.commands.sender.CommandSender; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -38,7 +37,7 @@ import java.util.List; public class CommandSuggestionsTest { - private static CommandManager manager; + private static CommandManager manager; @BeforeAll static void setupManager() { @@ -47,7 +46,7 @@ public class CommandSuggestionsTest { manager.command(manager.commandBuilder("test").argument(StaticArgument.required("two")).build()); manager.command(manager.commandBuilder("test") .argument(StaticArgument.required("var")) - .argument(StringArgument.newBuilder("str") + .argument(StringArgument.newBuilder("str") .withSuggestionsProvider((c, s) -> Arrays.asList("one", "two")) .build()) .argument(EnumArgument.required(TestEnum.class, "enum")) diff --git a/cloud-core/src/test/java/com/intellectualsites/commands/CommandTreeTest.java b/cloud-core/src/test/java/com/intellectualsites/commands/CommandTreeTest.java index c4e1d1f3..4e6e629f 100644 --- a/cloud-core/src/test/java/com/intellectualsites/commands/CommandTreeTest.java +++ b/cloud-core/src/test/java/com/intellectualsites/commands/CommandTreeTest.java @@ -28,7 +28,6 @@ import com.intellectualsites.commands.arguments.standard.IntegerArgument; import com.intellectualsites.commands.context.CommandContext; import com.intellectualsites.commands.exceptions.NoPermissionException; import com.intellectualsites.commands.meta.SimpleCommandMeta; -import com.intellectualsites.commands.sender.CommandSender; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -42,7 +41,7 @@ import java.util.concurrent.CompletionException; class CommandTreeTest { private static final int EXPECTED_INPUT_NUMBER = 15; - private static CommandManager manager; + private static CommandManager manager; @BeforeAll static void newTree() { @@ -62,7 +61,7 @@ class CommandTreeTest { @Test void parse() { - final Optional> command = manager.getCommandTree() + final Optional> command = manager.getCommandTree() .parse(new CommandContext<>( new TestCommandSender()), new LinkedList<>( diff --git a/cloud-core/src/test/java/com/intellectualsites/commands/ParserRegistryTest.java b/cloud-core/src/test/java/com/intellectualsites/commands/ParserRegistryTest.java index 0af0ae4a..8a9420c0 100644 --- a/cloud-core/src/test/java/com/intellectualsites/commands/ParserRegistryTest.java +++ b/cloud-core/src/test/java/com/intellectualsites/commands/ParserRegistryTest.java @@ -31,7 +31,6 @@ import com.intellectualsites.commands.arguments.parser.ParserRegistry; import com.intellectualsites.commands.arguments.parser.StandardParameters; import com.intellectualsites.commands.arguments.parser.StandardParserRegistry; import com.intellectualsites.commands.arguments.standard.IntegerArgument; -import com.intellectualsites.commands.sender.CommandSender; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -46,7 +45,7 @@ public class ParserRegistryTest { @Test void testParserRegistry() { - final ParserRegistry parserRegistry = new StandardParserRegistry<>(); + final ParserRegistry parserRegistry = new StandardParserRegistry<>(); final Range range = new Range() { @Override @@ -72,13 +71,14 @@ public class ParserRegistryTest { final ParserParameters parserParameters = parserRegistry.parseAnnotations(parsedType, Collections.singleton(range)); Assertions.assertTrue(parserParameters.has(StandardParameters.RANGE_MIN)); Assertions.assertTrue(parserParameters.has(StandardParameters.RANGE_MAX)); - final ArgumentParser parser = parserRegistry.createParser(parsedType, + final ArgumentParser parser = parserRegistry.createParser(parsedType, parserParameters) .orElseThrow( () -> new NullPointerException("No parser found")); Assertions.assertTrue(parser instanceof IntegerArgument.IntegerParser); @SuppressWarnings("unchecked") - final IntegerArgument.IntegerParser integerParser = (IntegerArgument.IntegerParser) parser; + final IntegerArgument.IntegerParser integerParser = + (IntegerArgument.IntegerParser) parser; Assertions.assertEquals(RANGE_MIN, integerParser.getMin()); Assertions.assertEquals(RANGE_MAX, integerParser.getMax()); } diff --git a/cloud-core/src/test/java/com/intellectualsites/commands/TestCommandManager.java b/cloud-core/src/test/java/com/intellectualsites/commands/TestCommandManager.java index 907a2111..2c8423c5 100644 --- a/cloud-core/src/test/java/com/intellectualsites/commands/TestCommandManager.java +++ b/cloud-core/src/test/java/com/intellectualsites/commands/TestCommandManager.java @@ -26,11 +26,10 @@ package com.intellectualsites.commands; import com.intellectualsites.commands.execution.CommandExecutionCoordinator; import com.intellectualsites.commands.internal.CommandRegistrationHandler; import com.intellectualsites.commands.meta.SimpleCommandMeta; -import com.intellectualsites.commands.sender.CommandSender; import javax.annotation.Nonnull; -public class TestCommandManager extends CommandManager { +public class TestCommandManager extends CommandManager { protected TestCommandManager() { super(CommandExecutionCoordinator.simpleCoordinator(), CommandRegistrationHandler.nullCommandRegistrationHandler()); @@ -42,5 +41,11 @@ public class TestCommandManager extends CommandManager Command sender type * @param Brigadier sender type */ -public final class CloudBrigadierManager { +public final class CloudBrigadierManager { private final Map, Function, ? extends ArgumentType>> mappers; diff --git a/cloud-minecraft/cloud-bukkit-test/src/main/java/com/intellectualsites/commands/BukkitTest.java b/cloud-minecraft/cloud-bukkit-test/src/main/java/com/intellectualsites/commands/BukkitTest.java index 719eb974..87cfe419 100644 --- a/cloud-minecraft/cloud-bukkit-test/src/main/java/com/intellectualsites/commands/BukkitTest.java +++ b/cloud-minecraft/cloud-bukkit-test/src/main/java/com/intellectualsites/commands/BukkitTest.java @@ -55,10 +55,13 @@ public final class BukkitTest extends JavaPlugin { @Override public void onEnable() { try { - final PaperCommandManager mgr = new PaperCommandManager<>(this, - CommandExecutionCoordinator - .simpleCoordinator(), - BukkitCommandSender::of); + final PaperCommandManager mgr = new PaperCommandManager<>( + this, + CommandExecutionCoordinator + .simpleCoordinator(), + BukkitCommandSender::of, + BukkitCommandSender::getInternalSender + ); mgr.registerBrigadier(); mgr.command(mgr.commandBuilder("gamemode", Collections.singleton("gajmöde"), diff --git a/cloud-minecraft/cloud-bukkit/src/main/java/com/intellectualsites/commands/BukkitCommand.java b/cloud-minecraft/cloud-bukkit/src/main/java/com/intellectualsites/commands/BukkitCommand.java index c3d93e03..8d3775aa 100644 --- a/cloud-minecraft/cloud-bukkit/src/main/java/com/intellectualsites/commands/BukkitCommand.java +++ b/cloud-minecraft/cloud-bukkit/src/main/java/com/intellectualsites/commands/BukkitCommand.java @@ -32,7 +32,7 @@ import org.bukkit.plugin.Plugin; import javax.annotation.Nonnull; import java.util.List; -final class BukkitCommand +final class BukkitCommand extends org.bukkit.command.Command implements PluginIdentifiableCommand { private final CommandArgument command; diff --git a/cloud-minecraft/cloud-bukkit/src/main/java/com/intellectualsites/commands/BukkitCommandManager.java b/cloud-minecraft/cloud-bukkit/src/main/java/com/intellectualsites/commands/BukkitCommandManager.java index 8427227d..baec20c3 100644 --- a/cloud-minecraft/cloud-bukkit/src/main/java/com/intellectualsites/commands/BukkitCommandManager.java +++ b/cloud-minecraft/cloud-bukkit/src/main/java/com/intellectualsites/commands/BukkitCommandManager.java @@ -39,29 +39,34 @@ import java.util.function.Function; * * @param Command sender type */ -public class BukkitCommandManager +public class BukkitCommandManager extends CommandManager { private final Plugin owningPlugin; + private final Function commandSenderMapper; + private final Function backwardsCommandSenderMapper; /** * Construct a new Bukkit command manager * - * @param owningPlugin Plugin that is constructing the manager - * @param commandExecutionCoordinator Coordinator provider - * @param commandSenderMapper Function that maps {@link CommandSender} to the command sender type + * @param owningPlugin Plugin that is constructing the manager + * @param commandExecutionCoordinator Coordinator provider + * @param commandSenderMapper Function that maps {@link CommandSender} to the command sender type + * @param backwardsCommandSenderMapper Function that maps the command sender type to {@link CommandSender} * @throws Exception If the construction of the manager fails */ public BukkitCommandManager(@Nonnull final Plugin owningPlugin, @Nonnull final Function, CommandExecutionCoordinator> commandExecutionCoordinator, - @Nonnull final Function commandSenderMapper) + @Nonnull final Function commandSenderMapper, + @Nonnull final Function backwardsCommandSenderMapper) throws Exception { super(commandExecutionCoordinator, new BukkitPluginRegistrationHandler<>()); ((BukkitPluginRegistrationHandler) this.getCommandRegistrationHandler()).initialize(this); this.owningPlugin = owningPlugin; this.commandSenderMapper = commandSenderMapper; + this.backwardsCommandSenderMapper = backwardsCommandSenderMapper; /* Register Bukkit parsers */ this.getParserRegistry().registerParserSupplier(TypeToken.of(World.class), params -> new WorldArgument.WorldParser<>()); @@ -93,4 +98,9 @@ public class BukkitCommandManager implements CommandRegistrationHandler { +final class BukkitPluginRegistrationHandler implements CommandRegistrationHandler { private final Map, org.bukkit.command.Command> registeredCommands = new HashMap<>(); diff --git a/cloud-minecraft/cloud-bukkit/src/main/java/com/intellectualsites/commands/parsers/WorldArgument.java b/cloud-minecraft/cloud-bukkit/src/main/java/com/intellectualsites/commands/parsers/WorldArgument.java index f7495e72..7be47a85 100644 --- a/cloud-minecraft/cloud-bukkit/src/main/java/com/intellectualsites/commands/parsers/WorldArgument.java +++ b/cloud-minecraft/cloud-bukkit/src/main/java/com/intellectualsites/commands/parsers/WorldArgument.java @@ -27,7 +27,6 @@ import com.intellectualsites.commands.arguments.CommandArgument; import com.intellectualsites.commands.arguments.parser.ArgumentParseResult; import com.intellectualsites.commands.arguments.parser.ArgumentParser; import com.intellectualsites.commands.context.CommandContext; -import com.intellectualsites.commands.sender.CommandSender; import org.bukkit.Bukkit; import org.bukkit.World; @@ -41,7 +40,7 @@ import java.util.stream.Collectors; * * @param Command sender type */ -public class WorldArgument extends CommandArgument { +public class WorldArgument extends CommandArgument { protected WorldArgument(final boolean required, @Nonnull final String name, @@ -57,7 +56,7 @@ public class WorldArgument extends CommandArgument CommandArgument.Builder newBuilder(@Nonnull final String name) { + public static CommandArgument.Builder newBuilder(@Nonnull final String name) { return new WorldArgument.Builder<>(name); } @@ -69,7 +68,7 @@ public class WorldArgument extends CommandArgument CommandArgument required(@Nonnull final String name) { + public static CommandArgument required(@Nonnull final String name) { return WorldArgument.newBuilder(name).asRequired().build(); } @@ -81,7 +80,7 @@ public class WorldArgument extends CommandArgument CommandArgument optional(@Nonnull final String name) { + public static CommandArgument optional(@Nonnull final String name) { return WorldArgument.newBuilder(name).asOptional().build(); } @@ -94,13 +93,13 @@ public class WorldArgument extends CommandArgument CommandArgument optional(@Nonnull final String name, + public static CommandArgument optional(@Nonnull final String name, @Nonnull final String defaultValue) { return WorldArgument.newBuilder(name).asOptionalWithDefault(defaultValue).build(); } - public static final class Builder extends CommandArgument.Builder { + public static final class Builder extends CommandArgument.Builder { protected Builder(@Nonnull final String name) { super(World.class, name); @@ -114,7 +113,7 @@ public class WorldArgument extends CommandArgument implements ArgumentParser { + public static final class WorldParser implements ArgumentParser { @Nonnull @Override diff --git a/cloud-minecraft/cloud-paper/src/main/java/com/intellectualsites/commands/PaperBrigadierListener.java b/cloud-minecraft/cloud-paper/src/main/java/com/intellectualsites/commands/PaperBrigadierListener.java index 27079609..a4c6245b 100644 --- a/cloud-minecraft/cloud-paper/src/main/java/com/intellectualsites/commands/PaperBrigadierListener.java +++ b/cloud-minecraft/cloud-paper/src/main/java/com/intellectualsites/commands/PaperBrigadierListener.java @@ -25,10 +25,9 @@ package com.intellectualsites.commands; import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource; import com.destroystokyo.paper.event.brigadier.CommandRegisteredEvent; -import com.intellectualsites.commands.brigadier.CloudBrigadierManager; import com.intellectualsites.commands.arguments.CommandArgument; +import com.intellectualsites.commands.brigadier.CloudBrigadierManager; import com.intellectualsites.commands.context.CommandContext; -import com.intellectualsites.commands.sender.CommandSender; import com.mojang.brigadier.arguments.ArgumentType; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -42,7 +41,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.UUID; -class PaperBrigadierListener implements Listener { +class PaperBrigadierListener implements Listener { private final CloudBrigadierManager brigadierManager; private final PaperCommandManager paperCommandManager; diff --git a/cloud-minecraft/cloud-paper/src/main/java/com/intellectualsites/commands/PaperCommandManager.java b/cloud-minecraft/cloud-paper/src/main/java/com/intellectualsites/commands/PaperCommandManager.java index 1c5ed01b..1f3bc9b1 100644 --- a/cloud-minecraft/cloud-paper/src/main/java/com/intellectualsites/commands/PaperCommandManager.java +++ b/cloud-minecraft/cloud-paper/src/main/java/com/intellectualsites/commands/PaperCommandManager.java @@ -37,7 +37,7 @@ import java.util.function.Function; * * @param Command sender type */ -public class PaperCommandManager +public class PaperCommandManager extends BukkitCommandManager { /** @@ -46,14 +46,16 @@ public class PaperCommandManager, CommandExecutionCoordinator> commandExecutionCoordinator, - @Nonnull final Function commandSenderMapper) throws + @Nonnull final Function commandSenderMapper, + @Nonnull final Function backwardsCommandSenderMapper) throws Exception { - super(owningPlugin, commandExecutionCoordinator, commandSenderMapper); + super(owningPlugin, commandExecutionCoordinator, commandSenderMapper, backwardsCommandSenderMapper); } /**