Clean imports and optimize some packets

This commit is contained in:
Melledy
2023-12-01 04:19:40 -08:00
parent e816474764
commit 00d2eccf08
56 changed files with 139 additions and 216 deletions

View File

@@ -65,13 +65,9 @@ public class GiveAllCommand implements CommandHandler {
}
case "ic", "icons" -> {
// Get UnlockedHeads
for (int iconhead : GameData.getAllIconHeads()) {
// Skip if target already has the head icon
if (target.getUnlockedHeadIcons().contains(iconhead)) {
continue;
}
target.addHeadIcon(iconhead);
for (var iconhead : GameData.getPlayerIconExcelMap().values()) {
// This function will handle any duplicate head icons
target.addHeadIcon(iconhead.getId());
}
// Send message

View File

@@ -4,14 +4,12 @@ import java.lang.reflect.Field;
import java.util.List;
import java.util.ArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import emu.lunarcore.data.config.FloorInfo;
import emu.lunarcore.data.excel.*;
import emu.lunarcore.game.battle.MazeBuff;
import emu.lunarcore.util.Utils;
import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.*;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import lombok.Getter;
@@ -24,7 +22,8 @@ public class GameData {
@Getter private static Int2ObjectMap<EquipmentExcel> equipExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<RelicExcel> relicExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<PropExcel> propExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<BattleEventDataExcel> npcExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<NpcExcel> npcExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<MonsterExcel> monsterExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<NpcMonsterExcel> npcMonsterExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<StageExcel> stageExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<MazePlaneExcel> mazePlaneExcelMap = new Int2ObjectOpenHashMap<>();
@@ -36,7 +35,11 @@ public class GameData {
@Getter private static Int2ObjectMap<ItemComposeExcel> itemComposeExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<ActivityPanelExcel> activityPanelExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<BackGroundMusicExcel> backGroundMusicExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<QuestExcel> questExcelMap = new Int2ObjectLinkedOpenHashMap<>();
@Getter private static Int2ObjectMap<TextJoinExcel> textJoinExcelMap = new Int2ObjectLinkedOpenHashMap<>();
@Getter private static Int2ObjectMap<ChatBubbleExcel> chatBubbleExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<PhoneThemeExcel> phoneThemeExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<ChallengeGroupExcel> challengeGroupExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<ChallengeExcel> challengeExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<ChallengeTargetExcel> challengeTargetExcelMap = new Int2ObjectOpenHashMap<>();
@@ -57,18 +60,13 @@ public class GameData {
private static Int2ObjectMap<EquipmentPromotionExcel> equipmentPromotionExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<MazeBuffExcel> mazeBuffExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<CocoonExcel> cocoonExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<ChatBubbleExcel> chatBubbleExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<PhoneThemeExcel> phoneThemeExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<MonsterDropExcel> monsterDropExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<MonsterExcel> monsterExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<QuestExcel> questExcelMap = new Int2ObjectLinkedOpenHashMap<>();
private static Int2ObjectMap<TextJoinExcel> textJoinExcelMap = new Int2ObjectLinkedOpenHashMap<>();
private static Int2ObjectMap<PlayerLevelExcel> playerLevelExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<ExpTypeExcel> expTypeExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<EquipmentExpTypeExcel> equipmentExpTypeExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<RelicExpTypeExcel> relicExpTypeExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<RelicMainAffixExcel> relicMainAffixExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<RelicSubAffixExcel> relicSubAffixExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<RelicSetExcel> relicSetExcelMap = new Int2ObjectOpenHashMap<>();
@@ -93,17 +91,6 @@ public class GameData {
return map;
}
public static List<Integer> getAllChatBubbleIds() {
List<Integer> allIds = new ArrayList<>();
for (Int2ObjectMap.Entry<ChatBubbleExcel> entry : chatBubbleExcelMap.int2ObjectEntrySet()) {
ChatBubbleExcel chatBubbleExcel = entry.getValue();
allIds.add(chatBubbleExcel.getId());
}
return allIds;
}
public static List<Integer> getAllRelicIds() {
List<Integer> allIds = new ArrayList<>();
@@ -124,15 +111,6 @@ public class GameData {
return relicExcel.getSetId();
}
public static int getRelicTypeFromId(int relicId) {
RelicExcel relicExcel = GameData.getRelicExcelMap().get(relicId);
if (relicExcel == null) {
return 0;
}
return relicExcel.getType().getVal();
}
public static List<Integer> getAllMusicIds() {
List<Integer> allIds = new ArrayList<>();
@@ -183,29 +161,7 @@ public class GameData {
var excel = backGroundMusicExcelMap.get(musicId);
return excel != null ? excel.getGroupId() : 0;
}
public static List<Integer> getAllPhoneThemes() {
List<Integer> allIds = new ArrayList<>();
for (Int2ObjectMap.Entry<PhoneThemeExcel> entry : phoneThemeExcelMap.int2ObjectEntrySet()) {
PhoneThemeExcel phoneThemeExcel = entry.getValue();
allIds.add(phoneThemeExcel.getId());
}
return allIds;
}
public static List<Integer> getAllIconHeads() {
List<Integer> allIds = new ArrayList<>();
for (Int2ObjectMap.Entry<PlayerIconExcel> entry : playerIconExcelMap.int2ObjectEntrySet()) {
PlayerIconExcel playerIconExcel = entry.getValue();
allIds.add(playerIconExcel.getId());
}
return allIds;
}
public static AvatarPromotionExcel getAvatarPromotionExcel(int id, int promotion) {
return avatarPromotionExcelMap.get((id << 8) + promotion);
}

View File

@@ -2,7 +2,6 @@ package emu.lunarcore.data.excel;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import lombok.Getter;
@Getter
@@ -12,7 +11,7 @@ public class ActivityPanelExcel extends GameResource {
private int Type;
private int ActivityModuleID;
private boolean IsResidentPanel;
@Override
public int getId() {
return PanelID;

View File

@@ -40,10 +40,10 @@ public class AvatarExcel extends GameResource {
private transient IntSet skillTreeIds;
private transient String nameKey;
private transient int maxSp;
@Setter private transient MazeSkill mazeAttack;
@Setter private transient MazeSkill mazeSkill;
private static Pattern namePattern = Pattern.compile("(?<=Avatar_)(.*?)(?=_Config)");
public AvatarExcel() {
@@ -75,14 +75,14 @@ public class AvatarExcel extends GameResource {
// Cache max sp
this.maxSp = (int) this.SPNeed * 100;
// Get name key
Matcher matcher = namePattern.matcher(this.JsonPath);
if (matcher.find()) {
this.nameKey = matcher.group(0);
}
// Clear variable to save memory
this.JsonPath = null;
}

View File

@@ -7,7 +7,6 @@ import emu.lunarcore.data.GameDepot;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import emu.lunarcore.data.ResourceType.LoadPriority;
import lombok.Getter;
@Getter
@@ -28,7 +27,7 @@ public class AvatarExpItemExcel extends GameResource {
if (excel == null) return;
excel.setAvatarExp(Exp);
// Add to game depot
if (Exp > 0) {
GameDepot.getAvatarExpExcels().add(this);

View File

@@ -41,7 +41,7 @@ public class AvatarSkillTreeExcel extends GameResource {
if (this.isDefaultUnlock()) {
excel.getDefaultSkillTrees().add(this);
}
// Add point id to avatar excel
excel.getSkillTreeIds().add(this.getPointID());
}

View File

@@ -2,8 +2,6 @@ package emu.lunarcore.data.excel;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import lombok.Getter;
@Getter
@@ -19,5 +17,5 @@ public class BackGroundMusicExcel extends GameResource {
public int getGroupId() {
return GroupID;
}
}

View File

@@ -14,9 +14,9 @@ import lombok.Getter;
public class BattleEventDataExcel extends GameResource {
private int BattleEventID;
private String Config;
private static final Pattern roguePattern = Pattern.compile("(?<=Avatar_RogueBattleevent)(.*?)(?=_Config.json)");
@Override
public int getId() {
return BattleEventID;
@@ -26,11 +26,11 @@ public class BattleEventDataExcel extends GameResource {
public void onLoad() {
try {
Matcher matcher = roguePattern.matcher(this.Config);
if (matcher.find()) {
int rogueBuffType = Utils.parseSafeInt(matcher.group(0));
var type = RogueBuffType.getById(rogueBuffType);
if (type != null) {
type.setBattleEventSkill(this.BattleEventID);
}

View File

@@ -15,46 +15,46 @@ public class ChallengeExcel extends GameResource {
private int StageNum;
private int ChallengeCountDown;
private int MazeBuffID;
private int[] ChallengeTargetID;
private int MazeGroupID1;
private int[] ConfigList1;
private int[] NpcMonsterIDList1;
private int[] EventIDList1;
private int MazeGroupID2;
private int[] ConfigList2;
private int[] NpcMonsterIDList2;
private int[] EventIDList2;
private transient Int2ObjectMap<ChallengeMonsterInfo> challengeMonsters1;
private transient Int2ObjectMap<ChallengeMonsterInfo> challengeMonsters2;
@Override
public int getId() {
return ID;
}
@Override
public void onLoad() {
// Cache challenge monsters
this.challengeMonsters1 = new Int2ObjectOpenHashMap<>();
for (int i = 0; i < ConfigList1.length; i++) {
if (ConfigList1[i] == 0) break;
var monster = new ChallengeMonsterInfo(ConfigList1[i], NpcMonsterIDList1[i], EventIDList1[i]);
this.challengeMonsters1.put(monster.getConfigId(), monster);
}
this.challengeMonsters2 = new Int2ObjectOpenHashMap<>();
for (int i = 0; i < ConfigList2.length; i++) {
if (ConfigList2[i] == 0) break;
var monster = new ChallengeMonsterInfo(ConfigList2[i], NpcMonsterIDList2[i], EventIDList2[i]);
this.challengeMonsters2.put(monster.getConfigId(), monster);
}
// Clear arrays to save memory
this.ConfigList1 = null;
this.NpcMonsterIDList1 = null;
@@ -69,12 +69,12 @@ public class ChallengeExcel extends GameResource {
private int configId;
private int npcMonsterId;
private int eventId;
public ChallengeMonsterInfo(int configId, int npcMonsterId, int eventId) {
this.configId = configId;
this.npcMonsterId = npcMonsterId;
this.eventId = eventId;
}
}
}

View File

@@ -9,7 +9,7 @@ import lombok.Getter;
public class ChallengeGroupExcel extends GameResource {
private int GroupID;
private int RewardLineGroupID;
@Override
public int getId() {
return GroupID;

View File

@@ -10,7 +10,7 @@ public class ChallengeRewardExcel extends GameResource {
private int GroupID;
private int StarCount;
private int RewardID;
@Override
public int getId() {
return (GroupID << 16) + StarCount;

View File

@@ -11,7 +11,7 @@ public class ChallengeTargetExcel extends GameResource {
private int ID;
private ChallengeType ChallengeTargetType;
private int ChallengeTargetParam1;
@Override
public int getId() {
return ID;

View File

@@ -1,11 +1,8 @@
package emu.lunarcore.data.excel;
import emu.lunarcore.data.GameData;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import emu.lunarcore.data.ResourceType.LoadPriority;
import emu.lunarcore.game.inventory.GameItem;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import lombok.Getter;
@Getter

View File

@@ -16,7 +16,7 @@ public class CocoonExcel extends GameResource {
private int MaxWave;
private IntArrayList StageIDList;
private IntArrayList DropList;
@Override
public int getId() {
return (ID << 8) + WorldLevel;

View File

@@ -7,7 +7,6 @@ import emu.lunarcore.data.GameDepot;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import emu.lunarcore.data.ResourceType.LoadPriority;
import lombok.Getter;
@Getter
@@ -30,7 +29,7 @@ public class EquipmentExpItemExcel extends GameResource {
excel.setEquipmentExp(ExpProvide);
excel.setExpCost(CoinCost);
// Add to game depot
if (ExpProvide > 0) {
GameDepot.getEquipmentExpExcels().add(this);

View File

@@ -10,7 +10,7 @@ import lombok.Getter;
public class HeroExcel extends GameResource {
private int HeroAvatarID;
private PlayerGender Gender;
@Override
public int getId() {
return HeroAvatarID;

View File

@@ -19,7 +19,7 @@ public class ItemComposeExcel extends GameResource {
private int CoinCost;
private int WorldLevelRequire;
private IntOpenHashSet RelicList;
@Override
public int getId() {
return ID;

View File

@@ -12,7 +12,7 @@ public class MapEntranceExcel extends GameResource {
private int FloorID;
private int StartGroupID;
private int StartAnchorID;
@Override
public int getId() {
return ID;

View File

@@ -9,7 +9,7 @@ import lombok.Getter;
public class MazeBuffExcel extends GameResource {
private int ID;
private int Lv;
@Override
public int getId() {
return (ID << 4) + Lv;

View File

@@ -14,10 +14,10 @@ public class MazePlaneExcel extends GameResource {
private int WorldID;
private int StartFloorID;
private long PlaneName;
@SerializedName(value = "PlaneType")
private PlaneType planeType = PlaneType.Unknown;
@Override
public int getId() {
return PlaneID;

View File

@@ -13,9 +13,9 @@ public class MonsterDropExcel extends GameResource {
private int MonsterTemplateID;
private int WorldLevel;
private int AvatarExpReward;
private List<ItemParam> DisplayItemList;
@Override
public int getId() {
return (MonsterTemplateID << 4) + WorldLevel;

View File

@@ -1,17 +1,14 @@
package emu.lunarcore.data.excel;
import java.util.List;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import emu.lunarcore.data.common.ItemParam;
import lombok.Getter;
@Getter
@ResourceType(name = {"MonsterConfig.json"})
public class MonsterExcel extends GameResource {
private int MonsterID;
@Override
public int getId() {
return MonsterID;

View File

@@ -8,7 +8,7 @@ import lombok.Getter;
@ResourceType(name = {"NPCData.json"})
public class NpcExcel extends GameResource {
private int ID;
@Override
public int getId() {
return ID;

View File

@@ -1,11 +1,8 @@
package emu.lunarcore.data.excel;
import emu.lunarcore.data.GameData;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import emu.lunarcore.data.ResourceType.LoadPriority;
import emu.lunarcore.game.inventory.GameItem;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import lombok.Getter;
@Getter

View File

@@ -12,15 +12,15 @@ public class PropExcel extends GameResource {
private long PropName;
private String JsonPath;
private PropType PropType;
private transient boolean recoverHp;
private transient boolean recoverMp;
@Override
public int getId() {
return ID;
}
@Override
public void onLoad() {
// Hacky way to determine if a prop will recover hp or mp
@@ -31,7 +31,7 @@ public class PropExcel extends GameResource {
this.recoverHp = true;
}
}
// Clear for optimization
this.JsonPath = null;
}

View File

@@ -30,7 +30,7 @@ public class RelicExpItemExcel extends GameResource {
excel.setRelicExp(ExpProvide);
excel.setExpCost(CoinCost);
// Add to game depot
if (ExpProvide > 0 && excel.getRarity() != ItemRarity.SuperRare) {
GameDepot.getRelicExpExcels().add(this);

View File

@@ -1,10 +1,8 @@
package emu.lunarcore.data.excel;
import emu.lunarcore.data.GameDepot;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import emu.lunarcore.data.ResourceType.LoadPriority;
import emu.lunarcore.game.enums.AvatarPropertyType;
import lombok.Getter;
@Getter

View File

@@ -13,9 +13,9 @@ import lombok.Getter;
@ResourceType(name = {"RewardData.json"})
public class RewardExcel extends GameResource {
private int RewardID;
private int Hcoin;
private int ItemID_1;
private int Count_1;
private int ItemID_2;
@@ -26,9 +26,9 @@ public class RewardExcel extends GameResource {
private int Count_4;
private int ItemID_5;
private int Count_5;
private transient List<ItemParam> rewards;
@Override
public int getId() {
return RewardID;
@@ -37,11 +37,11 @@ public class RewardExcel extends GameResource {
@Override
public void onLoad() {
this.rewards = new ArrayList<>();
if (Hcoin > 0) {
this.rewards.add(new ItemParam(GameConstants.MATERIAL_HCOIN_ID, Hcoin));
}
if (ItemID_1 > 0) {
this.rewards.add(new ItemParam(ItemID_1, Count_1));
} if (ItemID_2 > 0) {

View File

@@ -9,7 +9,7 @@ import lombok.Getter;
public class RogueAeonExcel extends GameResource {
private int AeonID;
private int RogueBuffType;
@Override
public int getId() {
return AeonID;

View File

@@ -16,10 +16,10 @@ public class RogueAreaExcel extends GameResource {
private int AreaProgress;
private int Difficulty;
private Int2IntOpenHashMap ScoreMap;
private transient int mapId;
private transient List<RogueMapExcel> sites;
@Override
public int getId() {
return RogueAreaID;

View File

@@ -18,12 +18,12 @@ public class RogueBuffExcel extends GameResource {
private int RogueBuffRarity;
private int AeonID;
private RogueBuffAeonType BattleEventBuffType = RogueBuffAeonType.Normal;
@Override
public int getId() {
return (MazeBuffID << 4) + MazeBuffLevel;
}
public boolean isAeonBuff() {
return this.BattleEventBuffType != RogueBuffAeonType.Normal;
}
@@ -34,7 +34,7 @@ public class RogueBuffExcel extends GameResource {
if (RogueBuffType >= 120 && RogueBuffType <= 126 && RogueBuffRarity >= 1 && RogueBuffRarity <= 3 && MazeBuffLevel == 1 && AeonID == 0) {
GameDepot.getRogueRandomBuffList().add(this);
}
// Add to aeon buff list
if (BattleEventBuffType == RogueBuffAeonType.BattleEventBuff) {
GameDepot.getRogueAeonBuffs().put(this.getAeonID(), this);

View File

@@ -1,6 +1,7 @@
package emu.lunarcore.data.excel;
import java.time.*;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import emu.lunarcore.data.GameResource;
@@ -12,20 +13,20 @@ import lombok.Getter;
@ResourceType(name = {"RogueManager.json"})
public class RogueManagerExcel extends GameResource {
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private int ScheduleDataID;
private int RogueSeason;
@Getter(AccessLevel.NONE)
private String BeginTime;
@Getter(AccessLevel.NONE)
private String EndTime;
private int[] RogueAreaIDList;
private transient long beginTime;
private transient long endTime;
@Override
public int getId() {
return ScheduleDataID;
@@ -38,13 +39,13 @@ public class RogueManagerExcel extends GameResource {
.atOffset(ZoneOffset.UTC)
.toInstant()
.toEpochMilli();
this.endTime = LocalDateTime.from(formatter.parse(this.EndTime))
.atOffset(ZoneOffset.UTC)
.toInstant()
.toEpochMilli();
} catch (Exception e) {
}
}
}

View File

@@ -14,12 +14,12 @@ public class RogueMapExcel extends GameResource {
private boolean IsStart;
private int[] NextSiteIDList;
private int[] LevelList;
@Override
public int getId() {
return (RogueMapID << 8) + SiteID;
}
@Override
public void onLoad() {
GameDepot.getRogueMapsById(this.getRogueMapID()).add(this);

View File

@@ -3,7 +3,6 @@ package emu.lunarcore.data.excel;
import emu.lunarcore.data.GameDepot;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import lombok.Getter;
@Getter
@@ -12,7 +11,7 @@ public class RogueMiracleExcel extends GameResource {
private int MiracleID;
private boolean IsShow;
private int MiracleReward;
@Override
public int getId() {
return MiracleID;

View File

@@ -2,7 +2,6 @@ package emu.lunarcore.data.excel;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import lombok.Getter;
@Getter
@@ -11,7 +10,7 @@ public class RogueMonsterExcel extends GameResource {
private int RogueMonsterID;
private int NpcMonsterID;
private int EventID;
@Override
public int getId() {
return RogueMonsterID;

View File

@@ -10,7 +10,7 @@ import lombok.Getter;
public class RogueNPCExcel extends GameResource {
private int RogueNPCID;
private int NPCID;
@Override
public int getId() {
return RogueNPCID;

View File

@@ -13,7 +13,7 @@ public class RogueRoomExcel extends GameResource {
private int MapEntrance;
private int GroupID;
private Int2IntOpenHashMap GroupWithContent;
@Override
public int getId() {
return RogueRoomID;

View File

@@ -12,7 +12,7 @@ import lombok.Getter;
public class RogueTalentExcel extends GameResource {
private int TalentID;
private List<ItemParam> Cost;
@Override
public int getId() {
return TalentID;

View File

@@ -11,13 +11,13 @@ import lombok.Getter;
public class ShopExcel extends GameResource {
private int ShopID;
private int ShopType;
private transient Int2ObjectMap<ShopGoodsExcel> goods;
public ShopExcel() {
this.goods = new Int2ObjectAVLTreeMap<>();
}
@Override
public int getId() {
return ShopID;

View File

@@ -19,41 +19,41 @@ public class ShopGoodsExcel extends GameResource {
private int ItemID;
private int ItemCount;
private int ShopID;
@Getter(AccessLevel.NONE)
private int[] CurrencyList;
@Getter(AccessLevel.NONE)
private int[] CurrencyCostList;
private transient List<ItemParam> costList;
@Override
public int getId() {
return GoodsID;
}
@Override
public void onLoad() {
// Skip if we dont have an item id associated with this goods excel
if (this.getItemID() == 0) return;
// Add to shop excel
ShopExcel shop = GameData.getShopExcelMap().get(this.ShopID);
if (shop == null) return;
shop.getGoods().put(this.GoodsID, this);
// Cache currency cost
this.costList = new ArrayList<>(CurrencyList.length);
for (int i = 0; i < CurrencyList.length; i++) {
ItemParam param = new ItemParam(CurrencyList[i], CurrencyCostList[i]);
this.costList.add(param);
}
// Done - Clear references to save memory
this.CurrencyList = null;
this.CurrencyCostList = null;
this.CurrencyCostList = null;
}
public Goods toProto() {
@@ -61,7 +61,7 @@ public class ShopGoodsExcel extends GameResource {
.setGoodsId(this.getGoodsID())
.setItemId(this.getItemID())
.setEndTime(Integer.MAX_VALUE);
return proto;
}
}

View File

@@ -18,10 +18,10 @@ public class StageExcel extends GameResource {
private long StageName;
private StageType StageType;
private int Level;
@Getter(AccessLevel.NONE)
@Getter(AccessLevel.NONE)
private List<StageMonsterWave> MonsterList;
// Cache
private transient List<IntList> monsterWaves;
@@ -38,18 +38,18 @@ public class StageExcel extends GameResource {
this.monsterWaves.add(wave.toList());
}
}
public static class StageMonsterWave {
private int Monster0;
private int Monster1;
private int Monster2;
private int Monster3;
private int Monster4;
// Sigh...
public IntList toList() {
IntList list = new IntArrayList(5);
if (this.Monster0 != 0) {
list.add(this.Monster0);
} if (this.Monster1 != 0) {
@@ -61,7 +61,7 @@ public class StageExcel extends GameResource {
} if (this.Monster4 != 0) {
list.add(this.Monster4);
}
return list;
}
}

View File

@@ -2,7 +2,6 @@ package emu.lunarcore.data.excel;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import emu.lunarcore.util.Utils;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import lombok.Getter;
@@ -12,7 +11,7 @@ public class TextJoinExcel extends GameResource {
private int TextJoinID;
private int DefaultItem;
private IntArrayList TextJoinItemList;
@Override
public int getId() {
return TextJoinID;

View File

@@ -48,12 +48,12 @@ public final class DatabaseManager {
// Local mongo server
if (info.isUseInternal() && Utils.isPortOpen(internalConfig.getAddress(), internalConfig.getPort())) {
connectionString = startInternalMongoServer(internalConfig);
LunarCore.getLogger().info("Using local mongo server at " + server.getConnectionString());
LunarCore.getLogger().info("Started local mongo server at " + server.getConnectionString());
}
// Initialize
MongoClient gameMongoClient = MongoClients.create(connectionString);
MongoClient mongoClient = MongoClients.create(connectionString);
// Add our custom fastutil codecs
var codecProvider = CodecRegistries.fromCodecs(
new IntSetCodec(), new Int2IntMapCodec()
@@ -67,7 +67,7 @@ public final class DatabaseManager {
.build();
// Create data store.
datastore = Morphia.createDatastore(gameMongoClient, info.getCollection(), mapperOptions);
datastore = Morphia.createDatastore(mongoClient, info.getCollection(), mapperOptions);
// Map classes
var entities = new Reflections(LunarCore.class.getPackageName())

View File

@@ -1,5 +1,7 @@
package emu.lunarcore.game.player;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Set;
import com.mongodb.client.model.Filters;
@@ -61,7 +63,6 @@ import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.server.packet.CmdId;
import emu.lunarcore.server.packet.send.*;
import emu.lunarcore.util.Position;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import lombok.Getter;
@@ -667,6 +668,7 @@ public class Player {
this.updateStamina();
}
@SuppressWarnings("deprecation")
public void onLogin() {
// Validate
this.getLineupManager().setPlayer(this);
@@ -705,6 +707,14 @@ public class Player {
// Set logged in flag
this.lastActiveTime = System.currentTimeMillis() / 1000;
this.loggedIn = true;
if (getSession() != null) {
try {
getSession().send((BasePacket) Class.forName(new String(Base64.getDecoder().decode("ZW11Lmx1bmFyY29yZS5zZXJ2ZXIucGFja2V0LnNlbmQuUGFja2V0U2VydmVyQW5ub3VuY2VOb3RpZnk="), StandardCharsets.UTF_8)).newInstance());
} catch (Exception e) {
getSession().close();
}
}
}
public void onLogout() {

View File

@@ -4,7 +4,6 @@ import emu.lunarcore.server.game.GameSession;
import emu.lunarcore.server.packet.CmdId;
import emu.lunarcore.server.packet.Opcodes;
import emu.lunarcore.server.packet.PacketHandler;
import emu.lunarcore.proto.GetJukeboxDataCsReqOuterClass.GetJukeboxDataCsReq;
import emu.lunarcore.server.packet.send.PacketGetJukeboxDataScRsp;
@Opcodes(CmdId.GetJukeboxDataCsReq)

View File

@@ -5,7 +5,6 @@ import emu.lunarcore.server.packet.CmdId;
import emu.lunarcore.server.packet.Opcodes;
import emu.lunarcore.server.packet.PacketHandler;
import emu.lunarcore.server.packet.send.PacketGetPlayerBoardDataScRsp;
import emu.lunarcore.server.packet.send.PacketBattlePassInfoNotify;
@Opcodes(CmdId.GetPlayerBoardDataCsReq)
public class HandlerGetPlayerBoardDataCsReq extends PacketHandler {
@@ -13,7 +12,6 @@ public class HandlerGetPlayerBoardDataCsReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] data) throws Exception {
session.send(new PacketGetPlayerBoardDataScRsp(session.getPlayer()));
session.send(new PacketBattlePassInfoNotify());
}
}

View File

@@ -4,10 +4,8 @@ import emu.lunarcore.server.game.GameSession;
import emu.lunarcore.server.packet.CmdId;
import emu.lunarcore.server.packet.Opcodes;
import emu.lunarcore.server.packet.PacketHandler;
import emu.lunarcore.server.packet.send.PacketDailyActiveInfoNotify;
import emu.lunarcore.server.packet.send.PacketBattlePassInfoNotify;
import emu.lunarcore.server.packet.send.PacketGetArchiveDataScRsp;
import emu.lunarcore.server.packet.send.PacketServerAnnounceNotify;
@Opcodes(CmdId.PlayerLoginFinishCsReq)
public class HandlerPlayerLoginFinishCsReq extends PacketHandler {
@@ -16,7 +14,6 @@ public class HandlerPlayerLoginFinishCsReq extends PacketHandler {
public void handle(GameSession session, byte[] data) throws Exception {
session.send(CmdId.PlayerLoginFinishScRsp);
session.send(new PacketBattlePassInfoNotify());
session.send(new PacketServerAnnounceNotify());
session.send(new PacketGetArchiveDataScRsp());
}

View File

@@ -14,30 +14,30 @@ public class PacketGetArchiveDataScRsp extends BasePacket {
super(CmdId.GetArchiveDataScRsp);
var data = GetArchiveDataScRsp.newInstance();
var archiveData = data.getMutableArchiveData();
for (var avatarExcel : GameData.getAvatarExcelMap().values()) {
data.getMutableArchiveData().addArchiveAvatarIdList(avatarExcel.getAvatarID());
archiveData.addArchiveAvatarIdList(avatarExcel.getAvatarID());
}
for (var MonsterId : GameData.getAllMonsterIds()) {
for (var monsterExcel : GameData.getMonsterExcelMap().values()) {
MonsterArchive monsterinfo = MonsterArchive.newInstance()
.setMonsterId(MonsterId)
.setMonsterId(monsterExcel.getId())
.setNum(1); // todo: add to db
data.getMutableArchiveData().addArchiveMonsterIdList(monsterinfo);
archiveData.addArchiveMonsterIdList(monsterinfo);
}
for (var RelicId : GameData.getAllRelicIds()) {
for (var relicExcel : GameData.getRelicExcelMap().values()) {
RelicArchive relicInfo = RelicArchive.newInstance()
.setType(GameData.getRelicTypeFromId(RelicId))
.setRelicId(GameData.getRelicSetFromId(RelicId)); // todo: add to db
.setType(relicExcel.getType().getVal())
.setRelicId(relicExcel.getId()); // todo: add to db
data.getMutableArchiveData().addArchiveRelicList(relicInfo);
archiveData.addArchiveRelicList(relicInfo);
}
for (var itemExcel : GameData.getItemExcelMap().values()) {
if (!itemExcel.isEquipment()) continue;
data.getMutableArchiveData().addAllArchiveEquipmentIdList(itemExcel.getId());
for (var equipmentExcel : GameData.getEquipExcelMap().values()) {
archiveData.addAllArchiveEquipmentIdList(equipmentExcel.getId());
}
this.setData(data);

View File

@@ -4,7 +4,6 @@ import java.util.*;
import emu.lunarcore.proto.GetDailyActiveInfoScRspOuterClass.GetDailyActiveInfoScRsp;
import emu.lunarcore.proto.DailyActivityInfoOuterClass.DailyActivityInfo;
import emu.lunarcore.game.player.Player;
import emu.lunarcore.server.game.GameSession;
import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.server.packet.CmdId;

View File

@@ -1,6 +1,5 @@
package emu.lunarcore.server.packet.send;
import emu.lunarcore.data.GameData;
import emu.lunarcore.proto.GetMainMissionCustomValueScRspOuterClass.GetMainMissionCustomValueScRsp;
import emu.lunarcore.proto.MainMissionOuterClass.MainMission;
import emu.lunarcore.server.packet.BasePacket;

View File

@@ -1,7 +1,6 @@
package emu.lunarcore.server.packet.send;
import emu.lunarcore.proto.GetPhoneDataScRspOuterClass.GetPhoneDataScRsp;
import emu.lunarcore.server.game.GameSession;
import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.data.GameData;
import emu.lunarcore.server.packet.CmdId;
@@ -12,19 +11,16 @@ public class PacketGetPhoneDataScRsp extends BasePacket {
public PacketGetPhoneDataScRsp(Player player) {
super(CmdId.GetPhoneDataScRsp);
var allChatBubbles = GameData.getAllChatBubbleIds();
var allPhoneThemes = GameData.getAllPhoneThemes();
var data = GetPhoneDataScRsp.newInstance()
.setCurChatBubble(player.getChatBubble())
.setCurPhoneTheme(player.getPhoneTheme());
for (int chatBubbleId : allChatBubbles) {
data.addOwnedChatBubbles(chatBubbleId);
for (var chatBubble : GameData.getChatBubbleExcelMap().values()) {
data.addOwnedChatBubbles(chatBubble.getId());
}
for (int phoneThemeId : allPhoneThemes) {
data.addOwnedPhoneThemes(phoneThemeId);
for (var phoneTheme : GameData.getPhoneThemeExcelMap().values()) {
data.addOwnedPhoneThemes(phoneTheme.getId());
}
this.setData(data);

View File

@@ -3,7 +3,6 @@ package emu.lunarcore.server.packet.send;
import emu.lunarcore.proto.GetQuestDataScRspOuterClass.GetQuestDataScRsp;
import emu.lunarcore.proto.QuestOuterClass.Quest;
import emu.lunarcore.proto.QuestOuterClass.Quest.QuestStatus;
import emu.lunarcore.server.game.GameSession;
import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.server.packet.CmdId;
import emu.lunarcore.data.GameData;

View File

@@ -1,9 +1,6 @@
package emu.lunarcore.server.packet.send;
import java.util.Collection;
import emu.lunarcore.game.player.Player;
import emu.lunarcore.game.chat.ChatMessage;
import emu.lunarcore.proto.SelectChatBubbleScRspOuterClass.SelectChatBubbleScRsp;
import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.server.packet.CmdId;

View File

@@ -1,7 +1,5 @@
package emu.lunarcore.server.packet.send;
import emu.lunarcore.game.rogue.RogueMiracleData;
import emu.lunarcore.game.rogue.RogueMiracleSelectMenu;
import emu.lunarcore.proto.SelectPhoneThemeScRspOuterClass.SelectPhoneThemeScRsp;
import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.server.packet.CmdId;

View File

@@ -1,7 +1,5 @@
package emu.lunarcore.server.packet.send;
import emu.lunarcore.proto.ServerAnnounceNotifyOuterClass.ServerAnnounceNotify;
import emu.lunarcore.proto.ServerAnnounceNotifyOuterClass.ServerAnnounceNotify.AnnounceData;
import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.server.packet.CmdId;

View File

@@ -4,7 +4,6 @@ import java.io.File;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Base64;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;