本文整理汇总了Java中org.spongepowered.api.service.permission.Subject.hasPermission方法的典型用法代码示例。如果您正苦于以下问题:Java Subject.hasPermission方法的具体用法?Java Subject.hasPermission怎么用?Java Subject.hasPermission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.service.permission.Subject
的用法示例。
在下文中一共展示了Subject.hasPermission方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: replaceMessage
import org.spongepowered.api.service.permission.Subject; //导入方法依赖的package包/类
public static String replaceMessage(final EChat chat, final Subject player, String message) {
Map<Pattern, EReplace<?>> replaces = new HashMap<Pattern, EReplace<?>>();
if (!player.hasPermission(EEPermissions.MSG_COLOR.get())) {
message = message.replaceAll(ChatService.REGEX_COLOR, "");
}
if (!player.hasPermission(EEPermissions.MSG_FORMAT.get())) {
message = message.replaceAll(ChatService.REGEX_FORMAT, "");
}
if (!player.hasPermission(EEPermissions.MSG_MAGIC.get())) {
message = message.replaceAll(ChatService.REGEX_MAGIC, "");
}
if (player.hasPermission(EEPermissions.MSG_CHARACTER.get())) {
replaces.putAll(chat.getReplaceCharacters());
}
if (player.hasPermission(EEPermissions.MSG_COMMAND.get())) {
replaces.putAll(chat.getReplaceCommand());
}
if (player.hasPermission(EEPermissions.MSG_ICONS.get())) {
replaces.putAll(chat.getReplaceIcons());
}
if (player.hasPermission(EEPermissions.MSG_URL.get())) {
replaces.putAll(chat.getReplaceUrl());
}
if (replaces.isEmpty()) return message;
return EFormatString.of(message).toString(replaces);
}
示例2: checkPerm
import org.spongepowered.api.service.permission.Subject; //导入方法依赖的package包/类
public boolean checkPerm(Subject subject, String... perms) {
boolean result = false;
for (String perm : perms) {
result = result || subject.hasPermission(perm);
}
if (invert) {
return !result;
} else {
return result;
}
}
示例3: hasPermissionWorld
import org.spongepowered.api.service.permission.Subject; //导入方法依赖的package包/类
public boolean hasPermissionWorld(Subject player, World world) {
return !this.getConfigs().isWorldPermissions() || player.hasPermission(EAPermissions.WORLDS.get() + "." + world.getName());
}