Looking for dev that can help me fix my timer

Status
This thread has been locked.

xguys

Banned
Feedback score
1
Posts
546
Reactions
71
Resources
0
hey so I fucked up my timer in my plugin so it defaults to even tho I write 200 in my config I can't seem to find a way to fix it (if you want to help let me know and if you want to fix it let me know I will pay you a little just for the fun xD)
I have made it so the timer Can set as a delay in min in the config but it just stays at the default 5

MAIN:
public static long timer = System.currentTimeMillis();
}, (long)(this.getConfig().getInt("delay") 20 60), (long)(this.getConfig().getInt("delay") 20 60));
Bukkit.getScheduler().runTaskTimer((Plugin)this, new Runnable(){




EVENTLISTENER:

long timer = Main.timer;
long next = System.currentTimeMillis() + (long)(this.plugin.getConfig().getInt("delay") * 1000);
player.sendMessage(String.valueOf(ChatColor.BLUE + "[Star] >>") + " \u00a7cThe next Star will fall in " + (5 - (int)((next - timer) / 1000) / 60) + " minute(s).");
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

xguys

Banned
Feedback score
1
Posts
546
Reactions
71
Resources
0
What are the '20 60' there?
60 means 60 ticks - 20 ticks = 1 second so 20 * 3 = 60, so that's 3 seconds. (Was my expiation but now I am confused not sure that is why)
 
Banned forever. Reason: Scamming (https://builtbybit.com/threads/xguys-scam-report.175191/)

Ferdz

Feedback score
0
Posts
57
Reactions
37
Resources
0
Ok but you are missing * symbols then. Also a second lasts 20 ticks. So you take the amount of minutes you want and multiply that with (20 * 60) ticks.
 

xguys

Banned
Feedback score
1
Posts
546
Reactions
71
Resources
0
Ok but you are missing * symbols then. Also a second lasts 20 ticks. So you take the amount of minutes you want and multiply that with (20 * 60) ticks.
Do you have a better idea on how to do the entire timer as I think I fucked it all up
 
Banned forever. Reason: Scamming (https://builtbybit.com/threads/xguys-scam-report.175191/)

Ferdz

Feedback score
0
Posts
57
Reactions
37
Resources
0
Depends on what exactly you want to do inside the timer. Do you want to execute something after a set amount of time? Or do something every X amount of ticks?
 

xguys

Banned
Feedback score
1
Posts
546
Reactions
71
Resources
0
Depends on what exactly you want to do inside the timer. Do you want to execute something after a set amount of time? Or do something every X amount of ticks?
I state the time in minutes in the config and then I can do /star timer to see when the next one drops
 
Banned forever. Reason: Scamming (https://builtbybit.com/threads/xguys-scam-report.175191/)

xguys

Banned
Feedback score
1
Posts
546
Reactions
71
Resources
0
Banned forever. Reason: Scamming (https://builtbybit.com/threads/xguys-scam-report.175191/)

Stockfish

Sometimes a software developer
Premium
Feedback score
2
Posts
185
Reactions
100
Resources
0
E8aotWz.png

Firstly, and foremost, I strongly urge you to use the code insertion option when displaying code. It's three seconds of work for you, and it's balm for our eyes.
Secondly, I believe this can be done in an easier manner. Allow me to demonstrate;
Code:
private double t;
  
    /*
     * t is going to be our time variable, which will be
     * modified in the runnable
     */
  
  
    // a simple method in which the runnable takes place
    private void onTimer() {
        t = 0; // setting the initial value of t
        new BukkitRunnable() {
            public void run() {
                t = t + 1; // every 20 ticks( 1 second ) we're going to get the
                           // value of t and increment it by 1
              
                getServer().broadcastMessage("seconds: " + t);
              
                if(t >= 10) {
                    this.cancel();
                }
              
                /*
                 *  we're going to be repeating this process until t is
                 *  larger or equal to 10. Then we'll cancel it
                 */
              
            }
        }.runTaskTimer(this, 0, 20);
        /*
         * this = the instance of the main class
         * 0 = the delay before we start the timer upon execution, in this case, there is no delay
         * 20 = the number of ticks you want the timer to run upon
         *         in other words, 20 ticks = 1 second.
         */
    }
Namely, what I'm doing is counting to ten, and not from it, but you can see what I'm getting at.
 

Ferdz

Feedback score
0
Posts
57
Reactions
37
Resources
0
E8aotWz.png

Firstly, and foremost, I strongly urge you to use the code insertion option when displaying code. It's three seconds of work for you, and it's balm for our eyes.
Secondly, I believe this can be done in an easier manner. Allow me to demonstrate;
Code:
private double t;
 
    /*
     * t is going to be our time variable, which will be
     * modified in the runnable
     */
 
 
    // a simple method in which the runnable takes place
    private void onTimer() {
        t = 0; // setting the initial value of t
        new BukkitRunnable() {
            public void run() {
                t = t + 1; // every 20 ticks( 1 second ) we're going to get the
                           // value of t and increment it by 1
             
                getServer().broadcastMessage("seconds: " + t);
             
                if(t >= 10) {
                    this.cancel();
                }
             
                /*
                 *  we're going to be repeating this process until t is
                 *  larger or equal to 10. Then we'll cancel it
                 */
             
            }
        }.runTaskTimer(this, 0, 20);
        /*
         * this = the instance of the main class
         * 0 = the delay before we start the timer upon execution, in this case, there is no delay
         * 20 = the number of ticks you want the timer to run upon
         *         in other words, 20 ticks = 1 second.
         */
    }
Namely, what I'm doing is counting to ten, and not from it, but you can see what I'm getting at.
So... the link I sent basically?
 
Status
This thread has been locked.
Top