java - How to get an elapsed time for this? -


i creating spigot (performance savvy fork of bukkit (minecraft server software)) plugin communicates bungee (proxy server managing multiple spigot instances) server.

i have functionality, when type command "/setbar (time-in-seconds) (message)", use api (barapi if familiar) create bar on every server connected bungee instance.

the fault when player joins 1 of spigot servers after command issued, bar not there. solve storing bar's information on proxy level , sending these values specific spigot instance player attempts join.

okay, enough background information. problem i'm having i'm storing time admin (or whoever issued command) requested in variable. when user joins, time have decremented (or lot.) way i've thought of making sure user joining receives proper elapsed time, (so barapi knows how large timer graphic needs be), storing time command executed in variable (currenttimemillis / currenttimenano) , converting seconds subtracting time specified in command.

i know there flaw logic here, , can't seem work out math. know rather simple, can provide extremely beneficial.

thanks in advance.

postscript: information have failed provide, please let me know , add post.

i realize bit of "no-end" question there isn't exact answer provided didn't give code.

here how solved in plain english, though:

  • store time command executed first in milliseconds.

  • when command executed next, remove first value new value , divide 1000 receive seconds-value.

  • the seconds-value elapsed time. once can find how time remaining subtracting seconds-value provided seconds-value bar.

  • erase bar user in question; recreate same values substitute seconds newly calculated seconds-value.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -