From 6e5d986687e390663a885ed7af9869209883b3ce Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 3 Sep 2022 03:36:51 +0000 Subject: [PATCH] Fix whitespace [skip actions] --- .../emu/grasscutter/command/CommandMap.java | 2 +- .../grasscutter/config/ConfigContainer.java | 2 +- .../grasscutter/data/common/PointData.java | 96 ++-- .../data/excels/AvatarCostumeData.java | 38 +- .../data/excels/EquipAffixData.java | 72 +-- .../emu/grasscutter/data/excels/ItemData.java | 2 +- .../data/excels/ReliquarySetData.java | 34 +- .../grasscutter/database/DatabaseHelper.java | 444 +++++++++--------- .../emu/grasscutter/game/avatar/Avatar.java | 2 +- .../grasscutter/game/entity/EntityAvatar.java | 2 +- .../entity/gadget/GadgetGatherObject.java | 90 ++-- .../game/entity/gadget/GadgetGatherPoint.java | 84 ++-- .../grasscutter/game/home/HomeBlockItem.java | 2 +- .../game/managers/mapmark/MapMark.java | 20 +- .../emu/grasscutter/game/quest/GameQuest.java | 2 +- .../grasscutter/game/quest/QuestManager.java | 6 +- .../emu/grasscutter/server/http/Router.java | 2 +- .../recv/HandlerMusicGameSettleReq.java | 16 +- .../recv/HandlerPersonalSceneJumpReq.java | 30 +- .../packet/send/PacketAddCustomTeamRsp.java | 2 +- .../send/PacketAvatarTeamUpdateNotify.java | 24 +- .../packet/send/PacketCreateVehicleRsp.java | 44 +- .../send/PacketCustomTeamListNotify.java | 2 +- .../send/PacketRemoveCustomTeamRsp.java | 2 +- 24 files changed, 510 insertions(+), 510 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/CommandMap.java b/src/main/java/emu/grasscutter/command/CommandMap.java index cb0e055fa..284667e73 100644 --- a/src/main/java/emu/grasscutter/command/CommandMap.java +++ b/src/main/java/emu/grasscutter/command/CommandMap.java @@ -225,7 +225,7 @@ public final class CommandMap { Grasscutter.getLogger().info("Command used by server console: " + rawMessage); } } - + rawMessage = rawMessage.trim(); if (rawMessage.length() == 0) { CommandHandler.sendTranslatedMessage(player, "commands.generic.not_specified"); diff --git a/src/main/java/emu/grasscutter/config/ConfigContainer.java b/src/main/java/emu/grasscutter/config/ConfigContainer.java index fa84e6a95..9417de7c6 100644 --- a/src/main/java/emu/grasscutter/config/ConfigContainer.java +++ b/src/main/java/emu/grasscutter/config/ConfigContainer.java @@ -96,7 +96,7 @@ public class ConfigContainer { public Set debugBlacklist = Set.of(); public ServerRunMode runMode = ServerRunMode.HYBRID; public boolean logCommands = false; - + public HTTP http = new HTTP(); public Game game = new Game(); diff --git a/src/main/java/emu/grasscutter/data/common/PointData.java b/src/main/java/emu/grasscutter/data/common/PointData.java index 0fc484135..4ec13dcb6 100644 --- a/src/main/java/emu/grasscutter/data/common/PointData.java +++ b/src/main/java/emu/grasscutter/data/common/PointData.java @@ -10,71 +10,71 @@ import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; public class PointData { - private int id; - private String $type; - private Position tranPos; + private int id; + private String $type; + private Position tranPos; - @SerializedName(value="dungeonIds", alternate={"JHHFPGJNMIN"}) - private int[] dungeonIds; + @SerializedName(value="dungeonIds", alternate={"JHHFPGJNMIN"}) + private int[] dungeonIds; - @SerializedName(value="dungeonRandomList", alternate={"OIBKFJNBLHO"}) - private int[] dungeonRandomList; + @SerializedName(value="dungeonRandomList", alternate={"OIBKFJNBLHO"}) + private int[] dungeonRandomList; - @SerializedName(value="tranSceneId", alternate={"JHBICGBAPIH"}) - private int tranSceneId; + @SerializedName(value="tranSceneId", alternate={"JHBICGBAPIH"}) + private int tranSceneId; - public int getId() { - return id; - } + public int getId() { + return id; + } - public void setId(int id) { - this.id = id; - } + public void setId(int id) { + this.id = id; + } - public String getType() { - return $type; - } + public String getType() { + return $type; + } - public Position getTranPos() { - return tranPos; - } + public Position getTranPos() { + return tranPos; + } - public int[] getDungeonIds() { - return dungeonIds; - } + public int[] getDungeonIds() { + return dungeonIds; + } - public int[] getDungeonRandomList() { - return dungeonRandomList; - } + public int[] getDungeonRandomList() { + return dungeonRandomList; + } - public int getTranSceneId() { - return tranSceneId; - } + public int getTranSceneId() { + return tranSceneId; + } - public void setTranSceneId(int tranSceneId) { - this.tranSceneId = tranSceneId; - } + public void setTranSceneId(int tranSceneId) { + this.tranSceneId = tranSceneId; + } - public void updateDailyDungeon() { + public void updateDailyDungeon() { if (getDungeonRandomList() == null || getDungeonRandomList().length == 0) { return; - } + } - IntList newDungeons = new IntArrayList(); - int day = Grasscutter.getCurrentDayOfWeek(); + IntList newDungeons = new IntArrayList(); + int day = Grasscutter.getCurrentDayOfWeek(); - for (int randomId : getDungeonRandomList()) { - DailyDungeonData data = GameData.getDailyDungeonDataMap().get(randomId); + for (int randomId : getDungeonRandomList()) { + DailyDungeonData data = GameData.getDailyDungeonDataMap().get(randomId); - if (data != null) { - int[] addDungeons = data.getDungeonsByDay(day); + if (data != null) { + int[] addDungeons = data.getDungeonsByDay(day); - for (int d : addDungeons) { - newDungeons.add(d); - } - } - } + for (int d : addDungeons) { + newDungeons.add(d); + } + } + } - this.dungeonIds = newDungeons.toIntArray(); - } + this.dungeonIds = newDungeons.toIntArray(); + } } diff --git a/src/main/java/emu/grasscutter/data/excels/AvatarCostumeData.java b/src/main/java/emu/grasscutter/data/excels/AvatarCostumeData.java index 71c6b583d..81ff1a148 100644 --- a/src/main/java/emu/grasscutter/data/excels/AvatarCostumeData.java +++ b/src/main/java/emu/grasscutter/data/excels/AvatarCostumeData.java @@ -6,30 +6,30 @@ import emu.grasscutter.data.ResourceType; @ResourceType(name = "AvatarCostumeExcelConfigData.json") public class AvatarCostumeData extends GameResource { - private int costumeId; - private int itemId; + private int costumeId; + private int itemId; private int characterId; private int quality; - - @Override - public int getId() { - return this.costumeId; - } - - public int getItemId() { - return this.itemId; - } - public int getCharacterId() { - return characterId; - } - - public int getQuality() { + @Override + public int getId() { + return this.costumeId; + } + + public int getItemId() { + return this.itemId; + } + + public int getCharacterId() { + return characterId; + } + + public int getQuality() { return quality; } @Override - public void onLoad() { - GameData.getAvatarCostumeDataItemIdMap().put(this.getItemId(), this); - } + public void onLoad() { + GameData.getAvatarCostumeDataItemIdMap().put(this.getItemId(), this); + } } diff --git a/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java b/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java index e17a74628..5bb147b8a 100644 --- a/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java +++ b/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java @@ -8,52 +8,52 @@ import emu.grasscutter.data.common.FightPropData; @ResourceType(name = "EquipAffixExcelConfigData.json") public class EquipAffixData extends GameResource { - private int affixId; + private int affixId; private int id; private int level; private long nameTextMapHash; private String openConfig; private FightPropData[] addProps; private float[] paramList; - - @Override - public int getId() { - return affixId; - } - - public int getMainId() { - return id; - } - public int getLevel() { - return level; - } + @Override + public int getId() { + return affixId; + } - public long getNameTextMapHash() { - return nameTextMapHash; - } + public int getMainId() { + return id; + } - public String getOpenConfig() { - return openConfig; - } + public int getLevel() { + return level; + } - public FightPropData[] getAddProps() { - return addProps; - } + public long getNameTextMapHash() { + return nameTextMapHash; + } - public float[] getParamList() { - return paramList; - } + public String getOpenConfig() { + return openConfig; + } - @Override - public void onLoad() { - ArrayList parsed = new ArrayList(getAddProps().length); - for (FightPropData prop : getAddProps()) { - if (prop.getPropType() != null && prop.getValue() != 0f) { - prop.onLoad(); - parsed.add(prop); - } - } - this.addProps = parsed.toArray(new FightPropData[parsed.size()]); - } + public FightPropData[] getAddProps() { + return addProps; + } + + public float[] getParamList() { + return paramList; + } + + @Override + public void onLoad() { + ArrayList parsed = new ArrayList(getAddProps().length); + for (FightPropData prop : getAddProps()) { + if (prop.getPropType() != null && prop.getValue() != 0f) { + prop.onLoad(); + parsed.add(prop); + } + } + this.addProps = parsed.toArray(new FightPropData[parsed.size()]); + } } diff --git a/src/main/java/emu/grasscutter/data/excels/ItemData.java b/src/main/java/emu/grasscutter/data/excels/ItemData.java index 7ff869f7f..457dc7bc0 100644 --- a/src/main/java/emu/grasscutter/data/excels/ItemData.java +++ b/src/main/java/emu/grasscutter/data/excels/ItemData.java @@ -120,7 +120,7 @@ public class ItemData extends GameResource { if (this.getFurnitureGadgetID() != null) { this.furnitureGadgetID = this.furnitureGadgetID.stream().filter(x -> x > 0).toList(); } - + // Prevent material type from being null this.materialType = this.materialType == null ? MaterialType.MATERIAL_NONE : this.materialType; } diff --git a/src/main/java/emu/grasscutter/data/excels/ReliquarySetData.java b/src/main/java/emu/grasscutter/data/excels/ReliquarySetData.java index b41b82ed7..f96d122f8 100644 --- a/src/main/java/emu/grasscutter/data/excels/ReliquarySetData.java +++ b/src/main/java/emu/grasscutter/data/excels/ReliquarySetData.java @@ -7,27 +7,27 @@ import emu.grasscutter.data.ResourceType; @ResourceType(name = "ReliquarySetExcelConfigData.json") public class ReliquarySetData extends GameResource { - private int setId; + private int setId; private int[] setNeedNum; - + @SerializedName(value="equipAffixId", alternate={"EquipAffixId"}) private int equipAffixId; - - @Override - public int getId() { - return setId; - } - - public int[] getSetNeedNum() { - return setNeedNum; - } - public int getEquipAffixId() { - return equipAffixId; - } + @Override + public int getId() { + return setId; + } - @Override - public void onLoad() { + public int[] getSetNeedNum() { + return setNeedNum; + } - } + public int getEquipAffixId() { + return equipAffixId; + } + + @Override + public void onLoad() { + + } } diff --git a/src/main/java/emu/grasscutter/database/DatabaseHelper.java b/src/main/java/emu/grasscutter/database/DatabaseHelper.java index 2592063a4..98d7bf819 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseHelper.java +++ b/src/main/java/emu/grasscutter/database/DatabaseHelper.java @@ -25,103 +25,103 @@ import emu.grasscutter.game.quest.GameMainQuest; import static com.mongodb.client.model.Filters.eq; public final class DatabaseHelper { - public static Account createAccount(String username) { - return createAccountWithUid(username, 0); - } + public static Account createAccount(String username) { + return createAccountWithUid(username, 0); + } - public static Account createAccountWithUid(String username, int reservedUid) { - // Unique names only - if (DatabaseHelper.checkIfAccountExists(username)) { - return null; - } + public static Account createAccountWithUid(String username, int reservedUid) { + // Unique names only + if (DatabaseHelper.checkIfAccountExists(username)) { + return null; + } - // Make sure there are no id collisions - if (reservedUid > 0) { - // Cannot make account with the same uid as the server console - if (reservedUid == GameConstants.SERVER_CONSOLE_UID) { - return null; - } + // Make sure there are no id collisions + if (reservedUid > 0) { + // Cannot make account with the same uid as the server console + if (reservedUid == GameConstants.SERVER_CONSOLE_UID) { + return null; + } - if (DatabaseHelper.checkIfAccountExists(reservedUid)) { - return null; - } + if (DatabaseHelper.checkIfAccountExists(reservedUid)) { + return null; + } - // Make sure no existing player already has this id. - if (DatabaseHelper.checkIfPlayerExists(reservedUid)) { - return null; - } - } + // Make sure no existing player already has this id. + if (DatabaseHelper.checkIfPlayerExists(reservedUid)) { + return null; + } + } - // Account - Account account = new Account(); - account.setUsername(username); - account.setId(Integer.toString(DatabaseManager.getNextId(account))); + // Account + Account account = new Account(); + account.setUsername(username); + account.setId(Integer.toString(DatabaseManager.getNextId(account))); - if (reservedUid > 0) { - account.setReservedPlayerUid(reservedUid); - } + if (reservedUid > 0) { + account.setReservedPlayerUid(reservedUid); + } - DatabaseHelper.saveAccount(account); - return account; - } + DatabaseHelper.saveAccount(account); + return account; + } - @Deprecated - public static Account createAccountWithPassword(String username, String password) { - // Unique names only - Account exists = DatabaseHelper.getAccountByName(username); - if (exists != null) { - return null; - } + @Deprecated + public static Account createAccountWithPassword(String username, String password) { + // Unique names only + Account exists = DatabaseHelper.getAccountByName(username); + if (exists != null) { + return null; + } - // Account - Account account = new Account(); - account.setId(Integer.toString(DatabaseManager.getNextId(account))); - account.setUsername(username); - account.setPassword(password); - DatabaseHelper.saveAccount(account); - return account; - } + // Account + Account account = new Account(); + account.setId(Integer.toString(DatabaseManager.getNextId(account))); + account.setUsername(username); + account.setPassword(password); + DatabaseHelper.saveAccount(account); + return account; + } - public static void saveAccount(Account account) { - DatabaseManager.getAccountDatastore().save(account); - } + public static void saveAccount(Account account) { + DatabaseManager.getAccountDatastore().save(account); + } - public static Account getAccountByName(String username) { - return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("username", username)).first(); - } + public static Account getAccountByName(String username) { + return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("username", username)).first(); + } - public static Account getAccountByToken(String token) { - if(token == null) return null; - return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("token", token)).first(); - } + public static Account getAccountByToken(String token) { + if (token == null) return null; + return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("token", token)).first(); + } - public static Account getAccountBySessionKey(String sessionKey) { - if(sessionKey == null) return null; - return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("sessionKey", sessionKey)).first(); - } + public static Account getAccountBySessionKey(String sessionKey) { + if (sessionKey == null) return null; + return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("sessionKey", sessionKey)).first(); + } - public static Account getAccountById(String uid) { - return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("_id", uid)).first(); - } + public static Account getAccountById(String uid) { + return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("_id", uid)).first(); + } - public static Account getAccountByPlayerId(int playerId) { - return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("reservedPlayerId", playerId)).first(); - } + public static Account getAccountByPlayerId(int playerId) { + return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("reservedPlayerId", playerId)).first(); + } - public static boolean checkIfAccountExists(String name) { - return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("username", name)).count() > 0; - } + public static boolean checkIfAccountExists(String name) { + return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("username", name)).count() > 0; + } - public static boolean checkIfAccountExists(int reservedUid) { - return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("reservedPlayerId", reservedUid)).count() > 0; - } + public static boolean checkIfAccountExists(int reservedUid) { + return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("reservedPlayerId", reservedUid)).count() > 0; + } - public static synchronized void deleteAccount(Account target) { - // To delete an account, we need to also delete all the other documents in the database that reference the account. - // This should optimally be wrapped inside a transaction, to make sure an error thrown mid-way does not leave the - // database in an inconsistent state, but unfortunately Mongo only supports that when we have a replica set ... + public static synchronized void deleteAccount(Account target) { + // To delete an account, we need to also delete all the other documents in the database that reference the account. + // This should optimally be wrapped inside a transaction, to make sure an error thrown mid-way does not leave the + // database in an inconsistent state, but unfortunately Mongo only supports that when we have a replica set ... - Player player = Grasscutter.getGameServer().getPlayerByAccountId(target.getId()); + Player player = Grasscutter.getGameServer().getPlayerByAccountId(target.getId()); // Close session first if (player != null) { @@ -152,187 +152,187 @@ public final class DatabaseHelper { // Finally, delete the account itself. DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("id", target.getId())).delete(); - } + } - public static List getAllPlayers() { - return DatabaseManager.getGameDatastore().find(Player.class).stream().toList(); - } + public static List getAllPlayers() { + return DatabaseManager.getGameDatastore().find(Player.class).stream().toList(); + } - public static Player getPlayerByUid(int id) { - return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("_id", id)).first(); - } + public static Player getPlayerByUid(int id) { + return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("_id", id)).first(); + } @Deprecated - public static Player getPlayerByAccount(Account account) { - return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("accountId", account.getId())).first(); - } + public static Player getPlayerByAccount(Account account) { + return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("accountId", account.getId())).first(); + } public static Player getPlayerByAccount(Account account, Class playerClass) { return DatabaseManager.getGameDatastore().find(playerClass).filter(Filters.eq("accountId", account.getId())).first(); } - public static boolean checkIfPlayerExists(int uid) { - return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("_id", uid)).count() > 0; - } + public static boolean checkIfPlayerExists(int uid) { + return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("_id", uid)).count() > 0; + } - public static synchronized Player generatePlayerUid(Player character, int reservedId) { - // Check if reserved id - int id; - if (reservedId > 0 && !checkIfPlayerExists(reservedId)) { - id = reservedId; - character.setUid(id); - } else { - do { - id = DatabaseManager.getNextId(character); - } - while (checkIfPlayerExists(id)); - character.setUid(id); - } - // Save to database - DatabaseManager.getGameDatastore().save(character); - return character; - } + public static synchronized Player generatePlayerUid(Player character, int reservedId) { + // Check if reserved id + int id; + if (reservedId > 0 && !checkIfPlayerExists(reservedId)) { + id = reservedId; + character.setUid(id); + } else { + do { + id = DatabaseManager.getNextId(character); + } + while (checkIfPlayerExists(id)); + character.setUid(id); + } + // Save to database + DatabaseManager.getGameDatastore().save(character); + return character; + } - public static synchronized int getNextPlayerId(int reservedId) { - // Check if reserved id - int id; - if (reservedId > 0 && !checkIfPlayerExists(reservedId)) { - id = reservedId; - } else { - do { - id = DatabaseManager.getNextId(Player.class); - } - while (checkIfPlayerExists(id)); - } - return id; - } + public static synchronized int getNextPlayerId(int reservedId) { + // Check if reserved id + int id; + if (reservedId > 0 && !checkIfPlayerExists(reservedId)) { + id = reservedId; + } else { + do { + id = DatabaseManager.getNextId(Player.class); + } + while (checkIfPlayerExists(id)); + } + return id; + } - public static void savePlayer(Player character) { - DatabaseManager.getGameDatastore().save(character); - } + public static void savePlayer(Player character) { + DatabaseManager.getGameDatastore().save(character); + } - public static void saveAvatar(Avatar avatar) { - DatabaseManager.getGameDatastore().save(avatar); - } + public static void saveAvatar(Avatar avatar) { + DatabaseManager.getGameDatastore().save(avatar); + } - public static List getAvatars(Player player) { - return DatabaseManager.getGameDatastore().find(Avatar.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList(); - } + public static List getAvatars(Player player) { + return DatabaseManager.getGameDatastore().find(Avatar.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList(); + } - public static void saveItem(GameItem item) { - DatabaseManager.getGameDatastore().save(item); - } + public static void saveItem(GameItem item) { + DatabaseManager.getGameDatastore().save(item); + } - public static boolean deleteItem(GameItem item) { - DeleteResult result = DatabaseManager.getGameDatastore().delete(item); - return result.wasAcknowledged(); - } + public static boolean deleteItem(GameItem item) { + DeleteResult result = DatabaseManager.getGameDatastore().delete(item); + return result.wasAcknowledged(); + } - public static List getInventoryItems(Player player) { - return DatabaseManager.getGameDatastore().find(GameItem.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList(); - } + public static List getInventoryItems(Player player) { + return DatabaseManager.getGameDatastore().find(GameItem.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList(); + } - public static List getFriends(Player player) { - return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList(); - } + public static List getFriends(Player player) { + return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList(); + } - public static List getReverseFriends(Player player) { - return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.eq("friendId", player.getUid())).stream().toList(); - } + public static List getReverseFriends(Player player) { + return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.eq("friendId", player.getUid())).stream().toList(); + } - public static void saveFriendship(Friendship friendship) { - DatabaseManager.getGameDatastore().save(friendship); - } + public static void saveFriendship(Friendship friendship) { + DatabaseManager.getGameDatastore().save(friendship); + } - public static void deleteFriendship(Friendship friendship) { - DatabaseManager.getGameDatastore().delete(friendship); - } + public static void deleteFriendship(Friendship friendship) { + DatabaseManager.getGameDatastore().delete(friendship); + } - public static Friendship getReverseFriendship(Friendship friendship) { - return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.and( - Filters.eq("ownerId", friendship.getFriendId()), - Filters.eq("friendId", friendship.getOwnerId()) - )).first(); - } + public static Friendship getReverseFriendship(Friendship friendship) { + return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.and( + Filters.eq("ownerId", friendship.getFriendId()), + Filters.eq("friendId", friendship.getOwnerId()) + )).first(); + } - public static List getGachaRecords(int ownerId, int page, int gachaType){ - return getGachaRecords(ownerId, page, gachaType, 10); - } + public static List getGachaRecords(int ownerId, int page, int gachaType) { + return getGachaRecords(ownerId, page, gachaType, 10); + } - public static List getGachaRecords(int ownerId, int page, int gachaType, int pageSize){ - return DatabaseManager.getGameDatastore().find(GachaRecord.class).filter( - Filters.eq("ownerId", ownerId), - Filters.eq("gachaType", gachaType) - ).iterator(new FindOptions() - .sort(Sort.descending("transactionDate")) - .skip(pageSize * page) - .limit(pageSize) - ).toList(); - } + public static List getGachaRecords(int ownerId, int page, int gachaType, int pageSize) { + return DatabaseManager.getGameDatastore().find(GachaRecord.class).filter( + Filters.eq("ownerId", ownerId), + Filters.eq("gachaType", gachaType) + ).iterator(new FindOptions() + .sort(Sort.descending("transactionDate")) + .skip(pageSize * page) + .limit(pageSize) + ).toList(); + } - public static long getGachaRecordsMaxPage(int ownerId, int page, int gachaType){ - return getGachaRecordsMaxPage(ownerId, page, gachaType, 10); - } + public static long getGachaRecordsMaxPage(int ownerId, int page, int gachaType) { + return getGachaRecordsMaxPage(ownerId, page, gachaType, 10); + } - public static long getGachaRecordsMaxPage(int ownerId, int page, int gachaType, int pageSize){ - long count = DatabaseManager.getGameDatastore().find(GachaRecord.class).filter( - Filters.eq("ownerId", ownerId), - Filters.eq("gachaType", gachaType) - ).count(); - return count / 10 + (count % 10 > 0 ? 1 : 0 ); - } + public static long getGachaRecordsMaxPage(int ownerId, int page, int gachaType, int pageSize) { + long count = DatabaseManager.getGameDatastore().find(GachaRecord.class).filter( + Filters.eq("ownerId", ownerId), + Filters.eq("gachaType", gachaType) + ).count(); + return count / 10 + (count % 10 > 0 ? 1 : 0 ); + } - public static void saveGachaRecord(GachaRecord gachaRecord){ - DatabaseManager.getGameDatastore().save(gachaRecord); - } + public static void saveGachaRecord(GachaRecord gachaRecord) { + DatabaseManager.getGameDatastore().save(gachaRecord); + } - public static List getAllMail(Player player) { - return DatabaseManager.getGameDatastore().find(Mail.class).filter(Filters.eq("ownerUid", player.getUid())).stream().toList(); - } + public static List getAllMail(Player player) { + return DatabaseManager.getGameDatastore().find(Mail.class).filter(Filters.eq("ownerUid", player.getUid())).stream().toList(); + } - public static void saveMail(Mail mail) { - DatabaseManager.getGameDatastore().save(mail); - } + public static void saveMail(Mail mail) { + DatabaseManager.getGameDatastore().save(mail); + } - public static boolean deleteMail(Mail mail) { - DeleteResult result = DatabaseManager.getGameDatastore().delete(mail); - return result.wasAcknowledged(); - } + public static boolean deleteMail(Mail mail) { + DeleteResult result = DatabaseManager.getGameDatastore().delete(mail); + return result.wasAcknowledged(); + } - public static List getAllQuests(Player player) { - return DatabaseManager.getGameDatastore().find(GameMainQuest.class).filter(Filters.eq("ownerUid", player.getUid())).stream().toList(); - } + public static List getAllQuests(Player player) { + return DatabaseManager.getGameDatastore().find(GameMainQuest.class).filter(Filters.eq("ownerUid", player.getUid())).stream().toList(); + } - public static void saveQuest(GameMainQuest quest) { - DatabaseManager.getGameDatastore().save(quest); - } + public static void saveQuest(GameMainQuest quest) { + DatabaseManager.getGameDatastore().save(quest); + } - public static boolean deleteQuest(GameMainQuest quest) { - return DatabaseManager.getGameDatastore().delete(quest).wasAcknowledged(); - } + public static boolean deleteQuest(GameMainQuest quest) { + return DatabaseManager.getGameDatastore().delete(quest).wasAcknowledged(); + } - public static GameHome getHomeByUid(int id) { - return DatabaseManager.getGameDatastore().find(GameHome.class).filter(Filters.eq("ownerUid", id)).first(); - } + public static GameHome getHomeByUid(int id) { + return DatabaseManager.getGameDatastore().find(GameHome.class).filter(Filters.eq("ownerUid", id)).first(); + } - public static void saveHome(GameHome gameHome) { - DatabaseManager.getGameDatastore().save(gameHome); - } + public static void saveHome(GameHome gameHome) { + DatabaseManager.getGameDatastore().save(gameHome); + } - public static BattlePassManager loadBattlePass(Player player) { - BattlePassManager manager = DatabaseManager.getGameDatastore().find(BattlePassManager.class).filter(Filters.eq("ownerUid", player.getUid())).first(); - if (manager == null) { - manager = new BattlePassManager(player); - manager.save(); - } else { - manager.setPlayer(player); - } - return manager; - } + public static BattlePassManager loadBattlePass(Player player) { + BattlePassManager manager = DatabaseManager.getGameDatastore().find(BattlePassManager.class).filter(Filters.eq("ownerUid", player.getUid())).first(); + if (manager == null) { + manager = new BattlePassManager(player); + manager.save(); + } else { + manager.setPlayer(player); + } + return manager; + } - public static void saveBattlePass(BattlePassManager manager) { - DatabaseManager.getGameDatastore().save(manager); - } + public static void saveBattlePass(BattlePassManager manager) { + DatabaseManager.getGameDatastore().save(manager); + } public static PlayerActivityData getPlayerActivityData(int uid, int activityId) { return DatabaseManager.getGameDatastore().find(PlayerActivityData.class) diff --git a/src/main/java/emu/grasscutter/game/avatar/Avatar.java b/src/main/java/emu/grasscutter/game/avatar/Avatar.java index 776d01815..81119f35b 100644 --- a/src/main/java/emu/grasscutter/game/avatar/Avatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/Avatar.java @@ -600,7 +600,7 @@ public class Avatar { } } } - + public void addToExtraAbilityEmbryos(String openConfig) { this.addToExtraAbilityEmbryos(openConfig, false); } diff --git a/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java b/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java index bfe145cd2..ee9573911 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java @@ -130,7 +130,7 @@ public class EntityAvatar extends GameEntity { if (!this.isAlive()) { return 0f; } - + float healed = super.heal(amount); if (healed > 0f) { diff --git a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java index b13369ed0..17e724c23 100644 --- a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java +++ b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java @@ -16,66 +16,66 @@ import emu.grasscutter.server.packet.send.PacketGadgetInteractRsp; import emu.grasscutter.utils.Utils; public class GadgetGatherObject extends GadgetContent { - private int itemId; - private boolean isForbidGuest; - - public GadgetGatherObject(EntityGadget gadget) { - super(gadget); - - if (gadget.getSpawnEntry() != null) { - this.itemId = gadget.getSpawnEntry().getGatherItemId(); - } - } - - public int getItemId() { - return this.itemId; - } + private int itemId; + private boolean isForbidGuest; - public boolean isForbidGuest() { - return isForbidGuest; - } + public GadgetGatherObject(EntityGadget gadget) { + super(gadget); - public boolean onInteract(Player player, GadgetInteractReq req) { - // Sanity check - ItemData itemData = GameData.getItemDataMap().get(getItemId()); - if (itemData == null) { - return false; - } + if (gadget.getSpawnEntry() != null) { + this.itemId = gadget.getSpawnEntry().getGatherItemId(); + } + } - GameItem item = new GameItem(itemData, 1); - player.getInventory().addItem(item, ActionReason.Gather); - - getGadget().getScene().broadcastPacket(new PacketGadgetInteractRsp(getGadget(), InteractType.INTERACT_TYPE_GATHER)); + public int getItemId() { + return this.itemId; + } - return true; - } + public boolean isForbidGuest() { + return isForbidGuest; + } - public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) { - GatherGadgetInfo gatherGadgetInfo = GatherGadgetInfo.newBuilder() - .setItemId(this.getItemId()) - .setIsForbidGuest(this.isForbidGuest()) - .build(); + public boolean onInteract(Player player, GadgetInteractReq req) { + // Sanity check + ItemData itemData = GameData.getItemDataMap().get(getItemId()); + if (itemData == null) { + return false; + } - gadgetInfo.setGatherGadget(gatherGadgetInfo); - } + GameItem item = new GameItem(itemData, 1); + player.getInventory().addItem(item, ActionReason.Gather); + + getGadget().getScene().broadcastPacket(new PacketGadgetInteractRsp(getGadget(), InteractType.INTERACT_TYPE_GATHER)); + + return true; + } + + public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) { + GatherGadgetInfo gatherGadgetInfo = GatherGadgetInfo.newBuilder() + .setItemId(this.getItemId()) + .setIsForbidGuest(this.isForbidGuest()) + .build(); + + gadgetInfo.setGatherGadget(gatherGadgetInfo); + } + + public void dropItems(Player player) { + Scene scene = getGadget().getScene(); + int times = Utils.randomRange(1,2); - public void dropItems(Player player) { - Scene scene = getGadget().getScene(); - int times = Utils.randomRange(1,2); - for (int i = 0 ; i < times ; i++) { EntityItem item = new EntityItem( - scene, - player, + scene, + player, GameData.getItemDataMap().get(itemId), getGadget().getPosition().nearby2d(1f).addY(2f), 1, true); - + scene.addEntity(item); } - + scene.killEntity(this.getGadget(), player.getTeamManager().getCurrentAvatarEntity().getId()); // Todo: add record - } + } } diff --git a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherPoint.java b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherPoint.java index aec836f3d..c024b0d02 100644 --- a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherPoint.java +++ b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherPoint.java @@ -14,50 +14,50 @@ import emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo; import emu.grasscutter.utils.Utils; public class GadgetGatherPoint extends GadgetContent { - private int itemId; - private boolean isForbidGuest; - - public GadgetGatherPoint(EntityGadget gadget) { - super(gadget); - - if (gadget.getSpawnEntry() != null) { - this.itemId = gadget.getSpawnEntry().getGatherItemId(); - } else { - GatherData gatherData = GameData.getGatherDataMap().get(gadget.getPointType()); - this.itemId = gatherData.getItemId(); - this.isForbidGuest = gatherData.isForbidGuest(); - } - } - - public int getItemId() { - return this.itemId; - } + private int itemId; + private boolean isForbidGuest; - public boolean isForbidGuest() { - return isForbidGuest; - } + public GadgetGatherPoint(EntityGadget gadget) { + super(gadget); - public boolean onInteract(Player player, GadgetInteractReq req) { - GameItem item = new GameItem(getItemId(), 1); - - player.getInventory().addItem(item, ActionReason.Gather); - - return true; - } + if (gadget.getSpawnEntry() != null) { + this.itemId = gadget.getSpawnEntry().getGatherItemId(); + } else { + GatherData gatherData = GameData.getGatherDataMap().get(gadget.getPointType()); + this.itemId = gatherData.getItemId(); + this.isForbidGuest = gatherData.isForbidGuest(); + } + } - public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) { - GatherGadgetInfo gatherGadgetInfo = GatherGadgetInfo.newBuilder() - .setItemId(this.getItemId()) - .setIsForbidGuest(this.isForbidGuest()) - .build(); + public int getItemId() { + return this.itemId; + } - gadgetInfo.setGatherGadget(gatherGadgetInfo); - } + public boolean isForbidGuest() { + return isForbidGuest; + } + + public boolean onInteract(Player player, GadgetInteractReq req) { + GameItem item = new GameItem(getItemId(), 1); + + player.getInventory().addItem(item, ActionReason.Gather); + + return true; + } + + public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) { + GatherGadgetInfo gatherGadgetInfo = GatherGadgetInfo.newBuilder() + .setItemId(this.getItemId()) + .setIsForbidGuest(this.isForbidGuest()) + .build(); + + gadgetInfo.setGatherGadget(gatherGadgetInfo); + } + + public void dropItems(Player player) { + Scene scene = getGadget().getScene(); + int times = Utils.randomRange(1,2); - public void dropItems(Player player) { - Scene scene = getGadget().getScene(); - int times = Utils.randomRange(1,2); - for (int i = 0 ; i < times ; i++) { EntityItem item = new EntityItem( scene, @@ -69,11 +69,11 @@ public class GadgetGatherPoint extends GadgetContent { .addZ(Utils.randomFloatRange(-1f, 1f)), 1, true); - + scene.addEntity(item); } - + scene.killEntity(this.getGadget(), player.getTeamManager().getCurrentAvatarEntity().getId()); // Todo: add record - } + } } diff --git a/src/main/java/emu/grasscutter/game/home/HomeBlockItem.java b/src/main/java/emu/grasscutter/game/home/HomeBlockItem.java index e43968d30..305f419c0 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeBlockItem.java +++ b/src/main/java/emu/grasscutter/game/home/HomeBlockItem.java @@ -45,7 +45,7 @@ public class HomeBlockItem { .toList(); } - public int calComfort(){ + public int calComfort() { return this.deployFurnitureList.stream() .mapToInt(HomeFurnitureItem::getComfort) .sum(); diff --git a/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java b/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java index 1d30692fa..a3a65ab9e 100644 --- a/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java +++ b/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java @@ -15,11 +15,11 @@ public class MapMark { private int monsterId; private MapMarkFromType mapMarkFromType; private int questId; - + @Deprecated // Morhpia public MapMark() { - this.mapMarkPointType = MapMarkPointType.MAP_MARK_POINT_TYPE_MONSTER; - this.mapMarkFromType = MapMarkFromType.MAP_MARK_FROM_TYPE_MONSTER; + this.mapMarkPointType = MapMarkPointType.MAP_MARK_POINT_TYPE_MONSTER; + this.mapMarkFromType = MapMarkFromType.MAP_MARK_FROM_TYPE_MONSTER; } public MapMark(MapMarkPoint mapMarkPoint) { @@ -35,28 +35,28 @@ public class MapMark { public int getSceneId() { return this.sceneId; } - + public String getName() { return this.name; } - + public Position getPosition() { return this.position; } - + public MapMarkPointType getMapMarkPointType() { return this.mapMarkPointType; } - + public int getMonsterId() { return this.monsterId; } - + public MapMarkFromType getMapMarkFromType() { return this.mapMarkFromType; } - + public int getQuestId() { return this.questId; } -} \ No newline at end of file +} diff --git a/src/main/java/emu/grasscutter/game/quest/GameQuest.java b/src/main/java/emu/grasscutter/game/quest/GameQuest.java index e82d9aaa7..f7dee8fe5 100644 --- a/src/main/java/emu/grasscutter/game/quest/GameQuest.java +++ b/src/main/java/emu/grasscutter/game/quest/GameQuest.java @@ -181,7 +181,7 @@ public class GameQuest { } return false; } - + public void save() { getMainQuest().save(); } diff --git a/src/main/java/emu/grasscutter/game/quest/QuestManager.java b/src/main/java/emu/grasscutter/game/quest/QuestManager.java index 462b83ba8..3d1df8471 100644 --- a/src/main/java/emu/grasscutter/game/quest/QuestManager.java +++ b/src/main/java/emu/grasscutter/game/quest/QuestManager.java @@ -313,20 +313,20 @@ public class QuestManager extends BasePlayerManager { } public void loadFromDatabase() { List quests = DatabaseHelper.getAllQuests(getPlayer()); - + for (GameMainQuest mainQuest : quests) { boolean cancelAdd = false; mainQuest.setOwner(this.getPlayer()); for (GameQuest quest : mainQuest.getChildQuests().values()) { QuestData questConfig = GameData.getQuestDataMap().get(quest.getSubQuestId()); - + if (questConfig == null) { mainQuest.delete(); cancelAdd = true; break; } - + quest.setMainQuest(mainQuest); quest.setConfig(questConfig); } diff --git a/src/main/java/emu/grasscutter/server/http/Router.java b/src/main/java/emu/grasscutter/server/http/Router.java index 1525344be..7388856b3 100644 --- a/src/main/java/emu/grasscutter/server/http/Router.java +++ b/src/main/java/emu/grasscutter/server/http/Router.java @@ -13,7 +13,7 @@ public interface Router { * @param javalin A Javalin instance. */ void applyRoutes(Javalin javalin); - + /** * Applies this handler to all endpoint types * @param javalin A Javalin instance. diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerMusicGameSettleReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerMusicGameSettleReq.java index d57c03ff9..a561cbf89 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerMusicGameSettleReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerMusicGameSettleReq.java @@ -15,12 +15,12 @@ import emu.grasscutter.server.packet.send.PacketMusicGameSettleRsp; @Opcodes(PacketOpcodes.MusicGameSettleReq) public class HandlerMusicGameSettleReq extends PacketHandler { - @Override - public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { - var req = MusicGameSettleReqOuterClass.MusicGameSettleReq.parseFrom(payload); + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + var req = MusicGameSettleReqOuterClass.MusicGameSettleReq.parseFrom(payload); var playerData = session.getPlayer().getActivityManager().getPlayerActivityDataByActivityType(ActivityType.NEW_ACTIVITY_MUSIC_GAME); - if(playerData.isEmpty()){ + if (playerData.isEmpty()) { return; } var handler = (MusicGameActivityHandler) playerData.get().getActivityHandler(); @@ -32,7 +32,7 @@ public class HandlerMusicGameSettleReq extends PacketHandler { // Probably was an issue in 2.8 but was discovered in 3.0 port. // - Benj - /*if(req.getMusicShareId() == 0){ + /*if (req.getMusicShareId() == 0) { session.getPlayer().getActivityManager().triggerWatcher( WatcherTriggerType.TRIGGER_FLEUR_FAIR_MUSIC_GAME_REACH_SCORE, String.valueOf(req.getMusicBasicId()), @@ -48,7 +48,7 @@ public class HandlerMusicGameSettleReq extends PacketHandler { // update activity info session.send(new PacketActivityInfoNotify(handler.toProto(playerData.get()))); - }else{ + }else { handler.setMusicGameCustomBeatmapRecord(playerData.get(), MusicGamePlayerData.CustomBeatmapRecord.of() .musicShareId(req.getMusicShareId()) @@ -58,7 +58,7 @@ public class HandlerMusicGameSettleReq extends PacketHandler { } - session.send(new PacketMusicGameSettleRsp(req.getMusicBasicId(), req.getMusicShareId(), isNewRecord));*/ - } + session.send(new PacketMusicGameSettleRsp(req.getMusicBasicId(), req.getMusicShareId(), isNewRecord));*/ + } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPersonalSceneJumpReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPersonalSceneJumpReq.java index 7396295c6..8922c138b 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPersonalSceneJumpReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPersonalSceneJumpReq.java @@ -13,24 +13,24 @@ import emu.grasscutter.utils.Position; @Opcodes(PacketOpcodes.PersonalSceneJumpReq) public class HandlerPersonalSceneJumpReq extends PacketHandler { - - @Override - public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { - PersonalSceneJumpReq req = PersonalSceneJumpReq.parseFrom(payload); - var player = session.getPlayer(); - // get the scene point - String code = player.getSceneId() + "_" + req.getPointId(); - ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(code); + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + PersonalSceneJumpReq req = PersonalSceneJumpReq.parseFrom(payload); + var player = session.getPlayer(); - if (scenePointEntry != null) { - Position pos = scenePointEntry.getPointData().getTranPos().clone(); // This might not need cloning - int sceneId = scenePointEntry.getPointData().getTranSceneId(); + // get the scene point + String code = player.getSceneId() + "_" + req.getPointId(); + ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(code); - player.getWorld().transferPlayerToScene(player, sceneId, pos); - session.send(new PacketPersonalSceneJumpRsp(sceneId, pos)); - } + if (scenePointEntry != null) { + Position pos = scenePointEntry.getPointData().getTranPos().clone(); // This might not need cloning + int sceneId = scenePointEntry.getPointData().getTranSceneId(); - } + player.getWorld().transferPlayerToScene(player, sceneId, pos); + session.send(new PacketPersonalSceneJumpRsp(sceneId, pos)); + } + + } } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketAddCustomTeamRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketAddCustomTeamRsp.java index 4a73cdd78..54cc022c9 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketAddCustomTeamRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketAddCustomTeamRsp.java @@ -12,7 +12,7 @@ public class PacketAddCustomTeamRsp extends BasePacket { AddCustomTeamRsp proto = AddCustomTeamRsp.newBuilder() .setRetcode(retcode.getNumber()) .build(); - + this.setData(proto); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarTeamUpdateNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarTeamUpdateNotify.java index bc756d990..79be0b104 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarTeamUpdateNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarTeamUpdateNotify.java @@ -11,17 +11,17 @@ import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam; import emu.grasscutter.net.proto.AvatarTeamUpdateNotifyOuterClass.AvatarTeamUpdateNotify; public class PacketAvatarTeamUpdateNotify extends BasePacket { - - public PacketAvatarTeamUpdateNotify(Player player) { - super(PacketOpcodes.AvatarTeamUpdateNotify); - AvatarTeamUpdateNotify.Builder proto = AvatarTeamUpdateNotify.newBuilder(); - - for (Entry entry : player.getTeamManager().getTeams().entrySet()) { - TeamInfo teamInfo = entry.getValue(); - proto.putAvatarTeamMap(entry.getKey(), teamInfo.toProto(player)); - } - - this.setData(proto); - } + public PacketAvatarTeamUpdateNotify(Player player) { + super(PacketOpcodes.AvatarTeamUpdateNotify); + + AvatarTeamUpdateNotify.Builder proto = AvatarTeamUpdateNotify.newBuilder(); + + for (Entry entry : player.getTeamManager().getTeams().entrySet()) { + TeamInfo teamInfo = entry.getValue(); + proto.putAvatarTeamMap(entry.getKey(), teamInfo.toProto(player)); + } + + this.setData(proto); + } } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java index d55d15f9f..ac3a3c4f9 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java @@ -17,33 +17,33 @@ import java.util.List; public class PacketCreateVehicleRsp extends BasePacket { - public PacketCreateVehicleRsp(Player player, int vehicleId, int pointId, Position pos, Position rot) { - super(PacketOpcodes.CreateVehicleRsp); - CreateVehicleRsp.Builder proto = CreateVehicleRsp.newBuilder(); + public PacketCreateVehicleRsp(Player player, int vehicleId, int pointId, Position pos, Position rot) { + super(PacketOpcodes.CreateVehicleRsp); + CreateVehicleRsp.Builder proto = CreateVehicleRsp.newBuilder(); - // Eject vehicle members and Kill previous vehicles if there are any - List previousVehicles = player.getScene().getEntities().values().stream() - .filter(entity -> entity instanceof EntityVehicle - && ((EntityVehicle) entity).getGadgetId() == vehicleId - && ((EntityVehicle) entity).getOwner().equals(player)) - .toList(); + // Eject vehicle members and Kill previous vehicles if there are any + List previousVehicles = player.getScene().getEntities().values().stream() + .filter(entity -> entity instanceof EntityVehicle + && ((EntityVehicle) entity).getGadgetId() == vehicleId + && ((EntityVehicle) entity).getOwner().equals(player)) + .toList(); - previousVehicles.stream().forEach(entity -> { - List vehicleMembers = ((EntityVehicle) entity).getVehicleMembers().stream().toList(); + previousVehicles.stream().forEach(entity -> { + List vehicleMembers = ((EntityVehicle) entity).getVehicleMembers().stream().toList(); - vehicleMembers.stream().forEach(vehicleMember -> { - player.getScene().broadcastPacket(new PacketVehicleInteractRsp(((EntityVehicle) entity), vehicleMember, VehicleInteractTypeOuterClass.VehicleInteractType.VEHICLE_INTERACT_TYPE_OUT)); - }); + vehicleMembers.stream().forEach(vehicleMember -> { + player.getScene().broadcastPacket(new PacketVehicleInteractRsp(((EntityVehicle) entity), vehicleMember, VehicleInteractTypeOuterClass.VehicleInteractType.VEHICLE_INTERACT_TYPE_OUT)); + }); - player.getScene().killEntity(entity, 0); - }); + player.getScene().killEntity(entity, 0); + }); - EntityVehicle vehicle = new EntityVehicle(player.getScene(), player, vehicleId, pointId, pos, rot); - player.getScene().addEntity(vehicle); + EntityVehicle vehicle = new EntityVehicle(player.getScene(), player, vehicleId, pointId, pos, rot); + player.getScene().addEntity(vehicle); - proto.setVehicleId(vehicleId); - proto.setEntityId(vehicle.getId()); + proto.setVehicleId(vehicleId); + proto.setEntityId(vehicle.getId()); - this.setData(proto.build()); - } + this.setData(proto.build()); + } } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketCustomTeamListNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketCustomTeamListNotify.java index 8ae0a62dd..e011b2d91 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketCustomTeamListNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketCustomTeamListNotify.java @@ -28,7 +28,7 @@ public class PacketCustomTeamListNotify extends BasePacket { TeamInfo teamInfo = entry.getValue(); proto.putAvatarTeamMap(entry.getKey(), teamInfo.toProto(player)); } - + this.setData(proto); } } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketRemoveCustomTeamRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketRemoveCustomTeamRsp.java index 8fc511b95..bbfa4b429 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketRemoveCustomTeamRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketRemoveCustomTeamRsp.java @@ -13,7 +13,7 @@ public class PacketRemoveCustomTeamRsp extends BasePacket { .setRetcode(retcode.getNumber()) .setId(id) .build(); - + this.setData(proto); }