forked from MagicBane/Server
Moving items out of constructor.
This commit is contained in:
@@ -45,7 +45,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|||||||
|
|
||||||
public abstract class AbstractCharacter extends AbstractWorldObject {
|
public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||||
|
|
||||||
protected final CharacterItemManager charItemManager;
|
protected CharacterItemManager charItemManager;
|
||||||
private final ReentrantReadWriteLock healthLock = new ReentrantReadWriteLock();
|
private final ReentrantReadWriteLock healthLock = new ReentrantReadWriteLock();
|
||||||
public short level;
|
public short level;
|
||||||
public AbstractWorldObject combatTarget;
|
public AbstractWorldObject combatTarget;
|
||||||
@@ -122,6 +122,15 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
|||||||
private boolean collided = false;
|
private boolean collided = false;
|
||||||
private byte aoecntr = 0;
|
private byte aoecntr = 0;
|
||||||
|
|
||||||
|
public AbstractCharacter() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.powers = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||||
|
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||||
|
this.initializeCharacter();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* No Id Constructor
|
* No Id Constructor
|
||||||
*/
|
*/
|
||||||
@@ -136,7 +145,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
|||||||
final short level,
|
final short level,
|
||||||
final int exp,
|
final int exp,
|
||||||
final Vector3fImmutable bindLoc,
|
final Vector3fImmutable bindLoc,
|
||||||
final Vector3fImmutable currentLoc,
|
|
||||||
final Vector3fImmutable faceDir,
|
final Vector3fImmutable faceDir,
|
||||||
final Guild guild,
|
final Guild guild,
|
||||||
final byte runningTrains
|
final byte runningTrains
|
||||||
@@ -154,7 +162,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
|||||||
this.exp = exp;
|
this.exp = exp;
|
||||||
this.walkMode = true;
|
this.walkMode = true;
|
||||||
this.bindLoc = bindLoc;
|
this.bindLoc = bindLoc;
|
||||||
;
|
|
||||||
this.faceDir = faceDir;
|
this.faceDir = faceDir;
|
||||||
this.guild = guild;
|
this.guild = guild;
|
||||||
this.runningTrains = runningTrains;
|
this.runningTrains = runningTrains;
|
||||||
@@ -162,8 +169,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
|||||||
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||||
this.initializeCharacter();
|
this.initializeCharacter();
|
||||||
|
|
||||||
// Dangerous to use THIS in a constructor!!!
|
|
||||||
this.charItemManager = new CharacterItemManager(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
|||||||
Guild guild, byte runningTrains) {
|
Guild guild, byte runningTrains) {
|
||||||
super(firstName, lastName, statStrCurrent, statDexCurrent, statConCurrent,
|
super(firstName, lastName, statStrCurrent, statDexCurrent, statConCurrent,
|
||||||
statIntCurrent, statSpiCurrent, level, exp, bindLoc,
|
statIntCurrent, statSpiCurrent, level, exp, bindLoc,
|
||||||
currentLoc, faceDir, guild,
|
faceDir, guild,
|
||||||
runningTrains);
|
runningTrains);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1928,6 +1928,10 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
@Override
|
@Override
|
||||||
public void runAfterLoad() {
|
public void runAfterLoad() {
|
||||||
|
|
||||||
|
// Initialize inventory
|
||||||
|
|
||||||
|
this.charItemManager = new CharacterItemManager(this);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.equipmentSetID != 0)
|
if (this.equipmentSetID != 0)
|
||||||
this.equip = MobBase.loadEquipmentSet(this.equipmentSetID);
|
this.equip = MobBase.loadEquipmentSet(this.equipmentSetID);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class NPC extends AbstractCharacter {
|
|||||||
Vector3fImmutable currentLoc, Vector3fImmutable faceDir, short healthCurrent, short manaCurrent, short stamCurrent, Guild guild,
|
Vector3fImmutable currentLoc, Vector3fImmutable faceDir, short healthCurrent, short manaCurrent, short stamCurrent, Guild guild,
|
||||||
byte runningTrains, int npcType, boolean isMob, Building building, int contractID, Zone parent) {
|
byte runningTrains, int npcType, boolean isMob, Building building, int contractID, Zone parent) {
|
||||||
super(name, "", statStrCurrent, statDexCurrent, statConCurrent, statIntCurrent, statSpiCurrent, level, exp,
|
super(name, "", statStrCurrent, statDexCurrent, statConCurrent, statIntCurrent, statSpiCurrent, level, exp,
|
||||||
bindLoc, currentLoc, faceDir, guild, runningTrains);
|
bindLoc, faceDir, guild, runningTrains);
|
||||||
this.loadID = npcType;
|
this.loadID = npcType;
|
||||||
this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID);
|
this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID);
|
||||||
|
|
||||||
@@ -1049,6 +1049,10 @@ public class NPC extends AbstractCharacter {
|
|||||||
if (wordCount(this.name) < 2 && this.contract != null)
|
if (wordCount(this.name) < 2 && this.contract != null)
|
||||||
this.name += " the " + this.contract.getName();
|
this.name += " the " + this.contract.getName();
|
||||||
|
|
||||||
|
// Initialize inventory
|
||||||
|
|
||||||
|
this.charItemManager = new CharacterItemManager(this);
|
||||||
|
|
||||||
// Configure parent zone adding this NPC to the
|
// Configure parent zone adding this NPC to the
|
||||||
// zone collection
|
// zone collection
|
||||||
|
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
short spiMod, Guild guild, byte runningTrains, Account account, Race race, BaseClass baseClass, byte skinColor, byte hairColor,
|
short spiMod, Guild guild, byte runningTrains, Account account, Race race, BaseClass baseClass, byte skinColor, byte hairColor,
|
||||||
byte beardColor, byte hairStyle, byte beardStyle) {
|
byte beardColor, byte hairStyle, byte beardStyle) {
|
||||||
super(firstName, lastName, (short) 1, (short) 1, (short) 1, (short) 1, (short) 1, (short) 1, 0,
|
super(firstName, lastName, (short) 1, (short) 1, (short) 1, (short) 1, (short) 1, (short) 1, 0,
|
||||||
Vector3fImmutable.ZERO, Vector3fImmutable.ZERO, Vector3fImmutable.ZERO,
|
Vector3fImmutable.ZERO, Vector3fImmutable.ZERO,
|
||||||
guild, runningTrains);
|
guild, runningTrains);
|
||||||
|
|
||||||
this.runes = new ArrayList<>();
|
this.runes = new ArrayList<>();
|
||||||
@@ -4582,10 +4582,9 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
@Override
|
@Override
|
||||||
public void runAfterLoad() {
|
public void runAfterLoad() {
|
||||||
|
|
||||||
// Create player bounds object
|
// Init inventory
|
||||||
|
|
||||||
// if ((MBServer.getApp() instanceof engine.server.world.WorldServer))
|
this.charItemManager = new CharacterItemManager(this);
|
||||||
// DbManager.GuildQueries.LOAD_GUILD_HISTORY_FOR_PLAYER(this);
|
|
||||||
|
|
||||||
Bounds playerBounds = Bounds.borrow();
|
Bounds playerBounds = Bounds.borrow();
|
||||||
playerBounds.setBounds(this.getLoc());
|
playerBounds.setBounds(this.getLoc());
|
||||||
|
|||||||
Reference in New Issue
Block a user