mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-01 05:57:09 +00:00
Fixing errors
This commit is contained in:
parent
3dde5ef578
commit
2a3a48f2ae
@ -3,23 +3,20 @@ package me.totalfreedom.totalfreedommod.perms;
|
|||||||
import net.luckperms.api.model.group.Group;
|
import net.luckperms.api.model.group.Group;
|
||||||
import net.luckperms.api.model.group.GroupManager;
|
import net.luckperms.api.model.group.GroupManager;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class GroupWrapper
|
public class GroupWrapper
|
||||||
{
|
{
|
||||||
private final GroupManager manager;
|
private final GroupManager manager;
|
||||||
private final Set<Group> groupSet;
|
|
||||||
|
|
||||||
public GroupWrapper(GroupManager manager)
|
public GroupWrapper(GroupManager manager)
|
||||||
{
|
{
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.groupSet = manager.getLoadedGroups();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Group> getGroup(String name)
|
public CompletableFuture<Group> getGroup(String name)
|
||||||
{
|
{
|
||||||
if (!manager.isLoaded(name) || !groupSet.contains(manager.getGroup(name)))
|
if (!manager.isLoaded(name) || !manager.getLoadedGroups().contains(manager.getGroup(name)))
|
||||||
{
|
{
|
||||||
return manager.createAndLoadGroup(name);
|
return manager.createAndLoadGroup(name);
|
||||||
}
|
}
|
||||||
@ -27,22 +24,8 @@ public class GroupWrapper
|
|||||||
return CompletableFuture.supplyAsync(() -> manager.getGroup(name));
|
return CompletableFuture.supplyAsync(() -> manager.getGroup(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Void> removeGroup(String name)
|
public void saveGroup(String name)
|
||||||
{
|
{
|
||||||
return getGroup(name).thenAccept(a ->
|
getGroup(name).thenAccept(manager::saveGroup);
|
||||||
{
|
|
||||||
manager.deleteGroup(a);
|
|
||||||
groupSet.remove(a);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletableFuture<Void> addGroup(String name)
|
|
||||||
{
|
|
||||||
return getGroup(name).thenAccept(groupSet::add);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletableFuture<Void> saveGroup(String name)
|
|
||||||
{
|
|
||||||
return getGroup(name).thenAccept(manager::saveGroup);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@ public class TrackWrapper
|
|||||||
return CompletableFuture.supplyAsync(() -> manager.getTrack(name));
|
return CompletableFuture.supplyAsync(() -> manager.getTrack(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Void> saveTrack(String name)
|
public void saveTrack(String name)
|
||||||
{
|
{
|
||||||
return getTrack(name).thenAccept(manager::saveTrack);
|
getTrack(name).thenAccept(manager::saveTrack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,10 @@ package me.totalfreedom.totalfreedommod.perms;
|
|||||||
import net.luckperms.api.cacheddata.CachedMetaData;
|
import net.luckperms.api.cacheddata.CachedMetaData;
|
||||||
import net.luckperms.api.cacheddata.CachedPermissionData;
|
import net.luckperms.api.cacheddata.CachedPermissionData;
|
||||||
import net.luckperms.api.context.ImmutableContextSet;
|
import net.luckperms.api.context.ImmutableContextSet;
|
||||||
|
import net.luckperms.api.model.group.Group;
|
||||||
import net.luckperms.api.model.user.User;
|
import net.luckperms.api.model.user.User;
|
||||||
import net.luckperms.api.model.user.UserManager;
|
import net.luckperms.api.model.user.UserManager;
|
||||||
|
import net.luckperms.api.node.NodeType;
|
||||||
import net.luckperms.api.platform.PlayerAdapter;
|
import net.luckperms.api.platform.PlayerAdapter;
|
||||||
import net.luckperms.api.query.QueryOptions;
|
import net.luckperms.api.query.QueryOptions;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -88,8 +90,22 @@ public class UserWrapper
|
|||||||
}).thenAccept(userDataSet::add);
|
}).thenAccept(userDataSet::add);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Void> saveUser(User user)
|
public void addToGroup(User user, Group group) {
|
||||||
|
CompletableFuture.runAsync(() ->
|
||||||
|
manager.modifyUser(user.getUniqueId(), c ->
|
||||||
|
group.getNodes(NodeType.INHERITANCE).forEach(node ->
|
||||||
|
c.data().add(node))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFromGroup(User user, Group group) {
|
||||||
|
CompletableFuture.runAsync(() ->
|
||||||
|
manager.modifyUser(user.getUniqueId(), c ->
|
||||||
|
group.getNodes(NodeType.INHERITANCE).forEach(node ->
|
||||||
|
c.data().remove(node))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveUser(User user)
|
||||||
{
|
{
|
||||||
return CompletableFuture.runAsync(() -> manager.saveUser(user));
|
CompletableFuture.runAsync(() -> manager.saveUser(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,13 +202,7 @@ public class Hierarchy
|
|||||||
{
|
{
|
||||||
userWrapper.getUserData(player).thenAccept(user ->
|
userWrapper.getUserData(player).thenAccept(user ->
|
||||||
{
|
{
|
||||||
for (InheritanceNode node : group.getLuckPermsGroup().getNodes(NodeType.INHERITANCE))
|
userWrapper.addToGroup(user.getUser(), group.getLuckPermsGroup());
|
||||||
{
|
|
||||||
user.getUser().data().add(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
user.getUser().getInheritedGroups(user.getQueryOptions()).add(group.getLuckPermsGroup());
|
|
||||||
|
|
||||||
userWrapper.saveUser(user.getUser());
|
userWrapper.saveUser(user.getUser());
|
||||||
}).whenComplete((a, b) ->
|
}).whenComplete((a, b) ->
|
||||||
{
|
{
|
||||||
@ -235,10 +229,7 @@ public class Hierarchy
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (InheritanceNode node : g.getNodes(NodeType.INHERITANCE))
|
userWrapper.removeFromGroup(data.getUser(), g);
|
||||||
{
|
|
||||||
data.getUser().data().remove(node);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
userWrapper.saveUser(data.getUser());
|
userWrapper.saveUser(data.getUser());
|
||||||
|
Loading…
Reference in New Issue
Block a user