Jump to content

Recommended Posts

Posted

Hi All,

I need to stop my server based on an external text file.

E.g.:

I have a file in a folder called "server_info.txt". Now, if this file begins with "stop" I need to stop the server.

 

Actually I read this file using the TickHandler (TickEvent.ServerTickEvent) every x minutes but I don't know if there's a possibility to stop the server using a method like "server.stop();" (?)

 

Thanks.

Posted (edited)
11 hours ago, oznecniV97 said:

Hi All,

I need to stop my server based on an external text file.

E.g.:

I have a file in a folder called "server_info.txt". Now, if this file begins with "stop" I need to stop the server.

 

Actually I read this file using the TickHandler (TickEvent.ServerTickEvent) every x minutes but I don't know if there's a possibility to stop the server using a method like "server.stop();" (?)

 

Thanks.

You literally wrote "SOLVED" on your last post and now you're opening a new thread about the same topic, this time asking for explanations...

I mean all I have to say is that that's not too professional...

11 hours ago, oznecniV97 said:

"server.stop();"

Very ambiguous. You have to get the server instance first from MinecraftServer, if I'm correct. You can't just write server.stop();

That will give you an error.

 

I'm not too sure how to force the server to SERVER_STOP state though, never had to use that anyways...

Edited by Differentiation
Posted

I'm not really sure why you'd want this, but the method you're looking for is simple: WorldServer#getMinecraftServer() to get the MinecraftServer instance associated with the world, then MinecraftServer#stopServer() to... you know, stop it.

  • Like 1

Whatever Minecraft needs, it is most likely not yet another tool tier.

Posted
8 hours ago, Differentiation said:

You literally wrote "SOLVED" on your last post and now you're opening a new thread about the same topic, this time asking for explanations...

I mean all I have to say is that that's not too professional...

This isn't the same topic.

The previous one is a topic about an action after the server stop.

This one is for stop the server based on an event.

 

7 hours ago, IceMetalPunk said:

I'm not really sure why you'd want this, but the method you're looking for is simple: WorldServer#getMinecraftServer() to get the MinecraftServer instance associated with the world, then MinecraftServer#stopServer() to... you know, stop it.

Thanks @IceMetalPunk for this solution.

I know, it's strange that I want to stop the server using this method, but I need it because I have a "remote" server and I need to control it without really interact with it. (I know that I didn't explain my idea, but without explain all the environment is too complex to explain just this part :S).

  • 2 months later...
Posted

MinecraftServer#stopServer is a pretty violent method, which should be avoided because it triggers the stopping process immediately.

I would recommand using MinecraftServer#initiateShutdown

  • Like 1

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.

Announcements



×
×
  • Create New...

Important Information

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