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
0a96012f
Commit
0a96012f
authored
Apr 21, 2022
by
KingRainbow44
Browse files
why is `Account#onLoad` THE DAMN REASON FOR HOURS OF TESTING
parent
b902fa6f
Changes
3
Hide whitespace changes
Inline
Side-by-side
build.gradle
View file @
0a96012f
...
...
@@ -14,8 +14,8 @@ plugins {
id
'application'
}
sourceCompatibility
=
1
7
targetCompatibility
=
1
7
sourceCompatibility
=
1
6
targetCompatibility
=
1
6
repositories
{
mavenCentral
()
...
...
src/main/java/emu/grasscutter/database/DatabaseManager.java
View file @
0a96012f
...
...
@@ -18,7 +18,6 @@ import emu.grasscutter.game.friends.Friendship;
import
emu.grasscutter.game.inventory.GenshinItem
;
public
final
class
DatabaseManager
{
private
static
MongoClient
mongoClient
;
private
static
Datastore
datastore
;
private
static
final
Class
<?>[]
mappedClasses
=
new
Class
<?>[]
{
...
...
@@ -35,7 +34,7 @@ public final class DatabaseManager {
public
static
void
initialize
()
{
// Initialize
mongoClient
=
MongoClients
.
create
(
Grasscutter
.
getConfig
().
DatabaseUrl
);
MongoClient
mongoClient
=
MongoClients
.
create
(
Grasscutter
.
getConfig
().
DatabaseUrl
);
// Set mapper options.
MapperOptions
mapperOptions
=
MapperOptions
.
builder
()
...
...
src/main/java/emu/grasscutter/game/Account.java
View file @
0a96012f
package
emu.grasscutter.game
;
import
dev.morphia.annotations.Collation
;
import
dev.morphia.annotations.Entity
;
import
dev.morphia.annotations.Id
;
import
dev.morphia.annotations.Indexed
;
import
dev.morphia.annotations.PreLoad
;
import
dev.morphia.annotations.*
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.utils.Crypto
;
import
emu.grasscutter.utils.Utils
;
import
dev.morphia.annotations.IndexOptions
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.mongodb.DBObject
;
@Entity
(
value
=
"accounts"
,
useDiscriminator
=
false
)
public
class
Account
{
@Id
private
String
id
;
...
...
@@ -30,7 +23,7 @@ public class Account {
private
String
token
;
private
String
sessionKey
;
// Session token for dispatch server
private
List
<
String
>
permissions
;
@Deprecated
public
Account
()
{
this
.
permissions
=
new
ArrayList
<>();
...
...
@@ -121,15 +114,16 @@ public class Account {
return
this
.
token
;
}
@PreLoad
public
void
onLoad
(
DBObject
dbObj
)
{
// Grant the superuser permissions to accounts created before the permissions update
if
(!
dbObj
.
containsField
(
"permissions"
))
{
this
.
addPermission
(
"*"
);
}
}
public
void
save
()
{
DatabaseHelper
.
saveAccount
(
this
);
}
// TODO: Find an implementation for this. Morphia 2.0 breaks this method for some reason?
// @PreLoad
// public void onLoad(DBObject object) {
// // Grant the superuser permissions to accounts created before the permissions update
// if (!object.containsField("permissions")) {
// this.addPermission("*");
// }
// }
}
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