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
6e14676a
Commit
6e14676a
authored
Apr 20, 2022
by
Melledy
Committed by
GitHub
Apr 20, 2022
Browse files
Merge pull request #54 from Grasscutters/auto-account
Fix permission issues when new users create an account
parents
af88b4cf
1ed04d32
Changes
4
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/Config.java
View file @
6e14676a
...
@@ -53,5 +53,6 @@ public final class Config {
...
@@ -53,5 +53,6 @@ public final class Config {
public
int
MaxEntityLimit
=
1000
;
// Max entity limit per world. // TODO: Enforce later.
public
int
MaxEntityLimit
=
1000
;
// Max entity limit per world. // TODO: Enforce later.
public
int
[]
WelcomeEmotes
=
{
2007
,
1002
,
4010
};
public
int
[]
WelcomeEmotes
=
{
2007
,
1002
,
4010
};
public
String
WelcomeMotd
=
"Welcome to Grasscutter emu"
;
public
String
WelcomeMotd
=
"Welcome to Grasscutter emu"
;
public
boolean
AutomaticallyCreateAccounts
=
false
;
}
}
}
}
src/main/java/emu/grasscutter/commands/CommandMap.java
View file @
6e14676a
...
@@ -91,7 +91,7 @@ public final class CommandMap {
...
@@ -91,7 +91,7 @@ public final class CommandMap {
public
void
invoke
(
GenshinPlayer
player
,
String
rawMessage
)
{
public
void
invoke
(
GenshinPlayer
player
,
String
rawMessage
)
{
rawMessage
=
rawMessage
.
trim
();
rawMessage
=
rawMessage
.
trim
();
if
(
rawMessage
.
length
()
==
0
)
{
if
(
rawMessage
.
length
()
==
0
)
{
CommandHandler
.
sendMessage
(
player
,
"No command specified."
);
CommandHandler
.
sendMessage
(
player
,
"No command specified."
);
return
;
}
}
// Remove prefix if present.
// Remove prefix if present.
...
@@ -113,7 +113,7 @@ public final class CommandMap {
...
@@ -113,7 +113,7 @@ public final class CommandMap {
if
(
player
!=
null
)
{
if
(
player
!=
null
)
{
String
permissionNode
=
this
.
annotations
.
get
(
label
).
permission
();
String
permissionNode
=
this
.
annotations
.
get
(
label
).
permission
();
Account
account
=
player
.
getAccount
();
Account
account
=
player
.
getAccount
();
if
(
permissionNode
!=
""
&&
!
account
.
hasPermission
(
permissionNode
))
{
if
(
!
permissionNode
.
isEmpty
()
&&
!
account
.
hasPermission
(
permissionNode
))
{
CommandHandler
.
sendMessage
(
player
,
"You do not have permission to run this command."
);
return
;
CommandHandler
.
sendMessage
(
player
,
"You do not have permission to run this command."
);
return
;
}
}
}
}
...
...
src/main/java/emu/grasscutter/commands/ServerCommands.java
View file @
6e14676a
...
@@ -188,6 +188,7 @@ public final class ServerCommands {
...
@@ -188,6 +188,7 @@ public final class ServerCommands {
}
else
{
}
else
{
CommandHandler
.
sendMessage
(
null
,
"Account created with UID "
+
account
.
getPlayerId
()
+
"."
);
CommandHandler
.
sendMessage
(
null
,
"Account created with UID "
+
account
.
getPlayerId
()
+
"."
);
account
.
addPermission
(
"*"
);
// Grant the player superuser permissions.
account
.
addPermission
(
"*"
);
// Grant the player superuser permissions.
account
.
save
();
// Save account to database.
}
}
return
;
return
;
case
"delete"
:
case
"delete"
:
...
...
src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java
View file @
6e14676a
...
@@ -225,11 +225,23 @@ public final class DispatchServer {
...
@@ -225,11 +225,23 @@ public final class DispatchServer {
// Login
// Login
Account
account
=
DatabaseHelper
.
getAccountByName
(
requestData
.
account
);
Account
account
=
DatabaseHelper
.
getAccountByName
(
requestData
.
account
);
//
Test
//
Check if account exists, else create a new one.
if
(
account
==
null
)
{
if
(
account
==
null
)
{
// Account doesnt exist, so we can either auto create it if the config value is set
if
(
Grasscutter
.
getConfig
().
ServerOptions
.
AutomaticallyCreateAccounts
)
{
// This account has been created AUTOMATICALLY. There will be no permissions added.
account
=
DatabaseHelper
.
createAccountWithId
(
requestData
.
account
,
0
);
responseData
.
message
=
"OK"
;
responseData
.
data
.
account
.
uid
=
account
.
getId
();
responseData
.
data
.
account
.
token
=
account
.
generateSessionKey
();
responseData
.
data
.
account
.
email
=
account
.
getEmail
();
}
else
{
responseData
.
retcode
=
-
201
;
responseData
.
retcode
=
-
201
;
responseData
.
message
=
"Username not found."
;
responseData
.
message
=
"Username not found."
;
}
}
else
{
}
else
{
// Account was found, log the player in
responseData
.
message
=
"OK"
;
responseData
.
message
=
"OK"
;
responseData
.
data
.
account
.
uid
=
account
.
getId
();
responseData
.
data
.
account
.
uid
=
account
.
getId
();
responseData
.
data
.
account
.
token
=
account
.
generateSessionKey
();
responseData
.
data
.
account
.
token
=
account
.
generateSessionKey
();
...
...
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