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

Subcommand information should be available at runtime #313

Closed
JorelAli opened this issue Jul 31, 2022 · 1 comment
Closed

Subcommand information should be available at runtime #313

JorelAli opened this issue Jul 31, 2022 · 1 comment
Labels
enhancement New feature or request implemented for next release This has been implemented in the current dev build for the next public release

Comments

@JorelAli
Copy link
Owner

Description

Commands with subcommands lose all of their subcommand information once the command is registered. This should be made accessible for runtime use.

Expected code

If you have this code:

CommandAPICommand main = null;
main = new CommandAPICommand("main")
	.executes((sender, args) -> {
		System.out.println(main.getSubcommands().size());
	});

CommandAPICommand sub = new CommandAPICommand("sub")
	.executes((sender, args) -> {
		System.out.println("Subcommand called");
	});

main.withSubcommand(sub);
main.register();

Then running /main should print 1.

Extra details

No response

@JorelAli JorelAli added the enhancement New feature or request label Jul 31, 2022
JorelAli added a commit that referenced this issue Jul 31, 2022
@JorelAli JorelAli added the implemented for next release This has been implemented in the current dev build for the next public release label Jul 31, 2022
@JorelAli
Copy link
Owner Author

Fixed in 8.5.1.

JorelAli added a commit that referenced this issue Oct 6, 2022
* Update version to 8.4.0-SNAPSHOT

* Fixes CommandAPI.fail() throwing an exception when it shouldn't

* Implement base type B for CustomArgument to access parsed arguments (in addition to strings)

* Update documentation for CustomArguments

* Finish documenting NBTCompoundArgument

* Stop JavaDocs complaining about type params for CustomArgument

* Update NBT API links

* Update nbtarguments.md

* Update troubleshooting.md

* Update argument casting types. Rename MinecraftKeyArgument -> NamespacedKeyArgument

* Adds NMS javadocs for classes

* Adds support for shaded versions of the CommandAPI to output Brigadier command tree JSON files

* Update incompatibleversions.md

* Update README.md

* Update README.md

* Work on upgrading guide

* Finish upgrading guide

* Handle license merging for NBT API

* Minor pom.xml tweaks + removing some deprecation warnings

* Fix plugin.yml and config.yml not saving in the plugin

* Update README.md

* Change version number to 8.4.0

* Build 8.4.0 documentation

* Build 8.4.0 JavaDocs

* Update index.html

* Update README.md

* Work on better JavaDocs. Fix EntityTypeArgument annotation having the wrong name. Adds namespacedkey argument annotation. Start moving out auxiliary NMS classes

* Move auxiliary classes out of NMS classes. Write more JavaDocs

* Document everything that JavaDocs is complaining about in commandapi-core (except NMS)

* Update JavaDocs

* Update documentation, update README

* Fixes #294

* Change annotations depending on spigot-api instead of spigot

* Change version to 8.4.1

* Adds 8.4.1 changelog entries and update homepage

* Fixes #296

* Update bug_report.md

* Target Brigadier 1.0.17 to fix compatibility with Minecraft 1.16.5 for #297

* Initial commit of test framework

* Make more progress with testing framework

* Adds first successful tests

* Adds dispatcher comparison tests

* Adds onDisable() method for the CommandAPI. Adds other argument implementations in test registry

* Adds throwable command tests

* Adds location argument test

* Pass NMS implementation to use specific NMS implementation for testing

* Tidy up NMS hierarchy

* Adds test case for advancements

* Adds base implementation of entity selector argument

* Adds test for multiple players. Add test for block position location arguments

* Throw greedy exceptions and invalid name exceptions. Adds command-based tests. Adds check for spaces in command names

* Adds potion effect test

* Adds test for suggestions

* Adds some list argument tests

* Adds test for PlayerArgument

* Adds test for strings and components. Deprecate ChatComponentArgument

* Remove unnecessary comment

* Initial commit of kotlin DSL in the documentation

* Tidy up JS implementation for kotlin dsl

* Fix refactor bugs + rebuild 8.4.0 documentation

* Create config.yml

* Create bug_report.yml

* Delete bug_report.md

* Update bug_report.yml

* Update bug_report.yml

* Update bug_report.yml

* Update config.yml

* Update bug_report.yml

* Update bug_report.yml

