mirror of
https://github.com/WiIIiam278/Velocitab.git
synced 2025-03-13 13:30:01 +01:00
enhancement: role weight fallback to luckperms placeholder (#238)
This commit is contained in:
parent
9cb20be6e0
commit
e398306cd7
@ -106,7 +106,8 @@ public enum Placeholder {
|
|||||||
.orElse(getPlaceholderFallback(plugin, "%luckperms_primary_group_name%"))),
|
.orElse(getPlaceholderFallback(plugin, "%luckperms_primary_group_name%"))),
|
||||||
ROLE_DISPLAY_NAME((plugin, player) -> player.getRole().getDisplayName()
|
ROLE_DISPLAY_NAME((plugin, player) -> player.getRole().getDisplayName()
|
||||||
.orElse(getPlaceholderFallback(plugin, "%luckperms_primary_group_name%"))),
|
.orElse(getPlaceholderFallback(plugin, "%luckperms_primary_group_name%"))),
|
||||||
ROLE_WEIGHT((plugin, player) -> player.getRoleWeightString()),
|
ROLE_WEIGHT((plugin, player) -> player.getRoleWeightString()
|
||||||
|
.orElse(getPlaceholderFallback(plugin, "%luckperms_meta_weight%"))),
|
||||||
SERVER_GROUP((plugin, player) -> player.getGroup().name()),
|
SERVER_GROUP((plugin, player) -> player.getGroup().name()),
|
||||||
SERVER_GROUP_INDEX((plugin, player) -> Integer.toString(player.getServerGroupPosition(plugin))),
|
SERVER_GROUP_INDEX((plugin, player) -> Integer.toString(player.getServerGroupPosition(plugin))),
|
||||||
DEBUG_TEAM_NAME((plugin, player) -> plugin.getFormatter().escape(player.getLastTeamName().orElse(""))),
|
DEBUG_TEAM_NAME((plugin, player) -> plugin.getFormatter().escape(player.getLastTeamName().orElse(""))),
|
||||||
|
@ -30,7 +30,7 @@ import java.util.Optional;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class Role implements Comparable<Role> {
|
public class Role implements Comparable<Role> {
|
||||||
|
|
||||||
public static final int DEFAULT_WEIGHT = 0;
|
public static final int DEFAULT_WEIGHT = -1;
|
||||||
public static final Role DEFAULT_ROLE = new Role(DEFAULT_WEIGHT, null, null, null, null);
|
public static final Role DEFAULT_ROLE = new Role(DEFAULT_WEIGHT, null, null, null, null);
|
||||||
@Getter
|
@Getter
|
||||||
private final int weight;
|
private final int weight;
|
||||||
@ -65,8 +65,11 @@ public class Role implements Comparable<Role> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
protected String getWeightString() {
|
protected Optional<String> getWeightString() {
|
||||||
return Integer.toString(weight);
|
if (weight == -1) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return Optional.of(Integer.toString(weight));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -96,7 +96,7 @@ public final class TabPlayer implements Comparable<TabPlayer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getRoleWeightString() {
|
public Optional<String> getRoleWeightString() {
|
||||||
return getRole().getWeightString();
|
return getRole().getWeightString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ public final class TabPlayer implements Comparable<TabPlayer> {
|
|||||||
@Override
|
@Override
|
||||||
public int compareTo(@NotNull TabPlayer o) {
|
public int compareTo(@NotNull TabPlayer o) {
|
||||||
final int roleDifference = role.compareTo(o.role);
|
final int roleDifference = role.compareTo(o.role);
|
||||||
if (roleDifference == 0) {
|
if (roleDifference <= 0) {
|
||||||
return player.getUsername().compareTo(o.player.getUsername());
|
return player.getUsername().compareTo(o.player.getUsername());
|
||||||
}
|
}
|
||||||
return roleDifference;
|
return roleDifference;
|
||||||
|
Loading…
Reference in New Issue
Block a user