Reloading server.properties

Discussion in 'Plugin Development' started by Zachster, Jun 29, 2012.

  1. Offline

    Zachster

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Is there a way to reload server.properties, similar to the reload command except for server.properties?
  2. Online

    ferrybig

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I dont think it cant reload al the properties from that file, like world-name port, ip and that kind of properties, because of this, I dont think there is an way
  3. Offline

    rominos2

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    You can't reload server.properties
    You need to restart the server
  4. Offline

    Bone008

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Why do people always give up at the first sign of challenge?
    Of course it is possible, obviously changes to stuff that is only cared about on startup (socket ip, port, etc.) don't actually change (unless you feel like closing the socket and re-opening it again with the new settings, effectively kicking all connected clients, kind of not very productive).

    Assuming that you want to use it in a somewhat sane way, the basic properties are in fact very easily changed (heck, they're even public and non-final!):
    https://github.com/Bukkit/CraftBukk...et/minecraft/server/MinecraftServer.java#L134

    The code shows what happens on startup. Depending on whether you want to update all (sane) properties or not, go through what is in there and set it again.
    The part that actually reads from the file is the PropertyManager. Invoking its constructor with the options in theory does its job of reloading.
    Then you only need to override all relevant attributes in the MinecraftServer class with the new values. Done.

    I'll stop at this theoretical part. If you feel like actually digging as deep as that, let me know and I'll try to explain how to do it code-wise. It's not that hard, just one reflection call to get the instance of MinecraftServer, (most of) the rest is public anyway.

    This post has been edited 1 time. It was last edited by Bone008 Jun 29, 2012.

Share This Page