Solved How to make a Bukkit Task look like a clock timer?

Discussion in 'Plugin Development' started by thepaperboy99, Aug 30, 2013.

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

    thepaperboy99

    Hello Bukkit, I’m working on this plugin, and in this plugin there’s a scheduler. Want I want to happen is that the time to look like a clock, such as 10:04. Any ways I can do this? Thanks.
     
  2. Offline

    CoderCloud

    Where do you need the time. In a chatmessage or on a scoreboard.

    To get the format you could use World.getTime() and calculate the time in hours.

    Code:
    float time
    float maxtime
     
    int hoursPerDay = 24
    int minPerHour = 60
     
    float curr = time/maxtime;
    float hourf = curr*(float)hoursPerDay;
    int hour = (int)(hourf);
    float minf = (hourf-hour)*(float)minPerHour;
    int min = (int)(minf);
     
    String timeFormat = hour + ":" + min;
     
    System.out.println("Time: " + timeFormat);
     
  3. Offline

    thepaperboy99

    Thanks! I need this for a scoreboard, each game will be 15 minutes. Know how to do that? Thanks. :)
     
  4. Offline

    pope_on_dope

    what i use for my projects:
    Code:java
    1. public static String diversify(int derp) {
    2. String string = ":";
    3. int hours = (int) ((derp / 1000 + 8) % 24);
    4. int minutes = (int) (60 * (derp % 1000) / 1000);
    5. string = hours+":"+minutes;
    6. return string;
    7. }
     
  5. Offline

    thepaperboy99

    I tried to use that to see how it works with my timer, and it seems to skip numbers most of the time, and looks like its going fast by a bit. Any suggestions? Thanks.
     
  6. Offline

    thepaperboy99

    Nm I figured it out by myself. Solved.
     
Thread Status:
Not open for further replies.

Share This Page