forked from Upstream/Velocitab
Tweak role sort order
This commit is contained in:
parent
dbccc21706
commit
22972281e2
@ -120,13 +120,10 @@ public class Velocitab {
|
||||
|
||||
@NotNull
|
||||
public TabPlayer getTabPlayer(@NotNull Player player) {
|
||||
return new TabPlayer(
|
||||
player,
|
||||
return new TabPlayer(player,
|
||||
getLuckPerms().map(hook -> hook.getPlayerRole(player))
|
||||
.orElse(Role.DEFAULT_ROLE),
|
||||
getLuckPerms().map(LuckPermsHook::getHighestWeight)
|
||||
.orElse(0),
|
||||
getLuckPerms().map(LuckPermsHook::getLowestWeight)
|
||||
.orElse(0));
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ import java.util.UUID;
|
||||
public class LuckPermsHook {
|
||||
|
||||
private int highestWeight = Role.DEFAULT_WEIGHT;
|
||||
private int lowestWeight = Role.DEFAULT_WEIGHT;
|
||||
private final Velocitab plugin;
|
||||
private final LuckPerms api;
|
||||
|
||||
@ -52,8 +51,7 @@ public class LuckPermsHook {
|
||||
.ifPresent(player -> plugin.getTabList().updatePlayer(new TabPlayer(
|
||||
player,
|
||||
getRoleFromMetadata(event.getData().getMetaData()),
|
||||
getHighestWeight(),
|
||||
getLowestWeight()
|
||||
getHighestWeight()
|
||||
)));
|
||||
}
|
||||
|
||||
@ -77,18 +75,6 @@ public class LuckPermsHook {
|
||||
return highestWeight;
|
||||
}
|
||||
|
||||
public int getLowestWeight() {
|
||||
if (lowestWeight == Role.DEFAULT_WEIGHT) {
|
||||
api.getGroupManager().getLoadedGroups().forEach(group -> {
|
||||
final OptionalInt weight = group.getWeight();
|
||||
if (weight.isPresent() && weight.getAsInt() < lowestWeight) {
|
||||
lowestWeight = weight.getAsInt();
|
||||
}
|
||||
});
|
||||
}
|
||||
return lowestWeight;
|
||||
}
|
||||
|
||||
private User getUser(@NotNull UUID uuid) {
|
||||
return api.getUserManager().getUser(uuid);
|
||||
}
|
||||
|
@ -41,9 +41,7 @@ public class Role implements Comparable<Role> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getStringComparableWeight(int maximumPossibleWeight, int lowestPossibleWeight) {
|
||||
return String.format("%0" + String.valueOf(maximumPossibleWeight).length() + "d", weight - lowestPossibleWeight)
|
||||
.replace(" ", "0")
|
||||
.replace("-", "0");
|
||||
public String getStringComparableWeight(int highestWeight) {
|
||||
return String.format("%0" + (highestWeight + "").length() + "d", highestWeight - weight);
|
||||
}
|
||||
}
|
||||
|
@ -12,13 +12,11 @@ public final class TabPlayer implements Comparable<TabPlayer> {
|
||||
private final Player player;
|
||||
private final Role role;
|
||||
private final int highestWeight;
|
||||
private final int lowestWeight;
|
||||
|
||||
public TabPlayer(@NotNull Player player, @NotNull Role role, int highestWeight, int lowestWeight) {
|
||||
public TabPlayer(@NotNull Player player, @NotNull Role role, int highestWeight) {
|
||||
this.player = player;
|
||||
this.role = role;
|
||||
this.highestWeight = highestWeight;
|
||||
this.lowestWeight = lowestWeight;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@ -45,7 +43,7 @@ public final class TabPlayer implements Comparable<TabPlayer> {
|
||||
|
||||
@NotNull
|
||||
public String getTeamName() {
|
||||
return role.getStringComparableWeight(highestWeight, lowestWeight) + "-" + getServerName() + "-" + player.getUsername();
|
||||
return role.getStringComparableWeight(highestWeight) + "-" + getServerName() + "-" + player.getUsername();
|
||||
}
|
||||
|
||||
public void sendHeaderAndFooter(@NotNull PlayerTabList tabList) {
|
||||
|
Loading…
Reference in New Issue
Block a user