mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-16 07:14:58 +01:00
Cleanup some code
This commit is contained in:
@@ -19,17 +19,6 @@ public class AvatarPromotionExcel extends GameResource {
|
|||||||
private int WorldLevelRequire;
|
private int WorldLevelRequire;
|
||||||
private List<ItemParam> PromotionCostList;
|
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
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return (AvatarID << 8) + Promotion;
|
return (AvatarID << 8) + Promotion;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import emu.lunarcore.game.enums.ItemSubType;
|
|||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
import it.unimi.dsi.fastutil.ints.IntList;
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -23,6 +24,8 @@ public class MappingInfoExcel extends GameResource {
|
|||||||
private int ID;
|
private int ID;
|
||||||
private int WorldLevel;
|
private int WorldLevel;
|
||||||
private String FarmType; // is enum
|
private String FarmType; // is enum
|
||||||
|
|
||||||
|
@Getter(AccessLevel.PRIVATE)
|
||||||
private List<ItemParam> DisplayItemList;
|
private List<ItemParam> DisplayItemList;
|
||||||
|
|
||||||
// Temp solution for handling drop tables
|
// 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import emu.lunarcore.data.ResourceType;
|
|||||||
import emu.lunarcore.data.ResourceType.LoadPriority;
|
import emu.lunarcore.data.ResourceType.LoadPriority;
|
||||||
import emu.lunarcore.data.common.ItemParam;
|
import emu.lunarcore.data.common.ItemParam;
|
||||||
import emu.lunarcore.game.drops.DropParam;
|
import emu.lunarcore.game.drops.DropParam;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -19,6 +20,7 @@ public class MonsterDropExcel extends GameResource {
|
|||||||
private int WorldLevel;
|
private int WorldLevel;
|
||||||
private int AvatarExpReward;
|
private int AvatarExpReward;
|
||||||
|
|
||||||
|
@Getter(AccessLevel.PRIVATE)
|
||||||
private List<ItemParam> DisplayItemList;
|
private List<ItemParam> DisplayItemList;
|
||||||
|
|
||||||
// Temp solution for handling drop tables
|
// Temp solution for handling drop tables
|
||||||
@@ -76,5 +78,8 @@ public class MonsterDropExcel extends GameResource {
|
|||||||
dropList.add(drop);
|
dropList.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear list once were done with it to free some memory
|
||||||
|
this.DisplayItemList = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import de.bwaldvogel.mongo.backend.memory.MemoryBackend;
|
|||||||
|
|
||||||
import dev.morphia.Datastore;
|
import dev.morphia.Datastore;
|
||||||
import dev.morphia.DeleteOptions;
|
import dev.morphia.DeleteOptions;
|
||||||
|
import dev.morphia.InsertOneOptions;
|
||||||
import dev.morphia.Morphia;
|
import dev.morphia.Morphia;
|
||||||
import dev.morphia.annotations.Entity;
|
import dev.morphia.annotations.Entity;
|
||||||
import dev.morphia.mapping.Mapper;
|
import dev.morphia.mapping.Mapper;
|
||||||
@@ -38,7 +39,9 @@ public final class DatabaseManager {
|
|||||||
@Getter private static MongoServer server;
|
@Getter private static MongoServer server;
|
||||||
private Datastore datastore;
|
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) {
|
public DatabaseManager(DatabaseInfo info, ServerType type) {
|
||||||
// Variables
|
// Variables
|
||||||
@@ -48,7 +51,7 @@ public final class DatabaseManager {
|
|||||||
// Local mongo server
|
// Local mongo server
|
||||||
if (info.isUseInternal() && Utils.isPortOpen(internalConfig.getAddress(), internalConfig.getPort())) {
|
if (info.isUseInternal() && Utils.isPortOpen(internalConfig.getAddress(), internalConfig.getPort())) {
|
||||||
connectionString = startInternalMongoServer(internalConfig);
|
connectionString = startInternalMongoServer(internalConfig);
|
||||||
LunarCore.getLogger().info("Started local mongo server at " + server.getConnectionString());
|
LunarCore.getLogger().info("Started local MongoDB server at " + server.getConnectionString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
@@ -59,7 +62,7 @@ public final class DatabaseManager {
|
|||||||
new IntSetCodec(), new IntListCodec(), new Int2IntMapCodec()
|
new IntSetCodec(), new IntListCodec(), new Int2IntMapCodec()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set mapper options.
|
// Set mapper options
|
||||||
MapperOptions mapperOptions = MapperOptions.builder()
|
MapperOptions mapperOptions = MapperOptions.builder()
|
||||||
.storeEmpties(true)
|
.storeEmpties(true)
|
||||||
.storeNulls(false)
|
.storeNulls(false)
|
||||||
@@ -149,11 +152,11 @@ public final class DatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T> void save(T obj) {
|
public <T> void save(T obj) {
|
||||||
getDatastore().save(obj);
|
getDatastore().save(obj, INSERT_OPTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> boolean delete(T obj) {
|
public <T> boolean delete(T obj) {
|
||||||
DeleteResult result = getDatastore().delete(obj);
|
DeleteResult result = getDatastore().delete(obj, DELETE_OPTIONS);
|
||||||
return result.getDeletedCount() > 0;
|
return result.getDeletedCount() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -247,7 +247,6 @@ public class GameItem {
|
|||||||
} else if (this.getId() != null) {
|
} else if (this.getId() != null) {
|
||||||
LunarCore.getGameDatabase().delete(this);
|
LunarCore.getGameDatabase().delete(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proto
|
// Proto
|
||||||
|
|||||||
@@ -80,8 +80,6 @@ public class ItemUseHandler {
|
|||||||
player.addFoodBuff(excel.getConsumeType(), excel);
|
player.addFoodBuff(excel.getConsumeType(), excel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO send buff refresh packet
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user