mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-07 03:19:47 +01:00
Fix not clearing user's permissions, and issue with unsetting permissions
This commit is contained in:
parent
f5995c0afa
commit
d5bc1cdf5d
@ -423,7 +423,7 @@ public abstract class PermissionHolder {
|
||||
* @throws ObjectLacksException if the holder doesn't have this node already
|
||||
*/
|
||||
public void unsetPermission(Node node) throws ObjectLacksException {
|
||||
if (hasPermission(node, false) == Tristate.FALSE) {
|
||||
if (hasPermission(node, false) != Tristate.TRUE) {
|
||||
throw new ObjectLacksException();
|
||||
}
|
||||
|
||||
|
@ -228,6 +228,13 @@ public class FlatfileDatastore extends Datastore {
|
||||
@Override
|
||||
public boolean saveUser(User user) {
|
||||
File userFile = new File(usersDir, user.getUuid().toString() + ".json");
|
||||
if (!plugin.getUserManager().shouldSave(user)) {
|
||||
if (userFile.exists()) {
|
||||
userFile.delete();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!userFile.exists()) {
|
||||
try {
|
||||
userFile.createNewFile();
|
||||
|
@ -169,7 +169,11 @@ public class MongoDBDatastore extends Datastore {
|
||||
@Override
|
||||
public boolean saveUser(User user) {
|
||||
if (!plugin.getUserManager().shouldSave(user)) {
|
||||
return true;
|
||||
boolean success = call(() -> {
|
||||
MongoCollection<Document> c = database.getCollection("users");
|
||||
return c.deleteOne(new Document("_id", user.getUuid())).wasAcknowledged();
|
||||
}, false);
|
||||
return success;
|
||||
}
|
||||
|
||||
boolean success = call(() -> {
|
||||
|
@ -55,7 +55,8 @@ abstract class SQLDatastore extends Datastore {
|
||||
private static final String USER_SELECT = "SELECT * FROM lp_users WHERE uuid=?";
|
||||
private static final String USER_SELECT_ALL = "SELECT uuid FROM lp_users";
|
||||
private static final String USER_UPDATE = "UPDATE lp_users SET name=?, primary_group = ?, perms=? WHERE uuid=?";
|
||||
private static final String USER_DELETE = "DELETE FROM lp_users WHERE perms=?";
|
||||
private static final String USER_DELETE = "DELETE FROM lp_users WHERE uuid=?";
|
||||
private static final String USER_DELETE_ALL = "DELETE FROM lp_users WHERE perms=?";
|
||||
|
||||
private static final String GROUP_INSERT = "INSERT INTO lp_groups VALUES(?, ?)";
|
||||
private static final String GROUP_SELECT = "SELECT perms FROM lp_groups WHERE name=?";
|
||||
@ -189,7 +190,13 @@ abstract class SQLDatastore extends Datastore {
|
||||
@Override
|
||||
public boolean saveUser(User user) {
|
||||
if (!plugin.getUserManager().shouldSave(user)) {
|
||||
return true;
|
||||
boolean success = runQuery(new QueryPS(USER_DELETE) {
|
||||
@Override
|
||||
void onRun(PreparedStatement preparedStatement) throws SQLException {
|
||||
preparedStatement.setString(1, user.getUuid().toString());
|
||||
}
|
||||
});
|
||||
return success;
|
||||
}
|
||||
|
||||
boolean success = runQuery(new QueryRS(USER_SELECT) {
|
||||
@ -234,7 +241,7 @@ abstract class SQLDatastore extends Datastore {
|
||||
|
||||
@Override
|
||||
public boolean cleanupUsers() {
|
||||
boolean success = runQuery(new QueryPS(USER_DELETE) {
|
||||
boolean success = runQuery(new QueryPS(USER_DELETE_ALL) {
|
||||
@Override
|
||||
void onRun(PreparedStatement preparedStatement) throws SQLException {
|
||||
preparedStatement.setString(1, "{\"group.default\":true}");
|
||||
|
@ -61,11 +61,13 @@ public abstract class UserManager extends AbstractManager<UUID, User> {
|
||||
|
||||
@Override
|
||||
public void copy(User from, User to) {
|
||||
if (from.getPrimaryGroup() != null) {
|
||||
// This isn't just a black user. we shouldn't override in that case.
|
||||
to.setNodes(from.getNodes());
|
||||
to.setPrimaryGroup(from.getPrimaryGroup());
|
||||
giveDefaultIfNeeded(to, true);
|
||||
to.refreshPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a user to the default group
|
||||
|
Loading…
Reference in New Issue
Block a user