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
bd9e207a
Commit
bd9e207a
authored
May 11, 2022
by
KingRainbow44
Browse files
Remove old config & migrate legacy configs
parent
11161227
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/Configuration.java
View file @
bd9e207a
package
emu.grasscutter
;
import
com.google.gson.JsonObject
;
import
emu.grasscutter.Grasscutter.*
;
import
emu.grasscutter.game.mail.Mail.*
;
import
java.io.FileReader
;
import
java.lang.reflect.Field
;
import
java.util.Arrays
;
import
java.util.Locale
;
...
...
@@ -24,7 +26,16 @@ public final class Configuration {
* Attempts to update the server's existing configuration to the latest configuration.
*/
public
static
void
updateConfig
()
{
var
existing
=
config
.
version
;
try
{
// Check if the server is using a legacy config.
JsonObject
configObject
=
Grasscutter
.
getGsonFactory
()
.
fromJson
(
new
FileReader
(
Grasscutter
.
configFile
),
JsonObject
.
class
);
if
(!
configObject
.
has
(
"version"
))
{
Grasscutter
.
getLogger
().
info
(
"Updating legacy configuration..."
);
Grasscutter
.
saveConfig
(
null
);
}
}
catch
(
Exception
ignored
)
{
}
var
existing
=
config
.
version
;
var
latest
=
version
();
if
(
existing
==
latest
)
...
...
src/main/java/emu/grasscutter/Grasscutter.java
View file @
bd9e207a
...
...
@@ -43,7 +43,7 @@ public final class Grasscutter {
private
static
Language
language
;
private
static
final
Gson
gson
=
new
GsonBuilder
().
setPrettyPrinting
().
create
();
p
rivate
static
final
File
configFile
=
new
File
(
"./config.json"
);
p
ublic
static
final
File
configFile
=
new
File
(
"./config.json"
);
private
static
int
day
;
// Current day of week.
...
...
@@ -60,6 +60,8 @@ public final class Grasscutter {
// Load server configuration.
config
=
Grasscutter
.
loadConfig
();
// Attempt to update configuration.
Configuration
.
updateConfig
();
// Load translation files.
Grasscutter
.
loadLanguage
();
...
...
src/main/java/emu/grasscutter/utils/Utils.java
View file @
bd9e207a
...
...
@@ -11,7 +11,6 @@ import java.util.Map;
import
java.util.Random
;
import
java.util.Locale
;
import
emu.grasscutter.Config
;
import
emu.grasscutter.Configuration
;
import
emu.grasscutter.Grasscutter
;
import
io.netty.buffer.ByteBuf
;
...
...
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