Don't assume primary group is always present

Fixes a potential issue with PEX 2.0 (and 1.x) where users may not have a primary group.
Closes #2901.
This commit is contained in:
md678685 2019-12-26 13:08:38 +00:00
parent 8a04c1e232
commit 1c4ce7b4bd

View File

@ -46,23 +46,31 @@ public abstract class AbstractVaultHandler extends SuperpermsHandler {
@Override @Override
public String getPrefix(final Player base) { public String getPrefix(final Player base) {
String playerPrefix = chat.getPlayerPrefix(base); String playerPrefix = chat.getPlayerPrefix(base);
if (playerPrefix == null) { if (playerPrefix != null) {
String playerGroup = perms.getPrimaryGroup(base);
return chat.getGroupPrefix(base.getWorld().getName(), playerGroup);
} else {
return playerPrefix; return playerPrefix;
} }
String playerGroup = perms.getPrimaryGroup(base);
if (playerGroup != null) {
return chat.getGroupPrefix(base.getWorld().getName(), playerGroup);
}
return null;
} }
@Override @Override
public String getSuffix(final Player base) { public String getSuffix(final Player base) {
String playerSuffix = chat.getPlayerSuffix(base); String playerSuffix = chat.getPlayerSuffix(base);
if (playerSuffix == null) { if (playerSuffix != null) {
String playerGroup = perms.getPrimaryGroup(base);
return chat.getGroupSuffix(base.getWorld().getName(), playerGroup);
} else {
return playerSuffix; return playerSuffix;
} }
String playerGroup = perms.getPrimaryGroup(base);
if (playerGroup != null) {
return chat.getGroupSuffix(base.getWorld().getName(), playerGroup);
}
return null;
} }
boolean canLoad() { boolean canLoad() {