forked from SteamWar/SteamWar
Format code
This commit is contained in:
@@ -23,32 +23,33 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class StateDependent {
|
||||
private static Set<StateDependent> listeners = new HashSet<>();
|
||||
private static Set<StateDependent> listeners = new HashSet<>();
|
||||
|
||||
private final Set<FightState> active;
|
||||
private boolean running;
|
||||
private final Set<FightState> active;
|
||||
private boolean running;
|
||||
|
||||
public StateDependent(final Set<FightState> active){
|
||||
this.active = active;
|
||||
running = false;
|
||||
listeners.add(this);
|
||||
}
|
||||
public StateDependent(final Set<FightState> active) {
|
||||
this.active = active;
|
||||
running = false;
|
||||
listeners.add(this);
|
||||
}
|
||||
|
||||
public abstract void enable();
|
||||
public abstract void disable();
|
||||
public abstract void enable();
|
||||
|
||||
static void setupState(FightState state){
|
||||
if (state == FightState.FIGHTING) {
|
||||
FightScoreboard.startTime();
|
||||
}
|
||||
for(StateDependent listener : listeners){
|
||||
if(listener.running && !listener.active.contains(state)){
|
||||
listener.disable();
|
||||
listener.running = false;
|
||||
}else if(!listener.running && listener.active.contains(state)){
|
||||
listener.enable();
|
||||
listener.running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract void disable();
|
||||
|
||||
static void setupState(FightState state) {
|
||||
if (state == FightState.FIGHTING) {
|
||||
FightScoreboard.startTime();
|
||||
}
|
||||
for (StateDependent listener : listeners) {
|
||||
if (listener.running && !listener.active.contains(state)) {
|
||||
listener.disable();
|
||||
listener.running = false;
|
||||
} else if (!listener.running && listener.active.contains(state)) {
|
||||
listener.enable();
|
||||
listener.running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user