diff --git a/Plugins/.idea/misc.xml b/Plugins/.idea/misc.xml
index d5107f5ca..76fba6e9f 100644
--- a/Plugins/.idea/misc.xml
+++ b/Plugins/.idea/misc.xml
@@ -10,7 +10,4 @@
-
-
-
\ No newline at end of file
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/AbstractWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/AbstractWorldEvent.java
deleted file mode 100644
index 42076e89b..000000000
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/AbstractWorldEvent.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package mineplex.game.clans.clans.worldevent;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public abstract class AbstractWorldEvent
-{
- private List _listeners;
-
- private boolean _running;
- private int _ticks;
-
- public AbstractWorldEvent()
- {
- _listeners = new ArrayList();
- }
-
- public final void start()
- {
- _running = true;
- customStart();
- }
-
- protected abstract void customStart();
-
- public final void cancel()
- {
- _running = false;
- customCancel();
- }
-
- protected abstract void customCancel();
-
- public void tick()
- {
- _ticks++;
- }
-
- public boolean isRunning()
- {
- return _running;
- }
-
- public void addListener(WorldEventListener listener)
- {
- _listeners.add(listener);
- }
-
- public void removeListener(WorldEventListener listener)
- {
- _listeners.remove(listener);
- }
-
- protected List getListeners()
- {
- return _listeners;
- }
-
- public void clearListeners()
- {
- _listeners.clear();
- }
-
- public int getTicks()
- {
- return _ticks;
- }
-
-}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/ConcreteWorldEventFactory.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/ConcreteWorldEventFactory.java
index c44b682ef..798574ea1 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/ConcreteWorldEventFactory.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/ConcreteWorldEventFactory.java
@@ -2,14 +2,16 @@ package mineplex.game.clans.clans.worldevent;
import org.bukkit.Location;
-import mineplex.game.clans.clans.worldevent.boss.GiantBoss;
+import mineplex.game.clans.clans.worldevent.event.AbstractWorldEvent;
+import mineplex.game.clans.clans.worldevent.event.WorldEventType;
+import mineplex.game.clans.clans.worldevent.event.boss.slime.SlimeBoss;
public class ConcreteWorldEventFactory implements WorldEventFactory
{
@Override
public AbstractWorldEvent fromName(Location location, String name)
{
- return new GiantBoss(location);
+ return new SlimeBoss(location);
}
@Override
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventFactory.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventFactory.java
index 1c63b90f6..30c719f15 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventFactory.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventFactory.java
@@ -2,6 +2,9 @@ package mineplex.game.clans.clans.worldevent;
import org.bukkit.Location;
+import mineplex.game.clans.clans.worldevent.event.AbstractWorldEvent;
+import mineplex.game.clans.clans.worldevent.event.WorldEventType;
+
public interface WorldEventFactory
{
public AbstractWorldEvent fromName(Location location, String name);
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventListener.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventListener.java
index 65ccc2331..606745c7a 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventListener.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventListener.java
@@ -1,5 +1,7 @@
package mineplex.game.clans.clans.worldevent;
+import mineplex.game.clans.clans.worldevent.event.AbstractWorldEvent;
+
public interface WorldEventListener
{
public void onComplete(AbstractWorldEvent event);
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java
index 34e102d19..a23b9b2ec 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java
@@ -12,6 +12,7 @@ import mineplex.core.MiniPlugin;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.worldevent.command.WorldEventCommand;
+import mineplex.game.clans.clans.worldevent.event.AbstractWorldEvent;
public class WorldEventManager extends MiniPlugin implements WorldEventListener
{
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java
deleted file mode 100644
index 322130393..000000000
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package mineplex.game.clans.clans.worldevent;
-
-public enum WorldEventType
-{
- BOSS_FIGHT;
-}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java
index 0649bd563..093f78807 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java
@@ -6,7 +6,7 @@ import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
-import mineplex.game.clans.clans.worldevent.AbstractWorldEvent;
+import mineplex.game.clans.clans.worldevent.event.AbstractWorldEvent;
import mineplex.game.clans.clans.worldevent.WorldEventManager;
public class StartCommand extends CommandBase
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/AbstractWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/AbstractWorldEvent.java
new file mode 100644
index 000000000..d79d6f40e
--- /dev/null
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/AbstractWorldEvent.java
@@ -0,0 +1,120 @@
+package mineplex.game.clans.clans.worldevent.event;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import org.bukkit.event.HandlerList;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import mineplex.game.clans.clans.worldevent.WorldEventListener;
+import mineplex.game.clans.clans.worldevent.WorldEventManager;
+import mineplex.game.clans.clans.worldevent.event.state.EventState;
+
+public abstract class AbstractWorldEvent
+{
+ private WorldEventManager _eventManager;
+
+ private List _listeners;
+
+ private boolean _running;
+ private int _ticks;
+ private Random _random;
+
+ // Event States
+ private List _states;
+ private int _maxTicksPerState;
+ private int _minTicksPerState;
+ private EventState _currentState;
+
+ public AbstractWorldEvent(WorldEventManager eventManager)
+ {
+ _eventManager = eventManager;
+ _listeners = new ArrayList();
+ _states = new ArrayList();
+ _random = new Random();
+ }
+
+ public final void start()
+ {
+ _running = true;
+ customStart();
+ }
+
+ protected abstract void customStart();
+
+ public final void cancel()
+ {
+ _running = false;
+ customCancel();
+ }
+
+ protected abstract void customCancel();
+
+ public void tick()
+ {
+ _ticks++;
+ if (_currentState != null) _currentState.tick();
+ }
+
+ public boolean isRunning()
+ {
+ return _running;
+ }
+
+ public void addListener(WorldEventListener listener)
+ {
+ _listeners.add(listener);
+ }
+
+ public void removeListener(WorldEventListener listener)
+ {
+ _listeners.remove(listener);
+ }
+
+ protected List getListeners()
+ {
+ return _listeners;
+ }
+
+ public void clearListeners()
+ {
+ _listeners.clear();
+ }
+
+ public int getTicks()
+ {
+ return _ticks;
+ }
+
+ public WorldEventManager getEventManager()
+ {
+ return _eventManager;
+ }
+
+ public EventState getRandomState()
+ {
+ return _states.get(_random.nextInt(_states.size()));
+ }
+
+ public void setState(EventState state)
+ {
+ JavaPlugin plugin = _eventManager.getPlugin();
+
+ // Unregister old state listener
+ HandlerList.unregisterAll(_currentState);
+ _currentState.onStateStop();
+
+ // Register new state listener
+ plugin.getServer().getPluginManager().registerEvents(state, plugin);
+ state.onStateStart();
+
+ _currentState = state;
+ }
+
+ public void addState(EventState state)
+ {
+ _states.add(state);
+ }
+
+}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/WorldEventType.java
new file mode 100644
index 000000000..f5a9bc050
--- /dev/null
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/WorldEventType.java
@@ -0,0 +1,6 @@
+package mineplex.game.clans.clans.worldevent.event;
+
+public enum WorldEventType
+{
+ BOSS_FIGHT;
+}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/AbstractBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/boss/AbstractBoss.java
similarity index 79%
rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/AbstractBoss.java
rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/boss/AbstractBoss.java
index 5f48ea7a5..5e3f133c5 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/AbstractBoss.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/boss/AbstractBoss.java
@@ -1,5 +1,6 @@
-package mineplex.game.clans.clans.worldevent.boss;
+package mineplex.game.clans.clans.worldevent.event.boss;
+import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
@@ -7,8 +8,10 @@ import org.bukkit.Location;
import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilTextBottom;
-import mineplex.game.clans.clans.worldevent.AbstractWorldEvent;
+import mineplex.game.clans.clans.worldevent.WorldEventManager;
+import mineplex.game.clans.clans.worldevent.event.AbstractWorldEvent;
import mineplex.game.clans.clans.worldevent.WorldEventListener;
+import mineplex.game.clans.clans.worldevent.event.state.EventState;
public abstract class AbstractBoss extends AbstractWorldEvent
{
@@ -21,9 +24,9 @@ public abstract class AbstractBoss extends AbstractWorldEvent
private Location _center;
private float _radiusSquared;
-
- public AbstractBoss(String name, Location center, float radius, double maxHealth)
+ public AbstractBoss(WorldEventManager eventManager, String name, Location center, float radius, double maxHealth)
{
+ super(eventManager);
_center = center;
_name = name;
_health = maxHealth;
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/GiantBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/boss/slime/SlimeBoss.java
similarity index 67%
rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/GiantBoss.java
rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/boss/slime/SlimeBoss.java
index a2a23b334..33171229f 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/GiantBoss.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/boss/slime/SlimeBoss.java
@@ -1,11 +1,13 @@
-package mineplex.game.clans.clans.worldevent.boss;
+package mineplex.game.clans.clans.worldevent.event.boss.slime;
import org.bukkit.Bukkit;
import org.bukkit.Location;
-public class GiantBoss extends AbstractBoss
+import mineplex.game.clans.clans.worldevent.event.boss.AbstractBoss;
+
+public class SlimeBoss extends AbstractBoss
{
- public GiantBoss(Location center)
+ public SlimeBoss(Location center)
{
super("Giant", center, 20, 300);
}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/boss/state/BossState.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/boss/state/BossState.java
new file mode 100644
index 000000000..fc8460302
--- /dev/null
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/boss/state/BossState.java
@@ -0,0 +1,20 @@
+package mineplex.game.clans.clans.worldevent.event.boss.state;
+
+import mineplex.game.clans.clans.worldevent.event.boss.AbstractBoss;
+import mineplex.game.clans.clans.worldevent.event.state.EventState;
+
+public abstract class BossState extends EventState
+{
+ private AbstractBoss _boss;
+
+ public BossState(AbstractBoss boss)
+ {
+ super(boss);
+ _boss = boss;
+ }
+
+ public AbstractBoss getBoss()
+ {
+ return _boss;
+ }
+}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/boss/state/SlamState.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/boss/state/SlamState.java
new file mode 100644
index 000000000..83d69c229
--- /dev/null
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/boss/state/SlamState.java
@@ -0,0 +1,27 @@
+package mineplex.game.clans.clans.worldevent.event.boss.state;
+
+import mineplex.game.clans.clans.worldevent.event.boss.AbstractBoss;
+
+public class SlamState extends BossState
+{
+ public SlamState(AbstractBoss boss)
+ {
+ super(boss);
+ }
+
+ @Override
+ public void onTick()
+ {
+
+ }
+
+ @Override
+ public void onStateStart()
+ {
+ }
+
+ @Override
+ public void onStateStop()
+ {
+ }
+}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/state/EventState.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/state/EventState.java
new file mode 100644
index 000000000..6a13025e4
--- /dev/null
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/state/EventState.java
@@ -0,0 +1,39 @@
+package mineplex.game.clans.clans.worldevent.event.state;
+
+import org.bukkit.event.Listener;
+
+import mineplex.game.clans.clans.worldevent.event.AbstractWorldEvent;
+
+public abstract class EventState implements Listener
+{
+ private AbstractWorldEvent _event;
+ private int _ticks;
+
+ public EventState(AbstractWorldEvent event)
+ {
+ _event = event;
+ _ticks = 0;
+ }
+
+ public AbstractWorldEvent getEvent()
+ {
+ return _event;
+ }
+
+ public final void tick()
+ {
+ _ticks++;
+ onTick();
+ }
+
+ public int getTicks()
+ {
+ return _ticks;
+ }
+
+ public abstract void onTick();
+
+ public abstract void onStateStart();
+
+ public abstract void onStateStop();
+}