More tutorial
This commit is contained in:
parent
05ef4d30c7
commit
b606c8da22
@ -39,6 +39,17 @@ public abstract class Tutorial implements Listener, ObjectiveListener
|
||||
public void start(Player player)
|
||||
{
|
||||
_playerSessionMap.put(player, new TutorialSession());
|
||||
// Start at first objective!
|
||||
setObjective(player, 0);
|
||||
}
|
||||
|
||||
private void setObjective(Player player, int objective)
|
||||
{
|
||||
if (_objectives.size() <= objective)
|
||||
throw new IndexOutOfBoundsException("Invalid objective index: " + objective + ", size: " + _objectives.size());
|
||||
|
||||
_playerSessionMap.get(player).setObjectiveIndex(objective);
|
||||
_objectives.get(objective).start(player);
|
||||
}
|
||||
|
||||
public boolean isInTutorial(Player player)
|
||||
|
@ -3,10 +3,13 @@ package mineplex.game.clans.tutorial;
|
||||
import java.util.EnumMap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.game.clans.tutorial.tutorials.combat.CombatTutorial;
|
||||
|
||||
public class TutorialManager extends MiniPlugin
|
||||
@ -19,7 +22,7 @@ public class TutorialManager extends MiniPlugin
|
||||
|
||||
_tutorialMap = new EnumMap<TutorialType, Tutorial>(TutorialType.class);
|
||||
|
||||
addTutorial(TutorialType.COMBAT, new CombatTutorial());
|
||||
addTutorial(TutorialType.COMBAT, new CombatTutorial(plugin));
|
||||
}
|
||||
|
||||
private void addTutorial(TutorialType type, Tutorial tutorial)
|
||||
@ -46,13 +49,19 @@ public class TutorialManager extends MiniPlugin
|
||||
|
||||
public boolean startTutorial(Player player, TutorialType type)
|
||||
{
|
||||
if (inTutorial(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Tutorial", "You are already in a tutorial"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_tutorialMap.containsKey(type))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Tutorial", "Starting Tutorial: " + type.name()));
|
||||
_tutorialMap.get(type).start(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,15 @@ public class TutorialSession
|
||||
|
||||
public TutorialSession()
|
||||
{
|
||||
}
|
||||
|
||||
public int getObjectiveIndex()
|
||||
{
|
||||
return _objectiveIndex;
|
||||
}
|
||||
|
||||
public void setObjectiveIndex(int objectiveIndex)
|
||||
{
|
||||
_objectiveIndex = objectiveIndex;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
package mineplex.game.clans.tutorial.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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.tutorial.TutorialManager;
|
||||
import mineplex.game.clans.tutorial.TutorialType;
|
||||
|
||||
public class StartCommand extends CommandBase<TutorialManager>
|
||||
{
|
||||
public StartCommand(TutorialManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "start");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length != 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Tutorial", "/tutorial start <name>"));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
TutorialType type = TutorialType.valueOf(args[0]);
|
||||
Plugin.startTutorial(caller, type);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Tutorial", "Invalid Tutorial: " + F.elem(args[0])));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package mineplex.game.clans.tutorial.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.game.clans.tutorial.TutorialManager;
|
||||
|
||||
public class TutorialCommand extends MultiCommandBase<TutorialManager>
|
||||
{
|
||||
public TutorialCommand(TutorialManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "tutorial", "tut");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void Help(Player caller, String[] args)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user