Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
5565a13d
Commit
5565a13d
authored
Aug 25, 2022
by
AnimeGitB
Browse files
Fix account deletion
parent
dd10dcc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/AccountCommand.java
View file @
5565a13d
...
...
@@ -99,10 +99,6 @@ public final class AccountCommand implements CommandHandler {
return
;
}
// Make sure player isn't online as we delete their account.
kickAccount
(
toDelete
);
// Finally, we do the actual deletion.
DatabaseHelper
.
deleteAccount
(
toDelete
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
sender
,
"commands.account.delete"
));
return
;
...
...
src/main/java/emu/grasscutter/database/DatabaseHelper.java
View file @
5565a13d
...
...
@@ -123,32 +123,31 @@ public final class DatabaseHelper {
Player
player
=
Grasscutter
.
getGameServer
().
getPlayerByAccountId
(
target
.
getId
());
// Close session first
if
(
player
!=
null
)
{
// Close session first
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
();
}
// Finally, delete the account itself.
DatabaseManager
.
getAccountDatastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"id"
,
target
.
getId
())).
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
()));
// 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
();
// Finally, delete the account itself.
DatabaseManager
.
getAccountDatastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"id"
,
target
.
getId
())).
delete
();
}
public
static
List
<
Player
>
getAllPlayers
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment