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