Cleanup some code

This commit is contained in:
Melledy
2023-12-16 02:20:47 -08:00
parent 6925ef4fe6
commit 5a88b233b2
6 changed files with 19 additions and 19 deletions

View File

@@ -19,17 +19,6 @@ public class AvatarPromotionExcel extends GameResource {
private int WorldLevelRequire;
private List<ItemParam> PromotionCostList;
private double AttackBase;
private double AttackAdd;
private double DefenceBase;
private double DefenceAdd;
private double HPBase;
private double HPAdd;
private double SpeedBase;
private double CriticalChance;
private double CriticalDamage;
private double BaseAggro;
@Override
public int getId() {
return (AvatarID << 8) + Promotion;

View File

@@ -15,6 +15,7 @@ import emu.lunarcore.game.enums.ItemSubType;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import lombok.AccessLevel;
import lombok.Getter;
@Getter
@@ -23,6 +24,8 @@ public class MappingInfoExcel extends GameResource {
private int ID;
private int WorldLevel;
private String FarmType; // is enum
@Getter(AccessLevel.PRIVATE)
private List<ItemParam> DisplayItemList;
// Temp solution for handling drop tables
@@ -198,5 +201,8 @@ public class MappingInfoExcel extends GameResource {
}
}
}
// Clear list once were done with it to free some memory
this.DisplayItemList = null;
}
}

View File

@@ -10,6 +10,7 @@ import emu.lunarcore.data.ResourceType;
import emu.lunarcore.data.ResourceType.LoadPriority;
import emu.lunarcore.data.common.ItemParam;
import emu.lunarcore.game.drops.DropParam;
import lombok.AccessLevel;
import lombok.Getter;
@Getter
@@ -19,6 +20,7 @@ public class MonsterDropExcel extends GameResource {
private int WorldLevel;
private int AvatarExpReward;
@Getter(AccessLevel.PRIVATE)
private List<ItemParam> DisplayItemList;
// Temp solution for handling drop tables
@@ -76,5 +78,8 @@ public class MonsterDropExcel extends GameResource {
dropList.add(drop);
}
}
// Clear list once were done with it to free some memory
this.DisplayItemList = null;
}
}

View File

@@ -20,6 +20,7 @@ import de.bwaldvogel.mongo.backend.memory.MemoryBackend;
import dev.morphia.Datastore;
import dev.morphia.DeleteOptions;
import dev.morphia.InsertOneOptions;
import dev.morphia.Morphia;
import dev.morphia.annotations.Entity;
import dev.morphia.mapping.Mapper;
@@ -38,7 +39,9 @@ public final class DatabaseManager {
@Getter private static MongoServer server;
private Datastore datastore;
private final DeleteOptions DELETE_MANY = new DeleteOptions().multi(true);
private static final InsertOneOptions INSERT_OPTIONS = new InsertOneOptions();
private static final DeleteOptions DELETE_OPTIONS = new DeleteOptions();
private static final DeleteOptions DELETE_MANY = new DeleteOptions().multi(true);
public DatabaseManager(DatabaseInfo info, ServerType type) {
// Variables
@@ -48,7 +51,7 @@ public final class DatabaseManager {
// Local mongo server
if (info.isUseInternal() && Utils.isPortOpen(internalConfig.getAddress(), internalConfig.getPort())) {
connectionString = startInternalMongoServer(internalConfig);
LunarCore.getLogger().info("Started local mongo server at " + server.getConnectionString());
LunarCore.getLogger().info("Started local MongoDB server at " + server.getConnectionString());
}
// Initialize
@@ -59,7 +62,7 @@ public final class DatabaseManager {
new IntSetCodec(), new IntListCodec(), new Int2IntMapCodec()
);
// Set mapper options.
// Set mapper options
MapperOptions mapperOptions = MapperOptions.builder()
.storeEmpties(true)
.storeNulls(false)
@@ -149,11 +152,11 @@ public final class DatabaseManager {
}
public <T> void save(T obj) {
getDatastore().save(obj);
getDatastore().save(obj, INSERT_OPTIONS);
}
public <T> boolean delete(T obj) {
DeleteResult result = getDatastore().delete(obj);
DeleteResult result = getDatastore().delete(obj, DELETE_OPTIONS);
return result.getDeletedCount() > 0;
}

View File

@@ -247,7 +247,6 @@ public class GameItem {
} else if (this.getId() != null) {
LunarCore.getGameDatabase().delete(this);
}
}
// Proto

View File

@@ -80,8 +80,6 @@ public class ItemUseHandler {
player.addFoodBuff(excel.getConsumeType(), excel);
}
// TODO send buff refresh packet
return true;
}
}