本文整理汇总了Java中me.lucko.luckperms.api.User.setPermissionUnchecked方法的典型用法代码示例。如果您正苦于以下问题:Java User.setPermissionUnchecked方法的具体用法?Java User.setPermissionUnchecked怎么用?Java User.setPermissionUnchecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类me.lucko.luckperms.api.User
的用法示例。
在下文中一共展示了User.setPermissionUnchecked方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToGroup
import me.lucko.luckperms.api.User; //导入方法依赖的package包/类
@Override
public boolean addToGroup(OfflinePlayer player, String group) {
Group newGroup = luckPermsApi.getGroup(group);
if (newGroup == null) {
return false;
}
User user = luckPermsApi.getUser(player.getName());
if (user == null) {
return false;
}
DataMutateResult result = user.setPermissionUnchecked(luckPermsApi.getNodeFactory().makeGroupNode(newGroup).build());
if (result == DataMutateResult.FAIL) {
return false;
}
saveUser(user);
luckPermsApi.cleanupUser(user);
return true;
}
示例2: setGroup
import me.lucko.luckperms.api.User; //导入方法依赖的package包/类
@Override
public boolean setGroup(OfflinePlayer player, String group) {
User user = luckPermsApi.getUser(player.getName());
if (user == null) {
return false;
}
Group permissionGroup = luckPermsApi.getGroup(group);
if (permissionGroup == null) {
return false;
}
Node groupNode = luckPermsApi.getNodeFactory().makeGroupNode(permissionGroup).build();
DataMutateResult result = user.setPermissionUnchecked(groupNode);
if (result == DataMutateResult.FAIL) {
return false;
}
user.clearMatching(node -> node.isGroupNode() && !node.getGroupName().equals(permissionGroup.getName()));
saveUser(user);
luckPermsApi.cleanupUser(user);
return true;
}
示例3: execute
import me.lucko.luckperms.api.User; //导入方法依赖的package包/类
@Override
protected void execute(Event e) {
if (offplayer.getSingle(e) == null) {
return;
}
Optional<LuckPermsApi> api = LuckPerms.getApiSafe();
Consumer<User> action = new Consumer<User>() {
Node pn = api.get().getNodeFactory().newBuilder(perm.getSingle(e)).setValue(bool.getSingle(e)).build();
@Override
public void accept(User t) {
DataMutateResult result = null;
if (mark == -1) {
result = t.setTransientPermissionUnchecked(pn);
} else {
result = t.setPermissionUnchecked(pn);
}
if (result != DataMutateResult.SUCCESS) {
return;
}
api.get().getStorage().saveUser(t).thenAcceptAsync(wasSuccessful -> {
if (!wasSuccessful) {
return;
}
t.refreshPermissions();
}, api.get().getStorage().getAsyncExecutor());
};
};
if (offplayer.getSingle(e).isOnline()) {
User user = api.get().getUser(offplayer.getSingle(e).getUniqueId());
if (user != null) {
action.accept(user);
}
} else {
api.get().getStorage().loadUser(offplayer.getSingle(e).getUniqueId()).thenAcceptAsync(wasSuccessful -> {
if (!wasSuccessful) {
return;
}
User loadedUser = api.get().getUser(offplayer.getSingle(e).getUniqueId());
if (loadedUser == null) {
return;
}
action.accept(loadedUser);
api.get().cleanupUser(loadedUser);
}, api.get().getStorage().getSyncExecutor());
}
}