Hot Summer Deals are Here!
Celebrate with up to 99% off on 17,300 resources
02
Days
17
Hours
52
Mins
54
Secs

Need help with exp bar cooldown

Status
This thread has been locked.

BeProud

Feedback score
0
Posts
113
Reactions
36
Resources
0
Hey nice people of MCM,

usually I'm not the type a person how asks very second for assistance, but currently I'm struggling with how this works. I'd like to make a exp bar cooldown like Velt/Arcane/Zonix did it. I know how to create a cooldown, I know that I need a task timer that ticks 20 times per second. But here's my problem: I can't figure out, how to calculate the experience. (I'm not that good at maths..)
I would be really thankful if anyone could help, or at least give me a hint. Means a lot to me.

Greetings, BeProud
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Kiri

Deactivated
Feedback score
45
Posts
368
Reactions
275
Resources
0
I've never played any of those servers, do you mind briefly explaining what the experience bar looks like during countdown?
 

BeProud

Feedback score
0
Posts
113
Reactions
36
Resources
0
I've never played any of those servers, do you mind briefly explaining what the experience bar looks like during countdown?
Its basically a cooldown, which will appear in the exp bar. The levels are the seconds left and the experience bar is how much there's left (calculated). At the cooldown start the experience bar should be full and at the end the experience bar empty. So that it just getting decreased. And I have no clue how I calculate it. I tried much methods, none of them worked.
 

Mooselk

Motocross enthusiast
Premium
Feedback score
9
Posts
298
Reactions
213
Resources
0
Not mine just found this on the internet. It's pretty dated but it might give a good idea of what to do.
 

BeProud

Feedback score
0
Posts
113
Reactions
36
Resources
0
Not mine just found this on the internet. It's pretty dated but it might give a good idea of what to do.
Doesn't help me. Ik how it works, I just don't know how I have to calculate the experience bar. Thanks though.
Really forgot this. I already looked over that when I was tired (late night coding), but it now seems to work.
For further ppl that don't know how it works, this is how I did it now: (DefaultValues.ENDER_PEARL_TIMER is an integer of 16 seconds)
Code:
@Override
    public void run() {
        PracticePlugin.getManagers().getManager().getEnderpearlCooldowns().entrySet().forEach((entry) -> {
            Player player = entry.getKey();
            TimerCooldown cooldown = entry.getValue();
           
            if (cooldown.isExpired()) {
                player.sendMessage(GRAY + "Your enderpearl cooldown expired.");
                player.setExp(0f);
                player.setLevel(0);
                PracticePlugin.getManagers().getManager().getEnderpearlCooldowns().remove(player);
                return;
            }
           
            double remainingTime = (double) cooldown.getRemaining() / 1000;
            float exp = (float) (player.getExp() - (1F / (DefaultValues.ENDER_PEARL_TIMER * 20)));
            player.setExp(exp);
            player.setLevel((int) remainingTime);
        });
    }
 
Status
This thread has been locked.
Top