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
16318b37
Commit
16318b37
authored
Apr 21, 2022
by
Melledy
Committed by
GitHub
Apr 21, 2022
Browse files
Merge pull request #74 from 4Benj/development
Server run modes and multi-server dispatch support
parents
8b5d7855
23caf994
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/Config.java
View file @
16318b37
package
emu.grasscutter
;
import
java.util.ArrayList
;
public
final
class
Config
{
public
String
DispatchServerIp
=
"0.0.0.0"
;
public
String
DispatchServerPublicIp
=
"127.0.0.1"
;
public
int
DispatchServerPort
=
443
;
public
String
DispatchServerKeystorePath
=
"./keystore.p12"
;
public
String
DispatchServerKeystorePassword
=
""
;
public
Boolean
UseSSL
=
true
;
public
String
GameServerName
=
"Test"
;
public
String
GameServerIp
=
"0.0.0.0"
;
public
String
GameServerPublicIp
=
"127.0.0.1"
;
public
int
GameServerPort
=
22102
;
public
String
DatabaseUrl
=
"mongodb://localhost:27017"
;
public
String
DatabaseCollection
=
"grasscutter"
;
...
...
@@ -21,26 +12,52 @@ public final class Config {
public
String
PACKETS_FOLDER
=
"./packets/"
;
public
String
DUMPS_FOLDER
=
"./dumps/"
;
public
String
KEY_FOLDER
=
"./keys/"
;
public
boolean
LOG_PACKETS
=
false
;
public
GameRates
Game
=
new
GameRates
();
public
ServerOptions
ServerOptions
=
new
ServerOptions
();
public
String
RunMode
=
"HYBRID"
;
// HYBRID, DISPATCH_ONLY, GAME_ONLY
public
GameServerOptions
GameServer
=
new
GameServerOptions
();
public
DispatchServerOptions
DispatchServer
=
new
DispatchServerOptions
();
public
Game
Rates
getGameRate
s
()
{
return
Game
;
public
Game
ServerOptions
getGameServerOption
s
()
{
return
Game
Server
;
}
public
ServerOptions
getServerOptions
()
{
return
ServerOptions
;
}
public
DispatchServerOptions
getDispatchOptions
()
{
return
DispatchServer
;
}
public
static
class
DispatchServerOptions
{
public
String
Ip
=
"0.0.0.0"
;
public
String
PublicIp
=
"127.0.0.1"
;
public
int
Port
=
443
;
public
String
KeystorePath
=
"./keystore.p12"
;
public
String
KeystorePassword
=
""
;
public
Boolean
UseSSL
=
true
;
public
boolean
AutomaticallyCreateAccounts
=
false
;
public
RegionInfo
[]
GameServers
=
{};
public
RegionInfo
[]
getGameServers
()
{
return
GameServers
;
}
public
static
class
GameRates
{
public
float
ADVENTURE_EXP_RATE
=
1.0f
;
public
float
MORA_RATE
=
1.0f
;
public
float
DOMAIN_DROP_RATE
=
1.0f
;
public
static
class
RegionInfo
{
public
String
Name
=
"os_usa"
;
public
String
Title
=
"Test"
;
public
String
Ip
=
"127.0.0.1"
;
public
int
Port
=
22102
;
}
}
public
static
class
GameServerOptions
{
public
String
Name
=
"Test"
;
public
String
Ip
=
"0.0.0.0"
;
public
String
PublicIp
=
"127.0.0.1"
;
public
int
Port
=
22102
;
public
String
DispatchServerDatabaseUrl
=
"mongodb://localhost:27017"
;
public
String
DispatchServerDatabaseCollection
=
"grasscutter"
;
public
boolean
LOG_PACKETS
=
false
;
public
static
class
ServerOptions
{
public
int
InventoryLimitWeapon
=
2000
;
public
int
InventoryLimitRelic
=
2000
;
public
int
InventoryLimitMaterial
=
2000
;
...
...
@@ -52,6 +69,15 @@ public final class Config {
public
boolean
WatchGacha
=
false
;
public
int
[]
WelcomeEmotes
=
{
2007
,
1002
,
4010
};
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 @
16318b37
...
...
@@ -73,11 +73,26 @@ public final class Grasscutter {
DatabaseManager
.
initialize
();
// Start servers.
dispatchServer
=
new
DispatchServer
();
dispatchServer
.
start
();
gameServer
=
new
GameServer
(
new
InetSocketAddress
(
getConfig
().
GameServerIp
,
getConfig
().
GameServerPort
));
gameServer
.
start
();
if
(
getConfig
().
RunMode
.
equalsIgnoreCase
(
"HYBRID"
))
{
dispatchServer
=
new
DispatchServer
();
dispatchServer
.
start
();
gameServer
=
new
GameServer
(
new
InetSocketAddress
(
getConfig
().
getGameServerOptions
().
Ip
,
getConfig
().
getGameServerOptions
().
Port
));
gameServer
.
start
();
}
else
if
(
getConfig
().
RunMode
.
equalsIgnoreCase
(
"DISPATCH_ONLY"
))
{
dispatchServer
=
new
DispatchServer
();
dispatchServer
.
start
();
}
else
if
(
getConfig
().
RunMode
.
equalsIgnoreCase
(
"GAME_ONLY"
))
{
gameServer
=
new
GameServer
(
new
InetSocketAddress
(
getConfig
().
getGameServerOptions
().
Ip
,
getConfig
().
getGameServerOptions
().
Port
));
gameServer
.
start
();
}
else
{
getLogger
().
error
(
"Invalid server run mode. "
+
getConfig
().
RunMode
);
getLogger
().
error
(
"Server run mode must be 'HYBRID', 'DISPATCH_ONLY', or 'GAME_ONLY'. Unable to start Grasscutter..."
);
getLogger
().
error
(
"Shutting down..."
);
System
.
exit
(
1
);
}
// Open console.
startConsole
();
...
...
@@ -106,9 +121,14 @@ public final class Grasscutter {
try
(
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
)))
{
while
((
input
=
br
.
readLine
())
!=
null
)
{
try
{
if
(
getConfig
().
RunMode
.
equalsIgnoreCase
(
"DISPATCH_ONLY"
))
{
getLogger
().
error
(
"Commands are not supported in dispatch only mode"
);
return
;
}
CommandMap
.
getInstance
().
invoke
(
null
,
input
);
}
catch
(
Exception
e
)
{
Grasscutter
.
getLogger
().
error
(
"Command error: "
+
e
.
getMessage
());
Grasscutter
.
getLogger
().
error
(
"Command error: "
);
e
.
printStackTrace
();
}
}
}
catch
(
Exception
e
)
{
...
...
src/main/java/emu/grasscutter/database/DatabaseHelper.java
View file @
16318b37
...
...
@@ -74,36 +74,36 @@ public class DatabaseHelper {
}
public
static
void
saveAccount
(
Account
account
)
{
DatabaseManager
.
getDatastore
().
save
(
account
);
DatabaseManager
.
get
Account
Datastore
().
save
(
account
);
}
public
static
Account
getAccountByName
(
String
username
)
{
MorphiaCursor
<
Account
>
cursor
=
DatabaseManager
.
getDatastore
().
createQuery
(
Account
.
class
).
field
(
"username"
).
equalIgnoreCase
(
username
).
find
(
FIND_ONE
);
MorphiaCursor
<
Account
>
cursor
=
DatabaseManager
.
get
Account
Datastore
().
createQuery
(
Account
.
class
).
field
(
"username"
).
equalIgnoreCase
(
username
).
find
(
FIND_ONE
);
if
(!
cursor
.
hasNext
())
return
null
;
return
cursor
.
next
();
}
public
static
Account
getAccountByToken
(
String
token
)
{
if
(
token
==
null
)
return
null
;
MorphiaCursor
<
Account
>
cursor
=
DatabaseManager
.
getDatastore
().
createQuery
(
Account
.
class
).
field
(
"token"
).
equal
(
token
).
find
(
FIND_ONE
);
MorphiaCursor
<
Account
>
cursor
=
DatabaseManager
.
get
Account
Datastore
().
createQuery
(
Account
.
class
).
field
(
"token"
).
equal
(
token
).
find
(
FIND_ONE
);
if
(!
cursor
.
hasNext
())
return
null
;
return
cursor
.
next
();
}
public
static
Account
getAccountById
(
String
uid
)
{
MorphiaCursor
<
Account
>
cursor
=
DatabaseManager
.
getDatastore
().
createQuery
(
Account
.
class
).
field
(
"_id"
).
equal
(
uid
).
find
(
FIND_ONE
);
MorphiaCursor
<
Account
>
cursor
=
DatabaseManager
.
get
Account
Datastore
().
createQuery
(
Account
.
class
).
field
(
"_id"
).
equal
(
uid
).
find
(
FIND_ONE
);
if
(!
cursor
.
hasNext
())
return
null
;
return
cursor
.
next
();
}
public
static
Account
getAccountByPlayerId
(
int
playerId
)
{
MorphiaCursor
<
Account
>
cursor
=
DatabaseManager
.
getDatastore
().
createQuery
(
Account
.
class
).
field
(
"playerId"
).
equal
(
playerId
).
find
(
FIND_ONE
);
MorphiaCursor
<
Account
>
cursor
=
DatabaseManager
.
get
Account
Datastore
().
createQuery
(
Account
.
class
).
field
(
"playerId"
).
equal
(
playerId
).
find
(
FIND_ONE
);
if
(!
cursor
.
hasNext
())
return
null
;
return
cursor
.
next
();
}
public
static
boolean
deleteAccount
(
String
username
)
{
Query
<
Account
>
q
=
DatabaseManager
.
getDatastore
().
createQuery
(
Account
.
class
).
field
(
"username"
).
equalIgnoreCase
(
username
);
Query
<
Account
>
q
=
DatabaseManager
.
get
Account
Datastore
().
createQuery
(
Account
.
class
).
field
(
"username"
).
equalIgnoreCase
(
username
);
return
DatabaseManager
.
getDatastore
().
findAndDelete
(
q
)
!=
null
;
}
...
...
src/main/java/emu/grasscutter/database/DatabaseManager.java
View file @
16318b37
...
...
@@ -17,7 +17,10 @@ import emu.grasscutter.game.inventory.GenshinItem;
public
final
class
DatabaseManager
{
private
static
MongoClient
mongoClient
;
private
static
MongoClient
dispatchMongoClient
;
private
static
Datastore
datastore
;
private
static
Datastore
dispatchDatastore
;
private
static
final
Class
<?>[]
mappedClasses
=
new
Class
<?>[]
{
DatabaseCounter
.
class
,
Account
.
class
,
GenshinPlayer
.
class
,
GenshinAvatar
.
class
,
GenshinItem
.
class
,
Friendship
.
class
...
...
@@ -26,14 +29,24 @@ public final class DatabaseManager {
public
static
MongoClient
getMongoClient
()
{
return
mongoClient
;
}
public
static
Datastore
getDatastore
()
{
return
datastore
;
}
public
static
MongoDatabase
getDatabase
()
{
public
static
Datastore
getDatastore
()
{
return
datastore
;
}
public
static
MongoDatabase
getDatabase
()
{
return
getDatastore
().
getDatabase
();
}
// Yes. I very dislike this method. However, this will be good for now.
// TODO: Add dispatch routes for player account management
public
static
Datastore
getAccountDatastore
()
{
if
(
Grasscutter
.
getConfig
().
RunMode
.
equalsIgnoreCase
(
"GAME_ONLY"
))
{
return
dispatchDatastore
;
}
else
{
return
datastore
;
}
}
public
static
void
initialize
()
{
// Initialize
...
...
@@ -67,6 +80,28 @@ public final class DatabaseManager {
datastore
.
ensureIndexes
();
}
}
if
(
Grasscutter
.
getConfig
().
RunMode
.
equalsIgnoreCase
(
"GAME_ONLY"
))
{
dispatchMongoClient
=
new
MongoClient
(
new
MongoClientURI
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
DispatchServerDatabaseUrl
));
dispatchDatastore
=
morphia
.
createDatastore
(
dispatchMongoClient
,
Grasscutter
.
getConfig
().
getGameServerOptions
().
DispatchServerDatabaseCollection
);
// Ensure indexes for dispatch server
try
{
dispatchDatastore
.
ensureIndexes
();
}
catch
(
MongoCommandException
e
)
{
Grasscutter
.
getLogger
().
info
(
"Mongo index error: "
,
e
);
// Duplicate index error
if
(
e
.
getCode
()
==
85
)
{
// Drop all indexes and re add them
MongoIterable
<
String
>
collections
=
dispatchDatastore
.
getDatabase
().
listCollectionNames
();
for
(
String
name
:
collections
)
{
dispatchDatastore
.
getDatabase
().
getCollection
(
name
).
dropIndexes
();
}
// Add back indexes
dispatchDatastore
.
ensureIndexes
();
}
}
}
}
public
static
synchronized
int
getNextId
(
Class
<?>
c
)
{
...
...
src/main/java/emu/grasscutter/game/GenshinPlayer.java
View file @
16318b37
...
...
@@ -293,7 +293,7 @@ public class GenshinPlayer {
}
private
float
getExpModifier
()
{
return
Grasscutter
.
getConfig
().
getGameRates
().
ADVENTURE_EXP_RATE
;
return
Grasscutter
.
getConfig
().
getGameServerOptions
().
getGameRates
().
ADVENTURE_EXP_RATE
;
}
// Affected by exp rate
...
...
src/main/java/emu/grasscutter/game/TeamInfo.java
View file @
16318b37
...
...
@@ -13,7 +13,7 @@ public class TeamInfo {
public
TeamInfo
()
{
this
.
name
=
""
;
this
.
avatars
=
new
ArrayList
<>(
Grasscutter
.
getConfig
().
getServerOptions
().
MaxAvatarsInTeam
);
this
.
avatars
=
new
ArrayList
<>(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
MaxAvatarsInTeam
);
}
public
String
getName
()
{
...
...
@@ -37,7 +37,7 @@ public class TeamInfo {
}
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
;
}
...
...
@@ -57,7 +57,7 @@ public class TeamInfo {
}
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
)
{
...
...
src/main/java/emu/grasscutter/game/TeamManager.java
View file @
16318b37
...
...
@@ -164,13 +164,13 @@ public class TeamManager {
public
int
getMaxTeamSize
()
{
if
(
getPlayer
().
isInMultiplayer
())
{
int
max
=
Grasscutter
.
getConfig
().
getServerOptions
().
MaxAvatarsInTeamMultiplayer
;
int
max
=
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
MaxAvatarsInTeamMultiplayer
;
if
(
getPlayer
().
getWorld
().
getHost
()
==
this
.
getPlayer
())
{
return
Math
.
max
(
1
,
(
int
)
Math
.
ceil
(
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
...
...
src/main/java/emu/grasscutter/game/gacha/GachaBanner.java
View file @
16318b37
...
...
@@ -92,7 +92,7 @@ public class GachaBanner {
}
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
()
.
setGachaType
(
this
.
getGachaType
())
...
...
src/main/java/emu/grasscutter/game/gacha/GachaManager.java
View file @
16318b37
...
...
@@ -299,7 +299,7 @@ public class GachaManager {
@Subscribe
public
synchronized
void
watchBannerJson
(
GameServerTickEvent
tickEvent
)
{
if
(
Grasscutter
.
getConfig
().
getServerOptions
().
WatchGacha
)
{
if
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
WatchGacha
)
{
try
{
WatchKey
watchKey
=
watchService
.
take
();
...
...
src/main/java/emu/grasscutter/game/inventory/Inventory.java
View file @
16318b37
...
...
@@ -37,10 +37,10 @@ public class Inventory implements Iterable<GenshinItem> {
this
.
store
=
new
Long2ObjectOpenHashMap
<>();
this
.
inventoryTypes
=
new
Int2ObjectOpenHashMap
<>();
this
.
createInventoryTab
(
ItemType
.
ITEM_WEAPON
,
new
EquipInventoryTab
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitWeapon
));
this
.
createInventoryTab
(
ItemType
.
ITEM_RELIQUARY
,
new
EquipInventoryTab
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitRelic
));
this
.
createInventoryTab
(
ItemType
.
ITEM_MATERIAL
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitMaterial
));
this
.
createInventoryTab
(
ItemType
.
ITEM_FURNITURE
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitFurniture
));
this
.
createInventoryTab
(
ItemType
.
ITEM_WEAPON
,
new
EquipInventoryTab
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitWeapon
));
this
.
createInventoryTab
(
ItemType
.
ITEM_RELIQUARY
,
new
EquipInventoryTab
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitRelic
));
this
.
createInventoryTab
(
ItemType
.
ITEM_MATERIAL
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitMaterial
));
this
.
createInventoryTab
(
ItemType
.
ITEM_FURNITURE
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitFurniture
));
}
public
GenshinPlayer
getPlayer
()
{
...
...
src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java
View file @
16318b37
This diff is collapsed.
Click to expand it.
src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java
View file @
16318b37
...
...
@@ -87,7 +87,7 @@ public class GameServerPacketHandler {
}
// Log unhandled packets
if
(
Grasscutter
.
getConfig
().
LOG_PACKETS
)
{
if
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
LOG_PACKETS
)
{
//Grasscutter.getLogger().info("Unhandled packet (" + opcode + "): " + PacketOpcodesUtil.getOpcodeName(opcode));
}
}
...
...
src/main/java/emu/grasscutter/server/game/GameSession.java
View file @
16318b37
...
...
@@ -165,7 +165,7 @@ public class GameSession extends MihoyoKcpChannel {
byte
[]
data
=
genshinPacket
.
build
();
// Log
if
(
Grasscutter
.
getConfig
().
LOG_PACKETS
)
{
if
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
LOG_PACKETS
)
{
logPacket
(
genshinPacket
);
}
...
...
@@ -225,7 +225,7 @@ public class GameSession extends MihoyoKcpChannel {
}
// Log packet
if
(
Grasscutter
.
getConfig
().
LOG_PACKETS
)
{
if
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
LOG_PACKETS
)
{
Grasscutter
.
getLogger
().
info
(
"RECV: "
+
PacketOpcodesUtil
.
getOpcodeName
(
opcode
)
+
" ("
+
opcode
+
")"
);
System
.
out
.
println
(
Utils
.
bytesToHex
(
payload
));
}
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLoginRsp.java
View file @
16318b37
package
emu.grasscutter.server.packet.send
;
import
com.google.protobuf.ByteString
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.PlayerLoginRspOuterClass.PlayerLoginRsp
;
import
emu.grasscutter.net.proto.QueryCurrRegionHttpRspOuterClass
;
import
emu.grasscutter.net.proto.RegionInfoOuterClass.RegionInfo
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.utils.FileUtils
;
import
java.io.File
;
import
java.net.URL
;
import
java.util.Base64
;
public
class
PacketPlayerLoginRsp
extends
GenshinPacket
{
private
static
QueryCurrRegionHttpRspOuterClass
.
QueryCurrRegionHttpRsp
regionCache
;
public
PacketPlayerLoginRsp
(
GameSession
session
)
{
super
(
PacketOpcodes
.
PlayerLoginRsp
,
1
);
this
.
setUseDispatchKey
(
true
);
RegionInfo
info
=
Grasscutter
.
getDispatchServer
().
getCurrRegion
().
getRegionInfo
();
RegionInfo
info
;
if
(
Grasscutter
.
getConfig
().
RunMode
.
equalsIgnoreCase
(
"GAME_ONLY"
))
{
if
(
regionCache
==
null
)
{
try
{
File
file
=
new
File
(
Grasscutter
.
getConfig
().
DATA_FOLDER
+
"query_cur_region.txt"
);
String
query_cur_region
=
""
;
if
(
file
.
exists
())
{
query_cur_region
=
new
String
(
FileUtils
.
read
(
file
));
}
else
{
Grasscutter
.
getLogger
().
warn
(
"query_cur_region not found! Using default current region."
);
}
byte
[]
decodedCurRegion
=
Base64
.
getDecoder
().
decode
(
query_cur_region
);
QueryCurrRegionHttpRspOuterClass
.
QueryCurrRegionHttpRsp
regionQuery
=
QueryCurrRegionHttpRspOuterClass
.
QueryCurrRegionHttpRsp
.
parseFrom
(
decodedCurRegion
);
RegionInfo
serverRegion
=
regionQuery
.
getRegionInfo
().
toBuilder
()
.
setIp
((
Grasscutter
.
getConfig
().
getGameServerOptions
().
PublicIp
.
isEmpty
()
?
Grasscutter
.
getConfig
().
getGameServerOptions
().
Ip
:
Grasscutter
.
getConfig
().
getGameServerOptions
().
PublicIp
))
.
setPort
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
Port
)
.
setSecretKey
(
ByteString
.
copyFrom
(
FileUtils
.
read
(
Grasscutter
.
getConfig
().
KEY_FOLDER
+
"dispatchSeed.bin"
)))
.
build
();
regionCache
=
regionQuery
.
toBuilder
().
setRegionInfo
(
serverRegion
).
build
();
}
catch
(
Exception
e
)
{
Grasscutter
.
getLogger
().
error
(
"Error while initializing region cache!"
,
e
);
}
}
info
=
regionCache
.
getRegionInfo
();
}
else
{
info
=
Grasscutter
.
getDispatchServer
().
getCurrRegion
().
getRegionInfo
();
}
PlayerLoginRsp
p
=
PlayerLoginRsp
.
newBuilder
()
.
setIsUseAbilityHash
(
true
)
// true
.
setAbilityHashCode
(
1844674
)
// 1844674
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketPlayerStoreNotify.java
View file @
16318b37
...
...
@@ -19,7 +19,7 @@ public class PacketPlayerStoreNotify extends GenshinPacket {
PlayerStoreNotify
.
Builder
p
=
PlayerStoreNotify
.
newBuilder
()
.
setStoreType
(
StoreType
.
StorePack
)
.
setWeightLimit
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitAll
);
.
setWeightLimit
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitAll
);
for
(
GenshinItem
item
:
player
.
getInventory
())
{
Item
itemProto
=
item
.
toProto
();
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketPullRecentChatRsp.java
View file @
16318b37
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.Config.ServerOptions
;
import
emu.grasscutter.Config.
Game
ServerOptions
;
import
emu.grasscutter.GenshinConstants
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.GenshinPlayer
;
...
...
@@ -14,7 +14,7 @@ public class PacketPullRecentChatRsp extends GenshinPacket {
public
PacketPullRecentChatRsp
(
GenshinPlayer
player
)
{
super
(
PacketOpcodes
.
PullRecentChatRsp
);
ServerOptions
serverOptions
=
Grasscutter
.
getConfig
().
getServerOptions
();
Game
ServerOptions
serverOptions
=
Grasscutter
.
getConfig
().
get
Game
ServerOptions
();
PullRecentChatRsp
.
Builder
proto
=
PullRecentChatRsp
.
newBuilder
();
if
(
serverOptions
.
WelcomeEmotes
!=
null
&&
serverOptions
.
WelcomeEmotes
.
length
>
0
)
{
...
...
@@ -33,7 +33,7 @@ public class PacketPullRecentChatRsp extends GenshinPacket {
.
setTime
((
int
)
(
System
.
currentTimeMillis
()
/
1000
))
.
setUid
(
GenshinConstants
.
SERVER_CONSOLE_UID
)
.
setToUid
(
player
.
getUid
())
.
setText
(
Grasscutter
.
getConfig
().
getServerOptions
().
WelcomeMotd
)
.
setText
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
WelcomeMotd
)
.
build
();
proto
.
addChatInfo
(
welcomeMotd
);
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketStoreWeightLimitNotify.java
View file @
16318b37
...
...
@@ -13,11 +13,11 @@ public class PacketStoreWeightLimitNotify extends GenshinPacket {
StoreWeightLimitNotify
p
=
StoreWeightLimitNotify
.
newBuilder
()
.
setStoreType
(
StoreType
.
StorePack
)
.
setWeightLimit
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitAll
)
.
setWeaponCountLimit
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitWeapon
)
.
setReliquaryCountLimit
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitRelic
)
.
setMaterialCountLimit
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitMaterial
)
.
setFurnitureCountLimit
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitFurniture
)
.
setWeightLimit
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitAll
)
.
setWeaponCountLimit
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitWeapon
)
.
setReliquaryCountLimit
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitRelic
)
.
setMaterialCountLimit
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitMaterial
)
.
setFurnitureCountLimit
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitFurniture
)
.
build
();
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