Skip to content

Conversation

@brachy84
Copy link
Member

@brachy84 brachy84 commented Nov 9, 2024

  • adds global commands variable which has helper methods to register client and server commands
  • if commands are registered during postInit they can be reloaded
  • see test in custom/vanilla.groovy

Copy link
Collaborator

@WaitingIdly WaitingIdly left a comment

Choose a reason for hiding this comment

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

it might be for documentation only (yippee), but doing something like commands.registerCommand('help') { server, sender, args -> sender.sendMessage('You cannot be helped') }
lets you override commands - and, depending on when things are loaded, might make your custom commands be overridden by preexisting ones.

}

public void registerClientCommand(ICommand command) {
if (FMLCommonHandler.instance().getSide().isServer()) return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this print a warning?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. This way you can just register a command without having to make sure it doent run on server

private boolean serverStarted = false;

public void registerCommand(ICommand command) {
if (GroovyScript.getSandbox().isRunning() && GroovyScript.getSandbox().getCurrentLoader().isReloadable()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i feel like this code being required for Commands to work in preInit (if im reading what the reason is correctly) might indicate a deeper issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

? I just dont want commands to reload when not registered durin postInit. I dont see any issue

@brachy84 brachy84 merged commit 0cdf700 into master Dec 6, 2024
@brachy84 brachy84 deleted the command branch December 6, 2024 20:50
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.

4 participants