How would you go about getting the Current server time in a plugin? I know that some vanilla servers report the time in chat when the message starts with Time, but how would you go about getting the time into a place where you could use it in your own chat messages in a plugin? (Ex. MOTD, Greeting Messages, etc. )
java.util.Calendar
Calendar.getInstance().getTime()
Ok thanks. Is there a way to get world time as well?
Probably within the main server object
This is the thing your looking for:
http://spongepowered.github.io/SpongeAPI/org/spongepowered/api/world/storage/WorldProperties.html#getTotalTime--
You can get it with calling this from the worldObject:
http://spongepowered.github.io/SpongeAPI/org/spongepowered/api/world/World.html#getProperties--
1 Like