mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-15 05:44:36 +01:00
Add !character command
This commit is contained in:
@@ -16,7 +16,7 @@ import us.hebi.quickbuf.RepeatedInt;
|
||||
@Getter
|
||||
@Entity(useDiscriminator = false)
|
||||
public class CharacterContact {
|
||||
private transient Character character;
|
||||
private transient GameCharacter character;
|
||||
|
||||
private boolean top;
|
||||
private long triggerTime;
|
||||
@@ -27,7 +27,7 @@ public class CharacterContact {
|
||||
|
||||
}
|
||||
|
||||
public CharacterContact(Character character) {
|
||||
public CharacterContact(GameCharacter character) {
|
||||
this.character = character;
|
||||
this.chats = new HashMap<>();
|
||||
this.triggerTime = character.getCreateTime();
|
||||
@@ -45,7 +45,7 @@ public class CharacterContact {
|
||||
}
|
||||
}
|
||||
|
||||
public void setCharacter(Character character) {
|
||||
public void setCharacter(GameCharacter character) {
|
||||
this.character = character;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class CharacterGemPreset {
|
||||
|
||||
}
|
||||
|
||||
public CharacterGemPreset(Character character) {
|
||||
public CharacterGemPreset(GameCharacter character) {
|
||||
this.gems = new int[] {-1, -1, -1};
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class CharacterStorage extends PlayerManager {
|
||||
private final Int2ObjectMap<Character> characters;
|
||||
private final Int2ObjectMap<GameCharacter> characters;
|
||||
private final Int2ObjectMap<GameDisc> discs;
|
||||
|
||||
public CharacterStorage(Player player) {
|
||||
@@ -28,7 +28,7 @@ public class CharacterStorage extends PlayerManager {
|
||||
|
||||
// Characters
|
||||
|
||||
public Character getCharacterById(int id) {
|
||||
public GameCharacter getCharacterById(int id) {
|
||||
if (id <= 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class CharacterStorage extends PlayerManager {
|
||||
return this.characters.containsKey(id);
|
||||
}
|
||||
|
||||
public Character addCharacter(int charId) {
|
||||
public GameCharacter addCharacter(int charId) {
|
||||
// Sanity check to make sure we dont have this character already
|
||||
if (this.hasCharacter(charId)) {
|
||||
return null;
|
||||
@@ -49,14 +49,14 @@ public class CharacterStorage extends PlayerManager {
|
||||
return this.addCharacter(GameData.getCharacterDataTable().get(charId));
|
||||
}
|
||||
|
||||
private Character addCharacter(CharacterDef data) {
|
||||
private GameCharacter addCharacter(CharacterDef data) {
|
||||
// Sanity check to make sure we dont have this character already
|
||||
if (this.hasCharacter(data.getId())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create character
|
||||
var character = new Character(this.getPlayer(), data);
|
||||
var character = new GameCharacter(this.getPlayer(), data);
|
||||
|
||||
// Save to database
|
||||
character.save();
|
||||
@@ -66,7 +66,7 @@ public class CharacterStorage extends PlayerManager {
|
||||
return character;
|
||||
}
|
||||
|
||||
public Collection<Character> getCharacterCollection() {
|
||||
public Collection<GameCharacter> getCharacterCollection() {
|
||||
return this.getCharacters().values();
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public class CharacterStorage extends PlayerManager {
|
||||
public void loadFromDatabase() {
|
||||
var db = Nebula.getGameDatabase();
|
||||
|
||||
db.getObjects(Character.class, "playerUid", getPlayerUid()).forEach(character -> {
|
||||
db.getObjects(GameCharacter.class, "playerUid", getPlayerUid()).forEach(character -> {
|
||||
// Get data
|
||||
var data = GameData.getCharacterDataTable().get(character.getCharId());
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import us.hebi.quickbuf.RepeatedInt;
|
||||
|
||||
@Getter
|
||||
@Entity(value = "characters", useDiscriminator = false)
|
||||
public class Character implements GameDatabaseObject {
|
||||
public class GameCharacter implements GameDatabaseObject {
|
||||
@Id
|
||||
private ObjectId uid;
|
||||
@Indexed
|
||||
@@ -65,15 +65,15 @@ public class Character implements GameDatabaseObject {
|
||||
private CharacterContact contact;
|
||||
|
||||
@Deprecated // Morphia only!
|
||||
public Character() {
|
||||
public GameCharacter() {
|
||||
|
||||
}
|
||||
|
||||
public Character(Player player, int charId) {
|
||||
public GameCharacter(Player player, int charId) {
|
||||
this(player, GameData.getCharacterDataTable().get(charId));
|
||||
}
|
||||
|
||||
public Character(Player player, CharacterDef data) {
|
||||
public GameCharacter(Player player, CharacterDef data) {
|
||||
this.player = player;
|
||||
this.playerUid = player.getUid();
|
||||
this.charId = data.getId();
|
||||
@@ -110,6 +110,14 @@ public class Character implements GameDatabaseObject {
|
||||
}
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public void setAdvance(int advance) {
|
||||
this.advance = advance;
|
||||
}
|
||||
|
||||
public int getMaxGainableExp() {
|
||||
if (this.getLevel() >= this.getMaxLevel()) {
|
||||
return 0;
|
||||
@@ -12,7 +12,7 @@ import emu.nebula.game.GameContextModule;
|
||||
import emu.nebula.game.account.Account;
|
||||
import emu.nebula.game.agent.AgentManager;
|
||||
import emu.nebula.game.battlepass.BattlePass;
|
||||
import emu.nebula.game.character.Character;
|
||||
import emu.nebula.game.character.GameCharacter;
|
||||
import emu.nebula.game.character.GameDisc;
|
||||
import emu.nebula.game.formation.FormationManager;
|
||||
import emu.nebula.game.friends.Friendship;
|
||||
@@ -167,7 +167,7 @@ public class PlayerModule extends GameContextModule {
|
||||
var datastore = Nebula.getGameDatabase().getDatastore();
|
||||
|
||||
// Delete data from collections
|
||||
datastore.getCollection(Character.class).deleteMany(multiFilter);
|
||||
datastore.getCollection(GameCharacter.class).deleteMany(multiFilter);
|
||||
datastore.getCollection(GameDisc.class).deleteMany(multiFilter);
|
||||
datastore.getCollection(GameItem.class).deleteMany(multiFilter);
|
||||
datastore.getCollection(GameResource.class).deleteMany(multiFilter);
|
||||
|
||||
@@ -11,7 +11,7 @@ import dev.morphia.annotations.Id;
|
||||
import emu.nebula.database.GameDatabaseObject;
|
||||
import emu.nebula.game.player.Player;
|
||||
import emu.nebula.game.tower.StarTowerBuild;
|
||||
import emu.nebula.game.character.Character;
|
||||
import emu.nebula.game.character.GameCharacter;
|
||||
import emu.nebula.proto.Public.HonorInfo;
|
||||
import emu.nebula.proto.ScoreBossRank.ScoreBossRankChar;
|
||||
import emu.nebula.proto.ScoreBossRank.ScoreBossRankData;
|
||||
@@ -155,7 +155,7 @@ public class ScoreBossRankEntry implements GameDatabaseObject {
|
||||
|
||||
}
|
||||
|
||||
public ScoreBossCharEntry(Character character) {
|
||||
public ScoreBossCharEntry(GameCharacter character) {
|
||||
this.id = character.getCharId();
|
||||
this.level = character.getLevel();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user