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
83fe5818
Commit
83fe5818
authored
Apr 21, 2022
by
Benjamin Elsdon
Browse files
Restructured the config file in preperation for server run modes
parent
74bce2fe
Changes
14
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/Config.java
View file @
83fe5818
package
emu.grasscutter
;
package
emu.grasscutter
;
public
final
class
Config
{
public
final
class
Config
{
public
String
DispatchServerIp
=
"127.0.0.1"
;
public
String
DispatchServerPublicIp
=
""
;
public
int
DispatchServerPort
=
443
;
public
String
DispatchServerKeystorePath
=
"./keystore.p12"
;
public
String
DispatchServerKeystorePassword
=
""
;
public
Boolean
UseSSL
=
true
;
public
String
GameServerName
=
"Test"
;
public
String
GameServerIp
=
"127.0.0.1"
;
public
String
GameServerPublicIp
=
""
;
public
int
GameServerPort
=
22102
;
public
int
UploadLogPort
=
80
;
public
String
DatabaseUrl
=
"mongodb://localhost:27017"
;
public
String
DatabaseUrl
=
"mongodb://localhost:27017"
;
public
String
DatabaseCollection
=
"grasscutter"
;
public
String
DatabaseCollection
=
"grasscutter"
;
...
@@ -23,26 +10,36 @@ public final class Config {
...
@@ -23,26 +10,36 @@ public final class Config {
public
String
PACKETS_FOLDER
=
"./packets/"
;
public
String
PACKETS_FOLDER
=
"./packets/"
;
public
String
DUMPS_FOLDER
=
"./dumps/"
;
public
String
DUMPS_FOLDER
=
"./dumps/"
;
public
String
KEY_FOLDER
=
"./keys/"
;
public
String
KEY_FOLDER
=
"./keys/"
;
public
boolean
LOG_PACKETS
=
false
;
public
Game
Rates
Game
=
new
GameRate
s
();
public
Game
ServerOptions
GameServer
=
new
GameServerOption
s
();
public
ServerOptions
ServerOptions
=
new
ServerOptions
();
public
Dispatch
ServerOptions
DispatchServer
=
new
Dispatch
ServerOptions
();
public
Game
Rates
getGameRate
s
()
{
public
Game
ServerOptions
getGameServerOption
s
()
{
return
Game
;
return
Game
Server
;
}
}
public
ServerOptions
getServerOptions
()
{
public
DispatchServerOptions
getDispatchOptions
()
{
return
DispatchServer
;
}
return
ServerOptions
;
}
public
static
class
GameRates
{
public
static
class
DispatchServerOptions
{
public
float
ADVENTURE_EXP_RATE
=
1.0f
;
public
String
Ip
=
"127.0.0.1"
;
public
float
MORA_RATE
=
1.0f
;
public
String
PublicIp
=
""
;
public
float
DOMAIN_DROP_RATE
=
1.0f
;
public
int
Port
=
443
;
public
int
UploadLogPort
=
80
;
public
String
KeystorePath
=
"./keystore.p12"
;
public
String
KeystorePassword
=
""
;
public
Boolean
UseSSL
=
true
;
public
boolean
AutomaticallyCreateAccounts
=
false
;
}
}
public
static
class
ServerOptions
{
public
static
class
GameServerOptions
{
public
String
Name
=
"Test"
;
public
String
Ip
=
"127.0.0.1"
;
public
String
PublicIp
=
""
;
public
int
Port
=
22102
;
public
boolean
LOG_PACKETS
=
false
;
public
int
InventoryLimitWeapon
=
2000
;
public
int
InventoryLimitWeapon
=
2000
;
public
int
InventoryLimitRelic
=
2000
;
public
int
InventoryLimitRelic
=
2000
;
public
int
InventoryLimitMaterial
=
2000
;
public
int
InventoryLimitMaterial
=
2000
;
...
@@ -54,6 +51,15 @@ public final class Config {
...
@@ -54,6 +51,15 @@ public final class Config {
public
boolean
WatchGacha
=
false
;
public
boolean
WatchGacha
=
false
;
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
;
public
GameRates
Game
=
new
GameRates
();
public
GameRates
getGameRates
()
{
return
Game
;
}
public
static
class
GameRates
{
public
float
ADVENTURE_EXP_RATE
=
1.0f
;
public
float
MORA_RATE
=
1.0f
;
public
float
DOMAIN_DROP_RATE
=
1.0f
;
}
}
}
}
}
src/main/java/emu/grasscutter/Grasscutter.java
View file @
83fe5818
...
@@ -76,7 +76,7 @@ public final class Grasscutter {
...
@@ -76,7 +76,7 @@ public final class Grasscutter {
dispatchServer
=
new
DispatchServer
();
dispatchServer
=
new
DispatchServer
();
dispatchServer
.
start
();
dispatchServer
.
start
();
gameServer
=
new
GameServer
(
new
InetSocketAddress
(
getConfig
().
GameServerIp
,
getConfig
().
GameServerPort
));
gameServer
=
new
GameServer
(
new
InetSocketAddress
(
getConfig
().
get
GameServer
Options
().
Ip
,
getConfig
().
get
GameServer
Options
().
Port
));
gameServer
.
start
();
gameServer
.
start
();
// Open console.
// Open console.
...
...
src/main/java/emu/grasscutter/game/GenshinPlayer.java
View file @
83fe5818
...
@@ -288,7 +288,7 @@ public class GenshinPlayer {
...
@@ -288,7 +288,7 @@ public class GenshinPlayer {
}
}
private
float
getExpModifier
()
{
private
float
getExpModifier
()
{
return
Grasscutter
.
getConfig
().
getGameRates
().
ADVENTURE_EXP_RATE
;
return
Grasscutter
.
getConfig
().
getGameServerOptions
().
getGameRates
().
ADVENTURE_EXP_RATE
;
}
}
// Affected by exp rate
// Affected by exp rate
...
...
src/main/java/emu/grasscutter/game/TeamInfo.java
View file @
83fe5818
...
@@ -13,7 +13,7 @@ public class TeamInfo {
...
@@ -13,7 +13,7 @@ public class TeamInfo {
public
TeamInfo
()
{
public
TeamInfo
()
{
this
.
name
=
""
;
this
.
name
=
""
;
this
.
avatars
=
new
ArrayList
<>(
Grasscutter
.
getConfig
().
getServerOptions
().
MaxAvatarsInTeam
);
this
.
avatars
=
new
ArrayList
<>(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
MaxAvatarsInTeam
);
}
}
public
String
getName
()
{
public
String
getName
()
{
...
@@ -37,7 +37,7 @@ public class TeamInfo {
...
@@ -37,7 +37,7 @@ public class TeamInfo {
}
}
public
boolean
addAvatar
(
GenshinAvatar
avatar
)
{
public
boolean
addAvatar
(
GenshinAvatar
avatar
)
{
if
(
size
()
>=
Grasscutter
.
getConfig
().
getServerOptions
().
MaxAvatarsInTeam
||
contains
(
avatar
))
{
if
(
size
()
>=
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
MaxAvatarsInTeam
||
contains
(
avatar
))
{
return
false
;
return
false
;
}
}
...
@@ -57,7 +57,7 @@ public class TeamInfo {
...
@@ -57,7 +57,7 @@ public class TeamInfo {
}
}
public
void
copyFrom
(
TeamInfo
team
)
{
public
void
copyFrom
(
TeamInfo
team
)
{
copyFrom
(
team
,
Grasscutter
.
getConfig
().
getServerOptions
().
MaxAvatarsInTeam
);
copyFrom
(
team
,
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
MaxAvatarsInTeam
);
}
}
public
void
copyFrom
(
TeamInfo
team
,
int
maxTeamSize
)
{
public
void
copyFrom
(
TeamInfo
team
,
int
maxTeamSize
)
{
...
...
src/main/java/emu/grasscutter/game/TeamManager.java
View file @
83fe5818
...
@@ -164,13 +164,13 @@ public class TeamManager {
...
@@ -164,13 +164,13 @@ public class TeamManager {
public
int
getMaxTeamSize
()
{
public
int
getMaxTeamSize
()
{
if
(
getPlayer
().
isInMultiplayer
())
{
if
(
getPlayer
().
isInMultiplayer
())
{
int
max
=
Grasscutter
.
getConfig
().
getServerOptions
().
MaxAvatarsInTeamMultiplayer
;
int
max
=
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
MaxAvatarsInTeamMultiplayer
;
if
(
getPlayer
().
getWorld
().
getHost
()
==
this
.
getPlayer
())
{
if
(
getPlayer
().
getWorld
().
getHost
()
==
this
.
getPlayer
())
{
return
Math
.
max
(
1
,
(
int
)
Math
.
ceil
(
max
/
(
double
)
getWorld
().
getPlayerCount
()));
return
Math
.
max
(
1
,
(
int
)
Math
.
ceil
(
max
/
(
double
)
getWorld
().
getPlayerCount
()));
}
}
return
Math
.
max
(
1
,
(
int
)
Math
.
floor
(
max
/
(
double
)
getWorld
().
getPlayerCount
()));
return
Math
.
max
(
1
,
(
int
)
Math
.
floor
(
max
/
(
double
)
getWorld
().
getPlayerCount
()));
}
}
return
Grasscutter
.
getConfig
().
getServerOptions
().
MaxAvatarsInTeam
;
return
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
MaxAvatarsInTeam
;
}
}
// Methods
// Methods
...
...
src/main/java/emu/grasscutter/game/gacha/GachaBanner.java
View file @
83fe5818
...
@@ -92,7 +92,7 @@ public class GachaBanner {
...
@@ -92,7 +92,7 @@ public class GachaBanner {
}
}
public
GachaInfo
toProto
()
{
public
GachaInfo
toProto
()
{
String
record
=
"http://"
+
(
Grasscutter
.
getConfig
().
Dispatch
Server
PublicIp
.
isEmpty
()
?
Grasscutter
.
getConfig
().
Dispatch
Server
Ip
:
Grasscutter
.
getConfig
().
Dispatch
Server
PublicIp
)
+
"/gacha"
;
String
record
=
"http://"
+
(
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
PublicIp
.
isEmpty
()
?
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
Ip
:
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
PublicIp
)
+
"/gacha"
;
GachaInfo
.
Builder
info
=
GachaInfo
.
newBuilder
()
GachaInfo
.
Builder
info
=
GachaInfo
.
newBuilder
()
.
setGachaType
(
this
.
getGachaType
())
.
setGachaType
(
this
.
getGachaType
())
...
...
src/main/java/emu/grasscutter/game/gacha/GachaManager.java
View file @
83fe5818
...
@@ -299,7 +299,7 @@ public class GachaManager {
...
@@ -299,7 +299,7 @@ public class GachaManager {
@Subscribe
@Subscribe
public
synchronized
void
watchBannerJson
(
GameServerTickEvent
tickEvent
)
{
public
synchronized
void
watchBannerJson
(
GameServerTickEvent
tickEvent
)
{
if
(
Grasscutter
.
getConfig
().
getServerOptions
().
WatchGacha
)
{
if
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
WatchGacha
)
{
try
{
try
{
WatchKey
watchKey
=
watchService
.
take
();
WatchKey
watchKey
=
watchService
.
take
();
...
...
src/main/java/emu/grasscutter/game/inventory/Inventory.java
View file @
83fe5818
...
@@ -37,10 +37,10 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -37,10 +37,10 @@ public class Inventory implements Iterable<GenshinItem> {
this
.
store
=
new
Long2ObjectOpenHashMap
<>();
this
.
store
=
new
Long2ObjectOpenHashMap
<>();
this
.
inventoryTypes
=
new
Int2ObjectOpenHashMap
<>();
this
.
inventoryTypes
=
new
Int2ObjectOpenHashMap
<>();
this
.
createInventoryTab
(
ItemType
.
ITEM_WEAPON
,
new
EquipInventoryTab
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitWeapon
));
this
.
createInventoryTab
(
ItemType
.
ITEM_WEAPON
,
new
EquipInventoryTab
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitWeapon
));
this
.
createInventoryTab
(
ItemType
.
ITEM_RELIQUARY
,
new
EquipInventoryTab
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitRelic
));
this
.
createInventoryTab
(
ItemType
.
ITEM_RELIQUARY
,
new
EquipInventoryTab
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitRelic
));
this
.
createInventoryTab
(
ItemType
.
ITEM_MATERIAL
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitMaterial
));
this
.
createInventoryTab
(
ItemType
.
ITEM_MATERIAL
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitMaterial
));
this
.
createInventoryTab
(
ItemType
.
ITEM_FURNITURE
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitFurniture
));
this
.
createInventoryTab
(
ItemType
.
ITEM_FURNITURE
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitFurniture
));
}
}
public
GenshinPlayer
getPlayer
()
{
public
GenshinPlayer
getPlayer
()
{
...
...
src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java
View file @
83fe5818
...
@@ -55,7 +55,7 @@ public final class DispatchServer {
...
@@ -55,7 +55,7 @@ public final class DispatchServer {
public
static
String
query_cur_region
=
""
;
public
static
String
query_cur_region
=
""
;
public
DispatchServer
()
{
public
DispatchServer
()
{
this
.
address
=
new
InetSocketAddress
(
Grasscutter
.
getConfig
().
Dispatch
Server
Ip
,
Grasscutter
.
getConfig
().
Dispatch
Server
Port
);
this
.
address
=
new
InetSocketAddress
(
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
Ip
,
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
Port
);
this
.
gson
=
new
GsonBuilder
().
create
();
this
.
gson
=
new
GsonBuilder
().
create
();
this
.
loadQueries
();
this
.
loadQueries
();
...
@@ -102,16 +102,16 @@ public final class DispatchServer {
...
@@ -102,16 +102,16 @@ public final class DispatchServer {
RegionSimpleInfo
server
=
RegionSimpleInfo
.
newBuilder
()
RegionSimpleInfo
server
=
RegionSimpleInfo
.
newBuilder
()
.
setName
(
"os_usa"
)
.
setName
(
"os_usa"
)
.
setTitle
(
Grasscutter
.
getConfig
().
GameServerName
)
.
setTitle
(
Grasscutter
.
getConfig
().
get
GameServer
Options
().
Name
)
.
setType
(
"DEV_PUBLIC"
)
.
setType
(
"DEV_PUBLIC"
)
.
setDispatchUrl
(
"https://"
+
(
Grasscutter
.
getConfig
().
Dispatch
Server
PublicIp
.
isEmpty
()
?
Grasscutter
.
getConfig
().
Dispatch
Server
Ip
:
Grasscutter
.
getConfig
().
Dispatch
Server
PublicIp
)
+
":"
+
getAddress
().
getPort
()
+
"/query_cur_region"
)
.
setDispatchUrl
(
"https://"
+
(
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
PublicIp
.
isEmpty
()
?
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
Ip
:
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
PublicIp
)
+
":"
+
getAddress
().
getPort
()
+
"/query_cur_region"
)
.
build
();
.
build
();
RegionSimpleInfo
serverTest2
=
RegionSimpleInfo
.
newBuilder
()
RegionSimpleInfo
serverTest2
=
RegionSimpleInfo
.
newBuilder
()
.
setName
(
"os_euro"
)
.
setName
(
"os_euro"
)
.
setTitle
(
"Grasscutter"
)
.
setTitle
(
"Grasscutter"
)
.
setType
(
"DEV_PUBLIC"
)
.
setType
(
"DEV_PUBLIC"
)
.
setDispatchUrl
(
"https://"
+
(
Grasscutter
.
getConfig
().
Dispatch
Server
PublicIp
.
isEmpty
()
?
Grasscutter
.
getConfig
().
Dispatch
Server
Ip
:
Grasscutter
.
getConfig
().
Dispatch
Server
PublicIp
)
+
":"
+
getAddress
().
getPort
()
+
"/query_cur_region"
)
.
setDispatchUrl
(
"https://"
+
(
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
PublicIp
.
isEmpty
()
?
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
Ip
:
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
PublicIp
)
+
":"
+
getAddress
().
getPort
()
+
"/query_cur_region"
)
.
build
();
.
build
();
QueryRegionListHttpRsp
regionList
=
QueryRegionListHttpRsp
.
newBuilder
()
QueryRegionListHttpRsp
regionList
=
QueryRegionListHttpRsp
.
newBuilder
()
...
@@ -123,8 +123,8 @@ public final class DispatchServer {
...
@@ -123,8 +123,8 @@ public final class DispatchServer {
.
build
();
.
build
();
RegionInfo
currentRegion
=
regionQuery
.
getRegionInfo
().
toBuilder
()
RegionInfo
currentRegion
=
regionQuery
.
getRegionInfo
().
toBuilder
()
.
setIp
((
Grasscutter
.
getConfig
().
GameServerPublicIp
.
isEmpty
()
?
Grasscutter
.
getConfig
().
GameServerIp
:
Grasscutter
.
getConfig
().
GameServerPublicIp
))
.
setIp
((
Grasscutter
.
getConfig
().
get
GameServer
Options
().
PublicIp
.
isEmpty
()
?
Grasscutter
.
getConfig
().
get
GameServer
Options
().
Ip
:
Grasscutter
.
getConfig
().
get
GameServer
Options
().
PublicIp
))
.
setPort
(
Grasscutter
.
getConfig
().
GameServerPort
)
.
setPort
(
Grasscutter
.
getConfig
().
get
GameServer
Options
().
Port
)
.
setSecretKey
(
ByteString
.
copyFrom
(
FileUtils
.
read
(
Grasscutter
.
getConfig
().
KEY_FOLDER
+
"dispatchSeed.bin"
)))
.
setSecretKey
(
ByteString
.
copyFrom
(
FileUtils
.
read
(
Grasscutter
.
getConfig
().
KEY_FOLDER
+
"dispatchSeed.bin"
)))
.
build
();
.
build
();
...
@@ -140,12 +140,12 @@ public final class DispatchServer {
...
@@ -140,12 +140,12 @@ public final class DispatchServer {
public
void
start
()
throws
Exception
{
public
void
start
()
throws
Exception
{
HttpServer
server
;
HttpServer
server
;
if
(
Grasscutter
.
getConfig
().
UseSSL
)
{
if
(
Grasscutter
.
getConfig
().
getDispatchOptions
().
UseSSL
)
{
HttpsServer
httpsServer
;
HttpsServer
httpsServer
;
httpsServer
=
HttpsServer
.
create
(
getAddress
(),
0
);
httpsServer
=
HttpsServer
.
create
(
getAddress
(),
0
);
SSLContext
sslContext
=
SSLContext
.
getInstance
(
"TLS"
);
SSLContext
sslContext
=
SSLContext
.
getInstance
(
"TLS"
);
try
(
FileInputStream
fis
=
new
FileInputStream
(
Grasscutter
.
getConfig
().
Dispatch
Server
KeystorePath
))
{
try
(
FileInputStream
fis
=
new
FileInputStream
(
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
KeystorePath
))
{
char
[]
keystorePassword
=
Grasscutter
.
getConfig
().
Dispatch
Server
KeystorePassword
.
toCharArray
();
char
[]
keystorePassword
=
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
KeystorePassword
.
toCharArray
();
KeyStore
ks
=
KeyStore
.
getInstance
(
"PKCS12"
);
KeyStore
ks
=
KeyStore
.
getInstance
(
"PKCS12"
);
ks
.
load
(
fis
,
keystorePassword
);
ks
.
load
(
fis
,
keystorePassword
);
KeyManagerFactory
kmf
=
KeyManagerFactory
.
getInstance
(
"SunX509"
);
KeyManagerFactory
kmf
=
KeyManagerFactory
.
getInstance
(
"SunX509"
);
...
@@ -228,7 +228,7 @@ public final class DispatchServer {
...
@@ -228,7 +228,7 @@ public final class DispatchServer {
// Check if account exists, else create a new one.
// 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
// Account doesnt exist, so we can either auto create it if the config value is set
if
(
Grasscutter
.
getConfig
().
Server
Options
.
AutomaticallyCreateAccounts
)
{
if
(
Grasscutter
.
getConfig
().
getDispatch
Options
()
.
AutomaticallyCreateAccounts
)
{
// This account has been created AUTOMATICALLY. There will be no permissions added.
// This account has been created AUTOMATICALLY. There will be no permissions added.
account
=
DatabaseHelper
.
createAccountWithId
(
requestData
.
account
,
0
);
account
=
DatabaseHelper
.
createAccountWithId
(
requestData
.
account
,
0
);
...
@@ -410,7 +410,7 @@ public final class DispatchServer {
...
@@ -410,7 +410,7 @@ public final class DispatchServer {
Grasscutter
.
getLogger
().
info
(
"Dispatch server started on port "
+
getAddress
().
getPort
());
Grasscutter
.
getLogger
().
info
(
"Dispatch server started on port "
+
getAddress
().
getPort
());
// Logging servers
// Logging servers
HttpServer
overseaLogServer
=
HttpServer
.
create
(
new
InetSocketAddress
(
Grasscutter
.
getConfig
().
Dispatch
Server
Ip
,
8888
),
0
);
HttpServer
overseaLogServer
=
HttpServer
.
create
(
new
InetSocketAddress
(
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
Ip
,
8888
),
0
);
overseaLogServer
.
createContext
(
// overseauspider.yuanshen.com
overseaLogServer
.
createContext
(
// overseauspider.yuanshen.com
"/log"
,
"/log"
,
new
DispatchHttpJsonHandler
(
"{\"code\":0}"
)
new
DispatchHttpJsonHandler
(
"{\"code\":0}"
)
...
@@ -418,7 +418,7 @@ public final class DispatchServer {
...
@@ -418,7 +418,7 @@ public final class DispatchServer {
overseaLogServer
.
start
();
overseaLogServer
.
start
();
Grasscutter
.
getLogger
().
info
(
"Log server (overseauspider) started on port "
+
8888
);
Grasscutter
.
getLogger
().
info
(
"Log server (overseauspider) started on port "
+
8888
);
HttpServer
uploadLogServer
=
HttpServer
.
create
(
new
InetSocketAddress
(
Grasscutter
.
getConfig
().
Dispatch
Server
Ip
,
Grasscutter
.
getConfig
().
UploadLogPort
),
0
);
HttpServer
uploadLogServer
=
HttpServer
.
create
(
new
InetSocketAddress
(
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
Ip
,
Grasscutter
.
getConfig
().
getDispatchOptions
().
UploadLogPort
),
0
);
uploadLogServer
.
createContext
(
// log-upload-os.mihoyo.com
uploadLogServer
.
createContext
(
// log-upload-os.mihoyo.com
"/crash/dataUpload"
,
"/crash/dataUpload"
,
new
DispatchHttpJsonHandler
(
"{\"code\":0}"
)
new
DispatchHttpJsonHandler
(
"{\"code\":0}"
)
...
@@ -435,7 +435,7 @@ public final class DispatchServer {
...
@@ -435,7 +435,7 @@ public final class DispatchServer {
os
.
close
();
os
.
close
();
});
});
uploadLogServer
.
start
();
uploadLogServer
.
start
();
Grasscutter
.
getLogger
().
info
(
"Log server (log-upload-os) started on port "
+
Grasscutter
.
getConfig
().
UploadLogPort
);
Grasscutter
.
getLogger
().
info
(
"Log server (log-upload-os) started on port "
+
Grasscutter
.
getConfig
().
getDispatchOptions
().
UploadLogPort
);
}
}
private
Map
<
String
,
String
>
parseQueryString
(
String
qs
)
{
private
Map
<
String
,
String
>
parseQueryString
(
String
qs
)
{
...
...
src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java
View file @
83fe5818
...
@@ -87,7 +87,7 @@ public class GameServerPacketHandler {
...
@@ -87,7 +87,7 @@ public class GameServerPacketHandler {
}
}
// Log unhandled packets
// Log unhandled packets
if
(
Grasscutter
.
getConfig
().
LOG_PACKETS
)
{
if
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
LOG_PACKETS
)
{
//Grasscutter.getLogger().info("Unhandled packet (" + opcode + "): " + PacketOpcodesUtil.getOpcodeName(opcode));
//Grasscutter.getLogger().info("Unhandled packet (" + opcode + "): " + PacketOpcodesUtil.getOpcodeName(opcode));
}
}
}
}
...
...
src/main/java/emu/grasscutter/server/game/GameSession.java
View file @
83fe5818
...
@@ -165,7 +165,7 @@ public class GameSession extends MihoyoKcpChannel {
...
@@ -165,7 +165,7 @@ public class GameSession extends MihoyoKcpChannel {
byte
[]
data
=
genshinPacket
.
build
();
byte
[]
data
=
genshinPacket
.
build
();
// Log
// Log
if
(
Grasscutter
.
getConfig
().
LOG_PACKETS
)
{
if
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
LOG_PACKETS
)
{
logPacket
(
genshinPacket
);
logPacket
(
genshinPacket
);
}
}
...
@@ -225,7 +225,7 @@ public class GameSession extends MihoyoKcpChannel {
...
@@ -225,7 +225,7 @@ public class GameSession extends MihoyoKcpChannel {
}
}
// Log packet
// Log packet
if
(
Grasscutter
.
getConfig
().
LOG_PACKETS
)
{
if
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
LOG_PACKETS
)
{
Grasscutter
.
getLogger
().
info
(
"RECV: "
+
PacketOpcodesUtil
.
getOpcodeName
(
opcode
)
+
" ("
+
opcode
+
")"
);
Grasscutter
.
getLogger
().
info
(
"RECV: "
+
PacketOpcodesUtil
.
getOpcodeName
(
opcode
)
+
" ("
+
opcode
+
")"
);
System
.
out
.
println
(
Utils
.
bytesToHex
(
payload
));
System
.
out
.
println
(
Utils
.
bytesToHex
(
payload
));
}
}
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketPlayerStoreNotify.java
View file @
83fe5818
...
@@ -19,7 +19,7 @@ public class PacketPlayerStoreNotify extends GenshinPacket {
...
@@ -19,7 +19,7 @@ public class PacketPlayerStoreNotify extends GenshinPacket {
PlayerStoreNotify
.
Builder
p
=
PlayerStoreNotify
.
newBuilder
()
PlayerStoreNotify
.
Builder
p
=
PlayerStoreNotify
.
newBuilder
()
.
setStoreType
(
StoreType
.
StorePack
)
.
setStoreType
(
StoreType
.
StorePack
)
.
setWeightLimit
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitAll
);
.
setWeightLimit
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitAll
);
for
(
GenshinItem
item
:
player
.
getInventory
())
{
for
(
GenshinItem
item
:
player
.
getInventory
())
{
Item
itemProto
=
item
.
toProto
();
Item
itemProto
=
item
.
toProto
();
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketPullRecentChatRsp.java
View file @
83fe5818
package
emu.grasscutter.server.packet.send
;
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.Config.ServerOptions
;
import
emu.grasscutter.Config.
Game
ServerOptions
;
import
emu.grasscutter.GenshinConstants
;
import
emu.grasscutter.GenshinConstants
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.GenshinPlayer
;
...
@@ -14,7 +14,7 @@ public class PacketPullRecentChatRsp extends GenshinPacket {
...
@@ -14,7 +14,7 @@ public class PacketPullRecentChatRsp extends GenshinPacket {
public
PacketPullRecentChatRsp
(
GenshinPlayer
player
)
{
public
PacketPullRecentChatRsp
(
GenshinPlayer
player
)
{
super
(
PacketOpcodes
.
PullRecentChatRsp
);
super
(
PacketOpcodes
.
PullRecentChatRsp
);
ServerOptions
serverOptions
=
Grasscutter
.
getConfig
().
getServerOptions
();
Game
ServerOptions
serverOptions
=
Grasscutter
.
getConfig
().
get
Game
ServerOptions
();
PullRecentChatRsp
.
Builder
proto
=
PullRecentChatRsp
.
newBuilder
();
PullRecentChatRsp
.
Builder
proto
=
PullRecentChatRsp
.
newBuilder
();
if
(
serverOptions
.
WelcomeEmotes
!=
null
&&
serverOptions
.
WelcomeEmotes
.
length
>
0
)
{
if
(
serverOptions
.
WelcomeEmotes
!=
null
&&
serverOptions
.
WelcomeEmotes
.
length
>
0
)
{
...
@@ -33,7 +33,7 @@ public class PacketPullRecentChatRsp extends GenshinPacket {
...
@@ -33,7 +33,7 @@ public class PacketPullRecentChatRsp extends GenshinPacket {
.
setTime
((
int
)
(
System
.
currentTimeMillis
()
/
1000
))
.
setTime
((
int
)
(
System
.
currentTimeMillis
()
/
1000
))
.
setUid
(
GenshinConstants
.
SERVER_CONSOLE_UID
)
.
setUid
(
GenshinConstants
.
SERVER_CONSOLE_UID
)
.
setToUid
(
player
.
getUid
())
.
setToUid
(
player
.
getUid
())
.
setText
(
Grasscutter
.
getConfig
().
getServerOptions
().
WelcomeMotd
)
.
setText
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
WelcomeMotd
)
.
build
();
.
build
();
proto
.
addChatInfo
(
welcomeMotd
);
proto
.
addChatInfo
(
welcomeMotd
);
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketStoreWeightLimitNotify.java
View file @
83fe5818
...
@@ -13,11 +13,11 @@ public class PacketStoreWeightLimitNotify extends GenshinPacket {
...
@@ -13,11 +13,11 @@ public class PacketStoreWeightLimitNotify extends GenshinPacket {
StoreWeightLimitNotify
p
=
StoreWeightLimitNotify
.
newBuilder
()
StoreWeightLimitNotify
p
=
StoreWeightLimitNotify
.
newBuilder
()
.
setStoreType
(
StoreType
.
StorePack
)
.
setStoreType
(
StoreType
.
StorePack
)
.
setWeightLimit
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitAll
)
.
setWeightLimit
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitAll
)
.
setWeaponCountLimit
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitWeapon
)
.
setWeaponCountLimit
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitWeapon
)
.
setReliquaryCountLimit
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitRelic
)
.
setReliquaryCountLimit
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitRelic
)
.
setMaterialCountLimit
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitMaterial
)
.
setMaterialCountLimit
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitMaterial
)
.
setFurnitureCountLimit
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitFurniture
)
.
setFurnitureCountLimit
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitFurniture
)
.
build
();
.
build
();
this
.
setData
(
p
);
this
.
setData
(
p
);
...
...
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