oznecniV97 Posted November 3, 2017 Posted November 3, 2017 (edited) 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 November 4, 2017 by oznecniV97 Quote
larsgerrits Posted November 3, 2017 Posted November 3, 2017 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? Quote 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/
oznecniV97 Posted November 3, 2017 Author Posted November 3, 2017 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 ) Quote
oznecniV97 Posted November 3, 2017 Author Posted November 3, 2017 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? Quote
oznecniV97 Posted November 4, 2017 Author Posted November 4, 2017 Oh, good point. Thanks @diesieben07 for the tip Quote
oznecniV97 Posted November 7, 2017 Author Posted November 7, 2017 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) Quote
oznecniV97 Posted November 7, 2017 Author Posted November 7, 2017 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. Quote
Recommended Posts
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.