Sync Minecraft day time with Realtime

Discussion in 'Plugin Development' started by MrFrozen, Oct 6, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    MrFrozen

    Hey Guys,

    I was wonderinf if there is any simpleway to syunc the minecraft in-game time with the realtime and also having a 24h clock in MC that I can implement in my code and also on other parts of the plugins that is not really necessary to know.

    So, How can I sync the time?
     
  2. Offline

    RoboticPlayer

    I believe there is a Java method that allows you to get the real time, but I don't know if off the top of my head.
     
  3. Offline

    mine-care

    @henderry2019 You can get it by a Date object, or use the methods from System class but that will return the server time... If the OP wants actual time sync per player they will have to find the timezone the player is on.
     
  4. Offline

    Zombie_Striker

    @MrFrozen
    1. Create a repeating task (i would set it for every second that way it doesn't look too glitchy, but you can set it to repeat after a longer amount of time if your server i laggy)
    2. Inside the repeating task, get the date variable.
    3. Set the time to the following (date.hour * 1000, + ((double)date.minute/60)*1000 + (date.seconds /60)*100). Every 1000 ticks is one hour.
     
    Last edited: Oct 6, 2015
  5. Offline

    Tecno_Wizard

    @Zombie_Striker,
    @MrFrozen
    Even better, set a gamerule for time to be locked and manually and calculate the time every few min.
     
  6. Offline

    MrFrozen

    No I want a time sync to Amsterdam GMT +1, And use that for the complete server..

    I want it to be done in the plugin for other futures of the plugin.

    I thought of that but I think that will be a decent option only it is not sync with a time zone in this case Amsterdam GMT +1

    -----------------------

    @timtower I know you made a plugin can you give me a little Idea or example of this. And yea I decomplied but I didnt get smarter off that
     
  7. Offline

    timtower Administrator Administrator Moderator

    @MrFrozen The decompiled plugin is the best that I can give you.
     
  8. Offline

    MisterErwin

    @MrFrozen Javas Date Object is in sync with the timezone the server is standing in.
    But you can also specify the timezone.
    So @Zombie_Striker s method should work :)
     
  9. Offline

    Scimiguy

    And on top of that, if you needed to change the timezone, you can just add/remove time to it manually to compensate
     
  10. Lock the time as Techno said then just set it every few mins or whatever.
     
  11. Offline

    Tecno_Wizard

    You cannot directly set a gamerule thorough the API, but you can dispatch the command as a a console.
     
  12. Offline

    timtower Administrator Administrator Moderator

    Seconds if you want it to be accurate and have not a too big time difference.
     
  13. boomboompower, mine-care and timtower like this.
Thread Status:
Not open for further replies.

Share This Page