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
b8f52999
Commit
b8f52999
authored
May 04, 2022
by
方块君
Committed by
Melledy
May 03, 2022
Browse files
Optimize multilingualism (using variables)
Optimize multilingualism (using variables)
parent
8733812e
Changes
28
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/TalentCommand.java
View file @
b8f52999
...
...
@@ -66,7 +66,7 @@ public final class TalentCommand implements CommandHandler {
// Packet
sender
.
sendPacket
(
new
PacketAvatarSkillChangeNotify
(
avatar
,
skillIdNorAtk
,
currentLevelNorAtk
,
nextLevel
));
sender
.
sendPacket
(
new
PacketAvatarSkillUpgradeRsp
(
avatar
,
skillIdNorAtk
,
currentLevelNorAtk
,
nextLevel
));
CommandHandler
.
sendMessage
(
sender
,
String
.
format
(
Grasscutter
.
getLanguage
().
Talent_set_atk
,
nextLevel
));
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Talent_set_atk
.
replace
(
"{level}"
,
Integer
.
toString
(
nextLevel
))
)
;
}
if
(
skillId
==
skillIdE
){
// Upgrade skill
...
...
@@ -76,7 +76,7 @@ public final class TalentCommand implements CommandHandler {
// Packet
sender
.
sendPacket
(
new
PacketAvatarSkillChangeNotify
(
avatar
,
skillIdE
,
currentLevelE
,
nextLevel
));
sender
.
sendPacket
(
new
PacketAvatarSkillUpgradeRsp
(
avatar
,
skillIdE
,
currentLevelE
,
nextLevel
));
CommandHandler
.
sendMessage
(
sender
,
String
.
format
(
Grasscutter
.
getLanguage
().
Talent_set_e
,
nextLevel
));
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Talent_set_e
.
replace
(
"{level}"
,
Integer
.
toString
(
nextLevel
))
)
;
}
if
(
skillId
==
skillIdQ
){
// Upgrade skill
...
...
@@ -86,7 +86,7 @@ public final class TalentCommand implements CommandHandler {
// Packet
sender
.
sendPacket
(
new
PacketAvatarSkillChangeNotify
(
avatar
,
skillIdQ
,
currentLevelQ
,
nextLevel
));
sender
.
sendPacket
(
new
PacketAvatarSkillUpgradeRsp
(
avatar
,
skillIdQ
,
currentLevelQ
,
nextLevel
));
CommandHandler
.
sendMessage
(
sender
,
String
.
format
(
Grasscutter
.
getLanguage
().
Talent_set_q
,
nextLevel
));
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Talent_set_q
.
replace
(
"{level}"
,
Integer
.
toString
(
nextLevel
))
)
;
}
}
catch
(
NumberFormatException
ignored
)
{
...
...
@@ -128,7 +128,7 @@ public final class TalentCommand implements CommandHandler {
// Packet
sender
.
sendPacket
(
new
PacketAvatarSkillChangeNotify
(
avatar
,
skillId
,
currentLevel
,
nextLevel
));
sender
.
sendPacket
(
new
PacketAvatarSkillUpgradeRsp
(
avatar
,
skillId
,
currentLevel
,
nextLevel
));
CommandHandler
.
sendMessage
(
sender
,
String
.
format
(
Grasscutter
.
getLanguage
().
Talent_set_this
,
nextLevel
));
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Talent_set_this
.
replace
(
"{level}"
,
Integer
.
toString
(
nextLevel
))
)
;
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Talent_invalid_talent_level
);
return
;
...
...
@@ -140,10 +140,10 @@ public final class TalentCommand implements CommandHandler {
int
skillIdNorAtk
=
avatar
.
getData
().
getSkillDepot
().
getSkills
().
get
(
0
);
int
skillIdE
=
avatar
.
getData
().
getSkillDepot
().
getSkills
().
get
(
1
);
int
skillIdQ
=
avatar
.
getData
().
getSkillDepot
().
getEnergySkill
();
CommandHandler
.
sendMessage
(
sender
,
String
.
format
(
Grasscutter
.
getLanguage
().
Talent_normal_attack_id
,
skillIdNorAtk
));
CommandHandler
.
sendMessage
(
sender
,
String
.
format
(
Grasscutter
.
getLanguage
().
Talent_e_skill_id
,
skillIdE
));
CommandHandler
.
sendMessage
(
sender
,
String
.
format
(
Grasscutter
.
getLanguage
().
Talent_q_skill_id
,
skillIdQ
));
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Talent_normal_attack_id
.
replace
(
"{id}"
,
Integer
.
toString
(
skillIdNorAtk
))
)
;
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Talent_e_skill_id
.
replace
(
"{id}"
,
Integer
.
toString
(
skillIdE
))
)
;
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Talent_q_skill_id
.
replace
(
"{id}"
,
Integer
.
toString
(
skillIdQ
))
)
;
break
;
}
}
...
...
src/main/java/emu/grasscutter/command/commands/TeleportCommand.java
View file @
b8f52999
...
...
@@ -82,7 +82,7 @@ public final class TeleportCommand implements CommandHandler {
if
(!
result
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Teleport_invalid_position
);
}
else
{
CommandHandler
.
sendMessage
(
sender
,
String
.
format
(
Grasscutter
.
getLanguage
().
Teleport_message
,
targetPlayer
.
getNickname
()
,
x
,
y
,
z
,
sceneId
));
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Teleport_message
.
replace
(
"{name}"
,
targetPlayer
.
getNickname
()
).
replace
(
"{x}"
,
Float
.
toString
(
x
)).
replace
(
"{y}"
,
Float
.
toString
(
y
)).
replace
(
"{z}"
,
Float
.
toString
(
z
)).
replace
(
"{id}"
,
Integer
.
toString
(
sceneId
))
)
;
}
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Teleport_invalid_position
);
...
...
src/main/java/emu/grasscutter/command/commands/WeatherCommand.java
View file @
b8f52999
...
...
@@ -34,7 +34,7 @@ public final class WeatherCommand implements CommandHandler {
sender
.
getScene
().
setWeather
(
weatherId
);
sender
.
getScene
().
setClimate
(
climate
);
sender
.
getScene
().
broadcastPacket
(
new
PacketSceneAreaWeatherNotify
(
sender
));
CommandHandler
.
sendMessage
(
sender
,
String
.
format
(
Grasscutter
.
getLanguage
().
Weather_message
,
weatherId
,
climateId
));
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Weather_message
.
replace
(
"{weatherId}"
,
Integer
.
toString
(
weatherId
)).
replace
(
"{climateId}"
,
Integer
.
toString
(
climateId
))
)
;
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
Grasscutter
.
getLanguage
().
Weather_invalid_id
);
}
...
...
src/main/java/emu/grasscutter/server/dispatch/DispatchHttpJsonHandler.java
View file @
b8f52999
...
...
@@ -32,7 +32,7 @@ public final class DispatchHttpJsonHandler implements HttpContextHandler {
public
void
handle
(
Request
req
,
Response
res
)
throws
IOException
{
// Checking for ALL here isn't required as when ALL is enabled enableDevLogging() gets enabled
if
(
Grasscutter
.
getConfig
().
DebugMode
==
ServerDebugMode
.
MISSING
&&
Arrays
.
stream
(
missingRoutes
).
anyMatch
(
x
->
x
==
req
.
baseUrl
()))
{
Grasscutter
.
getLogger
().
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Client_request
,
req
.
ip
(),
req
.
method
()
,
req
.
baseUrl
())
+
(
Grasscutter
.
getConfig
().
DebugMode
==
ServerDebugMode
.
MISSING
?
"(MISSING)"
:
""
));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Client_request
.
replace
(
"{ip}"
,
req
.
ip
()).
replace
(
"{method}"
,
req
.
method
()).
replace
(
"{url}"
,
req
.
baseUrl
())
+
(
Grasscutter
.
getConfig
().
DebugMode
==
ServerDebugMode
.
MISSING
?
"(MISSING)"
:
""
));
}
res
.
send
(
response
);
}
...
...
src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java
View file @
b8f52999
...
...
@@ -249,7 +249,7 @@ public final class DispatchServer {
httpServer
.
raw
().
error
(
404
,
ctx
->
{
if
(
Grasscutter
.
getConfig
().
DebugMode
==
ServerDebugMode
.
MISSING
)
{
Grasscutter
.
getLogger
().
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Potential_unhandled_request
,
ctx
.
method
()
,
ctx
.
url
()));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Potential_unhandled_request
.
replace
(
"{method}"
,
ctx
.
method
()).
replace
(
"{url}"
,
ctx
.
url
()));
}
ctx
.
contentType
(
"text/html"
);
ctx
.
result
(
"<!doctype html><html lang=\"en\"><body><img src=\"https://http.cat/404\" /></body></html>"
);
// I'm like 70% sure this won't break anything.
...
...
@@ -307,7 +307,7 @@ public final class DispatchServer {
if
(
requestData
==
null
)
{
return
;
}
Grasscutter
.
getLogger
().
info
(
String
.
format
(
"[Dispatch] Client %s is trying to
log
in"
,
req
.
ip
()));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Client_try_
login
.
replace
(
"{ip}
"
,
req
.
ip
()));
res
.
send
(
this
.
getAuthHandler
().
handleGameLogin
(
req
,
requestData
));
});
...
...
@@ -327,7 +327,7 @@ public final class DispatchServer {
return
;
}
LoginResultJson
responseData
=
new
LoginResultJson
();
Grasscutter
.
getLogger
().
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Client_login_token
,
req
.
ip
()));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Client_login_token
.
replace
(
"{ip}"
,
req
.
ip
()));
// Login
Account
account
=
DatabaseHelper
.
getAccountById
(
requestData
.
uid
);
...
...
@@ -337,16 +337,14 @@ public final class DispatchServer {
responseData
.
retcode
=
-
111
;
responseData
.
message
=
Grasscutter
.
getLanguage
().
Game_account_cache_error
;
Grasscutter
.
getLogger
()
.
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Client_token_login_failed
,
req
.
ip
()));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Client_token_login_failed
.
replace
(
"{ip}"
,
req
.
ip
()));
}
else
{
responseData
.
message
=
"OK"
;
responseData
.
data
.
account
.
uid
=
requestData
.
uid
;
responseData
.
data
.
account
.
token
=
requestData
.
token
;
responseData
.
data
.
account
.
email
=
account
.
getEmail
();
Grasscutter
.
getLogger
().
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Client_login_in_token
,
req
.
ip
(),
responseData
.
data
.
account
.
uid
));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Client_login_in_token
.
replace
(
"{ip}"
,
req
.
ip
()).
replace
(
"{uid}"
,
responseData
.
data
.
account
.
uid
));
}
res
.
send
(
responseData
);
...
...
@@ -378,16 +376,14 @@ public final class DispatchServer {
responseData
.
retcode
=
-
201
;
responseData
.
message
=
Grasscutter
.
getLanguage
().
Wrong_session_key
;
Grasscutter
.
getLogger
().
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Client_failed_exchange_combo_token
,
req
.
ip
()));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Client_failed_exchange_combo_token
.
replace
(
"{ip}"
,
req
.
ip
()));
}
else
{
responseData
.
message
=
"OK"
;
responseData
.
data
.
open_id
=
loginData
.
uid
;
responseData
.
data
.
combo_id
=
"157795300"
;
responseData
.
data
.
combo_token
=
account
.
generateLoginToken
();
Grasscutter
.
getLogger
().
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Client_exchange_combo_token
,
req
.
ip
()));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Client_exchange_combo_token
.
replace
(
"{ip}"
,
req
.
ip
()));
}
res
.
send
(
responseData
);
...
...
@@ -453,7 +449,7 @@ public final class DispatchServer {
httpServer
.
get
(
"/gcstatic/*"
,
new
StaticFileHandler
());
httpServer
.
listen
(
Grasscutter
.
getConfig
().
getDispatchOptions
().
Port
);
Grasscutter
.
getLogger
().
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Dispatch_start_server_port
,
httpServer
.
raw
().
port
()));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Dispatch_start_server_port
.
replace
(
"{port}"
,
Integer
.
toString
(
httpServer
.
raw
().
port
()))
)
;
}
private
Map
<
String
,
String
>
parseQueryString
(
String
qs
)
{
...
...
src/main/java/emu/grasscutter/server/dispatch/authentication/DefaultAuthenticationHandler.java
View file @
b8f52999
...
...
@@ -51,15 +51,12 @@ public class DefaultAuthenticationHandler implements AuthenticationHandler {
responseData
.
data
.
account
.
token
=
account
.
generateSessionKey
();
responseData
.
data
.
account
.
email
=
account
.
getEmail
();
Grasscutter
.
getLogger
()
.
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Client_failed_login_account_create
,
req
.
ip
(),
responseData
.
data
.
account
.
uid
));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Client_failed_login_account_create
.
replace
(
"{ip}"
,
req
.
ip
()).
replace
(
"{uid}"
,
responseData
.
data
.
account
.
uid
));
}
else
{
responseData
.
retcode
=
-
201
;
responseData
.
message
=
Grasscutter
.
getLanguage
().
Username_not_found_create_failed
;
Grasscutter
.
getLogger
().
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Client_failed_login_account_create_failed
,
req
.
ip
()));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Client_failed_login_account_no_found
.
replace
(
"{ip}"
,
req
.
ip
()));
}
}
else
{
responseData
.
retcode
=
-
201
;
...
...
@@ -75,8 +72,7 @@ public class DefaultAuthenticationHandler implements AuthenticationHandler {
responseData
.
data
.
account
.
token
=
account
.
generateSessionKey
();
responseData
.
data
.
account
.
email
=
account
.
getEmail
();
Grasscutter
.
getLogger
().
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Client_login
,
req
.
ip
(),
responseData
.
data
.
account
.
uid
));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Client_login
.
replace
(
"{ip}"
,
req
.
ip
()).
replace
(
"{uid}"
,
responseData
.
data
.
account
.
uid
));
}
return
responseData
;
...
...
src/main/java/emu/grasscutter/server/game/GameServer.java
View file @
b8f52999
...
...
@@ -208,7 +208,7 @@ public final class GameServer extends KcpServer {
@Override
public
void
onStartFinish
()
{
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Grasscutter_is_free
);
Grasscutter
.
getLogger
().
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Game_start_port
,
address
.
getPort
()));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Game_start_port
.
replace
(
"{port}"
,
Integer
.
toString
(
address
.
getPort
()))
)
;
ServerStartEvent
event
=
new
ServerStartEvent
(
ServerEvent
.
Type
.
GAME
,
OffsetDateTime
.
now
());
event
.
call
();
}
...
...
src/main/java/emu/grasscutter/server/game/GameSession.java
View file @
b8f52999
...
...
@@ -113,12 +113,12 @@ public class GameSession extends KcpChannel {
@Override
protected
void
onConnect
()
{
Grasscutter
.
getLogger
().
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Client_connect
,
getAddress
().
getHostString
().
toLowerCase
()));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Client_connect
.
replace
(
"{address}"
,
getAddress
().
getHostString
().
toLowerCase
()));
}
@Override
protected
synchronized
void
onDisconnect
()
{
// Synchronize so we dont add character at the same time
Grasscutter
.
getLogger
().
info
(
String
.
format
(
Grasscutter
.
getLanguage
().
Client_disconnect
,
getAddress
().
getHostString
().
toLowerCase
()));
Grasscutter
.
getLogger
().
info
(
Grasscutter
.
getLanguage
().
Client_disconnect
.
replace
(
"{address}"
,
getAddress
().
getHostString
().
toLowerCase
()));
// Set state so no more packets can be handled
this
.
setState
(
SessionState
.
INACTIVE
);
...
...
Prev
1
2
Next
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