implemented skip tutorial being permanent

This commit is contained in:
NewGarbo 2015-11-22 20:01:54 +00:00
parent 2e047b54c2
commit 47abbfbedf
4 changed files with 39 additions and 7 deletions

View File

@ -318,6 +318,22 @@ public abstract class Tutorial implements ScoreboardElement, Listener
return _taskManager.hasCompletedTask(player, _uniqueId);
}
public boolean hasSkipped(final Player player)
{
return _taskManager.hasCompletedTask(player, "SKIPPED" + _uniqueId);
}
public void skip(final Player player)
{
_taskManager.completedTask(new Callback<Boolean>()
{
public void run(Boolean data)
{
cancelFor(player);
}
}, player, "SKIPPED" + _uniqueId);
}
public String getUniqueId()
{
return _uniqueId;

View File

@ -83,6 +83,19 @@ public class TutorialManager extends MiniPlugin
}
}
public void skipTutorial(final Player player)
{
for (final Tutorial tutorial : _tutorials.values())
{
if (tutorial.isInTutorial(player))
{
tutorial.skip(player);
UtilPlayer.message(player, F.main("Tutorials", "You have skipped the " + F.elem(tutorial._friendlyName + " Tutorial") + "."));
break;
}
}
}
public Tutorial getTutorial(final Player player)
{
for (final Tutorial tutorial : _tutorials.values())

View File

@ -20,7 +20,7 @@ public class SkipTutorialCommand extends CommandBase<TutorialManager>
{
if (Plugin.isInTutorial(caller))
{
Plugin.cancelTutorial(caller);
Plugin.skipTutorial(caller);
}
else
{

View File

@ -67,16 +67,19 @@ public class TutorialGettingStarted extends Tutorial
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent evt)
{
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
if (!hasSkipped(evt.getPlayer()))
{
public void run()
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
{
if (!hasCompleted(evt.getPlayer()))
public void run()
{
startFor(evt.getPlayer());
if (!hasCompleted(evt.getPlayer()))
{
startFor(evt.getPlayer());
}
}
}
}, 40L);
}, 40L);
}
}
@EventHandler(priority = EventPriority.MONITOR)