Bukkit Plugins
9,321 Downloads Last Updated: Apr 6, 2012 Game Version: CB 1.2.5-R1.0

This project is abandoned and its default file will likely not work with the most recent version of Minecraft. Whether this project is out of date or its author has marked it as abandoned, this project is no longer maintained.



Important: This is just a library for using with other plugins. I you're searching for a plugin which let's you get/set the time in a 24 h format have a look at RealTimeSet

This library was splitted out from SignClock because I want to make plugins (ideas welcome) which should use a 24 h time format. This is what this library is for. Feel free to use it in your own plugins!

How to use


To use it in your plugin make lib24time a dependecy of it and import the library in the class files like this:

import com.V10lator.lib24time.lib24time

Check Version

Then, its highly recommended to make a versions check in onEnable() like this:

  info2log("ERROR: lib24time not ready!");
if(lib24time.getVersion() < 0.7D)
  info2log("ERROR: lib24time >= 0.7 needed (" + lib24time.getVersion() + " found)");

As you can see all is handled statically. Don't try to start an instance of the lib!

Get the Time

To get the time in your plugin you'll need a listener for the TimeChangeEvent, it could look like that:

import org.bukkit.World;
import org.bukkit.event.Event;
import org.bukkit.event.Listener;

import com.V10lator.lib24time.lib24time;
import com.V10lator.lib24time.event.TimeChangeEvent;

class TimeEventCustomListener implements Listener
  public void timeChange(TimeChangeEvent event)
    World world = event.getWorld();
    String now = event.getNewTime();


to get the old time you can use event.getOldTime(); - You can also cancel the event (event.setCancelled(true);).

There's also the function getTime(World world) in the library but it's recommended to use the event instead (if possible).

Get the Daytime

For the daytime there's the DaytimeChangedEvent or getDaytime(World world). It's recommended to prefer the event over the function here, too.

Set the Time

To set the time you can use the function setTime(String time).


There are more functions like formatting a minecraft timecode to a 24h time (code2time(long timecode)) in the library and if you think something is missing feel free to request it for a feature version.


  • Get and set the in-game time in 24 h format (hh:mm).
  • Get and set times from a timecode.
  • Calculate the remaining time till a given time.
  • Adjust the sun.


Posts Quoted: