Add a config option to force unlock all challenges

This commit is contained in:
Melledy
2023-11-23 02:44:14 -08:00
parent d1ad3829bc
commit 398d3872ae
2 changed files with 20 additions and 2 deletions

View File

@@ -86,6 +86,7 @@ public class Config {
public boolean autoCreateAccount = true;
public int entitySceneLimit = 2000;
public boolean spendStamina = true;
public boolean unlockAllChallenges = true;
public int staminaRecoveryRate = 5 * 60;
public int staminaReserveRecoveryRate = 18 * 60;
public Set<String> defaultPermissions = Set.of("*");

View File

@@ -1,6 +1,9 @@
package emu.lunarcore.server.packet.send;
import emu.lunarcore.LunarCore;
import emu.lunarcore.data.GameData;
import emu.lunarcore.game.player.Player;
import emu.lunarcore.proto.ChallengeOuterClass.Challenge;
import emu.lunarcore.proto.GetChallengeScRspOuterClass.GetChallengeScRsp;
import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.server.packet.CmdId;
@@ -12,9 +15,23 @@ public class PacketGetChallengeScRsp extends BasePacket {
var data = GetChallengeScRsp.newInstance();
if (LunarCore.getConfig().getServerOptions().unlockAllChallenges) {
// Add all challenge excels to our challenge list
// TODO find out which challenge groups are active so we dont have to send old challenge ids to the client
for (var challengeExcel : GameData.getChallengeExcelMap().values()) {
var history = player.getChallengeManager().getHistory().get(challengeExcel.getId());
if (history != null) {
data.addChallengeList(history.toProto());
} else {
data.addChallengeList(Challenge.newInstance().setChallengeId(challengeExcel.getId()));
}
}
} else {
for (var history : player.getChallengeManager().getHistory().values()) {
data.addChallengeList(history.toProto());
}
}
for (var reward : player.getChallengeManager().getTakenRewards().values()) {
data.addChallengeRewardList(reward.toProto());