In short:
The status
variable does not change because you are not saving a reference to the List
of Arena
objects that are returned from manager.getAllArenas()
that you use to set the Status
on. You want to look at your code and find a way to save the state of the Arena
object. There are a couple different ways to do this, but I am going to let you decide what is best for you.
The long explanation is below:
When you create an Object
in Java, you must hold the object (reference it) somewhere if you want to keep using the same object and save the state.
In your ArenaManager.onEnable()
method you call manager.getAllArenas()
and set the status
field on each Arena
object to Status.Idle
. Here:
public void onEnable(){
...
for(Arena arena : manager.getAllArenas()){
arena.onEnable();
}
...
foo();
}
The logic in manager.getAllArenas()
is essentially
1. Create new List<Arena>
2. Get the name of all the Arena objects from File
3. For every File object, create a new Arena object
4. Add new Arena object to List created in step 1.
You do not save this list anywhere when you call manager.getAllArenas()
in the ArenaManager.onEnable()
method, so once you exit the for loop, all the Arena
objects you set the Status
on in the Arena.onEnable()
method.
When you call foo()
later in the Arena.onEnable()
. You create a brand new list when you call manager.getAllArenas()
again, so this list was not effected by your for-loop
that set the status
to Status.Idle