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
32d2a211
Commit
32d2a211
authored
May 06, 2022
by
KingRainbow44
Browse files
Merge remote-tracking branch 'origin/development' into development
parents
043c7315
e29c2dc1
Changes
3
Hide whitespace changes
Inline
Side-by-side
proxy_config.py
View file @
32d2a211
import
os
# This can also be replaced with another IP address.
# This can also be replaced with another IP address.
USE_SSL
=
True
USE_SSL
=
True
REMOTE_HOST
=
"127.0.0.1"
REMOTE_HOST
=
"localhost"
REMOTE_PORT
=
443
REMOTE_PORT
=
443
\ No newline at end of file
if
os
.
getenv
(
'MITM_REMOTE_HOST'
)
!=
None
:
REMOTE_HOST
=
os
.
getenv
(
'MITM_REMOTE_HOST'
)
if
os
.
getenv
(
'MITM_REMOTE_PORT'
)
!=
None
:
REMOTE_PORT
=
int
(
os
.
getenv
(
'MITM_REMOTE_PORT'
))
if
os
.
getenv
(
'MITM_USE_SSL'
)
!=
None
:
USE_SSL
=
bool
(
os
.
getenv
(
'MITM_USE_SSL'
))
print
(
'MITM Remote Host: '
+
REMOTE_HOST
)
print
(
'MITM Remote Port: '
+
str
(
REMOTE_PORT
))
print
(
'MITM Use SSL '
+
str
(
USE_SSL
))
src/main/java/emu/grasscutter/Grasscutter.java
View file @
32d2a211
...
@@ -51,7 +51,7 @@ public final class Grasscutter {
...
@@ -51,7 +51,7 @@ public final class Grasscutter {
private
static
PluginManager
pluginManager
;
private
static
PluginManager
pluginManager
;
public
static
final
Reflections
reflector
=
new
Reflections
(
"emu.grasscutter"
);
public
static
final
Reflections
reflector
=
new
Reflections
(
"emu.grasscutter"
);
static
{
static
{
// Declare logback configuration.
// Declare logback configuration.
System
.
setProperty
(
"logback.configurationFile"
,
"src/main/resources/logback.xml"
);
System
.
setProperty
(
"logback.configurationFile"
,
"src/main/resources/logback.xml"
);
...
@@ -66,7 +66,7 @@ public final class Grasscutter {
...
@@ -66,7 +66,7 @@ public final class Grasscutter {
Utils
.
startupCheck
();
Utils
.
startupCheck
();
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Crypto
.
loadKeys
();
// Load keys from buffers.
Crypto
.
loadKeys
();
// Load keys from buffers.
// Parse arguments.
// Parse arguments.
...
@@ -127,7 +127,7 @@ public final class Grasscutter {
...
@@ -127,7 +127,7 @@ public final class Grasscutter {
// Open console.
// Open console.
startConsole
();
startConsole
();
}
}
/**
/**
* Server shutdown event.
* Server shutdown event.
...
...
src/main/java/emu/grasscutter/tools/Tools.java
View file @
32d2a211
package
emu.grasscutter.tools
;
package
emu.grasscutter.tools
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileReader
;
import
java.io.FileReader
;
import
java.io.FileWriter
;
import
java.io.FileWriter
;
import
java.io.FilenameFilter
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.io.OutputStreamWriter
;
import
java.io.OutputStreamWriter
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
...
@@ -30,13 +32,73 @@ import emu.grasscutter.data.def.SceneData;
...
@@ -30,13 +32,73 @@ import emu.grasscutter.data.def.SceneData;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.utils.Utils
;
public
final
class
Tools
{
public
final
class
Tools
{
public
static
void
createGmHandbook
()
throws
Exception
{
ToolsWithLanguageOption
.
createGmHandbook
(
getLanguageOption
());
}
public
static
void
createGachaMapping
(
String
location
)
throws
Exception
{
ToolsWithLanguageOption
.
createGachaMapping
(
location
,
getLanguageOption
());
}
public
static
List
<
String
>
getAvailableLanguage
()
throws
Exception
{
File
textMapFolder
=
new
File
(
Grasscutter
.
getConfig
().
RESOURCE_FOLDER
+
"TextMap"
);
List
<
String
>
availableLangList
=
new
ArrayList
<
String
>();
for
(
String
textMapFileName
:
textMapFolder
.
list
(
new
FilenameFilter
()
{
@Override
public
boolean
accept
(
File
dir
,
String
name
)
{
if
(
name
.
startsWith
(
"TextMap"
)
&&
name
.
endsWith
(
".json"
)){
return
true
;
}
return
false
;
}
}))
{
availableLangList
.
add
(
textMapFileName
.
replace
(
"TextMap"
,
""
).
replace
(
".json"
,
""
).
toLowerCase
());
}
return
availableLangList
;
}
public
static
String
getLanguageOption
()
throws
Exception
{
List
<
String
>
availableLangList
=
getAvailableLanguage
();
// Use system out for better format
if
(
availableLangList
.
size
()
==
1
)
{
return
availableLangList
.
get
(
0
).
toUpperCase
();
}
System
.
out
.
println
(
"The following languages mappings are available, please select one: [default: EN]"
);
String
groupedLangList
=
"> "
;
int
groupedLangCount
=
0
;
String
input
=
""
;
for
(
String
availableLanguage:
availableLangList
){
groupedLangCount
++;
groupedLangList
=
groupedLangList
+
""
+
availableLanguage
+
"\t"
;
if
(
groupedLangCount
==
6
)
{
System
.
out
.
println
(
groupedLangList
);
groupedLangCount
=
0
;
groupedLangList
=
"> "
;
}
}
if
(
groupedLangCount
>
0
)
{
System
.
out
.
println
(
groupedLangList
);
}
System
.
out
.
print
(
"\nYour choice:[EN] "
);
input
=
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
)).
readLine
();
if
(
availableLangList
.
contains
(
input
.
toLowerCase
()))
{
return
input
.
toUpperCase
();
}
Grasscutter
.
getLogger
().
info
(
"Invalid option. Will use EN(English) as fallback"
);
return
"EN"
;
}
}
final
class
ToolsWithLanguageOption
{
@SuppressWarnings
(
"deprecation"
)
@SuppressWarnings
(
"deprecation"
)
public
static
void
createGmHandbook
()
throws
Exception
{
public
static
void
createGmHandbook
(
String
language
)
throws
Exception
{
ResourceLoader
.
loadResources
();
ResourceLoader
.
loadResources
();
Map
<
Long
,
String
>
map
;
Map
<
Long
,
String
>
map
;
try
(
InputStreamReader
fileReader
=
new
InputStreamReader
(
new
FileInputStream
(
Utils
.
toFilePath
(
Grasscutter
.
getConfig
().
RESOURCE_FOLDER
+
"TextMap/TextMap
EN
.json"
)),
StandardCharsets
.
UTF_8
))
{
try
(
InputStreamReader
fileReader
=
new
InputStreamReader
(
new
FileInputStream
(
Utils
.
toFilePath
(
Grasscutter
.
getConfig
().
RESOURCE_FOLDER
+
"TextMap/TextMap
"
+
language
+
"
.json"
)),
StandardCharsets
.
UTF_8
))
{
map
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
new
TypeToken
<
Map
<
Long
,
String
>>()
{}.
getType
());
map
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
new
TypeToken
<
Map
<
Long
,
String
>>()
{}.
getType
());
}
}
...
@@ -96,11 +158,11 @@ public final class Tools {
...
@@ -96,11 +158,11 @@ public final class Tools {
}
}
@SuppressWarnings
(
"deprecation"
)
@SuppressWarnings
(
"deprecation"
)
public
static
void
createGachaMapping
(
String
location
)
throws
Exception
{
public
static
void
createGachaMapping
(
String
location
,
String
language
)
throws
Exception
{
ResourceLoader
.
loadResources
();
ResourceLoader
.
loadResources
();
Map
<
Long
,
String
>
map
;
Map
<
Long
,
String
>
map
;
try
(
InputStreamReader
fileReader
=
new
InputStreamReader
(
new
FileInputStream
(
Utils
.
toFilePath
(
Grasscutter
.
getConfig
().
RESOURCE_FOLDER
+
"TextMap/TextMap
EN
.json"
)),
StandardCharsets
.
UTF_8
))
{
try
(
InputStreamReader
fileReader
=
new
InputStreamReader
(
new
FileInputStream
(
Utils
.
toFilePath
(
Grasscutter
.
getConfig
().
RESOURCE_FOLDER
+
"TextMap/TextMap
"
+
language
+
"
.json"
)),
StandardCharsets
.
UTF_8
))
{
map
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
new
TypeToken
<
Map
<
Long
,
String
>>()
{}.
getType
());
map
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
new
TypeToken
<
Map
<
Long
,
String
>>()
{}.
getType
());
}
}
...
@@ -113,6 +175,9 @@ public final class Tools {
...
@@ -113,6 +175,9 @@ public final class Tools {
list
=
new
ArrayList
<>(
GameData
.
getAvatarDataMap
().
keySet
());
list
=
new
ArrayList
<>(
GameData
.
getAvatarDataMap
().
keySet
());
Collections
.
sort
(
list
);
Collections
.
sort
(
list
);
// if the user made choices for language, I assume it's okay to assign his/her selected language to "en-us"
// since it's the fallback language and there will be no difference in the gacha record page.
// The enduser can still modify the `gacha_mappings.js` directly to enable multilingual for the gacha record system.
writer
.
println
(
"mappings = {\"en-us\": {"
);
writer
.
println
(
"mappings = {\"en-us\": {"
);
// Avatars
// Avatars
...
@@ -140,10 +205,10 @@ public final class Tools {
...
@@ -140,10 +205,10 @@ public final class Tools {
default
:
default
:
color
=
"blue"
;
color
=
"blue"
;
}
}
// Got the magic number 4233146695 from manually search in the json file
writer
.
println
(
writer
.
println
(
"\""
+
(
avatarID
%
1000
+
1000
)
+
"\" : [\""
"\""
+
(
avatarID
%
1000
+
1000
)
+
"\" : [\""
+
map
.
get
(
data
.
getNameTextMapHash
())
+
"(
Avatar
)\", \""
+
map
.
get
(
data
.
getNameTextMapHash
())
+
"(
"
+
map
.
get
(
4233146695L
)+
"
)\", \""
+
color
+
"\"]"
);
+
color
+
"\"]"
);
}
}
...
@@ -173,11 +238,14 @@ public final class Tools {
...
@@ -173,11 +238,14 @@ public final class Tools {
default
:
default
:
continue
;
// skip unnecessary entries
continue
;
// skip unnecessary entries
}
}
// Got the magic number 4231343903 from manually search in the json file
writer
.
println
(
",\""
+
data
.
getId
()
+
writer
.
println
(
",\""
+
data
.
getId
()
+
"\" : [\""
+
map
.
get
(
data
.
getNameTextMapHash
()).
replaceAll
(
"\""
,
""
)
"\" : [\""
+
map
.
get
(
data
.
getNameTextMapHash
()).
replaceAll
(
"\""
,
""
)
+
"(
Weapon
)\",\""
+
color
+
"\"]"
);
+
"(
"
+
map
.
get
(
4231343903L
)+
"
)\",\""
+
color
+
"\"]"
);
}
}
writer
.
println
(
",\"200\": \"
Standard\", \"301\": \"Avatar Event\", \"302\": \"Weapon event
\""
);
writer
.
println
(
",\"200\": \"
"
+
map
.
get
(
332935371L
)+
"\", \"301\": \""
+
map
.
get
(
2272170627L
)
+
"\", \"302\": \""
+
map
.
get
(
2864268523L
)+
"
\""
);
writer
.
println
(
"}\n}"
);
writer
.
println
(
"}\n}"
);
}
}
...
...
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