java.lang.Object com.realtime.crossfire.jxclient.spells.SpellsManager
public class SpellsManager
Manages all known spells.
Field Summary | |
---|---|
private CrossfireSpellListener |
crossfireSpellListener
The listener to receive updates for spell information. |
private GuiStateListener |
guiStateListener
The GuiStateListener for detecting established or dropped
connections. |
private java.util.Collection<SpellsManagerListener> |
listeners
The SpellsManagerListeners to notify about
changes. |
private java.util.Comparator<Spell> |
spellNameComparator
A Comparator to compare Spell instances by spell path and
name. |
private java.util.List<Spell> |
spells
All known spells. |
private java.util.Map<java.lang.String,Spell> |
unknownSpells
All unknown spells that have been referenced before. |
Constructor Summary | |
---|---|
SpellsManager(CrossfireServerConnection crossfireServerConnection,
GuiStateManager guiStateManager)
Create a new instance. |
Method Summary | |
---|---|
void |
addCrossfireSpellChangedListener(SpellsManagerListener listener)
Adds a SpellsManagerListener to notify about changes. |
private void |
addSpell(int tag,
int level,
int castingTime,
int mana,
int grace,
int damage,
int skill,
int path,
int faceNum,
java.lang.String spellName,
java.lang.String message)
Adds a new spell. |
private void |
deleteSpell(int tag)
Deletes a spell. |
private void |
deleteSpellByIndex(int index)
Deletes a spell by index into spells . |
Spell |
getSpell(int index)
Returns a Spell instance by index. |
Spell |
getSpell(java.lang.String spellName)
Returns a Spell instance by spell name. |
int |
getSpells()
Returns the number of known spells. |
private void |
initSpells()
|
java.util.Iterator<Spell> |
iterator()
|
void |
removeCrossfireSpellChangedListener(SpellsManagerListener listener)
Removes a SpellsManagerListener to notify about changes. |
private void |
updateSpell(int flags,
int tag,
int mana,
int grace,
int damage)
Updates spell information. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
@NotNull private final CrossfireSpellListener crossfireSpellListener
@NotNull private final GuiStateListener guiStateListener
GuiStateListener
for detecting established or dropped
connections.
@NotNull private final java.util.Collection<SpellsManagerListener> listeners
SpellsManagerListeners
to notify about
changes.
@NotNull private final java.util.Comparator<Spell> spellNameComparator
Comparator
to compare Spell
instances by spell path and
name.
@NotNull private final java.util.List<Spell> spells
@NotNull private final java.util.Map<java.lang.String,Spell> unknownSpells
Spell
instance.
Constructor Detail |
---|
public SpellsManager(@NotNull CrossfireServerConnection crossfireServerConnection, @NotNull GuiStateManager guiStateManager)
crossfireServerConnection
- the connection to listen onguiStateManager
- the gui state manager to watchMethod Detail |
---|
public void addCrossfireSpellChangedListener(@NotNull SpellsManagerListener listener)
SpellsManagerListener
to notify about changes.
listener
- the listener to addprivate void addSpell(int tag, int level, int castingTime, int mana, int grace, int damage, int skill, int path, int faceNum, @NotNull java.lang.String spellName, @NotNull java.lang.String message)
unknownSpells
if
possible.
tag
- the spell's taglevel
- the spell's levelcastingTime
- the spell's casting timemana
- the spell's mana costgrace
- the spell's grace costdamage
- the spell's damageskill
- the spell's skillpath
- the spell's pathfaceNum
- the spell's face numberspellName
- the spell's namemessage
- the spells' descriptionprivate void deleteSpell(int tag)
tag
- the spell's tagprivate void deleteSpellByIndex(int index)
spells
.
index
- the index to delete@Nullable public Spell getSpell(int index)
Spell
instance by index.
index
- the index
null
if the index is invalid@NotNull public Spell getSpell(@NotNull java.lang.String spellName)
Spell
instance by spell name. Creates a new instance if
the spell is unknown.
spellName
- the spell name to find
public int getSpells()
private void initSpells()
public java.util.Iterator<Spell> iterator()
iterator
in interface java.lang.Iterable<Spell>
public void removeCrossfireSpellChangedListener(@NotNull SpellsManagerListener listener)
SpellsManagerListener
to notify about changes.
listener
- the listener to removeprivate void updateSpell(int flags, int tag, int mana, int grace, int damage)
flags
- specifies which fields to updatetag
- the spell's tagmana
- the spell's new mana costgrace
- the spell's new grace costdamage
- the spell's new damage