Jump to content

getting the instance of ServerCommandManager, from standalone and internal serve


Drofzz

Recommended Posts

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

Link to comment
Share on other sites

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());

}

 

 

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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