Jump to content

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


oznecniV97

Recommended Posts

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
Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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 ¬¬)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

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.