Commit 16318b37 authored by Melledy's avatar Melledy Committed by GitHub
Browse files

Merge pull request #74 from 4Benj/development

Server run modes and multi-server dispatch support
parents 8b5d7855 23caf994
package emu.grasscutter; package emu.grasscutter;
import java.util.ArrayList;
public final class Config { 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 DatabaseUrl = "mongodb://localhost:27017";
public String DatabaseCollection = "grasscutter"; public String DatabaseCollection = "grasscutter";
...@@ -21,26 +12,52 @@ public final class Config { ...@@ -21,26 +12,52 @@ 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 GameRates Game = new GameRates(); public String RunMode = "HYBRID"; // HYBRID, DISPATCH_ONLY, GAME_ONLY
public ServerOptions ServerOptions = new ServerOptions(); public GameServerOptions GameServer = new GameServerOptions();
public DispatchServerOptions DispatchServer = new DispatchServerOptions();
public GameRates getGameRates() { public GameServerOptions getGameServerOptions() {
return Game; return GameServer;
} }
public ServerOptions getServerOptions() { public DispatchServerOptions getDispatchOptions() { return DispatchServer; }
return ServerOptions;
} 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 static class RegionInfo {
public float ADVENTURE_EXP_RATE = 1.0f; public String Name = "os_usa";
public float MORA_RATE = 1.0f; public String Title = "Test";
public float DOMAIN_DROP_RATE = 1.0f; 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 InventoryLimitWeapon = 2000;
public int InventoryLimitRelic = 2000; public int InventoryLimitRelic = 2000;
public int InventoryLimitMaterial = 2000; public int InventoryLimitMaterial = 2000;
...@@ -52,6 +69,15 @@ public final class Config { ...@@ -52,6 +69,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;
}
} }
} }
...@@ -73,11 +73,26 @@ public final class Grasscutter { ...@@ -73,11 +73,26 @@ public final class Grasscutter {
DatabaseManager.initialize(); DatabaseManager.initialize();
// Start servers. // Start servers.
dispatchServer = new DispatchServer(); if(getConfig().RunMode.equalsIgnoreCase("HYBRID")) {
dispatchServer.start(); dispatchServer = new DispatchServer();
dispatchServer.start();
gameServer = new GameServer(new InetSocketAddress(getConfig().GameServerIp, getConfig().GameServerPort));
gameServer.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. // Open console.
startConsole(); startConsole();
...@@ -106,9 +121,14 @@ public final class Grasscutter { ...@@ -106,9 +121,14 @@ public final class Grasscutter {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
while ((input = br.readLine()) != null) { while ((input = br.readLine()) != null) {
try { try {
if(getConfig().RunMode.equalsIgnoreCase("DISPATCH_ONLY")) {
getLogger().error("Commands are not supported in dispatch only mode");
return;
}
CommandMap.getInstance().invoke(null, input); CommandMap.getInstance().invoke(null, input);
} catch (Exception e) { } catch (Exception e) {
Grasscutter.getLogger().error("Command error: " + e.getMessage()); Grasscutter.getLogger().error("Command error: ");
e.printStackTrace();
} }
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -74,36 +74,36 @@ public class DatabaseHelper { ...@@ -74,36 +74,36 @@ public class DatabaseHelper {
} }
public static void saveAccount(Account account) { public static void saveAccount(Account account) {
DatabaseManager.getDatastore().save(account); DatabaseManager.getAccountDatastore().save(account);
} }
public static Account getAccountByName(String username) { 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.getAccountDatastore().createQuery(Account.class).field("username").equalIgnoreCase(username).find(FIND_ONE);
if (!cursor.hasNext()) return null; if (!cursor.hasNext()) return null;
return cursor.next(); return cursor.next();
} }
public static Account getAccountByToken(String token) { public static Account getAccountByToken(String token) {
if (token == null) return null; if (token == null) return null;
MorphiaCursor<Account> cursor = DatabaseManager.getDatastore().createQuery(Account.class).field("token").equal(token).find(FIND_ONE); MorphiaCursor<Account> cursor = DatabaseManager.getAccountDatastore().createQuery(Account.class).field("token").equal(token).find(FIND_ONE);
if (!cursor.hasNext()) return null; if (!cursor.hasNext()) return null;
return cursor.next(); return cursor.next();
} }
public static Account getAccountById(String uid) { 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.getAccountDatastore().createQuery(Account.class).field("_id").equal(uid).find(FIND_ONE);
if (!cursor.hasNext()) return null; if (!cursor.hasNext()) return null;
return cursor.next(); return cursor.next();
} }
public static Account getAccountByPlayerId(int playerId) { 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.getAccountDatastore().createQuery(Account.class).field("playerId").equal(playerId).find(FIND_ONE);
if (!cursor.hasNext()) return null; if (!cursor.hasNext()) return null;
return cursor.next(); return cursor.next();
} }
public static boolean deleteAccount(String username) { public static boolean deleteAccount(String username) {
Query<Account> q = DatabaseManager.getDatastore().createQuery(Account.class).field("username").equalIgnoreCase(username); Query<Account> q = DatabaseManager.getAccountDatastore().createQuery(Account.class).field("username").equalIgnoreCase(username);
return DatabaseManager.getDatastore().findAndDelete(q) != null; return DatabaseManager.getDatastore().findAndDelete(q) != null;
} }
......
...@@ -17,7 +17,10 @@ import emu.grasscutter.game.inventory.GenshinItem; ...@@ -17,7 +17,10 @@ import emu.grasscutter.game.inventory.GenshinItem;
public final class DatabaseManager { public final class DatabaseManager {
private static MongoClient mongoClient; private static MongoClient mongoClient;
private static MongoClient dispatchMongoClient;
private static Datastore datastore; private static Datastore datastore;
private static Datastore dispatchDatastore;
private static final Class<?>[] mappedClasses = new Class<?>[] { private static final Class<?>[] mappedClasses = new Class<?>[] {
DatabaseCounter.class, Account.class, GenshinPlayer.class, GenshinAvatar.class, GenshinItem.class, Friendship.class DatabaseCounter.class, Account.class, GenshinPlayer.class, GenshinAvatar.class, GenshinItem.class, Friendship.class
...@@ -26,14 +29,24 @@ public final class DatabaseManager { ...@@ -26,14 +29,24 @@ public final class DatabaseManager {
public static MongoClient getMongoClient() { public static MongoClient getMongoClient() {
return mongoClient; return mongoClient;
} }
public static Datastore getDatastore() { public static Datastore getDatastore() {
return datastore; return datastore;
} }
public static MongoDatabase getDatabase() { public static MongoDatabase getDatabase() {
return getDatastore().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() { public static void initialize() {
// Initialize // Initialize
...@@ -67,6 +80,28 @@ public final class DatabaseManager { ...@@ -67,6 +80,28 @@ public final class DatabaseManager {
datastore.ensureIndexes(); 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) { public static synchronized int getNextId(Class<?> c) {
......
...@@ -293,7 +293,7 @@ public class GenshinPlayer { ...@@ -293,7 +293,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
......
...@@ -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().getGameServerOptions().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().getGameServerOptions().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().getGameServerOptions().MaxAvatarsInTeam);
} }
public void copyFrom(TeamInfo team, int maxTeamSize) { public void copyFrom(TeamInfo team, int maxTeamSize) {
......
...@@ -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().getGameServerOptions().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().getGameServerOptions().MaxAvatarsInTeam;
} }
// Methods // Methods
......
...@@ -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().DispatchServerPublicIp.isEmpty() ? Grasscutter.getConfig().DispatchServerIp : Grasscutter.getConfig().DispatchServerPublicIp) + "/gacha"; String record = "http://" + (Grasscutter.getConfig().getDispatchOptions().PublicIp.isEmpty() ? Grasscutter.getConfig().getDispatchOptions().Ip : Grasscutter.getConfig().getDispatchOptions().PublicIp) + "/gacha";
GachaInfo.Builder info = GachaInfo.newBuilder() GachaInfo.Builder info = GachaInfo.newBuilder()
.setGachaType(this.getGachaType()) .setGachaType(this.getGachaType())
......
...@@ -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().getGameServerOptions().WatchGacha) {
try { try {
WatchKey watchKey = watchService.take(); WatchKey watchKey = watchService.take();
......
...@@ -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().getGameServerOptions().InventoryLimitWeapon));
this.createInventoryTab(ItemType.ITEM_RELIQUARY, new EquipInventoryTab(Grasscutter.getConfig().getServerOptions().InventoryLimitRelic)); this.createInventoryTab(ItemType.ITEM_RELIQUARY, new EquipInventoryTab(Grasscutter.getConfig().getGameServerOptions().InventoryLimitRelic));
this.createInventoryTab(ItemType.ITEM_MATERIAL, new MaterialInventoryTab(Grasscutter.getConfig().getServerOptions().InventoryLimitMaterial)); this.createInventoryTab(ItemType.ITEM_MATERIAL, new MaterialInventoryTab(Grasscutter.getConfig().getGameServerOptions().InventoryLimitMaterial));
this.createInventoryTab(ItemType.ITEM_FURNITURE, new MaterialInventoryTab(Grasscutter.getConfig().getServerOptions().InventoryLimitFurniture)); this.createInventoryTab(ItemType.ITEM_FURNITURE, new MaterialInventoryTab(Grasscutter.getConfig().getGameServerOptions().InventoryLimitFurniture));
} }
public GenshinPlayer getPlayer() { public GenshinPlayer getPlayer() {
......
...@@ -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));
} }
} }
......
...@@ -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));
} }
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import com.google.protobuf.ByteString;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerLoginRspOuterClass.PlayerLoginRsp; import emu.grasscutter.net.proto.PlayerLoginRspOuterClass.PlayerLoginRsp;
import emu.grasscutter.net.proto.QueryCurrRegionHttpRspOuterClass;
import emu.grasscutter.net.proto.RegionInfoOuterClass.RegionInfo; import emu.grasscutter.net.proto.RegionInfoOuterClass.RegionInfo;
import emu.grasscutter.server.game.GameSession; 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 { public class PacketPlayerLoginRsp extends GenshinPacket {
private static QueryCurrRegionHttpRspOuterClass.QueryCurrRegionHttpRsp regionCache;
public PacketPlayerLoginRsp(GameSession session) { public PacketPlayerLoginRsp(GameSession session) {
super(PacketOpcodes.PlayerLoginRsp, 1); super(PacketOpcodes.PlayerLoginRsp, 1);
this.setUseDispatchKey(true); 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() PlayerLoginRsp p = PlayerLoginRsp.newBuilder()
.setIsUseAbilityHash(true) // true .setIsUseAbilityHash(true) // true
.setAbilityHashCode(1844674) // 1844674 .setAbilityHashCode(1844674) // 1844674
......
...@@ -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().getGameServerOptions().InventoryLimitAll);
for (GenshinItem item : player.getInventory()) { for (GenshinItem item : player.getInventory()) {
Item itemProto = item.toProto(); Item itemProto = item.toProto();
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.Config.ServerOptions; import emu.grasscutter.Config.GameServerOptions;
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(); GameServerOptions serverOptions = Grasscutter.getConfig().getGameServerOptions();
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().getGameServerOptions().WelcomeMotd)
.build(); .build();
proto.addChatInfo(welcomeMotd); proto.addChatInfo(welcomeMotd);
......
...@@ -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().getGameServerOptions().InventoryLimitAll)
.setWeaponCountLimit(Grasscutter.getConfig().getServerOptions().InventoryLimitWeapon) .setWeaponCountLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitWeapon)
.setReliquaryCountLimit(Grasscutter.getConfig().getServerOptions().InventoryLimitRelic) .setReliquaryCountLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitRelic)
.setMaterialCountLimit(Grasscutter.getConfig().getServerOptions().InventoryLimitMaterial) .setMaterialCountLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitMaterial)
.setFurnitureCountLimit(Grasscutter.getConfig().getServerOptions().InventoryLimitFurniture) .setFurnitureCountLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitFurniture)
.build(); .build();
this.setData(p); this.setData(p);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment