always pick last rank
This commit is contained in:
+1
-5
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'net.ltgt.apt' version '0.10'
|
||||
id 'io.franzbecker.gradle-lombok' version '1.14'
|
||||
}
|
||||
|
||||
group 'sh.okx'
|
||||
@@ -26,10 +26,6 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||
|
||||
compileOnly 'org.projectlombok:lombok:1.18.2'
|
||||
apt "org.projectlombok:lombok:1.18.2"
|
||||
|
||||
compile 'org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT'
|
||||
|
||||
compile('net.milkbowl.vault:VaultAPI:1.6') {
|
||||
|
||||
@@ -6,7 +6,10 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import sh.okx.rankup.ranks.Rank;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
@@ -39,12 +42,15 @@ public class RankList<T extends Rank> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public T getLast() {
|
||||
public List<T> getOrderedList() {
|
||||
List<T> list = new ArrayList<>();
|
||||
T t = getFirst();
|
||||
list.add(t);
|
||||
do {
|
||||
t = next(t);
|
||||
list.add(t);
|
||||
} while (!t.isLast());
|
||||
return t;
|
||||
return list;
|
||||
}
|
||||
|
||||
public T getByName(String name) {
|
||||
@@ -57,10 +63,14 @@ public class RankList<T extends Rank> {
|
||||
}
|
||||
|
||||
public T getByPlayer(Player player) {
|
||||
return ranks.stream()
|
||||
.filter(rank -> rank.isIn(player))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
List<T> list = getOrderedList();
|
||||
Collections.reverse(list);
|
||||
for (T t : list) {
|
||||
if (t.isIn(player)) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public T next(T rank) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# see https://github.com/okx-code/Rankup3/wiki/Rank-format
|
||||
|
||||
# this name can be equal to your rank name for simplicity,
|
||||
# eg "A" instead of "Aexample".
|
||||
Aexample:
|
||||
|
||||
Reference in New Issue
Block a user