當前位置: 首頁>>代碼示例>>Java>>正文


Java Group類代碼示例

本文整理匯總了Java中me.lucko.luckperms.api.Group的典型用法代碼示例。如果您正苦於以下問題:Java Group類的具體用法?Java Group怎麽用?Java Group使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Group類屬於me.lucko.luckperms.api包,在下文中一共展示了Group類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import me.lucko.luckperms.api.Group; //導入依賴的package包/類
@Override
protected void execute(Event e) {
	Optional<LuckPermsApi> api = LuckPerms.getApiSafe();
	for (Group g : api.get().getGroups()) {
		if (g.getName().equals(group.getSingle(e))) {
			api.get().getStorage().deleteGroup(g).thenAcceptAsync(wasSuccessful -> {
				if (!wasSuccessful) {
					return;
				}

				api.get().getStorage().loadAllGroups();

			}, api.get().getStorage().getAsyncExecutor());
			break;
		}
	}
}
 
開發者ID:Sharpjaws,項目名稱:SharpSK,代碼行數:18,代碼來源:EffLuckPermsDeleteGroup.java

示例2: addToGroup

import me.lucko.luckperms.api.Group; //導入依賴的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

示例3: removeFromGroup

import me.lucko.luckperms.api.Group; //導入依賴的package包/類
@Override
public boolean removeFromGroup(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();
    boolean result = user.unsetPermissionUnchecked(groupNode) != DataMutateResult.FAIL;

    luckPermsApi.cleanupUser(user);
    return result;
}
 
開發者ID:AuthMe,項目名稱:AuthMeReloaded,代碼行數:19,代碼來源:LuckPermsHandler.java

示例4: setGroup

import me.lucko.luckperms.api.Group; //導入依賴的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

示例5: getNext

