-
Notifications
You must be signed in to change notification settings - Fork 28
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
Commands helper #269
base: master
Are you sure you want to change the base?
Commands helper #269
Conversation
There was a problem hiding this 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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Commands.java
Outdated
Show resolved
Hide resolved
@@ -256,3 +256,7 @@ item('minecraft:golden_apple').setRarity(textformat('-1')) | |||
eventManager.listen(EnderTeleportEvent) { event -> | |||
event.setAttackDamage 19.5f | |||
} | |||
|
|||
commands.registerCommand('groovy_test') { server, sender, args -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be command.registerCommand
after rename
commands
variable which has helper methods to register client and server commandspostInit
they can be reloadedcustom/vanilla.groovy