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
c65443f4
Commit
c65443f4
authored
Apr 18, 2022
by
Melledy
Browse files
Fix permissions not saving
parent
057f568a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/commands/ServerCommands.java
View file @
c65443f4
...
...
@@ -138,7 +138,7 @@ public final class ServerCommands {
String
username
=
args
.
get
(
1
);
String
permission
=
args
.
get
(
2
);
Account
account
=
DatabaseHelper
.
getAccountByName
(
username
);
Account
account
=
Grasscutter
.
getGameServer
()
.
getAccountByName
(
username
);
if
(
account
==
null
)
{
CommandHandler
.
sendMessage
(
null
,
"Account not found."
);
return
;
}
...
...
@@ -146,18 +146,20 @@ public final class ServerCommands {
switch
(
action
)
{
default
:
CommandHandler
.
sendMessage
(
null
,
"Usage: permission <add|remove> <username> <permission>"
);
re
turn
;
b
re
ak
;
case
"add"
:
if
(
account
.
addPermission
(
permission
))
{
CommandHandler
.
sendMessage
(
null
,
"Permission added."
);
return
;
CommandHandler
.
sendMessage
(
null
,
"Permission added."
);
}
else
CommandHandler
.
sendMessage
(
null
,
"They already have this permission!"
);
re
turn
;
b
re
ak
;
case
"remove"
:
if
(
account
.
removePermission
(
permission
))
{
CommandHandler
.
sendMessage
(
null
,
"Permission removed."
);
return
;
CommandHandler
.
sendMessage
(
null
,
"Permission removed."
);
}
else
CommandHandler
.
sendMessage
(
null
,
"They don't have this permission!"
);
re
turn
;
b
re
ak
;
}
account
.
save
();
}
}
...
...
src/main/java/emu/grasscutter/game/Account.java
View file @
c65443f4
...
...
@@ -9,6 +9,7 @@ import emu.grasscutter.utils.Crypto;
import
emu.grasscutter.utils.Utils
;
import
dev.morphia.annotations.IndexOptions
;
import
java.util.ArrayList
;
import
java.util.List
;
@Entity
(
value
=
"accounts"
,
noClassnameStored
=
true
)
...
...
@@ -28,7 +29,9 @@ public class Account {
private
List
<
String
>
permissions
;
@Deprecated
public
Account
()
{}
public
Account
()
{
this
.
permissions
=
new
ArrayList
<>();
}
public
String
getId
()
{
return
id
;
...
...
src/main/java/emu/grasscutter/server/game/GameServer.java
View file @
c65443f4
...
...
@@ -8,6 +8,7 @@ import emu.grasscutter.GenshinConstants;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.commands.CommandMap
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.Account
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.dungeons.DungeonManager
;
import
emu.grasscutter.game.gacha.GachaManager
;
...
...
@@ -138,6 +139,14 @@ public final class GameServer extends MihoyoKcpServer {
return
player
.
getSocialDetail
();
}
public
Account
getAccountByName
(
String
username
)
{
Optional
<
GenshinPlayer
>
playerOpt
=
getPlayers
().
values
().
stream
().
filter
(
player
->
player
.
getAccount
().
getUsername
().
equals
(
username
)).
findFirst
();
if
(
playerOpt
.
get
()
!=
null
)
{
return
playerOpt
.
get
().
getAccount
();
}
return
DatabaseHelper
.
getAccountByName
(
username
);
}
public
void
onTick
()
throws
Exception
{
for
(
GenshinPlayer
player
:
this
.
getPlayers
().
values
())
{
player
.
onTick
();
...
...
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