mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 07:37:43 +00:00
Fix account deletion
This commit is contained in:
parent
dd10dcc09b
commit
5565a13df8
@ -99,10 +99,6 @@ public final class AccountCommand implements CommandHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure player isn't online as we delete their account.
|
|
||||||
kickAccount(toDelete);
|
|
||||||
|
|
||||||
// Finally, we do the actual deletion.
|
|
||||||
DatabaseHelper.deleteAccount(toDelete);
|
DatabaseHelper.deleteAccount(toDelete);
|
||||||
CommandHandler.sendMessage(sender, translate(sender, "commands.account.delete"));
|
CommandHandler.sendMessage(sender, translate(sender, "commands.account.delete"));
|
||||||
return;
|
return;
|
||||||
|
@ -123,32 +123,31 @@ public final class DatabaseHelper {
|
|||||||
|
|
||||||
Player player = Grasscutter.getGameServer().getPlayerByAccountId(target.getId());
|
Player player = Grasscutter.getGameServer().getPlayerByAccountId(target.getId());
|
||||||
|
|
||||||
|
// Close session first
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
// Close session first
|
|
||||||
player.getSession().close();
|
player.getSession().close();
|
||||||
|
|
||||||
// Delete data from collections
|
|
||||||
DatabaseManager.getGameDatabase().getCollection("activities").deleteMany(eq("uid",player.getUid()));
|
|
||||||
DatabaseManager.getGameDatabase().getCollection("homes").deleteMany(eq("ownerUid",player.getUid()));
|
|
||||||
DatabaseManager.getGameDatabase().getCollection("mail").deleteMany(eq("ownerUid", player.getUid()));
|
|
||||||
DatabaseManager.getGameDatabase().getCollection("avatars").deleteMany(eq("ownerId", player.getUid()));
|
|
||||||
DatabaseManager.getGameDatabase().getCollection("gachas").deleteMany(eq("ownerId", player.getUid()));
|
|
||||||
DatabaseManager.getGameDatabase().getCollection("items").deleteMany(eq("ownerId", player.getUid()));
|
|
||||||
DatabaseManager.getGameDatabase().getCollection("quests").deleteMany(eq("ownerUid", player.getUid()));
|
|
||||||
DatabaseManager.getGameDatabase().getCollection("battlepass").deleteMany(eq("ownerUid", player.getUid()));
|
|
||||||
|
|
||||||
// Delete friendships.
|
|
||||||
// Here, we need to make sure to not only delete the deleted account's friendships,
|
|
||||||
// but also all friendship entries for that account's friends.
|
|
||||||
DatabaseManager.getGameDatabase().getCollection("friendships").deleteMany(eq("ownerId", player.getUid()));
|
|
||||||
DatabaseManager.getGameDatabase().getCollection("friendships").deleteMany(eq("friendId", player.getUid()));
|
|
||||||
|
|
||||||
// Delete the player last.
|
|
||||||
DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("id", player.getUid())).delete();
|
|
||||||
}
|
}
|
||||||
|
// Delete data from collections
|
||||||
|
DatabaseManager.getGameDatabase().getCollection("activities").deleteMany(eq("uid",player.getUid()));
|
||||||
|
DatabaseManager.getGameDatabase().getCollection("homes").deleteMany(eq("ownerUid",player.getUid()));
|
||||||
|
DatabaseManager.getGameDatabase().getCollection("mail").deleteMany(eq("ownerUid", player.getUid()));
|
||||||
|
DatabaseManager.getGameDatabase().getCollection("avatars").deleteMany(eq("ownerId", player.getUid()));
|
||||||
|
DatabaseManager.getGameDatabase().getCollection("gachas").deleteMany(eq("ownerId", player.getUid()));
|
||||||
|
DatabaseManager.getGameDatabase().getCollection("items").deleteMany(eq("ownerId", player.getUid()));
|
||||||
|
DatabaseManager.getGameDatabase().getCollection("quests").deleteMany(eq("ownerUid", player.getUid()));
|
||||||
|
DatabaseManager.getGameDatabase().getCollection("battlepass").deleteMany(eq("ownerUid", player.getUid()));
|
||||||
|
|
||||||
// Finally, delete the account itself.
|
// Delete friendships.
|
||||||
DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("id", target.getId())).delete();
|
// Here, we need to make sure to not only delete the deleted account's friendships,
|
||||||
|
// but also all friendship entries for that account's friends.
|
||||||
|
DatabaseManager.getGameDatabase().getCollection("friendships").deleteMany(eq("ownerId", player.getUid()));
|
||||||
|
DatabaseManager.getGameDatabase().getCollection("friendships").deleteMany(eq("friendId", player.getUid()));
|
||||||
|
|
||||||
|
// Delete the player last.
|
||||||
|
DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("id", player.getUid())).delete();
|
||||||
|
|
||||||
|
// Finally, delete the account itself.
|
||||||
|
DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("id", target.getId())).delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Player> getAllPlayers() {
|
public static List<Player> getAllPlayers() {
|
||||||
|
Loading…
Reference in New Issue
Block a user