Posted November 4, 20177 yr 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.
November 4, 20177 yr 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 November 4, 20177 yr by Differentiation
November 4, 20177 yr 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. Whatever Minecraft needs, it is most likely not yet another tool tier.
November 4, 20177 yr Author 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 ).
January 21, 20187 yr MinecraftServer#stopServer is a pretty violent method, which should be avoided because it triggers the stopping process immediately. I would recommand using MinecraftServer#initiateShutdown
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.