Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by JacksonHogan, Jun 10, 2016.
How would i go about getting the highest player balance from vault, Kinda like a baltop.
You could loop through Bukkit.getOfflinePlayers
Just loop through all of the keys it stores (not sure if it's yml based) and check who has the highest balance out of all of them.
I'm using hashmaps.
How would i loop through them and get the highest integer (double) value?
Ah, just loop through each key and get the corresponding value.
double highest = 0
for(Double value: map.values())
if( value > highest)
highest = value;
That's just basic Java. I'd recommend reading some Java tutorials online to get the basics before making plugins.
That won't work exactly. The user doesn't know the highest amount.
int maxValue = Collections.max(yourMapHere.values());
The highest is a placeholder, which'll give you highest value.
Yes it would.
I've already posted how to get the highest value. The above method does not work. A "placeholder" does nothing at all.
Sorry, I missed the bit where it was setting the new value. But using my method is more efficient and more readable.
Yours uses Java 8, not everything supports Java 8.
-_- One day you'll realize what I mean.
I am so confused....
If i use Double balTop1 = Collections.max(topbal.values());
Double balTop1 = Collections.max(topbal.values());
Then how would i get the player?
double highest = 0;
for (Map.Entry<Player, Double> balance : map.entrySet())
if(balance.getValue() > highest)
highest = balance.getValue();
highestPlayer = balance.getKey();
I realized pretty quickly! xD I just had skimmed your code before without totally reading it. And yes, almost everything now supports Java 8 (this includes our main source of development in this case... namely Minecraft )
Just thought I'd pop in here to say Java 8 is the recommended version to use.
It is strongly advised to stop supporting Java 7 in favor of Java 8. Java 7 has been EOL for over a year now, and is no longer receiving security updates. Supporting anything less than Java 8 is enabling security risks, not to mention limiting you from using the new features it offers.
Last thing we need is a repeat of Java 6 lasting 10 years too long after it was marked EOL. Let Java 7 die already.
I meant for idiotic shared hosts. I love Java 8 for the simplicity it offers, the reliable, and the overall improvements. I use Java 8 for my server & my private plugins.
However, if you're working on a public plugin its best to make it compatible with Java 7&8.
Yeah... No it's not. If you're looking for publicity, go ahead compile with JDK 7. If you're smart and know that Java 7
you would switch to Java 8 regardless if it's a public plugin or not. If these so called "popular Minecraft hosts" don't want to update their software, they probably shouldn't be running in the first place. Running outdated software can only cause bad things.
Any idea how annoying it is to get the same complaints over and over again?