Remove cleanupUsers functionality
It was pretty useless (and wasn't implemented on SQL/Mongo storage types.) Data is naturally cleaned up over time as users are loaded/saved.
This commit is contained in:
parent
7b271e21e3
commit
5732e60510
@ -138,9 +138,13 @@ public interface Storage {
|
||||
* Removes users from the main storage who are "default". This is called every time the plugin loads.
|
||||
*
|
||||
* @return true if the operation completed successfully
|
||||
* @deprecated this method no longer does anything - the cleanup feature was removed. :)
|
||||
*/
|
||||
@Nonnull
|
||||
CompletableFuture<Boolean> cleanupUsers();
|
||||
@Deprecated
|
||||
default CompletableFuture<Boolean> cleanupUsers() {
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a set all "unique" user UUIDs.
|
||||
|
@ -97,11 +97,6 @@ public class StorageDelegate implements Storage {
|
||||
return handle.noBuffer().saveUser(UserDelegate.cast(user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> cleanupUsers() {
|
||||
return handle.noBuffer().cleanupUsers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Set<UUID>> getUniqueUsers() {
|
||||
return handle.noBuffer().getUniqueUsers();
|
||||
|
@ -120,11 +120,6 @@ public class AbstractStorage implements Storage {
|
||||
return makeFuture(() -> backing.saveUser(user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> cleanupUsers() {
|
||||
return makeFuture(backing::cleanupUsers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Set<UUID>> getUniqueUsers() {
|
||||
return makeFuture(backing::getUniqueUsers);
|
||||
|
@ -115,11 +115,6 @@ public class SplitBacking extends AbstractBacking {
|
||||
return backing.get(types.get("user")).saveUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cleanupUsers() {
|
||||
return backing.get(types.get("user")).cleanupUsers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> getUniqueUsers() {
|
||||
return backing.get(types.get("user")).getUniqueUsers();
|
||||
|
@ -73,8 +73,6 @@ public interface Storage {
|
||||
|
||||
CompletableFuture<Boolean> saveUser(User user);
|
||||
|
||||
CompletableFuture<Boolean> cleanupUsers();
|
||||
|
||||
CompletableFuture<Set<UUID>> getUniqueUsers();
|
||||
|
||||
CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(String permission);
|
||||
|
@ -76,8 +76,6 @@ public abstract class AbstractBacking {
|
||||
|
||||
public abstract boolean saveUser(User user);
|
||||
|
||||
public abstract boolean cleanupUsers();
|
||||
|
||||
public abstract Set<UUID> getUniqueUsers();
|
||||
|
||||
public abstract List<HeldPermission<UUID>> getUsersWithPermission(String permission);
|
||||
|
@ -109,9 +109,6 @@ public abstract class FlatfileBacking extends AbstractBacking {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// schedule user cleanup
|
||||
plugin.getScheduler().asyncLater(this::cleanupUsers, 10L);
|
||||
|
||||
setAcceptingLogins(true);
|
||||
}
|
||||
|
||||
|
@ -232,39 +232,6 @@ public class JSONBacking extends FlatfileBacking {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cleanupUsers() {
|
||||
return call("null", () -> {
|
||||
File[] files = usersDir.listFiles((dir, name1) -> name1.endsWith(".json"));
|
||||
if (files == null) return false;
|
||||
|
||||
for (File file : files) {
|
||||
call(file.getName(), () -> {
|
||||
registerFileAction("users", file);
|
||||
|
||||
JsonObject object = readObjectFromFile(file);
|
||||
|
||||
Set<NodeModel> nodes = new HashSet<>();
|
||||
nodes.addAll(deserializePermissions(object.get("permissions").getAsJsonArray()));
|
||||
|
||||
boolean shouldDelete = false;
|
||||
if (nodes.size() == 1) {
|
||||
for (NodeModel e : nodes) {
|
||||
// There's only one
|
||||
shouldDelete = e.getPermission().equalsIgnoreCase("group.default") && e.isValue();
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldDelete) {
|
||||
file.delete();
|
||||
}
|
||||
return true;
|
||||
}, true);
|
||||
}
|
||||
return true;
|
||||
}, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HeldPermission<UUID>> getUsersWithPermission(String permission) {
|
||||
ImmutableList.Builder<HeldPermission<UUID>> held = ImmutableList.builder();
|
||||
|
@ -234,39 +234,6 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cleanupUsers() {
|
||||
return call("null", () -> {
|
||||
File[] files = usersDir.listFiles((dir, name1) -> name1.endsWith(".yml"));
|
||||
if (files == null) return false;
|
||||
|
||||
for (File file : files) {
|
||||
call(file.getName(), () -> {
|
||||
registerFileAction("users", file);
|
||||
|
||||
Map<String, Object> values = readMapFromFile(file);
|
||||
|
||||
Set<NodeModel> nodes = new HashSet<>();
|
||||
nodes.addAll(deserializePermissions((List<Object>) values.get("permissions")));
|
||||
|
||||
boolean shouldDelete = false;
|
||||
if (nodes.size() == 1) {
|
||||
for (NodeModel e : nodes) {
|
||||
// There's only one
|
||||
shouldDelete = e.getPermission().equalsIgnoreCase("group.default") && e.isValue();
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldDelete) {
|
||||
file.delete();
|
||||
}
|
||||
return true;
|
||||
}, true);
|
||||
}
|
||||
return true;
|
||||
}, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HeldPermission<UUID>> getUsersWithPermission(String permission) {
|
||||
ImmutableList.Builder<HeldPermission<UUID>> held = ImmutableList.builder();
|
||||
|
@ -364,11 +364,6 @@ public class MongoDBBacking extends AbstractBacking {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cleanupUsers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> getUniqueUsers() {
|
||||
Set<UUID> uuids = new HashSet<>();
|
||||
|
@ -494,11 +494,6 @@ public class SQLBacking extends AbstractBacking {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cleanupUsers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> getUniqueUsers() {
|
||||
Set<UUID> uuids = new HashSet<>();
|
||||
|
@ -131,16 +131,6 @@ public class PhasedStorage implements Storage {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> cleanupUsers() {
|
||||
phaser.register();
|
||||
try {
|
||||
return backing.cleanupUsers();
|
||||
} finally {
|
||||
phaser.arriveAndDeregister();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Set<UUID>> getUniqueUsers() {
|
||||
phaser.register();
|
||||
|
Loading…
Reference in New Issue
Block a user