本文整理汇总了Java中ru.tehkode.permissions.PermissionUser.getOwnPrefix方法的典型用法代码示例。如果您正苦于以下问题:Java PermissionUser.getOwnPrefix方法的具体用法?Java PermissionUser.getOwnPrefix怎么用?Java PermissionUser.getOwnPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ru.tehkode.permissions.PermissionUser
的用法示例。
在下文中一共展示了PermissionUser.getOwnPrefix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrefix
import ru.tehkode.permissions.PermissionUser; //导入方法依赖的package包/类
@Override
public String getPrefix(Player p) {
PermissionUser user = ru.tehkode.permissions.bukkit.PermissionsEx.getPermissionManager().getUser(p);
if (user == null) {
return "";
}
if (!Config.MULTIPREFIXES.getBoolean()) {
return user.getPrefix(p.getWorld().getName());
}
String personalPrefix = user.getOwnPrefix();
String finalPrefix = "";
if (personalPrefix != null && !personalPrefix.isEmpty()) {
finalPrefix = personalPrefix;
}
PermissionGroup[] userGroups = user.getGroups();
int i = 0;
for (PermissionGroup group : userGroups) {
String groupPrefix = group.getPrefix();
if (groupPrefix != null && !groupPrefix.isEmpty()) {
if(i > 1) {
finalPrefix += " ";
}
finalPrefix += groupPrefix;
i ++;
}
}
return finalPrefix;
}
示例2: getPrefix
import ru.tehkode.permissions.PermissionUser; //导入方法依赖的package包/类
@Override
public String getPrefix(Player p, String world, boolean multiPrefixes, boolean PrependPlayerPrefix) {
final PermissionUser user = PermissionsEx.getPermissionManager().getUser(p.getName());
if (user == null) {
return "";
}
if (!multiPrefixes) {
return user.getPrefix(world);
}
String personalPrefix = user.getOwnPrefix();
// If player has own prefix, and don't want to prepend
if (!PrependPlayerPrefix && (personalPrefix != null && !personalPrefix.isEmpty())) {
return personalPrefix;
}
// PrependPlayerPrefix is true at this point
String finalPrefix = "";
if (personalPrefix != null && !personalPrefix.isEmpty()) {
finalPrefix = personalPrefix;
}
//adds in the user's groups first in order they are in
PermissionGroup[] userGroups = user.getGroups();
for (PermissionGroup group : userGroups) {
String groupPrefix = group.getPrefix();
if (groupPrefix == null || groupPrefix.isEmpty()) {
continue;
}
finalPrefix += groupPrefix;
}
//if there is no prefix so far, just sets it to "" to remove the %prefix and not add anything
if (finalPrefix == null || finalPrefix.isEmpty()) {
finalPrefix = "";
}
return finalPrefix;
}