Solved Get total game time?

Discussion in 'Spigot Plugin Development' started by ratquaza, Feb 11, 2020.

  1. How can I get the total game time passed, not the world time? I'm looking for the same value that returns when using /time query gametime
     
  2. You are going to have to tick the time yourself then. The total tick time is stored inside the world not the server.

    EDIT: Decided to do some digging real quick.

    1) Looking inside NMS I see that the command you are using uses the method: NMS.World#getTime()
    2) NMS.World returns NMS.WorldData#getTime()

    So since spigot isn't covering your specific issue. You are going to need to use NMS to get the value.

    Code (Java):
            World world = Bukkit.getWorlds().get(0);
            System.out.println(((CraftWorld) world).getHandle().worldData.getTime());
    This should help move you in the right direction. You will need to use reflections to access the method across multiple versions of spigot.
     
    #4 Heretere, Feb 11, 2020
    Last edited: Feb 11, 2020
    • Winner Winner x 1
    • Useful Useful x 1
  3. Did some testing and getTime() returns the same value as /time query daytime, thank you!