Jump to content

getting the instance of ServerCommandManager, from standalone and internal serve


Recommended Posts

Posted

hi guys

 

so i am trying to find the place where to get the instance of ServerCommandManager, for what i have come up with, its from the FMLServerHandler.instance().getServer().getCommandManager()

 

But my problem is, that when i try to use it, i get some problems.

 

@ServerStarted and @ServerStarting dosnt seem to work fir the internal server.

 

and as the sever is not initated yet in @Init, i kinda am confused where to register my custom commands. i am wondering if anyone had figured this out yet, as all the current google results, predates Forge 4.x

and gives me guides for Forge 3 instead:/

 

thanks

Posted

ServerStarted should work just fine fort the internal server, and thats where you're supposed to register your commands, so, figure out why your event isnt working.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

yeah, i kinda screwed it up, i forgot to add the right paremeters to the methode

 

it should be this

 

 

@ServerStarting

public void serverstart(FMLServerStartingEvent event){

ServerCommandManager scm = (ServerCommandManager)event.getServer().getCommandManager();

                logger.info("Adding Commands");

scm.registerCommand(new CommandTest());

}

 

 

i did the big mistake and wrote

 

 

@ServerStarting

public void serverstart(){

ServerCommandManager scm = (ServerCommandManager)FMLServerHandler.instance().getServer().getCommandManager();

                logger.info("Adding Commands");

scm.registerCommand(new CommandTest());

}

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.