import me.lucko.luckperms.api.Group; //導入依賴的package包/類
@Override
public String getNext(@Nonnull Group current) {
    Objects.requireNonNull(current, "current");
    try {
        return this.handle.getNext(ApiGroup.cast(current));
    } catch (IllegalArgumentException e) {
        return null;
    }
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:10,代碼來源:ApiTrack.java

示例6: getPrevious

import me.lucko.luckperms.api.Group; //導入依賴的package包/類
@Override
public String getPrevious(@Nonnull Group current) {
    Objects.requireNonNull(current, "current");
    try {
        return this.handle.getPrevious(ApiGroup.cast(current));
    } catch (IllegalArgumentException e) {
        return null;
    }
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:10,代碼來源:ApiTrack.java

示例7: deleteGroup

import me.lucko.luckperms.api.Group; //導入依賴的package包/類
@Nonnull
@Override
public CompletableFuture<Boolean> deleteGroup(@Nonnull Group group) {
    Objects.requireNonNull(group, "group");
    if (group.getName().equalsIgnoreCase(this.plugin.getConfiguration().get(ConfigKeys.DEFAULT_GROUP_NAME))) {
        throw new IllegalArgumentException("Cannot delete the default group.");
    }
    return this.handle.noBuffer().deleteGroup(ApiGroup.cast(group), DeletionCause.API).thenApply(x -> true);
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:10,代碼來源:ApiStorage.java

示例8: execute

import me.lucko.luckperms.api.Group; //導入依賴的package包/類
@Override
protected void execute(Event e) {

	Optional<LuckPermsApi> api = LuckPerms.getApiSafe();
	api.get().getStorage().createAndLoadGroup(group.getSingle(e)).thenAcceptAsync(success -> {
		if (!success) {
			return;
		}

		Group Lgroup = api.get().getGroup(group.getSingle(e));
		if (Lgroup == null) {
			return;
		}

		if (perms != null) {
			for (String s : perms.getAll(e)) {
				try {
					Node permission = api.get().buildNode(s).setValue(true).build();
					Lgroup.setPermission(permission);
				} catch (ObjectAlreadyHasException | IllegalArgumentException ex) {
					return;
				}
			}
		}
		api.get().getStorage().saveGroup(Lgroup);
	}, api.get().getStorage().getAsyncExecutor());
}
 
開發者ID:Sharpjaws,項目名稱:SharpSK,代碼行數:28,代碼來源:EffLuckPermsCreateGroup.java

示例9: get

import me.lucko.luckperms.api.Group; //導入依賴的package包/類
@Override
@Nullable
protected String[] get(Event e) {

	ArrayList<String> groups = new ArrayList<>();
	Optional<LuckPermsApi> api = LuckPerms.getApiSafe();
	if (pl.getSingle(e) == null) {
		return new String[groups.size()];
	}
	Consumer<User> action = new Consumer<User>() {
		@Override
		public void accept(User t) {

			for (Group g : api.get().getGroups()) {
				if (t.isInGroup(g)) {
					groups.add(g.getName());
				}
			}
		}

	};

	User user = api.get().getUser(pl.getSingle(e).getUniqueId());
	if (user != null) {
		action.accept(user);

	}
	return groups.toArray(new String[groups.size()]);
}
 
開發者ID:Sharpjaws,項目名稱:SharpSK,代碼行數:30,代碼來源:ExprLuckPermsAllGroupsOfPlayer.java

示例10: get

import me.lucko.luckperms.api.Group; //導入依賴的package包/類
@Override
@Nullable
protected String[] get(Event e) {
	Optional<LuckPermsApi> api = LuckPerms.getApiSafe();
	ArrayList<String> groups = new ArrayList<>();

	for (Group g : api.get().getGroups()) {
		groups.add(g.getName());
	}
	return groups.toArray(new String[groups.size()]);

}
 
開發者ID:Sharpjaws,項目名稱:SharpSK,代碼行數:13,代碼來源:ExprLuckPermsAllGroups.java

示例11: isInGroup

import me.lucko.luckperms.api.Group; //導入依賴的package包/類
@Override
public boolean isInGroup(OfflinePlayer player, String group) {
    User user = luckPermsApi.getUser(player.getName());
    if (user == null) {
        return false;
    }

    Group permissionGroup = luckPermsApi.getGroup(group);
    boolean result = permissionGroup != null && user.inheritsGroup(permissionGroup);

    luckPermsApi.cleanupUser(user);
    return result;
}
 
開發者ID:AuthMe,項目名稱:AuthMeReloaded,代碼行數:14,代碼來源:LuckPermsHandler.java

示例12: getGroups

import me.lucko.luckperms.api.Group; //導入依賴的package包/類
@Override
public List<String> getGroups(OfflinePlayer player) {
    User user = luckPermsApi.getUser(player.getName());
    if (user == null) {
        return Collections.emptyList();
    }

    List<String> result = user.getOwnNodes().stream()
        .filter(Node::isGroupNode)
        .map(n -> luckPermsApi.getGroupSafe(n.getGroupName()))
        .filter(Optional::isPresent)
        .map(Optional::get)
        .distinct()
        .sorted((o1, o2) -> {
            if (o1.getName().equals(user.getPrimaryGroup()) || o2.getName().equals(user.getPrimaryGroup())) {
                return o1.getName().equals(user.getPrimaryGroup()) ? 1 : -1;
            }

            int i = Integer.compare(o2.getWeight().orElse(0), o1.getWeight().orElse(0));
            return i != 0 ? i : o1.getName().compareToIgnoreCase(o2.getName());
        })
        .map(Group::getName)
        .collect(Collectors.toList());

    luckPermsApi.cleanupUser(user);
    return result;
}
 
開發者ID:AuthMe,項目名稱:AuthMeReloaded,代碼行數:28,代碼來源:LuckPermsHandler.java

示例13: getGroup

import me.lucko.luckperms.api.Group; //導入依賴的package包/類
@Override
public Group getGroup(@Nonnull String name) {
    Objects.requireNonNull(name, "name");
    me.lucko.luckperms.common.model.Group group = this.handle.getIfLoaded(name);
    return group == null ? null : group.getDelegate();
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:7,代碼來源:ApiGroupManager.java

示例14: getLoadedGroups

import me.lucko.luckperms.api.Group; //導入依賴的package包/類
@Nonnull
@Override
public Set<Group> getLoadedGroups() {
    return this.handle.getAll().values().stream().map(me.lucko.luckperms.common.model.Group::getDelegate).collect(Collectors.toSet());
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:6,代碼來源:ApiGroupManager.java

示例15: cast

import me.lucko.luckperms.api.Group; //導入依賴的package包/類
public static me.lucko.luckperms.common.model.Group cast(Group group) {
    Objects.requireNonNull(group, "group");
    Preconditions.checkState(group instanceof ApiGroup, "Illegal instance " + group.getClass() + " cannot be handled by this implementation.");
    return ((ApiGroup) group).getHandle();
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:6,代碼來源:ApiGroup.java


注:本文中的me.lucko.luckperms.api.Group類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。