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.

[1.10.2] [SOLVED] Server side - execute method after server stop

Featured Replies

Posted

Hi guys,

I want to make a mod that do some actions (like do a post call to a WebServer or other things) after the stop command is launched on server console.

p.s.: I know that if I add a command in the ServerStart.cmd as last command I can run another java application that do this, but I don't want to change that file.

 

Thanks.

Edited by oznecniV97

There's the FMLServerStoppingEvent you could use, however, based on your idea there might be a better option. What exactly do you want to do?

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author
36 minutes ago, larsgerrits said:

There's the FMLServerStoppingEvent you could use, however, based on your idea there might be a better option. What exactly do you want to do?

I want to zip my world and upload it on a cloud after server stop because I switch between 2 pc's and I do this manually everytime. (a real boring action ¬¬)

  • Author
3 hours ago, diesieben07 said:

This sounds like something you might want to do in an external script, completely separate from the server.

Do you think that is better?

I thought about a server side mod just to do all inside the single command "java -jar mc_server.jar nogui" but if I can't do it I'll write an external bat to run this script after the previous command.

With the second method it will works, right?

  • Author

Sorry guys, did you know if there's an event like the FMLServerStoppingEvent but for the start event?

I need to notify a remote server when my server is ready. (For ready I means that I can access on it with a minecraft client)

  • Author

Ok, I've found a solution.

		boolean open = true;
	    Socket socket = SocketFactory.getDefault().createSocket();
	    try {
	        socket.setSoTimeout(5000);
	        socket.connect(new InetSocketAddress("127.0.0.1", 25565));
	        socket.close();
	    } catch (ConnectException e) {
	        open = false;
	        System.err.println(e);
	    }

Using this code, if the soker.connection method throw a ConnectException it means that my server is offline (or is starting), else the server is up and running.

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.