mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-25 11:57:35 +00:00
Add PlayerFinishBattlePassMission
This commit is contained in:
parent
ee33fed721
commit
3436e0a3a8
@ -1,43 +1,26 @@
|
|||||||
package emu.grasscutter.game.battlepass;
|
package emu.grasscutter.game.battlepass;
|
||||||
|
|
||||||
import dev.morphia.annotations.Entity;
|
import dev.morphia.annotations.*;
|
||||||
import dev.morphia.annotations.Id;
|
import emu.grasscutter.*;
|
||||||
import dev.morphia.annotations.Indexed;
|
|
||||||
import emu.grasscutter.GameConstants;
|
|
||||||
import emu.grasscutter.Grasscutter;
|
|
||||||
import emu.grasscutter.data.GameData;
|
import emu.grasscutter.data.GameData;
|
||||||
import emu.grasscutter.data.common.ItemParamData;
|
import emu.grasscutter.data.common.ItemParamData;
|
||||||
import emu.grasscutter.data.excels.BattlePassRewardData;
|
import emu.grasscutter.data.excels.*;
|
||||||
import emu.grasscutter.data.excels.ItemData;
|
|
||||||
import emu.grasscutter.data.excels.RewardData;
|
|
||||||
import emu.grasscutter.database.DatabaseHelper;
|
import emu.grasscutter.database.DatabaseHelper;
|
||||||
import emu.grasscutter.game.inventory.GameItem;
|
import emu.grasscutter.game.inventory.*;
|
||||||
import emu.grasscutter.game.inventory.MaterialType;
|
import emu.grasscutter.game.player.*;
|
||||||
import emu.grasscutter.game.player.BasePlayerDataManager;
|
import emu.grasscutter.game.props.*;
|
||||||
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.net.proto.BattlePassCycleOuterClass.BattlePassCycle;
|
import emu.grasscutter.net.proto.BattlePassCycleOuterClass.BattlePassCycle;
|
||||||
import emu.grasscutter.net.proto.BattlePassRewardTakeOptionOuterClass.BattlePassRewardTakeOption;
|
import emu.grasscutter.net.proto.BattlePassRewardTakeOptionOuterClass.BattlePassRewardTakeOption;
|
||||||
import emu.grasscutter.net.proto.BattlePassScheduleOuterClass.BattlePassSchedule;
|
import emu.grasscutter.net.proto.BattlePassScheduleOuterClass.BattlePassSchedule;
|
||||||
import emu.grasscutter.net.proto.BattlePassUnlockStatusOuterClass.BattlePassUnlockStatus;
|
import emu.grasscutter.net.proto.BattlePassUnlockStatusOuterClass.BattlePassUnlockStatus;
|
||||||
import emu.grasscutter.server.packet.send.PacketBattlePassCurScheduleUpdateNotify;
|
import emu.grasscutter.server.packet.send.*;
|
||||||
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 lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
|
|
||||||
|
import java.time.*;
|
||||||
|
import java.time.temporal.TemporalAdjusters;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
@Entity(value = "battlepass", useDiscriminator = false)
|
@Entity(value = "battlepass", useDiscriminator = false)
|
||||||
public class BattlePassManager extends BasePlayerDataManager {
|
public class BattlePassManager extends BasePlayerDataManager {
|
||||||
@Id @Getter private ObjectId id;
|
@Id @Getter private ObjectId id;
|
||||||
@ -181,7 +164,7 @@ public class BattlePassManager extends BasePlayerDataManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updatedMissions.size() > 0) {
|
if (!updatedMissions.isEmpty()) {
|
||||||
// Save to db
|
// Save to db
|
||||||
this.save();
|
this.save();
|
||||||
|
|
||||||
@ -263,8 +246,7 @@ public class BattlePassManager extends BasePlayerDataManager {
|
|||||||
// Get rewards
|
// Get rewards
|
||||||
List<GameItem> rewardItems = null;
|
List<GameItem> rewardItems = null;
|
||||||
|
|
||||||
if (rewardList.size() > 0) {
|
if (!rewardList.isEmpty()) {
|
||||||
|
|
||||||
rewardItems = new ArrayList<>();
|
rewardItems = new ArrayList<>();
|
||||||
|
|
||||||
for (var option : rewardList) {
|
for (var option : rewardList) {
|
||||||
|
@ -5,6 +5,7 @@ import emu.grasscutter.data.excels.BattlePassMissionData;
|
|||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import emu.grasscutter.game.props.BattlePassMissionStatus;
|
import emu.grasscutter.game.props.BattlePassMissionStatus;
|
||||||
import emu.grasscutter.game.props.WatcherTriggerType;
|
import emu.grasscutter.game.props.WatcherTriggerType;
|
||||||
|
import emu.grasscutter.server.event.player.PlayerFinishBattlePassMission;
|
||||||
import emu.grasscutter.server.game.BaseGameSystem;
|
import emu.grasscutter.server.game.BaseGameSystem;
|
||||||
import emu.grasscutter.server.game.GameServer;
|
import emu.grasscutter.server.game.GameServer;
|
||||||
import emu.grasscutter.server.packet.send.PacketBattlePassMissionUpdateNotify;
|
import emu.grasscutter.server.packet.send.PacketBattlePassMissionUpdateNotify;
|
||||||
@ -68,6 +69,8 @@ public class BattlePassSystem extends BaseGameSystem {
|
|||||||
|
|
||||||
if (mission.getProgress() >= data.getProgress()) {
|
if (mission.getProgress() >= data.getProgress()) {
|
||||||
mission.setStatus(BattlePassMissionStatus.MISSION_STATUS_FINISHED);
|
mission.setStatus(BattlePassMissionStatus.MISSION_STATUS_FINISHED);
|
||||||
|
|
||||||
|
new PlayerFinishBattlePassMission(player, mission).call();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save to db
|
// Save to db
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user