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

View File

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