* Update bug_report.yml

* Update bug_report.yml

* Create documentation_amendment.yml

* Delete documentation-amendment.md

* Update documentation_amendment.yml

* Create suggestions_enhancements.yml

* Delete suggestions-enhancements.md

* Adds an example shaded project using maven

* adding CommandTree example in MyCommands.java

* Make CommandAPIHandler#parseArgument take in an array of previously parsed args instead of generating the args using CommandAPIHandler#generatePreviousArguments.

* Initial implementation of chat preview (with basic example)

* Tidy up codebase. Adds unhook method for chat preview

* Adds support for CommandAPI.fail inside preview arguments

* Adds isLoaded method to CommandAPI.java to avoid getting "You've tried to call the CommandAPI's onLoad() method more than once!".

* Adds the possibility to access CustomCommandExecutor and to clear the executors.

* Fix immutable executor issue with clearExecutors. Remove deprecated onLoad() method. Adds JavaDocs to isLoaded()

* Update Executable.java

* Refactor chat preview to its own class

* Only enable chat preview if the server allows chat preview

* Split 1.17 module into 1.17-common, 1.17, and 1.17.1

* Fixed `compatibleVersions()` method

* Tidy up 1.17 PR

* Share NMS code between 1.13.1 and 1.13.2

* Share NMS code between 1.14.x versions

* Share 1.16.4 and 1.16.5 NMS code

* Fix live build

* Fixes #305

* Justify the use of a giant switch statement in parseDefinedArgumentType

* Prevent using literal arguments as the base for custom arguments

* Update component test for spigot

* Adds support for chat preview (1.19+) in Spigot

* Rejig chat preview handler to not require unnecessary casting

* Change version to 8.5.0-SNAPSHOT

* Safeguard against async operations during chat preview handling

* Adds support for 1.19.1. Fix runtime error when typing in chat in 1.19+

* Adds 8.5.0 changelog to README

* Adds preview parsed input. Work on documentation for 8.5.0

* Fix legacy handling incorrectly

* Adds usePreview() method to chat preview

* Adds documentation + JavaDocs for chat preview. Adds 8.5.0 documentation

* Update home page

* Fix NPE with chat preview for non-CommandAPI commands. Fix paper not doing chat previewing properly

* Update compatible versions in README

* Change version to 8.5.0 in preparation for release

* Adds 8.5.0 JavaDocs

* Write documentation changelog entry

* Use 1.19.1 for plugin tests

* Set version to 8.5.1

* Fix packet with invalid signature bug

* Create a working version of 1.19's chat preview (no common) for snapshot builds

* Create 8.5.1-SNAPSHOT

* Implements #313 using subcommand cloning

* Implements the fix for #312. Adds getter methods for CommandAPICommand help

* Fix timeargument bug from #314

* Fixes suggestions for arguments not working inside subcommands with the same command name as the argument's node name

* Work on more NMS common. Adds shared implementation of ChatColor argument

* Share NMS enchantment implementation

* More tidying up of NMS_Common shared implementation

* Link all NMS versions together and specify the common classifier. Work on plugin test suite

* Tidy up plugin test failures

* Applies 1.19 common. Fix all broken plugin tests to use NMS 1.19

* Fix potion effect tests failing

* Tidy up leftover warnings

* Rename 'str' to 'key' in NMS common because it was too confusing

* Wraps 1.19.1 chat completion in Bukkit sync scheduler task

* Fixes #316 to do with reloading on Spigot

We don't need to directly access the completable future in a thread that isn't the main thread because it's already being processed in the manageBlocked call.

Additionally, we could go directly to Bukkit.getServer().syncCommands() instead of accessing that via NMS, but there's no real incentive to do it one way or the other.

* Replace node name identification of arguments for suggestion generation

* Rejig code in getRequiredArgumentBuilderDynamic so it's easier to understand

* Fix JavaDoc complaints

* Adds more Minecraft versions to bug template

* Added a method override for producing formatted WrapperCommandSyntaxExceptions using the Brigadier Message type.

* Adds support for 1.19.2. Draft work on the "latest" documentation page

