diff --git a/src/main/java/emu/grasscutter/game/player/PlayerOpenStateManager.java b/src/main/java/emu/grasscutter/game/player/PlayerOpenStateManager.java index 3bf1bf8cc..562c81ec9 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerOpenStateManager.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerOpenStateManager.java @@ -17,9 +17,11 @@ import static emu.grasscutter.game.props.OpenState.*; @Entity public class PlayerOpenStateManager { - @Transient private Player player; - @Getter private Map openStateMap; + + // Map of all open states that this player has. Do not put default values here. + private Map map; + /* //DO NOT MODIFY. Based on conversation of official server and client, game version 2.7 private static Set newPlayerOpenStates = Set.of(OPEN_STATE_DERIVATIVE_MALL,OPEN_STATE_PHOTOGRAPH,OPEN_STATE_BATTLE_PASS,OPEN_STATE_SHOP_TYPE_GENESISCRYSTAL,OPEN_STATE_SHOP_TYPE_RECOMMANDED, @@ -27,8 +29,10 @@ public class PlayerOpenStateManager { OPEN_STATE_WEAPON_PROMOTE,OPEN_STATE_AVATAR_PROMOTE,OPEN_STATE_AVATAR_TALENT,OPEN_STATE_WEAPON_UPGRADE,OPEN_STATE_RESIN,OPEN_STATE_RELIQUARY_UPGRADE, OPEN_STATE_SHOP_TYPE_VIRTUAL_SHOP,OPEN_STATE_RELIQUARY_PROMOTE); */ - //For development. Remove entry when properly implemented - private static Set devOpenStates = Set.of( + + // For development. Remove entry when properly implemented + // TODO - Set as boolean in OpenState + public static final Set DEV_OPEN_STATES = Set.of( OPEN_STATE_PAIMON, OPEN_STATE_PAIMON_NAVIGATION, OPEN_STATE_AVATAR_PROMOTE, @@ -75,7 +79,6 @@ public class PlayerOpenStateManager { OPEN_STATE_TOWER_FIRST_ENTER, OPEN_STATE_RESIN, OPEN_STATE_LIMIT_REGION_FRESHMEAT, - OPEN_STATE_LIMIT_REGION_GLOBAL, OPEN_STATE_MULTIPLAYER, OPEN_STATE_GUIDE_MOUSEPC, OPEN_STATE_GUIDE_MULTIPLAYER, @@ -114,7 +117,7 @@ public class PlayerOpenStateManager { OPEN_STATE_GUIDE_RELICRESOLVE, OPEN_STATE_GUIDE_GGUIDE, OPEN_STATE_GUIDE_GGUIDE_HINT, - OPEN_STATE_GUIDE_RIGHT_TEAM, // mobile phone only! + OPEN_STATE_GUIDE_QUICK_TEAMMEMBERCHANGE, OPEN_STATE_CITY_REPUATION_MENGDE, OPEN_STATE_CITY_REPUATION_LIYUE, OPEN_STATE_CITY_REPUATION_UI_HINT, @@ -195,10 +198,9 @@ public class PlayerOpenStateManager { OPEN_STATE_MAIL_COLLECT_UNLOCK_RED_POINT, OPEN_STATE_LUMEN_STONE, OPEN_STATE_GUIDE_CRYSTALLINK_BUFF - ); + ); public PlayerOpenStateManager(Player player) { - this.openStateMap = new HashMap<>(); this.player = player; } @@ -206,13 +208,19 @@ public class PlayerOpenStateManager { this.player = player; } - public Integer getOpenState(OpenState openState) { - return this.openStateMap.getOrDefault(openState.getValue(), 0); + public Map getOpenStateMap() { + if (this.map == null) this.map = new HashMap<>(); + return this.map; + } + + public int getOpenState(OpenState openState) { + return this.map.getOrDefault(openState.getValue(), 0); } + public void setOpenState(OpenState openState, Integer value) { - Integer previousValue = this.openStateMap.getOrDefault(openState.getValue(),0); + Integer previousValue = this.map.getOrDefault(openState.getValue(),0); if(!(value == previousValue)) { - this.openStateMap.put(openState.getValue(), value); + this.map.put(openState.getValue(), value); player.getSession().send(new PacketOpenStateChangeNotify(openState.getValue(),value)); } else { Grasscutter.getLogger().debug("Warning: OpenState {} is already set to {}!", openState, value); @@ -225,22 +233,7 @@ public class PlayerOpenStateManager { } } - public void onNewPlayerCreate() { - //newPlayerOpenStates.forEach(os -> this.setOpenState(os, 1)); - //setAllOpenStates(); - devOpenStates.forEach(os -> this.setOpenState(os, 1)); - } public void onPlayerLogin() { - /* - //little hack to give all openStates on second login - if(openStateMap.containsKey(OPEN_STATE_FRESHMAN_GUIDE.getValue())) { - setAllOpenStates(); - } - */ - player.getSession().send(new PacketOpenStateUpdateNotify(player)); - } - - public void setAllOpenStates() { - Stream.of(OpenState.values()).forEach(os -> this.setOpenState(os, 1)); + player.getSession().send(new PacketOpenStateUpdateNotify(this)); } } \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/game/props/OpenState.java b/src/main/java/emu/grasscutter/game/props/OpenState.java index d566e9051..560edf5f2 100644 --- a/src/main/java/emu/grasscutter/game/props/OpenState.java +++ b/src/main/java/emu/grasscutter/game/props/OpenState.java @@ -8,173 +8,186 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; public enum OpenState { - OPEN_STATE_NONE(0), - OPEN_STATE_PAIMON(1), - OPEN_STATE_PAIMON_NAVIGATION(2), - OPEN_STATE_AVATAR_PROMOTE(3), - OPEN_STATE_AVATAR_TALENT(4), - OPEN_STATE_WEAPON_PROMOTE(5), - OPEN_STATE_WEAPON_AWAKEN(6), - OPEN_STATE_QUEST_REMIND(7), - OPEN_STATE_GAME_GUIDE(8), - OPEN_STATE_COOK(9), - OPEN_STATE_WEAPON_UPGRADE(10), - OPEN_STATE_RELIQUARY_UPGRADE(11), - OPEN_STATE_RELIQUARY_PROMOTE(12), - OPEN_STATE_WEAPON_PROMOTE_GUIDE(13), - OPEN_STATE_WEAPON_CHANGE_GUIDE(14), - OPEN_STATE_PLAYER_LVUP_GUIDE(15), - OPEN_STATE_FRESHMAN_GUIDE(16), - OPEN_STATE_SKIP_FRESHMAN_GUIDE(17), - OPEN_STATE_GUIDE_MOVE_CAMERA(18), - OPEN_STATE_GUIDE_SCALE_CAMERA(19), - OPEN_STATE_GUIDE_KEYBOARD(20), - OPEN_STATE_GUIDE_MOVE(21), - OPEN_STATE_GUIDE_JUMP(22), - OPEN_STATE_GUIDE_SPRINT(23), - OPEN_STATE_GUIDE_MAP(24), - OPEN_STATE_GUIDE_ATTACK(25), - OPEN_STATE_GUIDE_FLY(26), - OPEN_STATE_GUIDE_TALENT(27), - OPEN_STATE_GUIDE_RELIC(28), - OPEN_STATE_GUIDE_RELIC_PROM(29), - OPEN_STATE_COMBINE(30), - OPEN_STATE_GACHA(31), - OPEN_STATE_GUIDE_GACHA(32), - OPEN_STATE_GUIDE_TEAM(33), - OPEN_STATE_GUIDE_PROUD(34), - OPEN_STATE_GUIDE_AVATAR_PROMOTE(35), - OPEN_STATE_GUIDE_ADVENTURE_CARD(36), - OPEN_STATE_FORGE(37), - OPEN_STATE_GUIDE_BAG(38), - OPEN_STATE_EXPEDITION(39), - OPEN_STATE_GUIDE_ADVENTURE_DAILYTASK(40), - OPEN_STATE_GUIDE_ADVENTURE_DUNGEON(41), - OPEN_STATE_TOWER(42), - OPEN_STATE_WORLD_STAMINA(43), - OPEN_STATE_TOWER_FIRST_ENTER(44), - OPEN_STATE_RESIN(45), - OPEN_STATE_LIMIT_REGION_FRESHMEAT(47), - OPEN_STATE_LIMIT_REGION_GLOBAL(48), - OPEN_STATE_MULTIPLAYER(49), - OPEN_STATE_GUIDE_MOUSEPC(50), - OPEN_STATE_GUIDE_MULTIPLAYER(51), - OPEN_STATE_GUIDE_DUNGEONREWARD(52), - OPEN_STATE_GUIDE_BLOSSOM(53), - OPEN_STATE_AVATAR_FASHION(54), - OPEN_STATE_PHOTOGRAPH(55), - OPEN_STATE_GUIDE_KSLQUEST(56), - OPEN_STATE_PERSONAL_LINE(57), - OPEN_STATE_GUIDE_PERSONAL_LINE(58), - OPEN_STATE_GUIDE_APPEARANCE(59), - OPEN_STATE_GUIDE_PROCESS(60), - OPEN_STATE_GUIDE_PERSONAL_LINE_KEY(61), - OPEN_STATE_GUIDE_WIDGET(62), - OPEN_STATE_GUIDE_ACTIVITY_SKILL_ASTER(63), - OPEN_STATE_GUIDE_COLDCLIMATE(64), - OPEN_STATE_DERIVATIVE_MALL(65), - OPEN_STATE_GUIDE_EXITMULTIPLAYER(66), - OPEN_STATE_GUIDE_THEATREMACHANICUS_BUILD(67), - OPEN_STATE_GUIDE_THEATREMACHANICUS_REBUILD(68), - OPEN_STATE_GUIDE_THEATREMACHANICUS_CARD(69), - OPEN_STATE_GUIDE_THEATREMACHANICUS_MONSTER(70), - OPEN_STATE_GUIDE_THEATREMACHANICUS_MISSION_CHECK(71), - OPEN_STATE_GUIDE_THEATREMACHANICUS_BUILD_SELECT(72), - OPEN_STATE_GUIDE_THEATREMACHANICUS_CHALLENGE_START(73), - OPEN_STATE_GUIDE_CONVERT(74), - OPEN_STATE_GUIDE_THEATREMACHANICUS_MULTIPLAYER(75), - OPEN_STATE_GUIDE_COOP_TASK(76), - OPEN_STATE_GUIDE_HOMEWORLD_ADEPTIABODE(77), - OPEN_STATE_GUIDE_HOMEWORLD_DEPLOY(78), - OPEN_STATE_GUIDE_CHANNELLERSLAB_EQUIP(79), - OPEN_STATE_GUIDE_CHANNELLERSLAB_MP_SOLUTION(80), - OPEN_STATE_GUIDE_CHANNELLERSLAB_POWER(81), - OPEN_STATE_GUIDE_HIDEANDSEEK_SKILL(82), - OPEN_STATE_GUIDE_HOMEWORLD_MAPLIST(83), - OPEN_STATE_GUIDE_RELICRESOLVE(84), - OPEN_STATE_GUIDE_GGUIDE(85), - OPEN_STATE_GUIDE_GGUIDE_HINT(86), - OPEN_STATE_GUIDE_RIGHT_TEAM(90), // mobile phone only! - OPEN_STATE_CITY_REPUATION_MENGDE(800), - OPEN_STATE_CITY_REPUATION_LIYUE(801), - OPEN_STATE_CITY_REPUATION_UI_HINT(802), - OPEN_STATE_CITY_REPUATION_INAZUMA(803), - OPEN_STATE_SHOP_TYPE_MALL(900), - OPEN_STATE_SHOP_TYPE_RECOMMANDED(901), - OPEN_STATE_SHOP_TYPE_GENESISCRYSTAL(902), - OPEN_STATE_SHOP_TYPE_GIFTPACKAGE(903), - OPEN_STATE_SHOP_TYPE_PAIMON(1001), - OPEN_STATE_SHOP_TYPE_CITY(1002), - OPEN_STATE_SHOP_TYPE_BLACKSMITH(1003), - OPEN_STATE_SHOP_TYPE_GROCERY(1004), - OPEN_STATE_SHOP_TYPE_FOOD(1005), - OPEN_STATE_SHOP_TYPE_SEA_LAMP(1006), - OPEN_STATE_SHOP_TYPE_VIRTUAL_SHOP(1007), - OPEN_STATE_SHOP_TYPE_LIYUE_GROCERY(1008), - OPEN_STATE_SHOP_TYPE_LIYUE_SOUVENIR(1009), - OPEN_STATE_SHOP_TYPE_LIYUE_RESTAURANT(1010), - OPEN_STATE_SHOP_TYPE_INAZUMA_SOUVENIR(1011), - OPEN_STATE_SHOP_TYPE_NPC_TOMOKI(1012), - OPEN_ADVENTURE_MANUAL(1100), - OPEN_ADVENTURE_MANUAL_CITY_MENGDE(1101), - OPEN_ADVENTURE_MANUAL_CITY_LIYUE(1102), - OPEN_ADVENTURE_MANUAL_MONSTER(1103), - OPEN_ADVENTURE_MANUAL_BOSS_DUNGEON(1104), - OPEN_STATE_ACTIVITY_SEALAMP(1200), - OPEN_STATE_ACTIVITY_SEALAMP_TAB2(1201), - OPEN_STATE_ACTIVITY_SEALAMP_TAB3(1202), - OPEN_STATE_BATTLE_PASS(1300), - OPEN_STATE_BATTLE_PASS_ENTRY(1301), - OPEN_STATE_ACTIVITY_CRUCIBLE(1400), - OPEN_STATE_ACTIVITY_NEWBEEBOUNS_OPEN(1401), - OPEN_STATE_ACTIVITY_NEWBEEBOUNS_CLOSE(1402), - OPEN_STATE_ACTIVITY_ENTRY_OPEN(1403), - OPEN_STATE_MENGDE_INFUSEDCRYSTAL(1404), - OPEN_STATE_LIYUE_INFUSEDCRYSTAL(1405), - OPEN_STATE_SNOW_MOUNTAIN_ELDER_TREE(1406), - OPEN_STATE_MIRACLE_RING(1407), - OPEN_STATE_COOP_LINE(1408), - OPEN_STATE_INAZUMA_INFUSEDCRYSTAL(1409), - OPEN_STATE_FISH(1410), - OPEN_STATE_GUIDE_SUMO_TEAM_SKILL(1411), - OPEN_STATE_GUIDE_FISH_RECIPE(1412), - OPEN_STATE_HOME(1500), - OPEN_STATE_ACTIVITY_HOMEWORLD(1501), - OPEN_STATE_ADEPTIABODE(1502), - OPEN_STATE_HOME_AVATAR(1503), - OPEN_STATE_HOME_EDIT(1504), - OPEN_STATE_HOME_EDIT_TIPS(1505), - OPEN_STATE_RELIQUARY_DECOMPOSE(1600), - OPEN_STATE_ACTIVITY_H5(1700), - OPEN_STATE_ORAIONOKAMI(2000), - OPEN_STATE_GUIDE_CHESS_MISSION_CHECK(2001), - OPEN_STATE_GUIDE_CHESS_BUILD(2002), - OPEN_STATE_GUIDE_CHESS_WIND_TOWER_CIRCLE(2003), - OPEN_STATE_GUIDE_CHESS_CARD_SELECT(2004), - OPEN_STATE_INAZUMA_MAINQUEST_FINISHED(2005), - OPEN_STATE_PAIMON_LVINFO(2100), - OPEN_STATE_TELEPORT_HUD(2101), - OPEN_STATE_GUIDE_MAP_UNLOCK(2102), - OPEN_STATE_GUIDE_PAIMON_LVINFO(2103), - OPEN_STATE_GUIDE_AMBORTRANSPORT(2104), - OPEN_STATE_GUIDE_FLY_SECOND(2105), - OPEN_STATE_GUIDE_KAEYA_CLUE(2106), - OPEN_STATE_CAPTURE_CODEX(2107), - OPEN_STATE_ACTIVITY_FISH_OPEN(2200), - OPEN_STATE_ACTIVITY_FISH_CLOSE(2201), - OPEN_STATE_GUIDE_ROGUE_MAP(2205), - OPEN_STATE_GUIDE_ROGUE_RUNE(2206), - OPEN_STATE_GUIDE_BARTENDER_FORMULA(2210), - OPEN_STATE_GUIDE_BARTENDER_MIX(2211), - OPEN_STATE_GUIDE_BARTENDER_CUP(2212), - OPEN_STATE_GUIDE_MAIL_FAVORITES(2400), - OPEN_STATE_GUIDE_POTION_CONFIGURE(2401), - OPEN_STATE_GUIDE_LANV2_FIREWORK(2402), - OPEN_STATE_LOADINGTIPS_ENKANOMIYA(2403), - OPEN_STATE_MICHIAE_CASKET(2500), - OPEN_STATE_MAIL_COLLECT_UNLOCK_RED_POINT(2501), - OPEN_STATE_LUMEN_STONE(2600), - OPEN_STATE_GUIDE_CRYSTALLINK_BUFF(2601); + OPEN_STATE_NONE (0), + OPEN_STATE_PAIMON (1), + OPEN_STATE_PAIMON_NAVIGATION (2), + OPEN_STATE_AVATAR_PROMOTE (3), + OPEN_STATE_AVATAR_TALENT (4), + OPEN_STATE_WEAPON_PROMOTE (5), + OPEN_STATE_WEAPON_AWAKEN (6), + OPEN_STATE_QUEST_REMIND (7), + OPEN_STATE_GAME_GUIDE (8), + OPEN_STATE_COOK (9), + OPEN_STATE_WEAPON_UPGRADE (10), + OPEN_STATE_RELIQUARY_UPGRADE (11), + OPEN_STATE_RELIQUARY_PROMOTE (12), + OPEN_STATE_WEAPON_PROMOTE_GUIDE (13), + OPEN_STATE_WEAPON_CHANGE_GUIDE (14), + OPEN_STATE_PLAYER_LVUP_GUIDE (15), + OPEN_STATE_FRESHMAN_GUIDE (16), + OPEN_STATE_SKIP_FRESHMAN_GUIDE (17), + OPEN_STATE_GUIDE_MOVE_CAMERA (18), + OPEN_STATE_GUIDE_SCALE_CAMERA (19), + OPEN_STATE_GUIDE_KEYBOARD (20), + OPEN_STATE_GUIDE_MOVE (21), + OPEN_STATE_GUIDE_JUMP (22), + OPEN_STATE_GUIDE_SPRINT (23), + OPEN_STATE_GUIDE_MAP (24), + OPEN_STATE_GUIDE_ATTACK (25), + OPEN_STATE_GUIDE_FLY (26), + OPEN_STATE_GUIDE_TALENT (27), + OPEN_STATE_GUIDE_RELIC (28), + OPEN_STATE_GUIDE_RELIC_PROM (29), + OPEN_STATE_COMBINE (30), + OPEN_STATE_GACHA (31), + OPEN_STATE_GUIDE_GACHA (32), + OPEN_STATE_GUIDE_TEAM (33), + OPEN_STATE_GUIDE_PROUD (34), + OPEN_STATE_GUIDE_AVATAR_PROMOTE (35), + OPEN_STATE_GUIDE_ADVENTURE_CARD (36), + OPEN_STATE_FORGE (37), + OPEN_STATE_GUIDE_BAG (38), + OPEN_STATE_EXPEDITION (39), + OPEN_STATE_GUIDE_ADVENTURE_DAILYTASK (40), + OPEN_STATE_GUIDE_ADVENTURE_DUNGEON (41), + OPEN_STATE_TOWER (42), + OPEN_STATE_WORLD_STAMINA (43), + OPEN_STATE_TOWER_FIRST_ENTER (44), + OPEN_STATE_RESIN (45), + OPEN_STATE_LIMIT_REGION_FRESHMEAT (47), + OPEN_STATE_LIMIT_REGION_GLOBAL (48), + OPEN_STATE_MULTIPLAYER (49), + OPEN_STATE_GUIDE_MOUSEPC (50), + OPEN_STATE_GUIDE_MULTIPLAYER (51), + OPEN_STATE_GUIDE_DUNGEONREWARD (52), + OPEN_STATE_GUIDE_BLOSSOM (53), + OPEN_STATE_AVATAR_FASHION (54), + OPEN_STATE_PHOTOGRAPH (55), + OPEN_STATE_GUIDE_KSLQUEST (56), + OPEN_STATE_PERSONAL_LINE (57), + OPEN_STATE_GUIDE_PERSONAL_LINE (58), + OPEN_STATE_GUIDE_APPEARANCE (59), + OPEN_STATE_GUIDE_PROCESS (60), + OPEN_STATE_GUIDE_PERSONAL_LINE_KEY (61), + OPEN_STATE_GUIDE_WIDGET (62), + OPEN_STATE_GUIDE_ACTIVITY_SKILL_ASTER (63), + OPEN_STATE_GUIDE_COLDCLIMATE (64), + OPEN_STATE_DERIVATIVE_MALL (65), + OPEN_STATE_GUIDE_EXITMULTIPLAYER (66), + OPEN_STATE_GUIDE_THEATREMACHANICUS_BUILD (67), + OPEN_STATE_GUIDE_THEATREMACHANICUS_REBUILD (68), + OPEN_STATE_GUIDE_THEATREMACHANICUS_CARD (69), + OPEN_STATE_GUIDE_THEATREMACHANICUS_MONSTER (70), + OPEN_STATE_GUIDE_THEATREMACHANICUS_MISSION_CHECK (71), + OPEN_STATE_GUIDE_THEATREMACHANICUS_BUILD_SELECT (72), + OPEN_STATE_GUIDE_THEATREMACHANICUS_CHALLENGE_START (73), + OPEN_STATE_GUIDE_CONVERT (74), + OPEN_STATE_GUIDE_THEATREMACHANICUS_MULTIPLAYER (75), + OPEN_STATE_GUIDE_COOP_TASK (76), + OPEN_STATE_GUIDE_HOMEWORLD_ADEPTIABODE (77), + OPEN_STATE_GUIDE_HOMEWORLD_DEPLOY (78), + OPEN_STATE_GUIDE_CHANNELLERSLAB_EQUIP (79), + OPEN_STATE_GUIDE_CHANNELLERSLAB_MP_SOLUTION (80), + OPEN_STATE_GUIDE_CHANNELLERSLAB_POWER (81), + OPEN_STATE_GUIDE_HIDEANDSEEK_SKILL (82), + OPEN_STATE_GUIDE_HOMEWORLD_MAPLIST (83), + OPEN_STATE_GUIDE_RELICRESOLVE (84), + OPEN_STATE_GUIDE_GGUIDE (85), + OPEN_STATE_GUIDE_GGUIDE_HINT (86), + OPEN_STATE_GUIDE_CHANNELLERSLAB_EQUIP_V2 (87), + OPEN_STATE_GUIDE_CHANNELLERSLAB_MP_SOLUTION_V2 (88), + OPEN_STATE_GUIDE_CHANNELLERSLAB_POWER_V2 (89), + OPEN_STATE_GUIDE_QUICK_TEAMMEMBERCHANGE (90), // Mobile only + OPEN_STATE_GGUIDE_FIRSTSHOW (91), + OPEN_STATE_GGUIDE_MAINPAGE_ENTRY_DISAPPEAR (92), + OPEN_STATE_CITY_REPUATION_MENGDE (800), + OPEN_STATE_CITY_REPUATION_LIYUE (801), + OPEN_STATE_CITY_REPUATION_UI_HINT (802), + OPEN_STATE_CITY_REPUATION_INAZUMA (803), + OPEN_STATE_SHOP_TYPE_MALL (900), + OPEN_STATE_SHOP_TYPE_RECOMMANDED (901), + OPEN_STATE_SHOP_TYPE_GENESISCRYSTAL (902), + OPEN_STATE_SHOP_TYPE_GIFTPACKAGE (903), + OPEN_STATE_SHOP_TYPE_PAIMON (1001), + OPEN_STATE_SHOP_TYPE_CITY (1002), + OPEN_STATE_SHOP_TYPE_BLACKSMITH (1003), + OPEN_STATE_SHOP_TYPE_GROCERY (1004), + OPEN_STATE_SHOP_TYPE_FOOD (1005), + OPEN_STATE_SHOP_TYPE_SEA_LAMP (1006), + OPEN_STATE_SHOP_TYPE_VIRTUAL_SHOP (1007), + OPEN_STATE_SHOP_TYPE_LIYUE_GROCERY (1008), + OPEN_STATE_SHOP_TYPE_LIYUE_SOUVENIR (1009), + OPEN_STATE_SHOP_TYPE_LIYUE_RESTAURANT (1010), + OPEN_STATE_SHOP_TYPE_INAZUMA_SOUVENIR (1011), + OPEN_STATE_SHOP_TYPE_NPC_TOMOKI (1012), + OPEN_STATE_SHOP_TYPE_INAZUMA_SOUVENIR_BLACK_BAR (1013), + OPEN_ADVENTURE_MANUAL (1100), + OPEN_ADVENTURE_MANUAL_CITY_MENGDE (1101), + OPEN_ADVENTURE_MANUAL_CITY_LIYUE (1102), + OPEN_ADVENTURE_MANUAL_MONSTER (1103), + OPEN_ADVENTURE_MANUAL_BOSS_DUNGEON (1104), + OPEN_STATE_ACTIVITY_SEALAMP (1200), + OPEN_STATE_ACTIVITY_SEALAMP_TAB2 (1201), + OPEN_STATE_ACTIVITY_SEALAMP_TAB3 (1202), + OPEN_STATE_BATTLE_PASS (1300), + OPEN_STATE_BATTLE_PASS_ENTRY (1301), + OPEN_STATE_ACTIVITY_CRUCIBLE (1400), + OPEN_STATE_ACTIVITY_NEWBEEBOUNS_OPEN (1401), + OPEN_STATE_ACTIVITY_NEWBEEBOUNS_CLOSE (1402), + OPEN_STATE_ACTIVITY_ENTRY_OPEN (1403), + OPEN_STATE_MENGDE_INFUSEDCRYSTAL (1404), + OPEN_STATE_LIYUE_INFUSEDCRYSTAL (1405), + OPEN_STATE_SNOW_MOUNTAIN_ELDER_TREE (1406), + OPEN_STATE_MIRACLE_RING (1407), + OPEN_STATE_COOP_LINE (1408), + OPEN_STATE_INAZUMA_INFUSEDCRYSTAL (1409), + OPEN_STATE_FISH (1410), + OPEN_STATE_GUIDE_SUMO_TEAM_SKILL (1411), + OPEN_STATE_GUIDE_FISH_RECIPE (1412), + OPEN_STATE_HOME (1500), + OPEN_STATE_ACTIVITY_HOMEWORLD (1501), + OPEN_STATE_ADEPTIABODE (1502), + OPEN_STATE_HOME_AVATAR (1503), + OPEN_STATE_HOME_EDIT (1504), + OPEN_STATE_HOME_EDIT_TIPS (1505), + OPEN_STATE_RELIQUARY_DECOMPOSE (1600), + OPEN_STATE_ACTIVITY_H5 (1700), + OPEN_STATE_ORAIONOKAMI (2000), + OPEN_STATE_GUIDE_CHESS_MISSION_CHECK (2001), + OPEN_STATE_GUIDE_CHESS_BUILD (2002), + OPEN_STATE_GUIDE_CHESS_WIND_TOWER_CIRCLE (2003), + OPEN_STATE_GUIDE_CHESS_CARD_SELECT (2004), + OPEN_STATE_INAZUMA_MAINQUEST_FINISHED (2005), + OPEN_STATE_PAIMON_LVINFO (2100), + OPEN_STATE_TELEPORT_HUD (2101), + OPEN_STATE_GUIDE_MAP_UNLOCK (2102), + OPEN_STATE_GUIDE_PAIMON_LVINFO (2103), + OPEN_STATE_GUIDE_AMBORTRANSPORT (2104), + OPEN_STATE_GUIDE_FLY_SECOND (2105), + OPEN_STATE_GUIDE_KAEYA_CLUE (2106), + OPEN_STATE_CAPTURE_CODEX (2107), + OPEN_STATE_ACTIVITY_FISH_OPEN (2200), + OPEN_STATE_ACTIVITY_FISH_CLOSE (2201), + OPEN_STATE_GUIDE_ROGUE_MAP (2205), + OPEN_STATE_GUIDE_ROGUE_RUNE (2206), + OPEN_STATE_GUIDE_BARTENDER_FORMULA (2210), + OPEN_STATE_GUIDE_BARTENDER_MIX (2211), + OPEN_STATE_GUIDE_BARTENDER_CUP (2212), + OPEN_STATE_GUIDE_MAIL_FAVORITES (2400), + OPEN_STATE_GUIDE_POTION_CONFIGURE (2401), + OPEN_STATE_GUIDE_LANV2_FIREWORK (2402), + OPEN_STATE_LOADINGTIPS_ENKANOMIYA (2403), + OPEN_STATE_MICHIAE_CASKET (2500), + OPEN_STATE_MAIL_COLLECT_UNLOCK_RED_POINT (2501), + OPEN_STATE_LUMEN_STONE (2600), + OPEN_STATE_GUIDE_CRYSTALLINK_BUFF (2601), + OPEN_STATE_GUIDE_MUSIC_GAME_V3 (2700), + OPEN_STATE_GUIDE_MUSIC_GAME_V3_REAL_TIME_EDIT (2701), + OPEN_STATE_GUIDE_MUSIC_GAME_V3_TIMELINE_EDIT (2702), + OPEN_STATE_GUIDE_MUSIC_GAME_V3_SETTING (2703), + OPEN_STATE_GUIDE_ROBOTGACHA (2704), + OPEN_STATE_GUIDE_FRAGILE_RESIN (2800), + OPEN_ADVENTURE_MANUAL_EDUCATION (2801); private final int value; private static final Int2ObjectMap map = new Int2ObjectOpenHashMap<>(); diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerLoginReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerLoginReq.java index 4578e7d1f..45810b16c 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerLoginReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerLoginReq.java @@ -40,8 +40,6 @@ public class HandlerPlayerLoginReq extends PacketHandler { // Show opening cutscene if player has no avatars if (player.getAvatars().getAvatarCount() == 0) { - // Set New Player OpenStates - player.getOpenStateManager().onNewPlayerCreate(); // Pick character session.setState(SessionState.PICKING_CHARACTER); session.send(new BasePacket(PacketOpcodes.DoSetPlayerBornDataNotify)); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketOpenStateUpdateNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketOpenStateUpdateNotify.java index 62ec01ea7..dc18ba836 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketOpenStateUpdateNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketOpenStateUpdateNotify.java @@ -1,25 +1,31 @@ package emu.grasscutter.server.packet.send; -import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.PlayerOpenStateManager; import emu.grasscutter.game.props.OpenState; import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.OpenStateUpdateNotifyOuterClass.OpenStateUpdateNotify; -import java.util.Map; /* Must be sent on login for openStates to work Tells the client to update its openStateMap for the keys sent. value is irrelevant */ public class PacketOpenStateUpdateNotify extends BasePacket { - public PacketOpenStateUpdateNotify(Player player) { + public PacketOpenStateUpdateNotify(PlayerOpenStateManager manager) { super(PacketOpcodes.OpenStateUpdateNotify); OpenStateUpdateNotify.Builder proto = OpenStateUpdateNotify.newBuilder(); - proto.putAllOpenStateMap(player.getOpenStateManager().getOpenStateMap()).build(); + for (OpenState state : OpenState.values()) { + // If the player has an open state stored in their map, then it would always override any default value + if (manager.getOpenStateMap().containsKey(state.getValue())) { + proto.putOpenStateMap(state.getValue(), manager.getOpenState(state)); + } else if (PlayerOpenStateManager.DEV_OPEN_STATES.contains(state)) { + // Add default value here. TODO properly put default values somewhere + proto.putOpenStateMap(state.getValue(), 1); + } + } this.setData(proto); }