Merge branch 'pregametutorial' of http://184.154.0.242:7990/scm/min/mineplex into type-wars

# Conflicts:
#	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java
This commit is contained in:
Sarah 2015-12-01 17:01:44 +01:00
commit d335e58652
3 changed files with 89 additions and 15 deletions

View File

@ -7,6 +7,7 @@ import mineplex.core.visibility.VisibilityManager;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent; import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent;
import nautilus.game.arcade.gametutorial.events.GameTutorialPhaseEvent;
import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent;
import org.bukkit.Location; import org.bukkit.Location;
@ -28,7 +29,12 @@ public abstract class GameTutorial
private int _tick; private int _tick;
public boolean SetTutorialPositions = true;
public boolean TeleportOnEnd = true; public boolean TeleportOnEnd = true;
public boolean RunTasksSync = true;
public long TimeBetweenPhase = 0;
public long StartAfterTutorial = 5000;
public GameTutorial(ArcadeManager manager, TutorialPhase[] phases) public GameTutorial(ArcadeManager manager, TutorialPhase[] phases)
{ {
@ -63,20 +69,22 @@ public abstract class GameTutorial
protected void nextPhase(boolean phaseOne) protected void nextPhase(boolean phaseOne)
{ {
TutorialPhase from = _currentPhase;
if(!phaseOne) if(!phaseOne)
_currentPhase = getNextPhase(); _currentPhase = getNextPhase();
if(_currentPhase == null) if(_currentPhase == null)
{ {
onEnd(); onEnd();
endTutorial();
_hasEnded = true; _hasEnded = true;
endTutorial();
Manager.getPluginManager().callEvent(new GameTutorialEndEvent(this)); Manager.getPluginManager().callEvent(new GameTutorialEndEvent(this));
} }
else else
{ {
Manager.GetChat().Silence(7000, false); Manager.GetChat().Silence(7000, false);
onPhaseChange(_currentPhase); onPhaseChange(_currentPhase);
Manager.getPluginManager().callEvent(new GameTutorialPhaseEvent(this, from, _currentPhase));
_currentPhase.start(phaseOne); _currentPhase.start(phaseOne);
} }
} }
@ -94,10 +102,19 @@ public abstract class GameTutorial
player.setAllowFlight(false); player.setAllowFlight(false);
player.setFlying(false); player.setFlying(false);
if(TeleportOnEnd) if(TeleportOnEnd)
{
Manager.runSyncLater(new Runnable()
{
@Override
public void run()
{
_team.SpawnTeleport(); _team.SpawnTeleport();
} }
Manager.GetChat().Silence(5000, false); }, 5);
Manager.GetGame().PrepareTime = (System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + 5000; }
}
Manager.GetChat().Silence(StartAfterTutorial, false);
Manager.GetGame().PrepareTime = (System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + StartAfterTutorial;
} }
protected TutorialPhase getNextPhase() protected TutorialPhase getNextPhase()

View File

@ -38,6 +38,9 @@ public abstract class TutorialPhase
final public void teleport() final public void teleport()
{ {
if(!getTutorial().SetTutorialPositions)
return;
if(_location != null && _target != null) if(_location != null && _target != null)
{ {
prepareLocations(); prepareLocations();
@ -61,7 +64,7 @@ public abstract class TutorialPhase
@Override @Override
public void run() public void run()
{ {
while(!_hasEnded) while(!_hasEnded && !getTutorial().hasEnded())
{ {
_tutorial.Manager.runSync(new Runnable() _tutorial.Manager.runSync(new Runnable()
{ {
@ -100,7 +103,7 @@ public abstract class TutorialPhase
TutorialText text = getNextMessage(); TutorialText text = getNextMessage();
if(text == null) if(text == null)
{ {
_tutorial.Manager.runSync(new Runnable() _tutorial.Manager.runSyncLater(new Runnable()
{ {
@Override @Override
public void run() public void run()
@ -109,7 +112,7 @@ public abstract class TutorialPhase
onEnd(); onEnd();
_tutorial.nextPhase(false); _tutorial.nextPhase(false);
} }
}); }, getTutorial().TimeBetweenPhase);
break; break;
} }
else else
@ -139,8 +142,8 @@ public abstract class TutorialPhase
private void displayMessage(final TutorialText text) private void displayMessage(final TutorialText text)
{ {
getTutorial().Manager.runSync(new Runnable() if(_tutorial.RunTasksSync)
{ _tutorial.Manager.runSync(new Runnable() {
@Override @Override
public void run() public void run()
{ {
@ -148,6 +151,11 @@ public abstract class TutorialPhase
} }
}); });
} }
else
{
onMessageDisplay(text);
}
}
protected TutorialText getNextMessage() protected TutorialText getNextMessage()
{ {

View File

@ -0,0 +1,49 @@
package nautilus.game.arcade.gametutorial.events;
import nautilus.game.arcade.gametutorial.GameTutorial;
import nautilus.game.arcade.gametutorial.TutorialPhase;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class GameTutorialPhaseEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private GameTutorial _tutorial;
private TutorialPhase _from;
private TutorialPhase _to;
public GameTutorialPhaseEvent(GameTutorial tutorial, TutorialPhase from, TutorialPhase to)
{
_tutorial = tutorial;
_from = from;
_to = to;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public GameTutorial getTutorial()
{
return _tutorial;
}
public TutorialPhase getFrom()
{
return _from;
}
public TutorialPhase getTo()
{
return _to;
}
}