* Improve ListArgument (#319)

* Use brigadier to suggest items one at a time

* Handle null tooltips

* Remove unnecessary variable now that it's only being used once

* Fix suggestion builder offset

* Only suggest values that complete current input

* Suggest deliminator if an argument is finished

* Remove test command

* Optimize imports

* Actually return CommandAPIMain back to normal

* Adds latest.html file for the latest documentation

* Work on 8.5.1 changelog. Adds loot table example.

The loot table example comes from the unused/6.0-release (commit 304b94b) which was provided by リク from the CommandAPI Discord

* Improvements to tooltips, including much easier ways to generate formatted tooltips, and utility methods for generating tooltips over an array of suggestions using a mapping function

* Adds some tests relating to issue #321

* Fix CLW remapping issues across 1.17 -> 1.19

* Fixes #323 due to shared NMS in 1.17 to 1.18

* Adds NMS hierarchy hook to logs

* Fix maven module naming issue

* Fix missing dependency in commandapi-plugin-test. Adds Maven cache to GitHub actions

* Use Maven batch mode for GitHub Actions

* Throw CommandSyntaxExceptions when ListArgument input is wrong (#324)

* Throw CommandSyntaxExceptions when ListArgument input is wrong

* Use ArgumentTests#assertInvalidSyntax() instead of assertNull()

* Use custom exception method when item is not allowed in list

* Adds documentation

* Update README.md

* Update NMS 1.19 with componentsToMessage method. Update ListArgument's tooltips to fit the new tooltip API methods.

* Add message to indicate if chat preview has been enabled

* Share and simplify ChatPreviewHandler code in 1.19+
Reduces plugin jar by ~2.4 kB
Makes code easier to understand and maintain

* Make sure that chatPreviewPacket will be responded to before consuming it

* Avoid if and else statements without { }

* Rename chatPreviewQueryToJson to parseChatPreviewQuery

* Cache InitialParse performed by channelRead for later call to parseChatPreviewQuery

* Remove unnecessary debug messages

* Don't send null ChatPreview components in 1.19.1/2

* Change version to 8.6.0-SNAPSHOT

* Format plugin converter code

* Work on new config.yml command parsing

* Initial commit of the command converter viewer

* Adds a suggestions box to the command visualizer.

Also:
- Simplifies the general structure of the command viewer
- Fixes the cursor disappearing
- Ensures clicking the chat box displays the cursor
- Adds support for up/down in that chat preview

* Refactor command visualizer, implement Minecraft-style styling text

* Prevent deleting the chatbox with backspace

* Adds tab-complete for suggestions

* Tidy things up, adds template for arguments

* Adds Brigadier Node.js module for more powerful parsing

* Adds half-baked argument parsing and argument declarations

* Adds basic implementation of literal arguments

* Link Brigadier to the main command executor. Fixed argument exceptions

* Adds Modrinth download count

* Use flat square badges instead of rounded badges

* Implementation of formatted tooltips using adventure's text api.

* Fixes compilation issues and potential crash with ListArgument

* Implements basic arguments and command tree construction from command syntax definition

* Adds extension for deleting all commands in the command dispatcher. Adds input for new commands

* Avoid potential method overload conflicts by renaming the Tooltip#of methods to be more descriptive.
Use StringTooltip#none instead of passing null as the tooltip.

* Adds colored arguments and all other Minecraft colors

* Adds support for literal arguments in the command visualizer

* Adds time argument to command visualizer

* Adds ChatColorArgument to command visualizer

* Added overrides for CommandAPI#fail using both BaseComponents and adventure chat component

* Provide deprecated javadoc description for Tooltip#toMessage with BaseComponents

* Provided deprecated Tooltip#of(String, String) method for backwards-compatibility

* Rename methods for BaseComponent to use BaseComponent in the name rather than bungee components

* Provided deprecated StringTooltip#of(String, String) method for backwards-compatibility

* Fix typo in Tooltip#ofAdventureComponent method name

* Removed deprecation on Tooltip#toMessage(BaseComponent[])

* Renamed Tooltip#ofMessage and CommandAPI#fail to more descriptive method names for their arguments

* Moves CommandAPI plugin tests to a package dev.jorel.commandapi.test

* Move webpack-cli dependency into `devDependencies` instead of regular `dependencies` in commandvisualizer

* Fix PlayerJoinEvent errors when running the CommandAPI's plugin test. Improve error messages for unimplemented methods

* Fix suggestions not displaying due to unexpected HTML codepoints in commands

* Use a second box for showing that a command is valid

* Fix focus issues with the chatbox and dodgy username matching

* Swapped adventure's BukkitComponentSerializer for the GsonComponentSerializer to permit Paper servers to work properly.

* Update README.md

Adds command trees example to main README

* Adds lots of lovely type annotations to the command visualizer

* Allow all suggestion and tooltip types to use collections as well as only arrays

* Update jszip.min.js

* Ignore node modules in commandvisualizer. Update jszip to 3.10.1

* Dev/kotlindocs (#342)

* First implementation of Kotlin in the documentation for BooleanArguments

* Improve kt example with lambdas for BooleanArgument

* Adds ranged argument kotlin docs + unregister commands kotlin docs

* Greedy, Location, Rotation, ChatColor argument examples in KotlinDocs

* Work on KotlinDocs (1/3). Fix #341 issue with mislinked documentation example

* Work on KotlinDocs (2/3). Note notable issues with TODO in Examples.kt

* Work on KotlinDocs examples (3/4)

* Work on KotlinDocs examples (4/?)

* Work on KotlinDocs examples (5/6)

* Finish work on KotlinDocs examples (6/6)

* Fix KotlinDocs example failing to compile

* Remove trailing spaces and unnecessary brackets

* Remove a TODO which has now been resolved

* Adds onDisable to the documentation with a clear example

* Adds support for CommandAPICommand cloning via copy constructor #338

* Work on implementing command ambiguity check

* Use Maven filtering to automatically update plugin.yml version

* Dev/command visualizer ts (#346)

* First implementation of command visualizer as typescript (ignoring arguments)

* Converts arguments.js -> arguments.ts

* Fix string reader parsing issues with block pos args

* Remove ts-errors. Prevent unused locals/parameters

* Tidy up directory structure, with src/ for sources and dist/ for outputs

* Update commandvisualizer readme with updated instructions

* Adds potion effect argument. Fix issues with autocomplete

* Adds AngleArgument and UUIDArgument

* Work on implementing the entity selector argument

* Make use of webpack-dev-server instead of http-server

* Adds NBT to entity selector argument type. Adds gamemode, sort and limit

* Adds better error message when NBT fails

* Adds scores, template for suggestions tags and ranged bounds to entity selector argument

* Add entity types, team and suggestions generator to entity selector argument

* Work on suggestions for entity argument. Adds scrolling suggestions + hover event. Work on pinpointing cursor placement nonsense

* Fix cursor placing bugs. Work on ensuring suggestions scroll into view. Fix suggestions autocomplete bugs.

* Fix Firefox incompatibilities with command visualizer

* Fix player limits and implement other entity selector arguments

* Augment node-brigadier's StringReader with readLocationLiteral method

* Move other StringReader extensions into brigadier_extensions

* Enable strict null checks

* Mess around with type predicates

* Move valid box below command entry. Add mousedown event for suggestions to autocomplete

* Fix webpack not recognising brigadier extensions

* Adds math operation argument. Simplify argument implementations

* Make a dedicated box for displaying errors

* Adds Enchantment, NBT, IntRange, FloatRange and Function arguments

* Implementation Function, ItemSlot, ResourceLocation, Rotation, ScoreboardSlot, Dimension arguments

* Reformat configuration documentation page to look nicer

* Remove section numbers from documentation

* Restructure project for multi-platform support

* Fix .gitignores

* Move bukkit dependencies from commandapi-core to commandapi-bukkit-core

* Remove unnecessary repositories

* Add repositories

* Add commandapi-bukkit-core dependency everywhere commandapi-core is

* Fully move dependency and build configuration to commandapi-bukkit-core to prepare for moving all classes

* Move all classes from commandapi-core to commandapi-bukkit-core

* Configure maven structure for a velocity platform implementation

* Add velocity-api dependency to velocity core

Co-authored-by: Jorel Ali <github@jorel.dev>
Co-authored-by: DerEchtePilz <tlfm90@gmail.com>
Co-authored-by: BuildTools <unconfigured@null.spigotmc.org>
Co-authored-by: 469512345 <e69512345@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request implemented for next release This has been implemented in the current dev build for the next public release
Projects
None yet
Development

No branches or pull requests

1 participant