Skip to content

Conversation

Score2
Copy link

@Score2 Score2 commented May 29, 2025

Motivation

As the title says, it enables node console to directly get suggestions from the service, especially when you need to use cloudnet to debug the service.

The java sub-process started by cloudnet does not have a complete terminal environment, so it cannot directly get the service suggestions. Therefore, it can only communicate with the bridge through ChannelMessage to get suggestions.

btw, I think service suggestions are more useful on the web than on the node console, like https://github.com/docimin/cloudnet-webinterface

Modification

  • Added suggestion processor ServiceCommand#suggestCommands
  • Added a method SpecificCloudServiceProvider#consoleSuggestion in wrapper, Implementation in AbstractService to request suggestions from bridge.
  • Fixed suggestion-processor for @Greedy processes in DefaultSuggestionProcessor

Service Platfrom Implementations

I think the feasibility and rationality of this function still need further discussion, so it is not adapted to all platforms.

  • Bukkit
  • BungeeCord
  • Velocity
  • Sponge
  • Fabric
  • Limbo(LOOPHP)
  • Nukkit
  • WaterDog
  • Minestom

Result

Perfect. Like these:

Bukkit BungeeCord Velocity
screenshot_ 2025-05-30 at 01 50 17 screenshot_ 2025-05-30 at 01 50 44 screenshot_ 2025-05-30 at 01 51 20

demo video like this

Other context

Once merged, module-rest will be directly compatible with this change, further enhancing the web-interface console of service.

@Score2 Score2 marked this pull request as draft May 29, 2025 18:54
// fix the suggestion of greedy
var lastWhitespace = commandInput.input().lastIndexOf(' ');
if (lastWhitespace != -1) {
commandInput.cursor(lastWhitespace);
Copy link
Author

@Score2 Score2 May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth mentioning that this is a potentially destructive fix.

actually, I've tried setting the cursor in the Parser, but it obviously doesn't work for the Greedy argument, because CommandTree#L841(Incendo/cloud) restores the cursor modified in the Parser.

at least in my opinion, there is no better way to solve it properly.

Copy link
Member

@derklaro derklaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The biggest issue I have with the current implementation is that this introduces a dependency of the node on the bridge, which might not be installed. I think it would be better if the node provides an interface that can be implemented by modules and resolves it using the service registry. This way a module can hook into the node rather than the node hooking into the bridge.

@@ -411,6 +412,19 @@ public void restart() {
this.updateLifecycle(ServiceLifeCycle.RUNNING);
}

@Override
public Collection<String> consoleSuggestion(@NonNull String line) {
var listPropertyType = TypeFactory.parameterizedClass(List.class, String.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method should return a future instead so that the caller can better handle errors and apply timeouts.

@derklaro derklaro added v: 4.X This pull should be included in the 4.0 release in: node An issue/pull request releated to the node module code t: improvement The pull request improves existing code in: module An issue/pull request releated to one of the internal modules labels May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: module An issue/pull request releated to one of the internal modules in: node An issue/pull request releated to the node module code t: improvement The pull request improves existing code v: 4.X This pull should be included in the 4.0 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants