mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-27 01:33:05 +00:00
Another Vault fix & cleanup User / Group classes
This commit is contained in:
4 files changed
+56
-179
No files matched your search
@@ -26,7 +26,6 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.event.events.GroupAddEvent;
|
||||
import me.lucko.luckperms.api.implementation.internal.GroupLink;
|
||||
import me.lucko.luckperms.api.implementation.internal.PermissionHolderLink;
|
||||
@@ -35,9 +34,6 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.utils.Identifiable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ToString(of = {"name"})
|
||||
@EqualsAndHashCode(of = {"name"}, callSuper = false)
|
||||
public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
@@ -73,7 +69,7 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
* @return true if the user is a member of the group
|
||||
*/
|
||||
public boolean inheritsGroup(Group group) {
|
||||
return group.getName().equalsIgnoreCase(this.getName()) || inheritsGroup(group, "global");
|
||||
return group.getName().equalsIgnoreCase(this.getName()) || hasPermission("group." + group.getName(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,10 +118,6 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
throw new ObjectAlreadyHasException();
|
||||
}
|
||||
|
||||
if (server == null) {
|
||||
server = "global";
|
||||
}
|
||||
|
||||
setPermission("group." + group.getName(), true, server);
|
||||
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, null, 0L));
|
||||
}
|
||||
@@ -142,10 +134,6 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
throw new ObjectAlreadyHasException();
|
||||
}
|
||||
|
||||
if (server == null) {
|
||||
server = "global";
|
||||
}
|
||||
|
||||
setPermission("group." + group.getName(), true, server, world);
|
||||
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, world, 0L));
|
||||
}
|
||||
@@ -177,10 +165,6 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
throw new ObjectAlreadyHasException();
|
||||
}
|
||||
|
||||
if (server == null) {
|
||||
server = "global";
|
||||
}
|
||||
|
||||
setPermission("group." + group.getName(), true, server, expireAt);
|
||||
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, null, expireAt));
|
||||
}
|
||||
@@ -198,10 +182,6 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
throw new ObjectAlreadyHasException();
|
||||
}
|
||||
|
||||
if (server == null) {
|
||||
server = "global";
|
||||
}
|
||||
|
||||
setPermission("group." + group.getName(), true, server, world, expireAt);
|
||||
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, world, expireAt));
|
||||
}
|
||||
@@ -212,7 +192,7 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
* @throws ObjectLacksException if the group does not already inherit the group
|
||||
*/
|
||||
public void unsetInheritGroup(Group group) throws ObjectLacksException {
|
||||
unsetInheritGroup(group, "global");
|
||||
unsetPermission("group." + group.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,7 +202,7 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
* @throws ObjectLacksException if the group does not already inherit the group
|
||||
*/
|
||||
public void unsetInheritGroup(Group group, boolean temporary) throws ObjectLacksException {
|
||||
unsetInheritGroup(group, "global", temporary);
|
||||
unsetPermission("group." + group.getName(), temporary);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,10 +212,6 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
* @throws ObjectLacksException if the group does not already inherit the group
|
||||
*/
|
||||
public void unsetInheritGroup(Group group, String server) throws ObjectLacksException {
|
||||
if (server == null) {
|
||||
server = "global";
|
||||
}
|
||||
|
||||
unsetPermission("group." + group.getName(), server);
|
||||
}
|
||||
|
||||
@@ -247,10 +223,6 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
* @throws ObjectLacksException if the group does not already inherit the group
|
||||
*/
|
||||
public void unsetInheritGroup(Group group, String server, String world) throws ObjectLacksException {
|
||||
if (server == null) {
|
||||
server = "global";
|
||||
}
|
||||
|
||||
unsetPermission("group." + group.getName(), server, world);
|
||||
}
|
||||
|
||||
@@ -262,10 +234,6 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
* @throws ObjectLacksException if the group does not already inherit the group
|
||||
*/
|
||||
public void unsetInheritGroup(Group group, String server, boolean temporary) throws ObjectLacksException {
|
||||
if (server == null) {
|
||||
server = "global";
|
||||
}
|
||||
|
||||
unsetPermission("group." + group.getName(), server, temporary);
|
||||
}
|
||||
|
||||
@@ -278,10 +246,6 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
* @throws ObjectLacksException if the group does not already inherit the group
|
||||
*/
|
||||
public void unsetInheritGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException {
|
||||
if (server == null) {
|
||||
server = "global";
|
||||
}
|
||||
|
||||
unsetPermission("group." + group.getName(), server, world, temporary);
|
||||
}
|
||||
|
||||
@@ -291,49 +255,4 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
public void clearNodes() {
|
||||
getNodes().clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link List} of all of the groups the group inherits, on all servers
|
||||
* @return a {@link List} of group names
|
||||
*/
|
||||
public List<String> getGroupNames() {
|
||||
return getGroups(null, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link List} of the groups the group inherits on a specific server
|
||||
* @param server the server to check
|
||||
* @param world the world to check
|
||||
* @return a {@link List} of group names
|
||||
*/
|
||||
public List<String> getLocalGroups(String server, String world) {
|
||||
return getGroups(server, world, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link List} of the groups the group inherits on a specific server
|
||||
* @param server the server to check
|
||||
* @return a {@link List} of group names
|
||||
*/
|
||||
public List<String> getLocalGroups(String server) {
|
||||
return getLocalGroups(server, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link List} of the groups the group inherits on a specific server with the option to include global
|
||||
* groups or all groups
|
||||
* @param server Which server to check on
|
||||
* @param world Which world to check on
|
||||
* @param includeGlobal Whether to include global groups
|
||||
* @return a {@link List} of group names
|
||||
*/
|
||||
private List<String> getGroups(String server, String world, boolean includeGlobal) {
|
||||
// Call super #getPermissions method, and just sort through those
|
||||
return getNodes().stream()
|
||||
.filter(n -> n.shouldApplyOnWorld(world, includeGlobal, true))
|
||||
.filter(n -> n.shouldApplyOnServer(server, includeGlobal, true))
|
||||
.filter(Node::isGroupNode)
|
||||
.map(Node::getGroupName)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user