Timer Signs

Discussion in 'Plugin Requests' started by Jaackk, Jan 23, 2016.

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

    Jaackk

    Plugin category: Mechanics?


    Suggested name: Timer Signs


    What I want: I'm simply looking for a plugin that will allow me to create signs (colour codes supported) that will show a timer counting down. Here is an example:

    Example Sign (open)
    [​IMG]


    It would be helpful if server reloads and restarts didn't effect it.

    Ideas for commands:

    No commands needed, just the way in which the sign is created is important and could be done any way that is easiest to do.


    Ideas for permissions:

    TimedSigns.Create



    When I'd like it by:

    February if possible,
    I'd put it on a sign if I could ;)
     
  2. Offline

    XavierMechanics

    Nice idea but, how can you create a timer if there's no commands?

    I mean, if i want a 24hour countdown sign, how will i do it.
     
  3. Offline

    Jaackk


    I was thinking you could place down a sign and type whatever it needs to be activated. I was thinking if this was the time length at the bottom that would be great. e.g (#)d (#)h (#)m - You know how signs like in essentials and things work where you type [buy] or whatever and the plugin knows.

    "No commands needed, just the way in which the sign is created is important and could be done any way that is easiest to do."

    It's up to the developer as I stated which ever way is easiest is fine with me, all I need it the plugin it's not important how it is activated.

    Best Regards,
    Jack.
     
  4. Offline

    pie_flavor

    @Jaackk I will make this. No guarantee on whether restarts will affect it.
    Edit: @Jaackk Does it need to have the full 3 lines of customizable text?
     
    Last edited: Jan 23, 2016
    Jaackk likes this.
  5. Offline

    Jaackk


    @pie_flavor Hey, sorry I didn't get a notification on your reply,

    It's not essential but it would be nice.
    If not I can always change it with a plugin I have called sign edit.

    If it's too much hassle don't worry about it being 3 whole lines.

    Many Thanks,
    Jack.
     
  6. @pie_flavor @Jaackk

    This plugin will ruin his server if he has it the way he requested. You'll need to have tasks running every second for every sign for this to work, plus chunks always loaded where the signs are (and always updating), which can easily add up to become your evil lag overlord. I thus have a better proposal.

    When a player right-clicks a designated sign, the plugin will get the current time then display the amount of time needed to elapse before the set time is reached. The sign will only update on right-clicking.
     
  7. Offline

    pie_flavor

    @0ct0berBkkitPlgins Wow, I never think about the chunkloading aspect when making things like this.
     
  8. Offline

    Jaackk


    @pie_flavor @0ct0berBkkitPlgins

    Very good point, did not think of this,

    Maybe the sign could say (Right click to view) or something rather than having an outdated time on the sign that may confuse players.

    Many thanks,

    Jack.
     
    0ct0berBkkitPlgins likes this.
  9. Yes, that is a good idea. That way, the plugin will only be doing any work on the PlayerInteractEvent when someone clicks a sign, which will cause virtually no performance drop.
     
    Jaackk likes this.
  10. Offline

    87pen

    @0ct0berBkkitPlgins Store the amount update signs if the chunk is loaded? I don't see why this is a problem since chunks have an isLoaded Method? Tasks shouldn't be a problem unless you program them extremely inefficiently. Really I don't see how this plugin could cause much of any lag at all.
     
    0566 and I Al Istannen like this.
  11. Offline

    I Al Istannen

    @pie_flavor @0ct0berBkkitPlgins Why run a task for every sign? Just store the locations somewhere, create ONE runnable and perform the logic there. You can then check if the chunk is loaded (Location.getChunk(), Chunk.isLoaded()) and if so you can fetch the sign and alter it. Only problem could be signs that were broken. You could either protect them or remove them from the location list if there is no sign at the location (which you will need to check nevertheless cause of the blockstate).
     
  12. @I Al Istannen That isn't the plan. The plan is to display it when players click the sign.
     
  13. Offline

    I Al Istannen

    @0ct0berBkkitPlgins And why? I think it looks better if it updates automatically.


    @Jaackk
    I have done what you asked for. Right now the signs aren't protected from breaking, I can add that if you want or you protect them. They are now. And, do you want them to execute a command upon reaching 0?

    You create a sign by writing "[timer]" in the first line. Then in the second line you write the time. E.g.
    Code:
    "[timer]"
    "65d 75h 64m 10s 50ms"
    
    
    You can also don't write the spaces if the space gets tight. You have just one line though. Again, I can change that if you want that.
    It can (depending on how you make the config) look like this:
    2016-01-27_20.11.08.png

    As a gif (just 20 FPS):
    TimerSigns.gif

    Permissions:
    "TimerSigns.Create"
    "TimerSigns.Destroy" ==> Allows you to break the sign
    "TimerSigns.Reload"

    Commands:
    "/timersigns <write what you want or nothing at all>" ==> Reloads the config

    Config:
    You can change the text on the sign. You can change the 2!! messages send. You can change the number format. You can change the update intervall. If you choose it closer, the sign will be more accurate, but it will take more procession power. But it shouldn't be mentionable.

    That's it basically.

    Link: https://www.dropbox.com/s/tgi8twusr3kzvdd/TimerSigns.jar?dl=1

    If you don't trust it since it is dropbox, in the .jar (open with winrar, 7zip or similar programs) is the source code. You can compile it yourself if you want to :)
     
    Last edited: Jan 27, 2016
  14. Offline

    20zinnm

    Consider using TimeUnit and String.format() to have, say, "Xhr Ym Zs"
     
  15. Offline

    I Al Istannen

    @20zinnm Ah haven't used it. Yes, would also be possible (and much easier :p) thanks for the tip! I will change it in the future!
     
  16. @I Al Istannen You just wasted @pie_flavor 's efforts. It's not very kind to make a plugin when someone else is already working on it, because they don't get credit for it and their work becomes useless. This is also far more complicated and resource intensive than need be for the request.
     
  17. Offline

    20zinnm

    [​IMG]
    If you don't get the joke:
    Spoiler (open)

    The car in the United States is known as a "Bug," but here it's labelled as a feature.
     
  18. Offline

    pie_flavor

  19. Offline

    I Al Istannen

    @pie_flavor
    I thought you stopped doing it. Im sorry, interpreted your post in a wrong way :(
    Feel free to continue the plugin and post it though, doesn't mean it isn't useful.
    Again, I am sorry!


    @0ct0berBkkitPlgins
    I have built it in such a way, that I thought it would make a nice, somewhat customizable plugin following the OP and not beeing too heavy for the server (BUT there is surely a more optimized way to achieve the exact same thing. I don't claim I write (super) efficient code, nor did I spent much time optimizing it.). It updates 1 time in a second (or less if the server has lower TPS than 20, it is running on the server Thread) in the standard configuration, but it is adjustable.

    It runs a for loop n times, where n is the amount of signs. So for 10 signs it runs 10 times the update method per chosen interval. Inside the method are about 15 lines of code not doing any intense calculations and a for loop running 4 times. I do believe that this is negligible.
    It should be around O(n) (x*n*c, x (number of instructions in the method) and c (time for the execution of a instruction) are constants and therefore negligible) but correct me if I'm wrong!

    The main reason however is that it also updates if you don't click on it. I think it looks a lot nicer.

    But of course I would greatly appreciate you pointing out some bottlenecks or bad design choices!

    @20zinnm
    I may be just plain stupid, but I don't know what you want to express with that image of a "Käfer" ;)
     
  20. Offline

    20zinnm

    See the spoiler.
     
  21. Offline

    I Al Istannen

    @20zinnm Sorry, should have been more specific. I do know the expression "It's not a bug, it's a feature". I just don't know how that relates to my post. But I guess explaining ruins the joke :D
     
  22. Offline

    20zinnm

    xD It's because
    . Resource intensity = feature/bug? Because it really shouldn't be intensive but at the same time it adds to it...
     
  23. Offline

    pie_flavor

Thread Status:
Not open for further replies.

Share This Page