From 6b52f0649a6ebcb8ca16fabe47b0ecbd20e64cbd Mon Sep 17 00:00:00 2001 From: Melledy <121644117+Melledy@users.noreply.github.com> Date: Sun, 7 Jan 2024 06:50:31 -0800 Subject: [PATCH] General refactoring --- .../GroupStateChangeCsReqOuterClass.java | 71 ++++++++++--------- .../GroupStateChangeScNotifyOuterClass.java | 70 +++++++++--------- .../GroupStateChangeScRspOuterClass.java | 71 ++++++++++--------- .../emu/lunarcore/command/CommandArgs.java | 4 +- .../emu/lunarcore/data/config/FloorInfo.java | 3 - .../emu/lunarcore/data/excel/CocoonExcel.java | 4 ++ .../emu/lunarcore/game/battle/Battle.java | 31 +++++--- .../lunarcore/game/battle/BattleService.java | 6 ++ .../emu/lunarcore/game/player/Player.java | 24 +++++-- .../game/player/lineup/PlayerTempLineup.java | 20 ++++++ .../lunarcore/game/rogue/RogueInstance.java | 2 +- .../game/scene/entity/EntityProp.java | 5 ++ ...riggerPuzzleCompassWayPointController.java | 32 --------- .../recv/HandlerGroupStateChangeCsReq.java | 6 +- .../send/PacketGroupStateChangeScNotify.java | 4 +- .../send/PacketGroupStateChangeScRsp.java | 2 +- 16 files changed, 192 insertions(+), 163 deletions(-) create mode 100644 src/main/java/emu/lunarcore/game/player/lineup/PlayerTempLineup.java delete mode 100644 src/main/java/emu/lunarcore/game/scene/triggers/TriggerPuzzleCompassWayPointController.java diff --git a/src/generated/main/emu/lunarcore/proto/GroupStateChangeCsReqOuterClass.java b/src/generated/main/emu/lunarcore/proto/GroupStateChangeCsReqOuterClass.java index 210b8a00c..dba35092e 100644 --- a/src/generated/main/emu/lunarcore/proto/GroupStateChangeCsReqOuterClass.java +++ b/src/generated/main/emu/lunarcore/proto/GroupStateChangeCsReqOuterClass.java @@ -19,9 +19,9 @@ public static final class GroupStateChangeCsReq extends ProtoMessageoptional .GroupStateInfo group_info = 6; + * optional .GroupStateInfo group_state_info = 6; */ - private final GroupStateInfoOuterClass.GroupStateInfo groupInfo = GroupStateInfoOuterClass.GroupStateInfo.newInstance(); + private final GroupStateInfoOuterClass.GroupStateInfo groupStateInfo = GroupStateInfoOuterClass.GroupStateInfo.newInstance(); private GroupStateChangeCsReq() { } @@ -34,39 +34,39 @@ public static GroupStateChangeCsReq newInstance() { } /** - * optional .GroupStateInfo group_info = 6; - * @return whether the groupInfo field is set + * optional .GroupStateInfo group_state_info = 6; + * @return whether the groupStateInfo field is set */ - public boolean hasGroupInfo() { + public boolean hasGroupStateInfo() { return (bitField0_ & 0x00000001) != 0; } /** - * optional .GroupStateInfo group_info = 6; + * optional .GroupStateInfo group_state_info = 6; * @return this */ - public GroupStateChangeCsReq clearGroupInfo() { + public GroupStateChangeCsReq clearGroupStateInfo() { bitField0_ &= ~0x00000001; - groupInfo.clear(); + groupStateInfo.clear(); return this; } /** - * optional .GroupStateInfo group_info = 6; + * optional .GroupStateInfo group_state_info = 6; * * This method returns the internal storage object without modifying any has state. * The returned object should not be modified and be treated as read-only. * - * Use {@link #getMutableGroupInfo()} if you want to modify it. + * Use {@link #getMutableGroupStateInfo()} if you want to modify it. * * @return internal storage object for reading */ - public GroupStateInfoOuterClass.GroupStateInfo getGroupInfo() { - return groupInfo; + public GroupStateInfoOuterClass.GroupStateInfo getGroupStateInfo() { + return groupStateInfo; } /** - * optional .GroupStateInfo group_info = 6; + * optional .GroupStateInfo group_state_info = 6; * * This method returns the internal storage object and sets the corresponding * has state. The returned object will become part of this message and its @@ -74,19 +74,20 @@ public GroupStateInfoOuterClass.GroupStateInfo getGroupInfo() { * * @return internal storage object for modifications */ - public GroupStateInfoOuterClass.GroupStateInfo getMutableGroupInfo() { + public GroupStateInfoOuterClass.GroupStateInfo getMutableGroupStateInfo() { bitField0_ |= 0x00000001; - return groupInfo; + return groupStateInfo; } /** - * optional .GroupStateInfo group_info = 6; - * @param value the groupInfo to set + * optional .GroupStateInfo group_state_info = 6; + * @param value the groupStateInfo to set * @return this */ - public GroupStateChangeCsReq setGroupInfo(final GroupStateInfoOuterClass.GroupStateInfo value) { + public GroupStateChangeCsReq setGroupStateInfo( + final GroupStateInfoOuterClass.GroupStateInfo value) { bitField0_ |= 0x00000001; - groupInfo.copyFrom(value); + groupStateInfo.copyFrom(value); return this; } @@ -95,7 +96,7 @@ public GroupStateChangeCsReq copyFrom(final GroupStateChangeCsReq other) { cachedSize = other.cachedSize; if ((bitField0_ | other.bitField0_) != 0) { bitField0_ = other.bitField0_; - groupInfo.copyFrom(other.groupInfo); + groupStateInfo.copyFrom(other.groupStateInfo); } return this; } @@ -106,8 +107,8 @@ public GroupStateChangeCsReq mergeFrom(final GroupStateChangeCsReq other) { return this; } cachedSize = -1; - if (other.hasGroupInfo()) { - getMutableGroupInfo().mergeFrom(other.groupInfo); + if (other.hasGroupStateInfo()) { + getMutableGroupStateInfo().mergeFrom(other.groupStateInfo); } return this; } @@ -119,7 +120,7 @@ public GroupStateChangeCsReq clear() { } cachedSize = -1; bitField0_ = 0; - groupInfo.clear(); + groupStateInfo.clear(); return this; } @@ -130,7 +131,7 @@ public GroupStateChangeCsReq clearQuick() { } cachedSize = -1; bitField0_ = 0; - groupInfo.clearQuick(); + groupStateInfo.clearQuick(); return this; } @@ -144,14 +145,14 @@ public boolean equals(Object o) { } GroupStateChangeCsReq other = (GroupStateChangeCsReq) o; return bitField0_ == other.bitField0_ - && (!hasGroupInfo() || groupInfo.equals(other.groupInfo)); + && (!hasGroupStateInfo() || groupStateInfo.equals(other.groupStateInfo)); } @Override public void writeTo(final ProtoSink output) throws IOException { if ((bitField0_ & 0x00000001) != 0) { output.writeRawByte((byte) 50); - output.writeMessageNoTag(groupInfo); + output.writeMessageNoTag(groupStateInfo); } } @@ -159,7 +160,7 @@ public void writeTo(final ProtoSink output) throws IOException { protected int computeSerializedSize() { int size = 0; if ((bitField0_ & 0x00000001) != 0) { - size += 1 + ProtoSink.computeMessageSizeNoTag(groupInfo); + size += 1 + ProtoSink.computeMessageSizeNoTag(groupStateInfo); } return size; } @@ -172,8 +173,8 @@ public GroupStateChangeCsReq mergeFrom(final ProtoSource input) throws IOExcepti while (true) { switch (tag) { case 50: { - // groupInfo - input.readMessage(groupInfo); + // groupStateInfo + input.readMessage(groupStateInfo); bitField0_ |= 0x00000001; tag = input.readTag(); if (tag != 0) { @@ -198,7 +199,7 @@ public GroupStateChangeCsReq mergeFrom(final ProtoSource input) throws IOExcepti public void writeTo(final JsonSink output) throws IOException { output.beginObject(); if ((bitField0_ & 0x00000001) != 0) { - output.writeMessage(FieldNames.groupInfo, groupInfo); + output.writeMessage(FieldNames.groupStateInfo, groupStateInfo); } output.endObject(); } @@ -210,11 +211,11 @@ public GroupStateChangeCsReq mergeFrom(final JsonSource input) throws IOExceptio } while (!input.isAtEnd()) { switch (input.readFieldHash()) { - case -1483311155: - case 1282170478: { - if (input.isAtField(FieldNames.groupInfo)) { + case 1415312672: + case 1198732636: { + if (input.isAtField(FieldNames.groupStateInfo)) { if (!input.trySkipNullValue()) { - input.readMessage(groupInfo); + input.readMessage(groupStateInfo); bitField0_ |= 0x00000001; } } else { @@ -275,7 +276,7 @@ public GroupStateChangeCsReq create() { * Contains name constants used for serializing JSON */ static class FieldNames { - static final FieldName groupInfo = FieldName.forField("groupInfo", "group_info"); + static final FieldName groupStateInfo = FieldName.forField("groupStateInfo", "group_state_info"); } } } diff --git a/src/generated/main/emu/lunarcore/proto/GroupStateChangeScNotifyOuterClass.java b/src/generated/main/emu/lunarcore/proto/GroupStateChangeScNotifyOuterClass.java index 7453478d6..bdd29e77e 100644 --- a/src/generated/main/emu/lunarcore/proto/GroupStateChangeScNotifyOuterClass.java +++ b/src/generated/main/emu/lunarcore/proto/GroupStateChangeScNotifyOuterClass.java @@ -19,9 +19,9 @@ public static final class GroupStateChangeScNotify extends ProtoMessageoptional .GroupStateInfo group_info = 8; + * optional .GroupStateInfo group_state_info = 8; */ - private final GroupStateInfoOuterClass.GroupStateInfo groupInfo = GroupStateInfoOuterClass.GroupStateInfo.newInstance(); + private final GroupStateInfoOuterClass.GroupStateInfo groupStateInfo = GroupStateInfoOuterClass.GroupStateInfo.newInstance(); private GroupStateChangeScNotify() { } @@ -34,39 +34,39 @@ public static GroupStateChangeScNotify newInstance() { } /** - * optional .GroupStateInfo group_info = 8; - * @return whether the groupInfo field is set + * optional .GroupStateInfo group_state_info = 8; + * @return whether the groupStateInfo field is set */ - public boolean hasGroupInfo() { + public boolean hasGroupStateInfo() { return (bitField0_ & 0x00000001) != 0; } /** - * optional .GroupStateInfo group_info = 8; + * optional .GroupStateInfo group_state_info = 8; * @return this */ - public GroupStateChangeScNotify clearGroupInfo() { + public GroupStateChangeScNotify clearGroupStateInfo() { bitField0_ &= ~0x00000001; - groupInfo.clear(); + groupStateInfo.clear(); return this; } /** - * optional .GroupStateInfo group_info = 8; + * optional .GroupStateInfo group_state_info = 8; * * This method returns the internal storage object without modifying any has state. * The returned object should not be modified and be treated as read-only. * - * Use {@link #getMutableGroupInfo()} if you want to modify it. + * Use {@link #getMutableGroupStateInfo()} if you want to modify it. * * @return internal storage object for reading */ - public GroupStateInfoOuterClass.GroupStateInfo getGroupInfo() { - return groupInfo; + public GroupStateInfoOuterClass.GroupStateInfo getGroupStateInfo() { + return groupStateInfo; } /** - * optional .GroupStateInfo group_info = 8; + * optional .GroupStateInfo group_state_info = 8; * * This method returns the internal storage object and sets the corresponding * has state. The returned object will become part of this message and its @@ -74,20 +74,20 @@ public GroupStateInfoOuterClass.GroupStateInfo getGroupInfo() { * * @return internal storage object for modifications */ - public GroupStateInfoOuterClass.GroupStateInfo getMutableGroupInfo() { + public GroupStateInfoOuterClass.GroupStateInfo getMutableGroupStateInfo() { bitField0_ |= 0x00000001; - return groupInfo; + return groupStateInfo; } /** - * optional .GroupStateInfo group_info = 8; - * @param value the groupInfo to set + * optional .GroupStateInfo group_state_info = 8; + * @param value the groupStateInfo to set * @return this */ - public GroupStateChangeScNotify setGroupInfo( + public GroupStateChangeScNotify setGroupStateInfo( final GroupStateInfoOuterClass.GroupStateInfo value) { bitField0_ |= 0x00000001; - groupInfo.copyFrom(value); + groupStateInfo.copyFrom(value); return this; } @@ -96,7 +96,7 @@ public GroupStateChangeScNotify copyFrom(final GroupStateChangeScNotify other) { cachedSize = other.cachedSize; if ((bitField0_ | other.bitField0_) != 0) { bitField0_ = other.bitField0_; - groupInfo.copyFrom(other.groupInfo); + groupStateInfo.copyFrom(other.groupStateInfo); } return this; } @@ -107,8 +107,8 @@ public GroupStateChangeScNotify mergeFrom(final GroupStateChangeScNotify other) return this; } cachedSize = -1; - if (other.hasGroupInfo()) { - getMutableGroupInfo().mergeFrom(other.groupInfo); + if (other.hasGroupStateInfo()) { + getMutableGroupStateInfo().mergeFrom(other.groupStateInfo); } return this; } @@ -120,7 +120,7 @@ public GroupStateChangeScNotify clear() { } cachedSize = -1; bitField0_ = 0; - groupInfo.clear(); + groupStateInfo.clear(); return this; } @@ -131,7 +131,7 @@ public GroupStateChangeScNotify clearQuick() { } cachedSize = -1; bitField0_ = 0; - groupInfo.clearQuick(); + groupStateInfo.clearQuick(); return this; } @@ -145,14 +145,14 @@ public boolean equals(Object o) { } GroupStateChangeScNotify other = (GroupStateChangeScNotify) o; return bitField0_ == other.bitField0_ - && (!hasGroupInfo() || groupInfo.equals(other.groupInfo)); + && (!hasGroupStateInfo() || groupStateInfo.equals(other.groupStateInfo)); } @Override public void writeTo(final ProtoSink output) throws IOException { if ((bitField0_ & 0x00000001) != 0) { output.writeRawByte((byte) 66); - output.writeMessageNoTag(groupInfo); + output.writeMessageNoTag(groupStateInfo); } } @@ -160,7 +160,7 @@ public void writeTo(final ProtoSink output) throws IOException { protected int computeSerializedSize() { int size = 0; if ((bitField0_ & 0x00000001) != 0) { - size += 1 + ProtoSink.computeMessageSizeNoTag(groupInfo); + size += 1 + ProtoSink.computeMessageSizeNoTag(groupStateInfo); } return size; } @@ -173,8 +173,8 @@ public GroupStateChangeScNotify mergeFrom(final ProtoSource input) throws IOExce while (true) { switch (tag) { case 66: { - // groupInfo - input.readMessage(groupInfo); + // groupStateInfo + input.readMessage(groupStateInfo); bitField0_ |= 0x00000001; tag = input.readTag(); if (tag != 0) { @@ -199,7 +199,7 @@ public GroupStateChangeScNotify mergeFrom(final ProtoSource input) throws IOExce public void writeTo(final JsonSink output) throws IOException { output.beginObject(); if ((bitField0_ & 0x00000001) != 0) { - output.writeMessage(FieldNames.groupInfo, groupInfo); + output.writeMessage(FieldNames.groupStateInfo, groupStateInfo); } output.endObject(); } @@ -211,11 +211,11 @@ public GroupStateChangeScNotify mergeFrom(final JsonSource input) throws IOExcep } while (!input.isAtEnd()) { switch (input.readFieldHash()) { - case -1483311155: - case 1282170478: { - if (input.isAtField(FieldNames.groupInfo)) { + case 1415312672: + case 1198732636: { + if (input.isAtField(FieldNames.groupStateInfo)) { if (!input.trySkipNullValue()) { - input.readMessage(groupInfo); + input.readMessage(groupStateInfo); bitField0_ |= 0x00000001; } } else { @@ -276,7 +276,7 @@ public GroupStateChangeScNotify create() { * Contains name constants used for serializing JSON */ static class FieldNames { - static final FieldName groupInfo = FieldName.forField("groupInfo", "group_info"); + static final FieldName groupStateInfo = FieldName.forField("groupStateInfo", "group_state_info"); } } } diff --git a/src/generated/main/emu/lunarcore/proto/GroupStateChangeScRspOuterClass.java b/src/generated/main/emu/lunarcore/proto/GroupStateChangeScRspOuterClass.java index c2473826a..d6be4f149 100644 --- a/src/generated/main/emu/lunarcore/proto/GroupStateChangeScRspOuterClass.java +++ b/src/generated/main/emu/lunarcore/proto/GroupStateChangeScRspOuterClass.java @@ -24,9 +24,9 @@ public static final class GroupStateChangeScRsp extends ProtoMessageoptional .GroupStateInfo group_info = 3; + * optional .GroupStateInfo group_state_info = 3; */ - private final GroupStateInfoOuterClass.GroupStateInfo groupInfo = GroupStateInfoOuterClass.GroupStateInfo.newInstance(); + private final GroupStateInfoOuterClass.GroupStateInfo groupStateInfo = GroupStateInfoOuterClass.GroupStateInfo.newInstance(); private GroupStateChangeScRsp() { } @@ -76,39 +76,39 @@ public GroupStateChangeScRsp setRetcode(final int value) { } /** - * optional .GroupStateInfo group_info = 3; - * @return whether the groupInfo field is set + * optional .GroupStateInfo group_state_info = 3; + * @return whether the groupStateInfo field is set */ - public boolean hasGroupInfo() { + public boolean hasGroupStateInfo() { return (bitField0_ & 0x00000002) != 0; } /** - * optional .GroupStateInfo group_info = 3; + * optional .GroupStateInfo group_state_info = 3; * @return this */ - public GroupStateChangeScRsp clearGroupInfo() { + public GroupStateChangeScRsp clearGroupStateInfo() { bitField0_ &= ~0x00000002; - groupInfo.clear(); + groupStateInfo.clear(); return this; } /** - * optional .GroupStateInfo group_info = 3; + * optional .GroupStateInfo group_state_info = 3; * * This method returns the internal storage object without modifying any has state. * The returned object should not be modified and be treated as read-only. * - * Use {@link #getMutableGroupInfo()} if you want to modify it. + * Use {@link #getMutableGroupStateInfo()} if you want to modify it. * * @return internal storage object for reading */ - public GroupStateInfoOuterClass.GroupStateInfo getGroupInfo() { - return groupInfo; + public GroupStateInfoOuterClass.GroupStateInfo getGroupStateInfo() { + return groupStateInfo; } /** - * optional .GroupStateInfo group_info = 3; + * optional .GroupStateInfo group_state_info = 3; * * This method returns the internal storage object and sets the corresponding * has state. The returned object will become part of this message and its @@ -116,19 +116,20 @@ public GroupStateInfoOuterClass.GroupStateInfo getGroupInfo() { * * @return internal storage object for modifications */ - public GroupStateInfoOuterClass.GroupStateInfo getMutableGroupInfo() { + public GroupStateInfoOuterClass.GroupStateInfo getMutableGroupStateInfo() { bitField0_ |= 0x00000002; - return groupInfo; + return groupStateInfo; } /** - * optional .GroupStateInfo group_info = 3; - * @param value the groupInfo to set + * optional .GroupStateInfo group_state_info = 3; + * @param value the groupStateInfo to set * @return this */ - public GroupStateChangeScRsp setGroupInfo(final GroupStateInfoOuterClass.GroupStateInfo value) { + public GroupStateChangeScRsp setGroupStateInfo( + final GroupStateInfoOuterClass.GroupStateInfo value) { bitField0_ |= 0x00000002; - groupInfo.copyFrom(value); + groupStateInfo.copyFrom(value); return this; } @@ -138,7 +139,7 @@ public GroupStateChangeScRsp copyFrom(final GroupStateChangeScRsp other) { if ((bitField0_ | other.bitField0_) != 0) { bitField0_ = other.bitField0_; retcode = other.retcode; - groupInfo.copyFrom(other.groupInfo); + groupStateInfo.copyFrom(other.groupStateInfo); } return this; } @@ -152,8 +153,8 @@ public GroupStateChangeScRsp mergeFrom(final GroupStateChangeScRsp other) { if (other.hasRetcode()) { setRetcode(other.retcode); } - if (other.hasGroupInfo()) { - getMutableGroupInfo().mergeFrom(other.groupInfo); + if (other.hasGroupStateInfo()) { + getMutableGroupStateInfo().mergeFrom(other.groupStateInfo); } return this; } @@ -166,7 +167,7 @@ public GroupStateChangeScRsp clear() { cachedSize = -1; bitField0_ = 0; retcode = 0; - groupInfo.clear(); + groupStateInfo.clear(); return this; } @@ -177,7 +178,7 @@ public GroupStateChangeScRsp clearQuick() { } cachedSize = -1; bitField0_ = 0; - groupInfo.clearQuick(); + groupStateInfo.clearQuick(); return this; } @@ -192,7 +193,7 @@ public boolean equals(Object o) { GroupStateChangeScRsp other = (GroupStateChangeScRsp) o; return bitField0_ == other.bitField0_ && (!hasRetcode() || retcode == other.retcode) - && (!hasGroupInfo() || groupInfo.equals(other.groupInfo)); + && (!hasGroupStateInfo() || groupStateInfo.equals(other.groupStateInfo)); } @Override @@ -203,7 +204,7 @@ public void writeTo(final ProtoSink output) throws IOException { } if ((bitField0_ & 0x00000002) != 0) { output.writeRawByte((byte) 26); - output.writeMessageNoTag(groupInfo); + output.writeMessageNoTag(groupStateInfo); } } @@ -214,7 +215,7 @@ protected int computeSerializedSize() { size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode); } if ((bitField0_ & 0x00000002) != 0) { - size += 1 + ProtoSink.computeMessageSizeNoTag(groupInfo); + size += 1 + ProtoSink.computeMessageSizeNoTag(groupStateInfo); } return size; } @@ -236,8 +237,8 @@ public GroupStateChangeScRsp mergeFrom(final ProtoSource input) throws IOExcepti } } case 26: { - // groupInfo - input.readMessage(groupInfo); + // groupStateInfo + input.readMessage(groupStateInfo); bitField0_ |= 0x00000002; tag = input.readTag(); if (tag != 0) { @@ -265,7 +266,7 @@ public void writeTo(final JsonSink output) throws IOException { output.writeUInt32(FieldNames.retcode, retcode); } if ((bitField0_ & 0x00000002) != 0) { - output.writeMessage(FieldNames.groupInfo, groupInfo); + output.writeMessage(FieldNames.groupStateInfo, groupStateInfo); } output.endObject(); } @@ -288,11 +289,11 @@ public GroupStateChangeScRsp mergeFrom(final JsonSource input) throws IOExceptio } break; } - case -1483311155: - case 1282170478: { - if (input.isAtField(FieldNames.groupInfo)) { + case 1415312672: + case 1198732636: { + if (input.isAtField(FieldNames.groupStateInfo)) { if (!input.trySkipNullValue()) { - input.readMessage(groupInfo); + input.readMessage(groupStateInfo); bitField0_ |= 0x00000002; } } else { @@ -355,7 +356,7 @@ public GroupStateChangeScRsp create() { static class FieldNames { static final FieldName retcode = FieldName.forField("retcode"); - static final FieldName groupInfo = FieldName.forField("groupInfo", "group_info"); + static final FieldName groupStateInfo = FieldName.forField("groupStateInfo", "group_state_info"); } } } diff --git a/src/main/java/emu/lunarcore/command/CommandArgs.java b/src/main/java/emu/lunarcore/command/CommandArgs.java index 6cfd18ee8..c585fc6d3 100644 --- a/src/main/java/emu/lunarcore/command/CommandArgs.java +++ b/src/main/java/emu/lunarcore/command/CommandArgs.java @@ -71,8 +71,8 @@ public CommandArgs(Player sender, List args) { if (this.flags == null) this.flags = new ObjectOpenHashSet<>(); this.flags.add(arg); it.remove(); - } else if (arg.contains(":")) { - String[] split = arg.split(":"); + } else if (arg.contains(":") || arg.contains(",")) { + String[] split = arg.split("[:,]"); if (split.length >= 2) { int key = Integer.parseInt(split[0]); int value = Integer.parseInt(split[1]); diff --git a/src/main/java/emu/lunarcore/data/config/FloorInfo.java b/src/main/java/emu/lunarcore/data/config/FloorInfo.java index 3b6602dc6..646954126 100644 --- a/src/main/java/emu/lunarcore/data/config/FloorInfo.java +++ b/src/main/java/emu/lunarcore/data/config/FloorInfo.java @@ -7,7 +7,6 @@ import emu.lunarcore.game.enums.PropState; import emu.lunarcore.game.scene.triggers.TriggerOpenTreasureWhenMonsterDie; -import emu.lunarcore.game.scene.triggers.TriggerPuzzleCompassWayPointController; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; @@ -72,8 +71,6 @@ public void onLoad() { // Hacky way to setup prop triggers if (json.contains("Maze_GroupProp_OpenTreasure_WhenMonsterDie")) { prop.setTrigger(new TriggerOpenTreasureWhenMonsterDie(group.getId())); - } else if (json.contains("Maze_Chap02_X201_Event_PuzzleCompass_WayPoint_Controller")) { - prop.setTrigger(new TriggerPuzzleCompassWayPointController(group.getId())); } // Clear for garbage collection diff --git a/src/main/java/emu/lunarcore/data/excel/CocoonExcel.java b/src/main/java/emu/lunarcore/data/excel/CocoonExcel.java index 621257bd9..3b7c5b375 100644 --- a/src/main/java/emu/lunarcore/data/excel/CocoonExcel.java +++ b/src/main/java/emu/lunarcore/data/excel/CocoonExcel.java @@ -22,6 +22,10 @@ public class CocoonExcel extends GameResource { public int getId() { return (ID << 8) + WorldLevel; } + + public int getCocoonId() { + return ID; + } public int getRandomStage() { return Utils.randomElement(StageIDList); diff --git a/src/main/java/emu/lunarcore/game/battle/Battle.java b/src/main/java/emu/lunarcore/game/battle/Battle.java index fd3c312dd..853731679 100644 --- a/src/main/java/emu/lunarcore/game/battle/Battle.java +++ b/src/main/java/emu/lunarcore/game/battle/Battle.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.function.Consumer; import emu.lunarcore.GameConstants; import emu.lunarcore.data.GameData; @@ -12,7 +13,9 @@ import emu.lunarcore.game.player.Player; import emu.lunarcore.game.player.lineup.PlayerLineup; import emu.lunarcore.game.scene.entity.EntityMonster; +import emu.lunarcore.proto.BattleEndStatusOuterClass.BattleEndStatus; import emu.lunarcore.proto.BattleEventBattleInfoOuterClass.BattleEventBattleInfo; +import emu.lunarcore.proto.BattleStatisticsOuterClass.BattleStatistics; import emu.lunarcore.proto.SceneBattleInfoOuterClass.SceneBattleInfo; import emu.lunarcore.util.Utils; import it.unimi.dsi.fastutil.ints.IntArrayList; @@ -32,8 +35,10 @@ public class Battle { private final long timestamp; private StageExcel stage; // Main battle stage - private IntList turnSnapshotList; // TODO maybe turn it into a map? + private IntList battleEvents; // TODO maybe turn it into a map? + // Internal battle data + @Setter private BattleEndStatus result; @Setter private int staminaCost; @Setter private int roundsLimit; @@ -42,6 +47,9 @@ public class Battle { @Setter private int worldLevel; @Setter private int cocoonWave; + // OnFinish Callback + @Setter private Consumer onFinish; + private Battle(Player player, PlayerLineup lineup) { this.id = player.getNextBattleId(); this.player = player; @@ -54,9 +62,16 @@ private Battle(Player player, PlayerLineup lineup) { } public Battle(Player player, PlayerLineup lineup, StageExcel stage) { + this(player, lineup, stage, true); + } + + public Battle(Player player, PlayerLineup lineup, StageExcel stage, boolean loadStage) { this(player, lineup); this.stage = stage; - this.loadStage(stage); + + if (loadStage) { + this.loadStage(stage); + } } public Battle(Player player, PlayerLineup lineup, List stages) { @@ -122,11 +137,11 @@ private void loadStage(StageExcel stage, EntityMonster npcMonster) { } } - public IntList getTurnSnapshotList() { - if (this.turnSnapshotList == null) { - this.turnSnapshotList = new IntArrayList(); + public IntList getBattleEvents() { + if (this.battleEvents == null) { + this.battleEvents = new IntArrayList(); } - return this.turnSnapshotList; + return this.battleEvents; } public void setCustomLevel(int level) { @@ -216,8 +231,8 @@ public SceneBattleInfo toProto() { } // Client turn snapshots - if (this.turnSnapshotList != null) { - for (int id : this.turnSnapshotList) { + if (this.battleEvents != null) { + for (int id : this.battleEvents) { var event = BattleEventBattleInfo.newInstance() .setBattleEventId(id); diff --git a/src/main/java/emu/lunarcore/game/battle/BattleService.java b/src/main/java/emu/lunarcore/game/battle/BattleService.java index 60562f4ad..f6cbb5a02 100644 --- a/src/main/java/emu/lunarcore/game/battle/BattleService.java +++ b/src/main/java/emu/lunarcore/game/battle/BattleService.java @@ -225,6 +225,7 @@ public Battle finishBattle(Player player, BattleEndStatus result, BattleStatisti // Get battle object and setup variables Battle battle = player.getBattle(); + battle.setResult(result); int minimumHp = 0; boolean updateStatus = true; @@ -311,6 +312,11 @@ public Battle finishBattle(Player player, BattleEndStatus result, BattleStatisti player.getRogueInstance().onBattleFinish(battle, result, stats); } + // Battle callback + if (battle.getOnFinish() != null) { + battle.getOnFinish().accept(stats); + } + // Done - Clear battle object from player player.setBattle(null); return battle; diff --git a/src/main/java/emu/lunarcore/game/player/Player.java b/src/main/java/emu/lunarcore/game/player/Player.java index 02d8aca3a..843f32b52 100644 --- a/src/main/java/emu/lunarcore/game/player/Player.java +++ b/src/main/java/emu/lunarcore/game/player/Player.java @@ -29,6 +29,7 @@ import emu.lunarcore.game.chat.ChatMessage; import emu.lunarcore.game.enums.PlaneType; import emu.lunarcore.game.enums.PropState; +import emu.lunarcore.game.enums.PropType; import emu.lunarcore.game.friends.FriendList; import emu.lunarcore.game.friends.Friendship; import emu.lunarcore.game.gacha.PlayerGachaInfo; @@ -46,7 +47,6 @@ import emu.lunarcore.game.scene.SceneBuff; import emu.lunarcore.game.scene.entity.EntityProp; import emu.lunarcore.game.scene.entity.GameEntity; -import emu.lunarcore.game.scene.triggers.PropTriggerType; import emu.lunarcore.proto.BoardDataSyncOuterClass.BoardDataSync; import emu.lunarcore.proto.FriendOnlineStatusOuterClass.FriendOnlineStatus; import emu.lunarcore.proto.HeadIconOuterClass.HeadIcon; @@ -606,15 +606,16 @@ public EntityProp interactWithProp(int interactId, int propEntityId) { // Save old state PropState oldState = prop.getState(); + PropState newState = interactExcel.getTargetState(); // Set group and prop state - this.sendPacket(new PacketGroupStateChangeScNotify(getEntryId(), prop.getGroupId(), interactExcel.getTargetState())); - prop.setState(interactExcel.getTargetState()); + this.sendPacket(new PacketGroupStateChangeScNotify(getEntryId(), prop.getGroupId(), newState)); + prop.setState(newState); // Handle any extra interaction actions switch (prop.getExcel().getPropType()) { case PROP_TREASURE_CHEST -> { - if (oldState == PropState.ChestClosed && prop.getState() == PropState.ChestUsed) { + if (oldState == PropState.ChestClosed && newState == PropState.ChestUsed) { // Handle drops var drops = this.getServer().getDropService().calculateDropsFromProp(prop.getPropId()); this.getInventory().addItems(drops, true); @@ -622,10 +623,21 @@ public EntityProp interactWithProp(int interactId, int propEntityId) { } case PROP_MAZE_PUZZLE -> { // Trigger event - this.getScene().invokePropTrigger(PropTriggerType.PUZZLE_FINISH, prop.getGroupId(), prop.getInstId()); + if (newState == PropState.Open || newState == PropState.Closed) { + // Unlock everything in the prop's group + for (var p : getScene().getEntitiesByGroup(EntityProp.class, prop.getGroupId())) { + if (p.getPropType() == PropType.PROP_TREASURE_CHEST) { + p.setState(PropState.ChestClosed); + } else if (p.getPropType() == PropType.PROP_MAZE_PUZZLE) { + // Skip + } else { + p.setState(PropState.Open); + } + } + } } default -> { - + // Skip } } diff --git a/src/main/java/emu/lunarcore/game/player/lineup/PlayerTempLineup.java b/src/main/java/emu/lunarcore/game/player/lineup/PlayerTempLineup.java new file mode 100644 index 000000000..cea5f19a5 --- /dev/null +++ b/src/main/java/emu/lunarcore/game/player/lineup/PlayerTempLineup.java @@ -0,0 +1,20 @@ +package emu.lunarcore.game.player.lineup; + +import emu.lunarcore.game.player.Player; + +public class PlayerTempLineup extends PlayerExtraLineup { + + public PlayerTempLineup(Player player) { + super(player, 0); + } + + @Override + public void save() { + // Ignored + } + + @Override + public void delete() { + // Ignored + } +} diff --git a/src/main/java/emu/lunarcore/game/rogue/RogueInstance.java b/src/main/java/emu/lunarcore/game/rogue/RogueInstance.java index 3e5325db3..c918414cd 100644 --- a/src/main/java/emu/lunarcore/game/rogue/RogueInstance.java +++ b/src/main/java/emu/lunarcore/game/rogue/RogueInstance.java @@ -325,7 +325,7 @@ public synchronized void onBattleStart(Battle battle) { if (buff.getExcel().getBattleEventBuffType() == RogueBuffAeonType.BattleEventBuff) { RogueBuffType type = RogueBuffType.getById(getAeonBuffType()); if (type != null && type.getBattleEventSkill() != 0) { - battle.getTurnSnapshotList().add(type.getBattleEventSkill()); + battle.getBattleEvents().add(type.getBattleEventSkill()); } } } diff --git a/src/main/java/emu/lunarcore/game/scene/entity/EntityProp.java b/src/main/java/emu/lunarcore/game/scene/entity/EntityProp.java index d42d3d94e..e6faca9f9 100644 --- a/src/main/java/emu/lunarcore/game/scene/entity/EntityProp.java +++ b/src/main/java/emu/lunarcore/game/scene/entity/EntityProp.java @@ -4,6 +4,7 @@ import emu.lunarcore.data.config.PropInfo; import emu.lunarcore.data.excel.PropExcel; import emu.lunarcore.game.enums.PropState; +import emu.lunarcore.game.enums.PropType; import emu.lunarcore.game.scene.Scene; import emu.lunarcore.game.scene.entity.extra.PropRogueData; import emu.lunarcore.proto.MotionInfoOuterClass.MotionInfo; @@ -54,6 +55,10 @@ public int getPropId() { return excel.getId(); } + public PropType getPropType() { + return getExcel().getPropType(); + } + public boolean setState(PropState state) { return this.setState(state, this.getScene().isLoaded()); } diff --git a/src/main/java/emu/lunarcore/game/scene/triggers/TriggerPuzzleCompassWayPointController.java b/src/main/java/emu/lunarcore/game/scene/triggers/TriggerPuzzleCompassWayPointController.java deleted file mode 100644 index 4b48a6fa1..000000000 --- a/src/main/java/emu/lunarcore/game/scene/triggers/TriggerPuzzleCompassWayPointController.java +++ /dev/null @@ -1,32 +0,0 @@ -package emu.lunarcore.game.scene.triggers; - -import emu.lunarcore.game.enums.PropState; -import emu.lunarcore.game.scene.Scene; -import emu.lunarcore.game.scene.entity.EntityProp; -import lombok.Getter; - -@Getter -public class TriggerPuzzleCompassWayPointController extends PropTrigger { - private int groupId; - - public TriggerPuzzleCompassWayPointController(int groupId) { - this.groupId = groupId; - } - - @Override - public PropTriggerType getType() { - return PropTriggerType.PUZZLE_FINISH; - } - - @Override - public boolean shouldRun(int groupId, int instId) { - return this.groupId == groupId; - } - - @Override - public void run(Scene scene) { - for (var prop : scene.getEntitiesByGroup(EntityProp.class, groupId)) { - prop.setState(PropState.Open); - } - } -} diff --git a/src/main/java/emu/lunarcore/server/packet/recv/HandlerGroupStateChangeCsReq.java b/src/main/java/emu/lunarcore/server/packet/recv/HandlerGroupStateChangeCsReq.java index 79b261a84..dfe0d4ff4 100644 --- a/src/main/java/emu/lunarcore/server/packet/recv/HandlerGroupStateChangeCsReq.java +++ b/src/main/java/emu/lunarcore/server/packet/recv/HandlerGroupStateChangeCsReq.java @@ -14,10 +14,10 @@ public class HandlerGroupStateChangeCsReq extends PacketHandler { @Override public void handle(GameSession session, byte[] data) throws Exception { var req = GroupStateChangeCsReq.parseFrom(data); - var groupInfo = req.getMutableGroupInfo(); + var groupStateInfo = req.getMutableGroupStateInfo(); - session.send(new PacketGroupStateChangeScNotify(groupInfo)); - session.send(new PacketGroupStateChangeScRsp(groupInfo)); + session.send(new PacketGroupStateChangeScNotify(groupStateInfo)); + session.send(new PacketGroupStateChangeScRsp(groupStateInfo)); } } diff --git a/src/main/java/emu/lunarcore/server/packet/send/PacketGroupStateChangeScNotify.java b/src/main/java/emu/lunarcore/server/packet/send/PacketGroupStateChangeScNotify.java index 7547f2551..e8fe64e80 100644 --- a/src/main/java/emu/lunarcore/server/packet/send/PacketGroupStateChangeScNotify.java +++ b/src/main/java/emu/lunarcore/server/packet/send/PacketGroupStateChangeScNotify.java @@ -12,7 +12,7 @@ public PacketGroupStateChangeScNotify(GroupStateInfo groupInfo) { super(CmdId.GroupStateChangeScNotify); var data = GroupStateChangeScNotify.newInstance(); - data.setGroupInfo(groupInfo); + data.setGroupStateInfo(groupInfo); this.setData(data); } @@ -22,7 +22,7 @@ public PacketGroupStateChangeScNotify(int entryId, int groupId, PropState state) var data = GroupStateChangeScNotify.newInstance(); - data.getMutableGroupInfo() + data.getMutableGroupStateInfo() .setEntryId(entryId) .setGroupId(groupId) .setGroupState(state.getVal()); diff --git a/src/main/java/emu/lunarcore/server/packet/send/PacketGroupStateChangeScRsp.java b/src/main/java/emu/lunarcore/server/packet/send/PacketGroupStateChangeScRsp.java index a5e5d9d11..335fc52bc 100644 --- a/src/main/java/emu/lunarcore/server/packet/send/PacketGroupStateChangeScRsp.java +++ b/src/main/java/emu/lunarcore/server/packet/send/PacketGroupStateChangeScRsp.java @@ -11,7 +11,7 @@ public PacketGroupStateChangeScRsp(GroupStateInfo groupInfo) { super(CmdId.GroupStateChangeScRsp); var data = GroupStateChangeScNotify.newInstance(); - data.setGroupInfo(groupInfo); + data.setGroupStateInfo(groupInfo); this.setData(data); }