mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-12 20:34:36 +01:00
Fix infinite arena not being challengeable if unlockInstances was true
This commit is contained in:
@@ -20,7 +20,7 @@ public class InfinityTowerManager extends PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getBountyLevel() {
|
public int getBountyLevel() {
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean apply(int levelId, long buildId) {
|
public boolean apply(int levelId, long buildId) {
|
||||||
|
|||||||
@@ -5,12 +5,8 @@ import emu.nebula.net.NetMsgId;
|
|||||||
import emu.nebula.proto.InfinityTowerInfo.InfinityTowerInfoResp;
|
import emu.nebula.proto.InfinityTowerInfo.InfinityTowerInfoResp;
|
||||||
import emu.nebula.proto.Public.InfinityTowerLevelInfo;
|
import emu.nebula.proto.Public.InfinityTowerLevelInfo;
|
||||||
import emu.nebula.net.HandlerId;
|
import emu.nebula.net.HandlerId;
|
||||||
import emu.nebula.Nebula;
|
|
||||||
import emu.nebula.data.GameData;
|
|
||||||
import emu.nebula.net.GameSession;
|
import emu.nebula.net.GameSession;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
|
||||||
|
|
||||||
@HandlerId(NetMsgId.infinity_tower_info_req)
|
@HandlerId(NetMsgId.infinity_tower_info_req)
|
||||||
public class HandlerInfinityTowerInfoReq extends NetHandler {
|
public class HandlerInfinityTowerInfoReq extends NetHandler {
|
||||||
|
|
||||||
@@ -18,38 +14,15 @@ public class HandlerInfinityTowerInfoReq extends NetHandler {
|
|||||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||||
// Build response
|
// Build response
|
||||||
var rsp = InfinityTowerInfoResp.newInstance()
|
var rsp = InfinityTowerInfoResp.newInstance()
|
||||||
.setBountyLevel(0);
|
.setBountyLevel(session.getPlayer().getInfinityTowerManager().getBountyLevel());
|
||||||
|
|
||||||
// Add unlocked levels
|
// Get infinite arena log from player progress
|
||||||
if (Nebula.getConfig().getServerOptions().unlockInstances) {
|
for (var entry : session.getPlayer().getProgress().getInfinityArenaLog().int2IntEntrySet()) {
|
||||||
// Force unlock every level
|
var info = InfinityTowerLevelInfo.newInstance()
|
||||||
var levels = new Int2ObjectOpenHashMap<InfinityTowerLevelInfo>();
|
.setId(entry.getIntKey())
|
||||||
|
.setLevelId(entry.getIntValue());
|
||||||
|
|
||||||
for (var data : GameData.getInfinityTowerLevelDataTable()) {
|
rsp.addInfos(info);
|
||||||
int id = (int) Math.floor(data.getId() / 10000D);
|
|
||||||
|
|
||||||
var info = levels.computeIfAbsent(
|
|
||||||
id,
|
|
||||||
diff -> InfinityTowerLevelInfo.newInstance().setId(id)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data.getId() > info.getLevelId()) {
|
|
||||||
info.setLevelId(data.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var info : levels.values()) {
|
|
||||||
rsp.addInfos(info);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Get infinite arena log from player progress
|
|
||||||
for (var entry : session.getPlayer().getProgress().getInfinityArenaLog().int2IntEntrySet()) {
|
|
||||||
var info = InfinityTowerLevelInfo.newInstance()
|
|
||||||
.setId(entry.getIntKey())
|
|
||||||
.setLevelId(entry.getIntValue());
|
|
||||||
|
|
||||||
rsp.addInfos(info);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode and send
|
// Encode and send
|
||||||
|
|||||||
Reference in New Issue
Block a user