diff --git a/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java b/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java index a034b26f4..df93a4239 100644 --- a/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java +++ b/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java @@ -1,43 +1,26 @@ package emu.grasscutter.game.battlepass; -import dev.morphia.annotations.Entity; -import dev.morphia.annotations.Id; -import dev.morphia.annotations.Indexed; -import emu.grasscutter.GameConstants; -import emu.grasscutter.Grasscutter; +import dev.morphia.annotations.*; +import emu.grasscutter.*; import emu.grasscutter.data.GameData; import emu.grasscutter.data.common.ItemParamData; -import emu.grasscutter.data.excels.BattlePassRewardData; -import emu.grasscutter.data.excels.ItemData; -import emu.grasscutter.data.excels.RewardData; +import emu.grasscutter.data.excels.*; import emu.grasscutter.database.DatabaseHelper; -import emu.grasscutter.game.inventory.GameItem; -import emu.grasscutter.game.inventory.MaterialType; -import emu.grasscutter.game.player.BasePlayerDataManager; -import emu.grasscutter.game.player.Player; -import emu.grasscutter.game.props.BattlePassMissionRefreshType; -import emu.grasscutter.game.props.BattlePassMissionStatus; -import emu.grasscutter.game.props.ItemUseOp; -import emu.grasscutter.game.props.WatcherTriggerType; +import emu.grasscutter.game.inventory.*; +import emu.grasscutter.game.player.*; +import emu.grasscutter.game.props.*; import emu.grasscutter.net.proto.BattlePassCycleOuterClass.BattlePassCycle; import emu.grasscutter.net.proto.BattlePassRewardTakeOptionOuterClass.BattlePassRewardTakeOption; import emu.grasscutter.net.proto.BattlePassScheduleOuterClass.BattlePassSchedule; import emu.grasscutter.net.proto.BattlePassUnlockStatusOuterClass.BattlePassUnlockStatus; -import emu.grasscutter.server.packet.send.PacketBattlePassCurScheduleUpdateNotify; -import emu.grasscutter.server.packet.send.PacketBattlePassMissionUpdateNotify; -import emu.grasscutter.server.packet.send.PacketTakeBattlePassRewardRsp; -import java.time.DayOfWeek; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.temporal.TemporalAdjusters; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import emu.grasscutter.server.packet.send.*; import lombok.Getter; import org.bson.types.ObjectId; +import java.time.*; +import java.time.temporal.TemporalAdjusters; +import java.util.*; + @Entity(value = "battlepass", useDiscriminator = false) public class BattlePassManager extends BasePlayerDataManager { @Id @Getter private ObjectId id; @@ -181,7 +164,7 @@ public class BattlePassManager extends BasePlayerDataManager { } } - if (updatedMissions.size() > 0) { + if (!updatedMissions.isEmpty()) { // Save to db this.save(); @@ -263,8 +246,7 @@ public class BattlePassManager extends BasePlayerDataManager { // Get rewards List rewardItems = null; - if (rewardList.size() > 0) { - + if (!rewardList.isEmpty()) { rewardItems = new ArrayList<>(); for (var option : rewardList) { diff --git a/src/main/java/emu/grasscutter/game/battlepass/BattlePassSystem.java b/src/main/java/emu/grasscutter/game/battlepass/BattlePassSystem.java index 02477e0c9..c5369731a 100644 --- a/src/main/java/emu/grasscutter/game/battlepass/BattlePassSystem.java +++ b/src/main/java/emu/grasscutter/game/battlepass/BattlePassSystem.java @@ -5,6 +5,7 @@ import emu.grasscutter.data.excels.BattlePassMissionData; import emu.grasscutter.game.player.Player; import emu.grasscutter.game.props.BattlePassMissionStatus; import emu.grasscutter.game.props.WatcherTriggerType; +import emu.grasscutter.server.event.player.PlayerFinishBattlePassMission; import emu.grasscutter.server.game.BaseGameSystem; import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.packet.send.PacketBattlePassMissionUpdateNotify; @@ -68,6 +69,8 @@ public class BattlePassSystem extends BaseGameSystem { if (mission.getProgress() >= data.getProgress()) { mission.setStatus(BattlePassMissionStatus.MISSION_STATUS_FINISHED); + + new PlayerFinishBattlePassMission(player, mission).call(); } // Save to db diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerFinishBattlePassMission.java b/src/main/java/emu/grasscutter/server/event/player/PlayerFinishBattlePassMission.java new file mode 100644 index 000000000..e17dabb9f --- /dev/null +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerFinishBattlePassMission.java @@ -0,0 +1,17 @@ +package emu.grasscutter.server.event.player; + +import emu.grasscutter.game.battlepass.*; +import emu.grasscutter.game.player.Player; +import emu.grasscutter.server.event.types.PlayerEvent; +import lombok.Getter; + +@Getter +public final class PlayerFinishBattlePassMission extends PlayerEvent { + private final BattlePassMission mission; + + public PlayerFinishBattlePassMission(Player player, BattlePassMission mission) { + super(player); + + this.mission = mission; + } +}