Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Allow RequiredArgumentBuilder to be extended #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

willkroboth
Copy link

This PR makes RequiredArgumentBuilder's constructor protected, which makes it possible to create a class that extends RequiredArgumentBuilder.


Currently, while RequiredArgumentBuilder is a public, non-final class, its only constructor is private:

public class RequiredArgumentBuilder<S, T> extends ArgumentBuilder<S, RequiredArgumentBuilder<S, T>> {
private final String name;
private final ArgumentType<T> type;
private SuggestionProvider<S> suggestionsProvider = null;
private RequiredArgumentBuilder(final String name, final ArgumentType<T> type) {
this.name = name;
this.type = type;
}
public static <S, T> RequiredArgumentBuilder<S, T> argument(final String name, final ArgumentType<T> type) {
return new RequiredArgumentBuilder<>(name, type);
}
public RequiredArgumentBuilder<S, T> suggests(final SuggestionProvider<S> provider) {

This makes it impossible to extend RequiredArgumentBuilder, since there is no valid accessible signature for the super call in a subclass.

On the contrary, LiteralArgumentBuilder's constructor is protected:

public class LiteralArgumentBuilder<S> extends ArgumentBuilder<S, LiteralArgumentBuilder<S>> {
private final String literal;
protected LiteralArgumentBuilder(final String literal) {
this.literal = literal;
}
public static <S> LiteralArgumentBuilder<S> literal(final String name) {
return new LiteralArgumentBuilder<>(name);
}
@Override
protected LiteralArgumentBuilder<S> getThis() {

Subclasses are allowed to access protected members of their superclass, so it is possible to extend LiteralArgumentBuilder.

Since RequiredArgumentBuilder and LiteralArgumentBuilder are not final, it seems to me that were intended to be extendable.

willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Dec 27, 2023
Changes:
- Implemented `FlagsArgument` (#483)
  - Moved var handles for `CommandNode` `children`,`literals`, and `arguments` to `CommandAPIHandler`
  - Added `FlagsArgumentCommon` FlagsArgumentRootNode` and `FlagsArgumentEndingNode` to handle the special node structure and parsing required
- Updated `CustomArgument`
  - All `AbstractArgument` builder methods are delegated to the base argument
  - Replaced `CommandAPIExecutor` parameter of `AbstractArgument#addArgumentNodes` to a `Function` to allow object that hold arguments to better control how those arguments are executed
- Added package `dev.jorel.commandapi.commandnodes` for class that extend `CommandNode` and related classes
- Tweaked some exceptions
  - `GreedyArgumentException`
    - Changed because the `FlagsArgument` is sometimes greedy - only greedy iff it has no terminal branches
    - Greedy arguments are now detected when `AbstractArgument#addArgumentNodes` returns an empty list
    - Tweaked the exception message
  - `DuplicateNodeNameException`
    - Changed because literal arguments can conflict with other nodes if they are listed
    - Now thrown when two listed arguments have the same node name
    - Added `UnnamedArgumentCommandNode` to make sure unlisted arguments do not conflict
    - Renamed `MultiLiteralCommandNode` to `NamedLiteralCommandNode` for use by listed `Literal` arguments
    - Tweaked the exception message

TODO:
- Clean up code
- Add tests
- Remove test commands in CommandAPIMain
- Add javadocs and documentation
- Hope Mojang/brigadier#144 is resolved, otherwise be annoyed :(
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Feb 28, 2024
Changes:
- Implemented `FlagsArgument` (#483)
  - Moved var handles for `CommandNode` `children`,`literals`, and `arguments` to `CommandAPIHandler`
  - Added `FlagsArgumentCommon` FlagsArgumentRootNode` and `FlagsArgumentEndingNode` to handle the special node structure and parsing required
- Updated `CustomArgument`
  - All `AbstractArgument` builder methods are delegated to the base argument
  - Replaced `CommandAPIExecutor` parameter of `AbstractArgument#addArgumentNodes` to a `Function` to allow object that hold arguments to better control how those arguments are executed
- Added package `dev.jorel.commandapi.commandnodes` for class that extend `CommandNode` and related classes
- Tweaked some exceptions
  - `GreedyArgumentException`
    - Changed because the `FlagsArgument` is sometimes greedy - only greedy iff it has no terminal branches
    - Greedy arguments are now detected when `AbstractArgument#addArgumentNodes` returns an empty list
    - Tweaked the exception message
  - `DuplicateNodeNameException`
    - Changed because literal arguments can conflict with other nodes if they are listed
    - Now thrown when two listed arguments have the same node name
    - Added `UnnamedArgumentCommandNode` to make sure unlisted arguments do not conflict
    - Renamed `MultiLiteralCommandNode` to `NamedLiteralCommandNode` for use by listed `Literal` arguments
    - Tweaked the exception message

TODO:
- Clean up code
- Add tests
- Remove test commands in CommandAPIMain
- Add javadocs and documentation
- Hope Mojang/brigadier#144 is resolved, otherwise be annoyed :(
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Mar 19, 2024
Changes:
- Implemented `FlagsArgument` (#483)
  - Moved var handles for `CommandNode` `children`,`literals`, and `arguments` to `CommandAPIHandler`
  - Added `FlagsArgumentCommon` FlagsArgumentRootNode` and `FlagsArgumentEndingNode` to handle the special node structure and parsing required
- Updated `CustomArgument`
  - All `AbstractArgument` builder methods are delegated to the base argument
  - Replaced `CommandAPIExecutor` parameter of `AbstractArgument#addArgumentNodes` to a `Function` to allow object that hold arguments to better control how those arguments are executed
- Added package `dev.jorel.commandapi.commandnodes` for class that extend `CommandNode` and related classes
- Tweaked some exceptions
  - `GreedyArgumentException`
    - Changed because the `FlagsArgument` is sometimes greedy - only greedy iff it has no terminal branches
    - Greedy arguments are now detected when `AbstractArgument#addArgumentNodes` returns an empty list
    - Tweaked the exception message
  - `DuplicateNodeNameException`
    - Changed because literal arguments can conflict with other nodes if they are listed
    - Now thrown when two listed arguments have the same node name
    - Added `UnnamedArgumentCommandNode` to make sure unlisted arguments do not conflict
    - Renamed `MultiLiteralCommandNode` to `NamedLiteralCommandNode` for use by listed `Literal` arguments
    - Tweaked the exception message

TODO:
- Clean up code
- Add tests
- Remove test commands in CommandAPIMain
- Add javadocs and documentation
- Hope Mojang/brigadier#144 is resolved, otherwise be annoyed :(
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Apr 29, 2024
Changes:
- Implemented `FlagsArgument` (#483)
  - Moved var handles for `CommandNode` `children`,`literals`, and `arguments` to `CommandAPIHandler`
  - Added `FlagsArgumentCommon` FlagsArgumentRootNode` and `FlagsArgumentEndingNode` to handle the special node structure and parsing required
- Updated `CustomArgument`
  - All `AbstractArgument` builder methods are delegated to the base argument
  - Replaced `CommandAPIExecutor` parameter of `AbstractArgument#addArgumentNodes` to a `Function` to allow object that hold arguments to better control how those arguments are executed
- Added package `dev.jorel.commandapi.commandnodes` for class that extend `CommandNode` and related classes
- Tweaked some exceptions
  - `GreedyArgumentException`
    - Changed because the `FlagsArgument` is sometimes greedy - only greedy iff it has no terminal branches
    - Greedy arguments are now detected when `AbstractArgument#addArgumentNodes` returns an empty list
    - Tweaked the exception message
  - `DuplicateNodeNameException`
    - Changed because literal arguments can conflict with other nodes if they are listed
    - Now thrown when two listed arguments have the same node name
    - Added `UnnamedArgumentCommandNode` to make sure unlisted arguments do not conflict
    - Renamed `MultiLiteralCommandNode` to `NamedLiteralCommandNode` for use by listed `Literal` arguments
    - Tweaked the exception message

TODO:
- Clean up code
- Add tests
- Remove test commands in CommandAPIMain
- Add javadocs and documentation
- Hope Mojang/brigadier#144 is resolved, otherwise be annoyed :(
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Apr 30, 2024
- Removed `CommandAPIHandler#previewableArguments` and related methods
- Added `PreviewableCommandNode` for storing `Previewable` information directly in Brigadier's tree
- Tweak `NMS_1_19_Common_ChatPreviewHandler` to build previews from the node tree rather than by the node path

TODO: Should probably test these changes on a real server to verify. Also, another example of Mojang/brigadier#144 being annoying.
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Apr 30, 2024
Changes:
- Implemented `FlagsArgument` (#483)
  - Moved var handles for `CommandNode` `children`,`literals`, and `arguments` to `CommandAPIHandler`
  - Added `FlagsArgumentCommon` FlagsArgumentRootNode` and `FlagsArgumentEndingNode` to handle the special node structure and parsing required
- Updated `CustomArgument`
  - All `AbstractArgument` builder methods are delegated to the base argument
  - Replaced `CommandAPIExecutor` parameter of `AbstractArgument#addArgumentNodes` to a `Function` to allow object that hold arguments to better control how those arguments are executed
- Added package `dev.jorel.commandapi.commandnodes` for class that extend `CommandNode` and related classes
- Tweaked some exceptions
  - `GreedyArgumentException`
    - Changed because the `FlagsArgument` is sometimes greedy - only greedy iff it has no terminal branches
    - Greedy arguments are now detected when `AbstractArgument#addArgumentNodes` returns an empty list
    - Tweaked the exception message
  - `DuplicateNodeNameException`
    - Changed because literal arguments can conflict with other nodes if they are listed
    - Now thrown when two listed arguments have the same node name
    - Added `UnnamedArgumentCommandNode` to make sure unlisted arguments do not conflict
    - Renamed `MultiLiteralCommandNode` to `NamedLiteralCommandNode` for use by listed `Literal` arguments
    - Tweaked the exception message

TODO:
- Clean up code
- Add tests
- Remove test commands in CommandAPIMain
- Add javadocs and documentation
- Hope Mojang/brigadier#144 is resolved, otherwise be annoyed :(
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Apr 30, 2024
- Removed `CommandAPIHandler#previewableArguments` and related methods
- Added `PreviewableCommandNode` for storing `Previewable` information directly in Brigadier's tree
- Tweak `NMS_1_19_Common_ChatPreviewHandler` to build previews from the node tree rather than by the node path

TODO: Should probably test these changes on a real server to verify. Also, another example of Mojang/brigadier#144 being annoying.
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request May 13, 2024
Changes:
- Implemented `FlagsArgument` (#483)
  - Moved var handles for `CommandNode` `children`,`literals`, and `arguments` to `CommandAPIHandler`
  - Added `FlagsArgumentCommon` FlagsArgumentRootNode` and `FlagsArgumentEndingNode` to handle the special node structure and parsing required
- Updated `CustomArgument`
  - All `AbstractArgument` builder methods are delegated to the base argument
  - Replaced `CommandAPIExecutor` parameter of `AbstractArgument#addArgumentNodes` to a `Function` to allow object that hold arguments to better control how those arguments are executed
- Added package `dev.jorel.commandapi.commandnodes` for class that extend `CommandNode` and related classes
- Tweaked some exceptions
  - `GreedyArgumentException`
    - Changed because the `FlagsArgument` is sometimes greedy - only greedy iff it has no terminal branches
    - Greedy arguments are now detected when `AbstractArgument#addArgumentNodes` returns an empty list
    - Tweaked the exception message
  - `DuplicateNodeNameException`
    - Changed because literal arguments can conflict with other nodes if they are listed
    - Now thrown when two listed arguments have the same node name
    - Added `UnnamedArgumentCommandNode` to make sure unlisted arguments do not conflict
    - Renamed `MultiLiteralCommandNode` to `NamedLiteralCommandNode` for use by listed `Literal` arguments
    - Tweaked the exception message

TODO:
- Clean up code
- Add tests
- Remove test commands in CommandAPIMain
- Add javadocs and documentation
- Hope Mojang/brigadier#144 is resolved, otherwise be annoyed :(
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request May 13, 2024
- Removed `CommandAPIHandler#previewableArguments` and related methods
- Added `PreviewableCommandNode` for storing `Previewable` information directly in Brigadier's tree
- Tweak `NMS_1_19_Common_ChatPreviewHandler` to build previews from the node tree rather than by the node path

TODO: Should probably test these changes on a real server to verify. Also, another example of Mojang/brigadier#144 being annoying.
@willkroboth
Copy link
Author

I realized this is exactly the same PR as #122. I don't think I'll close this though, since double the PRs means double the chance this gets noticed by Mojang :P.

willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request May 14, 2024
Changes:
- Implemented `FlagsArgument` (#483)
  - Moved var handles for `CommandNode` `children`,`literals`, and `arguments` to `CommandAPIHandler`
  - Added `FlagsArgumentCommon` FlagsArgumentRootNode` and `FlagsArgumentEndingNode` to handle the special node structure and parsing required
- Updated `CustomArgument`
  - All `AbstractArgument` builder methods are delegated to the base argument
  - Replaced `CommandAPIExecutor` parameter of `AbstractArgument#addArgumentNodes` to a `Function` to allow object that hold arguments to better control how those arguments are executed
- Added package `dev.jorel.commandapi.commandnodes` for class that extend `CommandNode` and related classes
- Tweaked some exceptions
  - `GreedyArgumentException`
    - Changed because the `FlagsArgument` is sometimes greedy - only greedy iff it has no terminal branches
    - Greedy arguments are now detected when `AbstractArgument#addArgumentNodes` returns an empty list
    - Tweaked the exception message
  - `DuplicateNodeNameException`
    - Changed because literal arguments can conflict with other nodes if they are listed
    - Now thrown when two listed arguments have the same node name
    - Added `UnnamedArgumentCommandNode` to make sure unlisted arguments do not conflict
    - Renamed `MultiLiteralCommandNode` to `NamedLiteralCommandNode` for use by listed `Literal` arguments
    - Tweaked the exception message

TODO:
- Clean up code
- Add tests
- Remove test commands in CommandAPIMain
- Add javadocs and documentation
- Hope Mojang/brigadier#144 is resolved, otherwise be annoyed :(
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request May 14, 2024
- Removed `CommandAPIHandler#previewableArguments` and related methods
- Added `PreviewableCommandNode` for storing `Previewable` information directly in Brigadier's tree
- Tweak `NMS_1_19_Common_ChatPreviewHandler` to build previews from the node tree rather than by the node path

TODO: Should probably test these changes on a real server to verify. Also, another example of Mojang/brigadier#144 being annoying.
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Jun 3, 2024
Changes:
- Implemented `FlagsArgument` (#483)
  - Moved var handles for `CommandNode` `children`,`literals`, and `arguments` to `CommandAPIHandler`
  - Added `FlagsArgumentCommon` FlagsArgumentRootNode` and `FlagsArgumentEndingNode` to handle the special node structure and parsing required
- Updated `CustomArgument`
  - All `AbstractArgument` builder methods are delegated to the base argument
  - Replaced `CommandAPIExecutor` parameter of `AbstractArgument#addArgumentNodes` to a `Function` to allow object that hold arguments to better control how those arguments are executed
- Added package `dev.jorel.commandapi.commandnodes` for class that extend `CommandNode` and related classes
- Tweaked some exceptions
  - `GreedyArgumentException`
    - Changed because the `FlagsArgument` is sometimes greedy - only greedy iff it has no terminal branches
    - Greedy arguments are now detected when `AbstractArgument#addArgumentNodes` returns an empty list
    - Tweaked the exception message
  - `DuplicateNodeNameException`
    - Changed because literal arguments can conflict with other nodes if they are listed
    - Now thrown when two listed arguments have the same node name
    - Added `UnnamedArgumentCommandNode` to make sure unlisted arguments do not conflict
    - Renamed `MultiLiteralCommandNode` to `NamedLiteralCommandNode` for use by listed `Literal` arguments
    - Tweaked the exception message

TODO:
- Clean up code
- Add tests
- Remove test commands in CommandAPIMain
- Add javadocs and documentation
- Hope Mojang/brigadier#144 is resolved, otherwise be annoyed :(
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Jun 3, 2024
- Removed `CommandAPIHandler#previewableArguments` and related methods
- Added `PreviewableCommandNode` for storing `Previewable` information directly in Brigadier's tree
- Tweak `NMS_1_19_Common_ChatPreviewHandler` to build previews from the node tree rather than by the node path

TODO: Should probably test these changes on a real server to verify. Also, another example of Mojang/brigadier#144 being annoying.
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Jun 8, 2024
Changes:
- Implemented `FlagsArgument` (#483)
  - Moved var handles for `CommandNode` `children`,`literals`, and `arguments` to `CommandAPIHandler`
  - Added `FlagsArgumentCommon` FlagsArgumentRootNode` and `FlagsArgumentEndingNode` to handle the special node structure and parsing required
- Updated `CustomArgument`
  - All `AbstractArgument` builder methods are delegated to the base argument
  - Replaced `CommandAPIExecutor` parameter of `AbstractArgument#addArgumentNodes` to a `Function` to allow objects that hold arguments to better control how those arguments are executed
- Added package `dev.jorel.commandapi.commandnodes` for class that extend `CommandNode` and related classes
- Tweaked some exceptions
  - `GreedyArgumentException`
    - Changed because the `FlagsArgument` is sometimes greedy - only greedy iff it has no terminal branches
    - Greedy arguments are now detected when `AbstractArgument#addArgumentNodes` returns an empty list
    - Tweaked the exception message
  - `DuplicateNodeNameException`
    - Changed because literal arguments can conflict with other nodes if they are listed
    - Now thrown when two listed arguments have the same node name
    - Added `UnnamedArgumentCommandNode` to make sure unlisted arguments do not conflict
    - Renamed `MultiLiteralCommandNode` to `NamedLiteralCommandNode` for use by listed `Literal` arguments
    - Tweaked the exception message

TODO:
- Clean up code
- Add tests
- Remove test commands in CommandAPIMain
- Add javadocs and documentation
- Hope Mojang/brigadier#144 is resolved, otherwise be annoyed :(
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Jun 8, 2024
- Removed `CommandAPIHandler#previewableArguments` and related methods
- Added `PreviewableCommandNode` for storing `Previewable` information directly in Brigadier's tree
- Tweak `NMS_1_19_Common_ChatPreviewHandler` to build previews from the node tree rather than by the node path

TODO: Should probably test these changes on a real server to verify. Also, another example of Mojang/brigadier#144 being annoying.
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Jun 17, 2024
Changes:
- Implemented `FlagsArgument` (#483)
  - Moved var handles for `CommandNode` `children`,`literals`, and `arguments` to `CommandAPIHandler`
  - Added `FlagsArgumentCommon` FlagsArgumentRootNode` and `FlagsArgumentEndingNode` to handle the special node structure and parsing required
- Updated `CustomArgument`
  - All `AbstractArgument` builder methods are delegated to the base argument
  - Replaced `CommandAPIExecutor` parameter of `AbstractArgument#addArgumentNodes` to a `Function` to allow objects that hold arguments to better control how those arguments are executed
- Added package `dev.jorel.commandapi.commandnodes` for class that extend `CommandNode` and related classes
- Tweaked some exceptions
  - `GreedyArgumentException`
    - Changed because the `FlagsArgument` is sometimes greedy - only greedy iff it has no terminal branches
    - Greedy arguments are now detected when `AbstractArgument#addArgumentNodes` returns an empty list
    - Tweaked the exception message
  - `DuplicateNodeNameException`
    - Changed because literal arguments can conflict with other nodes if they are listed
    - Now thrown when two listed arguments have the same node name
    - Added `UnnamedArgumentCommandNode` to make sure unlisted arguments do not conflict
    - Renamed `MultiLiteralCommandNode` to `NamedLiteralCommandNode` for use by listed `Literal` arguments
    - Tweaked the exception message

TODO:
- Clean up code
- Add tests
- Remove test commands in CommandAPIMain
- Add javadocs and documentation
- Hope Mojang/brigadier#144 is resolved, otherwise be annoyed :(
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Jun 17, 2024
- Removed `CommandAPIHandler#previewableArguments` and related methods
- Added `PreviewableCommandNode` for storing `Previewable` information directly in Brigadier's tree
- Tweak `NMS_1_19_Common_ChatPreviewHandler` to build previews from the node tree rather than by the node path

TODO: Should probably test these changes on a real server to verify. Also, another example of Mojang/brigadier#144 being annoying.
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Jul 4, 2024
Changes:
- Implemented `FlagsArgument` (#483)
  - Moved var handles for `CommandNode` `children`,`literals`, and `arguments` to `CommandAPIHandler`
  - Added `FlagsArgumentCommon` FlagsArgumentRootNode` and `FlagsArgumentEndingNode` to handle the special node structure and parsing required
- Updated `CustomArgument`
  - All `AbstractArgument` builder methods are delegated to the base argument
  - Replaced `CommandAPIExecutor` parameter of `AbstractArgument#addArgumentNodes` to a `Function` to allow objects that hold arguments to better control how those arguments are executed
- Added package `dev.jorel.commandapi.commandnodes` for class that extend `CommandNode` and related classes
- Tweaked some exceptions
  - `GreedyArgumentException`
    - Changed because the `FlagsArgument` is sometimes greedy - only greedy iff it has no terminal branches
    - Greedy arguments are now detected when `AbstractArgument#addArgumentNodes` returns an empty list
    - Tweaked the exception message
  - `DuplicateNodeNameException`
    - Changed because literal arguments can conflict with other nodes if they are listed
    - Now thrown when two listed arguments have the same node name
    - Added `UnnamedArgumentCommandNode` to make sure unlisted arguments do not conflict
    - Renamed `MultiLiteralCommandNode` to `NamedLiteralCommandNode` for use by listed `Literal` arguments
    - Tweaked the exception message

TODO:
- Clean up code
- Add tests
- Remove test commands in CommandAPIMain
- Add javadocs and documentation
- Hope Mojang/brigadier#144 is resolved, otherwise be annoyed :(
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Jul 4, 2024
- Removed `CommandAPIHandler#previewableArguments` and related methods
- Added `PreviewableCommandNode` for storing `Previewable` information directly in Brigadier's tree
- Tweak `NMS_1_19_Common_ChatPreviewHandler` to build previews from the node tree rather than by the node path

TODO: Should probably test these changes on a real server to verify. Also, another example of Mojang/brigadier#144 being annoying.
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Aug 15, 2024
Changes:
- Implemented `FlagsArgument` (#483)
  - Moved var handles for `CommandNode` `children`,`literals`, and `arguments` to `CommandAPIHandler`
  - Added `FlagsArgumentCommon` FlagsArgumentRootNode` and `FlagsArgumentEndingNode` to handle the special node structure and parsing required
- Updated `CustomArgument`
  - All `AbstractArgument` builder methods are delegated to the base argument
  - Replaced `CommandAPIExecutor` parameter of `AbstractArgument#addArgumentNodes` to a `Function` to allow objects that hold arguments to better control how those arguments are executed
- Added package `dev.jorel.commandapi.commandnodes` for class that extend `CommandNode` and related classes
- Tweaked some exceptions
  - `GreedyArgumentException`
    - Changed because the `FlagsArgument` is sometimes greedy - only greedy iff it has no terminal branches
    - Greedy arguments are now detected when `AbstractArgument#addArgumentNodes` returns an empty list
    - Tweaked the exception message
  - `DuplicateNodeNameException`
    - Changed because literal arguments can conflict with other nodes if they are listed
    - Now thrown when two listed arguments have the same node name
    - Added `UnnamedArgumentCommandNode` to make sure unlisted arguments do not conflict
    - Renamed `MultiLiteralCommandNode` to `NamedLiteralCommandNode` for use by listed `Literal` arguments
    - Tweaked the exception message

TODO:
- Clean up code
- Add tests
- Remove test commands in CommandAPIMain
- Add javadocs and documentation
- Hope Mojang/brigadier#144 is resolved, otherwise be annoyed :(
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Aug 15, 2024
- Removed `CommandAPIHandler#previewableArguments` and related methods
- Added `PreviewableCommandNode` for storing `Previewable` information directly in Brigadier's tree
- Tweak `NMS_1_19_Common_ChatPreviewHandler` to build previews from the node tree rather than by the node path

TODO: Should probably test these changes on a real server to verify. Also, another example of Mojang/brigadier#144 being annoying.
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Sep 1, 2024
Changes:
- Implemented `FlagsArgument` (#483)
  - Moved var handles for `CommandNode` `children`,`literals`, and `arguments` to `CommandAPIHandler`
  - Added `FlagsArgumentCommon` FlagsArgumentRootNode` and `FlagsArgumentEndingNode` to handle the special node structure and parsing required
- Updated `CustomArgument`
  - All `AbstractArgument` builder methods are delegated to the base argument
  - Replaced `CommandAPIExecutor` parameter of `AbstractArgument#addArgumentNodes` to a `Function` to allow objects that hold arguments to better control how those arguments are executed
- Added package `dev.jorel.commandapi.commandnodes` for class that extend `CommandNode` and related classes
- Tweaked some exceptions
  - `GreedyArgumentException`
    - Changed because the `FlagsArgument` is sometimes greedy - only greedy iff it has no terminal branches
    - Greedy arguments are now detected when `AbstractArgument#addArgumentNodes` returns an empty list
    - Tweaked the exception message
  - `DuplicateNodeNameException`
    - Changed because literal arguments can conflict with other nodes if they are listed
    - Now thrown when two listed arguments have the same node name
    - Added `UnnamedArgumentCommandNode` to make sure unlisted arguments do not conflict
    - Renamed `MultiLiteralCommandNode` to `NamedLiteralCommandNode` for use by listed `Literal` arguments
    - Tweaked the exception message

TODO:
- Clean up code
- Add tests
- Remove test commands in CommandAPIMain
- Add javadocs and documentation
- Hope Mojang/brigadier#144 is resolved, otherwise be annoyed :(
willkroboth added a commit to JorelAli/CommandAPI that referenced this pull request Sep 1, 2024
- Removed `CommandAPIHandler#previewableArguments` and related methods
- Added `PreviewableCommandNode` for storing `Previewable` information directly in Brigadier's tree
- Tweak `NMS_1_19_Common_ChatPreviewHandler` to build previews from the node tree rather than by the node path

TODO: Should probably test these changes on a real server to verify. Also, another example of Mojang/brigadier#144 being annoying.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant