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