Time & Signs?

Discussion in 'Plugin Development' started by ServerfromMinecraft, Aug 9, 2012.

Thread Status:
Not open for further replies.
  1. Hi all,
    today i have tryed to display the current time on a sign.
    i have made that if i rightklick a sign, the current time is displayed. but - how i can get that its update it automaticalls? without rightclick?
     
  2. Offline

    Darq

  3. Thanks! i take a look ;)

    EDIT:// I have now made a method for update the sign, but its used just 1time, and not repeating!

    Code:
    public void aktualisieren(final Sign s, final Player p){
    plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable(){
    public void run(){
    p.sendMessage("update");
    s.setLine(1,ChatColor.BLUE + df.format(dt));
    s.update();
    }}, 10L, 2000000L);
    }
    why D: ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  4. Offline

    Njol

    Firstly use a sync task, not an async one, and secondly you have set the delay too high: 2 million ticks (wtf?) (20 ticks = 1 second)
     
  5. Ok! i have make it so high because i would that the repeating task repeat ininitely times, but i dont know how :(
     
  6. Offline

    Njol

    The task already runs infinitely, but only once every 2 million ticks. Read the documentation of the method you're using ;)
     
  7. Offline

    p000ison

    Ja Hallo erstmal,

    Simply put there in the 4. Argument 20L to update the sign every second. You can put in the 3. also 20L so the tast starts after 1 sec. But I would recommand you to make only one task and update multiple signs with it. Also you will need to store the signs in a database to know where they are. And another thing is that you dont need to change the sign. You only have to send a fake package to the client. (player.sendBlockChange())
     
  8. Thanks for your answers!

    i try it out :)

    Ok, i have changed the 2millions to 20, yet its send "update" but the stext on the sign not change :(

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  9. Offline

    Njol

    Your variable 'dt' newer changes - You likely want to use System.currentTimeMillis() directly.
     
    Deathmarine likes this.
Thread Status:
Not open for further replies.

Share This Page