当前位置: 首页>>代码示例>>Java>>正文


Java User.setPermissionUnchecked方法代码示例

本文整理汇总了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;
}
 
开发者ID:AuthMe,项目名称:AuthMeReloaded,代码行数:23,代码来源:LuckPermsHandler.java

示例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;
}
 
开发者ID:AuthMe,项目名称:AuthMeReloaded,代码行数:22,代码来源:LuckPermsHandler.java

示例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());

	}
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:54,代码来源:EffLuckPermsSetPerm.java


注:本文中的me.lucko.luckperms.api.User.setPermissionUnchecked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。