Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

getting the instance of ServerCommandManager, from standalone and internal serve

Featured Replies

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

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

  • Author

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.