Merge remote-tracking branch 'origin/clans-beta' into clans-beta
This commit is contained in:
commit
fd1638a572
@ -100,17 +100,4 @@ public class UtilText {
|
|||||||
{
|
{
|
||||||
return new String(new byte[times]).replace("\0", txt);
|
return new String(new byte[times]).replace("\0", txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String insertEvery(String txt, String insert, int chars)
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder(insert + txt);
|
|
||||||
if (txt.length() > chars)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < txt.length() / chars; i++)
|
|
||||||
{
|
|
||||||
builder.insert(chars * i, insert);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@ public class PlayerTutorial
|
|||||||
private final Tutorial _tutorial;
|
private final Tutorial _tutorial;
|
||||||
private final Player _player;
|
private final Player _player;
|
||||||
|
|
||||||
private int _currentPart = 1;
|
private final HashMap<String, Object> _data = new HashMap<>();
|
||||||
private HashMap<String, Object> _data = new HashMap<>();
|
private int _currentTask = 1;
|
||||||
|
|
||||||
public PlayerTutorial(final Player player, final TaskManager taskManager, final Tutorial tutorial)
|
public PlayerTutorial(final Player player, final TaskManager taskManager, final Tutorial tutorial)
|
||||||
{
|
{
|
||||||
@ -26,23 +26,22 @@ public class PlayerTutorial
|
|||||||
{
|
{
|
||||||
PlayerTutorial user = new PlayerTutorial(player, taskManager, tutorial);
|
PlayerTutorial user = new PlayerTutorial(player, taskManager, tutorial);
|
||||||
|
|
||||||
for (int i : tutorial.getParts().keySet())
|
for (final int i : tutorial.getTasks().keySet())
|
||||||
{
|
{
|
||||||
if (taskManager.hasCompletedTask(player, tutorial.getType().getId() + tutorial.getPart(i).getNameID()))
|
if (taskManager.hasCompletedTask(player, tutorial.getType().getId() + tutorial.getTask(i).getNameID()))
|
||||||
{
|
{
|
||||||
user._currentPart = i;
|
user._currentTask = i;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tutorial.getPart(user._currentPart).sendDescriptionTo(player);
|
tutorial.getTask(user._currentTask).sendDescriptionTo(player);
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrentPart()
|
public int getCurrentTask()
|
||||||
{
|
{
|
||||||
return _currentPart;
|
return _currentTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tutorial getTutorial()
|
public Tutorial getTutorial()
|
||||||
@ -60,29 +59,29 @@ public class PlayerTutorial
|
|||||||
return _taskManager;
|
return _taskManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishedPart(final int partID)
|
public void setTaskFinished(final int taskID)
|
||||||
{
|
{
|
||||||
_currentPart = partID + 1;
|
_currentTask = taskID + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFinishedPart(TutorialPart part)
|
public boolean hasFinishedTask(final TutorialTask task)
|
||||||
{
|
{
|
||||||
return part.getID() < _currentPart;
|
return task.getID() < _currentTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T getData(String name, T defValue)
|
public <T> T getData(final String name, final T defValue)
|
||||||
{
|
{
|
||||||
if (!_data.containsKey(name)) _data.put(name, defValue);
|
if (!_data.containsKey(name)) _data.put(name, defValue);
|
||||||
|
|
||||||
return (T) _data.get(name);
|
return (T) _data.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T getData(String name)
|
public <T> T getData(final String name)
|
||||||
{
|
{
|
||||||
return (T) _data .get(name);
|
return (T) _data .get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void setData(String name, T value)
|
public <T> void setData(final String name, final T value)
|
||||||
{
|
{
|
||||||
_data.put(name, value);
|
_data.put(name, value);
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,13 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import mineplex.core.common.Pair;
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilFirework;
|
import mineplex.core.common.util.UtilFirework;
|
||||||
|
import mineplex.core.common.util.UtilParticle;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
import mineplex.core.scoreboard.ScoreboardManager;
|
import mineplex.core.scoreboard.ScoreboardManager;
|
||||||
import mineplex.core.scoreboard.elements.ScoreboardElement;
|
import mineplex.core.scoreboard.elements.ScoreboardElement;
|
||||||
import mineplex.core.task.TaskManager;
|
import mineplex.core.task.TaskManager;
|
||||||
@ -38,7 +39,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
|||||||
|
|
||||||
private final int _rewardAmount;
|
private final int _rewardAmount;
|
||||||
|
|
||||||
private final HashMap<Integer, Pair<TutorialPart, Consumer<Player>>> _parts;
|
private final HashMap<Integer, TutorialTask> _tasks;
|
||||||
protected final HashMap<String, PlayerTutorial> _inTutorial;
|
protected final HashMap<String, PlayerTutorial> _inTutorial;
|
||||||
private final TutorialType _type;
|
private final TutorialType _type;
|
||||||
|
|
||||||
@ -52,13 +53,13 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
|||||||
_rewardAmount = rewardAmount;
|
_rewardAmount = rewardAmount;
|
||||||
_manager = manager;
|
_manager = manager;
|
||||||
_type = type;
|
_type = type;
|
||||||
_parts = new HashMap<>();
|
_tasks = new HashMap<>();
|
||||||
_inTutorial = new HashMap<>();
|
_inTutorial = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getLines(ScoreboardManager manager, Player player, ArrayList<String> out)
|
public ArrayList<String> getLines(final ScoreboardManager manager, final Player player, final ArrayList<String> out)
|
||||||
{
|
{
|
||||||
ArrayList<String> lines = new ArrayList<>();
|
final ArrayList<String> lines = new ArrayList<>();
|
||||||
|
|
||||||
if (!isInTutorial(player) || !_doScoreboard)
|
if (!isInTutorial(player) || !_doScoreboard)
|
||||||
{
|
{
|
||||||
@ -67,19 +68,19 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
|||||||
|
|
||||||
out.clear();
|
out.clear();
|
||||||
|
|
||||||
PlayerTutorial ptutorial = _inTutorial.get(player.getName());
|
final PlayerTutorial ptutorial = _inTutorial.get(player.getName());
|
||||||
|
|
||||||
lines.add(C.cAqua + _type.getFriendlyName() + " Tutorial");
|
lines.add(C.cAqua + _type.getFriendlyName() + " Tutorial");
|
||||||
|
|
||||||
for (Pair<TutorialPart, Consumer<Player>> part : _parts.values())
|
for (final TutorialTask task : _tasks.values())
|
||||||
{
|
{
|
||||||
if (ptutorial.hasFinishedPart(part.getLeft()))
|
if (ptutorial.hasFinishedTask(task))
|
||||||
{
|
{
|
||||||
lines.add(C.cGreen + part.getLeft().getID() + ". " + part.getLeft().getName());
|
lines.add(C.cGreen + task.getID() + ". " + task.getName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lines.add(C.cRed + part.getLeft().getID() + ". " + part.getLeft().getName());
|
lines.add(C.cRed + task.getID() + ". " + task.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,36 +91,26 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Consumer<Player> addPart(final int id, final String name, final String description)
|
protected void addTask(final int id, final String name, final String description)
|
||||||
{
|
{
|
||||||
final Consumer<Player> consumer = new Consumer<Player>()
|
_tasks.put(id, new TutorialTask(id, name, description));
|
||||||
{
|
|
||||||
public void consume(Player player)
|
|
||||||
{
|
|
||||||
finishPart(player, id);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
_parts.put(id, Pair.create(new TutorialPart(id, name, description, consumer), consumer));
|
|
||||||
|
|
||||||
return consumer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finishPart(final Player player, final int partID)
|
protected void finishTask(final Player player, final int taskID)
|
||||||
{
|
{
|
||||||
final Pair<TutorialPart, Consumer<Player>> part = _parts.get(partID);
|
final TutorialTask task = _tasks.get(taskID);
|
||||||
|
|
||||||
_inTutorial.get(player.getName()).finishedPart(partID);
|
_inTutorial.get(player.getName()).setTaskFinished(taskID);
|
||||||
|
|
||||||
if (!_taskManager.hasCompletedTask(player, _type.getId() + part.getLeft().getNameID()))
|
if (!_taskManager.hasCompletedTask(player, _type.getId() + task.getNameID()))
|
||||||
{
|
{
|
||||||
_taskManager.completedTask(new Callback<Boolean>()
|
_taskManager.completedTask(new Callback<Boolean>()
|
||||||
{
|
{
|
||||||
public void run(Boolean completed)
|
public void run(final Boolean completed)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(player, F.main("Tutorials", "You have completed task " + F.elem(partID + " (" + part.getLeft().getName() + ")") + ". " + (_parts.size() - partID) + " tasks to go!"));
|
UtilPlayer.message(player, F.main("Tutorials", "You have completed task " + F.elem(taskID + " (" + task.getName() + ")") + ". " + (_tasks.size() - taskID) + " tasks to go!"));
|
||||||
|
|
||||||
if (partID == _parts.size())
|
if (taskID == _tasks.size())
|
||||||
{
|
{
|
||||||
finishFor(player);
|
finishFor(player);
|
||||||
}
|
}
|
||||||
@ -129,25 +120,20 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
|||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
_parts.get(partID + 1).getLeft().sendDescriptionTo(player);
|
_tasks.get(taskID + 1).sendDescriptionTo(player);
|
||||||
newPart(partID + 1);
|
|
||||||
}
|
}
|
||||||
}, 40L);
|
}, 40L);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
|
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
|
||||||
}
|
}
|
||||||
}, player, _type.getId() + part.getLeft().getNameID());
|
}, player, _type.getId() + task.getNameID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void newPart(int partID)
|
public TutorialTask getTask(final int taskID)
|
||||||
{
|
{
|
||||||
}
|
return _tasks.get(taskID);
|
||||||
|
|
||||||
public TutorialPart getPart(final int partID)
|
|
||||||
{
|
|
||||||
return _parts.get(partID).getLeft();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TutorialType getType()
|
public TutorialType getType()
|
||||||
@ -166,21 +152,21 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
|||||||
{
|
{
|
||||||
_taskManager.completedTask(new Callback<Boolean>()
|
_taskManager.completedTask(new Callback<Boolean>()
|
||||||
{
|
{
|
||||||
public void run(Boolean completed)
|
public void run(final Boolean completed)
|
||||||
{
|
{
|
||||||
_goldManager.addGold(player, _rewardAmount);
|
_goldManager.addGold(player, _rewardAmount);
|
||||||
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_rewardAmount + " Gold") + "."));
|
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_rewardAmount + " Gold") + "."));
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
final int index = i;
|
final int index = i;
|
||||||
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
|
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, (index % 2 == 0) ? Color.RED : Color.LIME, false, false, new Vector(0, 0, 0), 1);
|
UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, (index % 2 == 0) ? Color.RED : Color.LIME, false, false, new Vector(0, 0, 0), 0);
|
||||||
}
|
}
|
||||||
}, i * 30);
|
}, i * 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, player, _type.getId());
|
}, player, _type.getId());
|
||||||
@ -212,9 +198,9 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
|||||||
return _inTutorial.containsKey(player);
|
return _inTutorial.containsKey(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Integer, Pair<TutorialPart, Consumer<Player>>> getParts()
|
public HashMap<Integer, TutorialTask> getTasks()
|
||||||
{
|
{
|
||||||
return _parts;
|
return _tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDoneBefore(final Player player)
|
public boolean hasDoneBefore(final Player player)
|
||||||
|
@ -13,7 +13,7 @@ import mineplex.core.common.util.UtilPlayer;
|
|||||||
import mineplex.core.task.TaskManager;
|
import mineplex.core.task.TaskManager;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
import mineplex.game.clans.economy.GoldManager;
|
import mineplex.game.clans.economy.GoldManager;
|
||||||
import mineplex.game.clans.tutorials.commands.EndTutorialCommand;
|
import mineplex.game.clans.tutorials.commands.SkipTutorialCommand;
|
||||||
import mineplex.game.clans.tutorials.commands.QAResetCommand;
|
import mineplex.game.clans.tutorials.commands.QAResetCommand;
|
||||||
import mineplex.game.clans.tutorials.commands.TaskInfoCommand;
|
import mineplex.game.clans.tutorials.commands.TaskInfoCommand;
|
||||||
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
|
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
|
||||||
@ -25,8 +25,7 @@ public class TutorialManager extends MiniPlugin
|
|||||||
|
|
||||||
private final HashMap<TutorialType, Tutorial> _tutorials = new HashMap<>();
|
private final HashMap<TutorialType, Tutorial> _tutorials = new HashMap<>();
|
||||||
|
|
||||||
private TaskManager _taskManager;
|
private final TaskManager _taskManager;
|
||||||
|
|
||||||
|
|
||||||
public TutorialManager(final JavaPlugin plugin, final GoldManager goldManager, final TaskManager taskManager, final ClansManager clansManager)
|
public TutorialManager(final JavaPlugin plugin, final GoldManager goldManager, final TaskManager taskManager, final ClansManager clansManager)
|
||||||
{
|
{
|
||||||
@ -44,7 +43,7 @@ public class TutorialManager extends MiniPlugin
|
|||||||
|
|
||||||
public void addCommands()
|
public void addCommands()
|
||||||
{
|
{
|
||||||
this.addCommand(new EndTutorialCommand(this));
|
this.addCommand(new SkipTutorialCommand(this));
|
||||||
this.addCommand(new TaskInfoCommand(this));
|
this.addCommand(new TaskInfoCommand(this));
|
||||||
this.addCommand(new QAResetCommand(this));
|
this.addCommand(new QAResetCommand(this));
|
||||||
}
|
}
|
||||||
@ -76,9 +75,9 @@ public class TutorialManager extends MiniPlugin
|
|||||||
}, 40L);
|
}, 40L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInTutorial(Player player)
|
public boolean isInTutorial(final Player player)
|
||||||
{
|
{
|
||||||
for (Tutorial tutorial : _tutorials.values())
|
for (final Tutorial tutorial : _tutorials.values())
|
||||||
{
|
{
|
||||||
if (tutorial.isInTutorial(player))
|
if (tutorial.isInTutorial(player))
|
||||||
{
|
{
|
||||||
@ -89,9 +88,9 @@ public class TutorialManager extends MiniPlugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelTutorial(Player player)
|
public void cancelTutorial(final Player player)
|
||||||
{
|
{
|
||||||
for (Tutorial tutorial : _tutorials.values())
|
for (final Tutorial tutorial : _tutorials.values())
|
||||||
{
|
{
|
||||||
if (tutorial.isInTutorial(player))
|
if (tutorial.isInTutorial(player))
|
||||||
{
|
{
|
||||||
@ -102,9 +101,9 @@ public class TutorialManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tutorial getTutorial(Player player)
|
public Tutorial getTutorial(final Player player)
|
||||||
{
|
{
|
||||||
for (Tutorial tutorial : _tutorials.values())
|
for (final Tutorial tutorial : _tutorials.values())
|
||||||
{
|
{
|
||||||
if (tutorial.isInTutorial(player))
|
if (tutorial.isInTutorial(player))
|
||||||
{
|
{
|
||||||
|
@ -6,19 +6,17 @@ import mineplex.core.common.util.C;
|
|||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilText;
|
import mineplex.core.common.util.UtilText;
|
||||||
|
|
||||||
public class TutorialPart
|
public class TutorialTask
|
||||||
{
|
{
|
||||||
private final String _name;
|
private final String _name;
|
||||||
private final String _description;
|
private final String _description;
|
||||||
private final int _id;
|
private final int _id;
|
||||||
private final Consumer<Player> _waiter;
|
|
||||||
|
|
||||||
public TutorialPart(final int id, final String name, final String description, final Consumer<Player> waiter)
|
public TutorialTask(final int id, final String name, final String description)
|
||||||
{
|
{
|
||||||
_id = id;
|
_id = id;
|
||||||
_name = name;
|
_name = name;
|
||||||
_description = description;
|
_description = description;
|
||||||
_waiter = waiter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getID()
|
public int getID()
|
||||||
@ -41,16 +39,11 @@ public class TutorialPart
|
|||||||
return _name.replace(" ", "");
|
return _name.replace(" ", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendDescriptionTo(Player player)
|
public void sendDescriptionTo(final Player player)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(player, C.cGreen + "==== Pt." + _id + ": " + _name + " ====");
|
UtilPlayer.message(player, C.cGreen + "==== Pt." + _id + ": " + _name + " ====");
|
||||||
UtilPlayer.message(player, UtilText.insertEvery(_description, C.cYellow, 20).replace("{", C.cAqua).replace("}", C.cYellow));
|
UtilPlayer.message(player, C.cYellow + _description.replace("{", C.cAqua).replace("}", C.cYellow));
|
||||||
UtilPlayer.message(player, C.cGreen + UtilText.repeat("=", _name.length() + ("=== Pt." + _id + ": ===").length()));
|
UtilPlayer.message(player, C.cGreen + UtilText.repeat("=", _name.length() + ("=== Pt." + _id + ": ===").length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Consumer<Player> getWaiter()
|
|
||||||
{
|
|
||||||
return _waiter;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,29 +1,19 @@
|
|||||||
package mineplex.game.clans.tutorials;
|
package mineplex.game.clans.tutorials;
|
||||||
|
|
||||||
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
|
|
||||||
import mineplex.game.clans.tutorials.types.TutorialOnGoingMap;
|
|
||||||
|
|
||||||
public enum TutorialType
|
public enum TutorialType
|
||||||
{
|
{
|
||||||
GETTING_STARTED(TutorialGettingStarted.class, "Getting Started", "GettingStartedTutorial"),
|
GETTING_STARTED("Getting Started", "GettingStartedTutorial"),
|
||||||
ON_GOING(TutorialOnGoingMap.class, "Ongoing Map", "OngoingMapTutorial");
|
ON_GOING("Ongoing Map", "OngoingMapTutorial");
|
||||||
|
|
||||||
private final Class<? extends Tutorial> _clazz;
|
|
||||||
private final String _uniqueId;
|
private final String _uniqueId;
|
||||||
private final String _friendlyName;
|
private final String _friendlyName;
|
||||||
|
|
||||||
TutorialType(final Class<? extends Tutorial> clazz, final String friendlyName, final String uniqueId)
|
TutorialType( final String friendlyName, final String uniqueId)
|
||||||
{
|
{
|
||||||
_clazz = clazz;
|
|
||||||
_uniqueId = uniqueId;
|
_uniqueId = uniqueId;
|
||||||
_friendlyName = friendlyName;
|
_friendlyName = friendlyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends Tutorial> getClazz()
|
|
||||||
{
|
|
||||||
return _clazz;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId()
|
public String getId()
|
||||||
{
|
{
|
||||||
return _uniqueId;
|
return _uniqueId;
|
||||||
|
@ -21,7 +21,7 @@ public class OngoingOptOutCommand extends CommandBase<TutorialManager>
|
|||||||
{
|
{
|
||||||
Plugin.getTaskManager().completedTask(new Callback<Boolean>()
|
Plugin.getTaskManager().completedTask(new Callback<Boolean>()
|
||||||
{
|
{
|
||||||
public void run(Boolean completed)
|
public void run(final Boolean completed)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Tutorials", "You have opted out of territory warnings, be careful!"));
|
UtilPlayer.message(caller, F.main("Tutorials", "You have opted out of territory warnings, be careful!"));
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,11 @@ import java.util.Arrays;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Pair;
|
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.game.clans.tutorials.Consumer;
|
|
||||||
import mineplex.game.clans.tutorials.TutorialManager;
|
import mineplex.game.clans.tutorials.TutorialManager;
|
||||||
import mineplex.game.clans.tutorials.TutorialPart;
|
import mineplex.game.clans.tutorials.TutorialTask;
|
||||||
import mineplex.game.clans.tutorials.TutorialType;
|
import mineplex.game.clans.tutorials.TutorialType;
|
||||||
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
|
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
|
||||||
|
|
||||||
@ -31,17 +29,17 @@ public class QAResetCommand extends CommandBase<TutorialManager>
|
|||||||
// ANNOYING PLEASE DON'T HARM ME IT'S
|
// ANNOYING PLEASE DON'T HARM ME IT'S
|
||||||
// ONLY A TEMP COMMAND FOR TESTING
|
// ONLY A TEMP COMMAND FOR TESTING
|
||||||
{
|
{
|
||||||
TutorialGettingStarted tutorial = (TutorialGettingStarted) Plugin.getTutorials().get(TutorialType.GETTING_STARTED);
|
final TutorialGettingStarted tutorial = (TutorialGettingStarted) Plugin.getTutorials().get(TutorialType.GETTING_STARTED);
|
||||||
|
|
||||||
UtilPlayer.message(caller, F.main("Tutorials", Arrays.toString(Plugin.getTaskManager().Get(caller).TasksCompleted.toArray())));
|
UtilPlayer.message(caller, F.main("Tutorials", Arrays.toString(Plugin.getTaskManager().Get(caller).TasksCompleted.toArray())));
|
||||||
|
|
||||||
Plugin.getTaskManager().Get(caller).TasksCompleted.remove(Plugin.getTaskManager().getTaskId(tutorial.getType().getId()));
|
Plugin.getTaskManager().Get(caller).TasksCompleted.remove(Plugin.getTaskManager().getTaskId(tutorial.getType().getId()));
|
||||||
UtilPlayer.message(caller, F.main("Tutorials", "Removed " + F.elem(tutorial.getType().getId())));
|
UtilPlayer.message(caller, F.main("Tutorials", "Removed " + F.elem(tutorial.getType().getId())));
|
||||||
|
|
||||||
for (Pair<TutorialPart, Consumer<Player>> part : tutorial.getParts().values())
|
for (final TutorialTask task : tutorial.getTasks().values())
|
||||||
{
|
{
|
||||||
Plugin.getTaskManager().Get(caller).TasksCompleted.remove(Plugin.getTaskManager().getTaskId(tutorial.getType().getId() + part.getLeft().getNameID()));
|
Plugin.getTaskManager().Get(caller).TasksCompleted.remove(Plugin.getTaskManager().getTaskId(tutorial.getType().getId() + task.getNameID()));
|
||||||
UtilPlayer.message(caller, F.main("Tutorials", "Removed " + F.elem(tutorial.getType().getId() + part.getLeft().getNameID()) + " (" + Plugin.getTaskManager().getTaskId(tutorial.getType().getId() + part.getLeft().getNameID()) + ")"));
|
UtilPlayer.message(caller, F.main("Tutorials", "Removed " + F.elem(tutorial.getType().getId() + task.getNameID()) + " (" + Plugin.getTaskManager().getTaskId(tutorial.getType().getId() + task.getNameID()) + ")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
UtilPlayer.message(caller, F.main("Tutorials", Arrays.toString(Plugin.getTaskManager().Get(caller).TasksCompleted.toArray())));
|
UtilPlayer.message(caller, F.main("Tutorials", Arrays.toString(Plugin.getTaskManager().Get(caller).TasksCompleted.toArray())));
|
||||||
|
@ -8,9 +8,9 @@ import mineplex.core.common.util.F;
|
|||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.game.clans.tutorials.TutorialManager;
|
import mineplex.game.clans.tutorials.TutorialManager;
|
||||||
|
|
||||||
public class EndTutorialCommand extends CommandBase<TutorialManager>
|
public class SkipTutorialCommand extends CommandBase<TutorialManager>
|
||||||
{
|
{
|
||||||
public EndTutorialCommand(final TutorialManager plugin)
|
public SkipTutorialCommand(final TutorialManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ALL, "skiptutorial", "skiptut", "st");
|
super(plugin, Rank.ALL, "skiptutorial", "skiptut", "st");
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ public class TaskInfoCommand extends CommandBase<TutorialManager>
|
|||||||
{
|
{
|
||||||
if (Plugin.isInTutorial(caller))
|
if (Plugin.isInTutorial(caller))
|
||||||
{
|
{
|
||||||
Plugin.getTutorial(caller).getPart(Plugin.getTutorial(caller).get(caller).getCurrentPart()).sendDescriptionTo(caller);
|
Plugin.getTutorial(caller).getTask(Plugin.getTutorial(caller).get(caller).getCurrentTask()).sendDescriptionTo(caller);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -28,17 +29,18 @@ public class TutorialGettingStarted extends Tutorial
|
|||||||
{
|
{
|
||||||
super(50, goldManager, taskManager, clansManager, manager, TutorialType.GETTING_STARTED);
|
super(50, goldManager, taskManager, clansManager, manager, TutorialType.GETTING_STARTED);
|
||||||
|
|
||||||
addPart(1, "Create A Clan", "To create your own clan, type {/c create [name]}. Don’t worry about being though, you can always disband this clan and join another later if you need to!");
|
addTask(1, "Welcome", "Welcome to Clans! Before you start playing Clans, you should be familiar with the various commands. Type {/c help} now to view all of the commands for Clans!");
|
||||||
addPart(2, "Viewing Clan Info", "Now you can view information about your clan. To do this type {/c [name]}! You can also use any clans name to get some information about them as well.");
|
addTask(2, "Create A Clan", "To create your own clan, type {/c create [name]}. Don’t worry about your friends though, you can always disband this clan and join another later if you need to!");
|
||||||
addPart(3, "Leave Spawn", "Now you can leave the Spawn Island. Don't worry, you won’t get hurt from the fall! Once you jump off though, PvP is enabled! Be careful!");
|
addTask(3, "Viewing Clan Info", "Now you can view information about your clan. To do this type {/c [name]}! You can also use any clans name to get some information about them as well.");
|
||||||
addPart(4, "Go To The Wilderness", "Access your map with {/map} and head out into the wilderness! You’ll see various other locations marked on your map later.");
|
addTask(4, "Leave Spawn", "Now you can leave the Spawn Island. Don't worry, you won’t get hurt from the fall! Once you jump off though, PvP is enabled! Be careful!");
|
||||||
addPart(5, "Claiming Territory", "In order to claim a chunk of land for your clan you type {/c claim}! Notice though, your clan runs on energy! You can buy energy from the shops!");
|
addTask(5, "Go To The Wilderness", "Access your map with {/map} and head out into the wilderness! You’ll see various other locations marked on your map later.");
|
||||||
addPart(6, "Visit The Shops", "At the shops you can buy most things you need! Once a day you can transfer 1000 gems to 5000 clans gold here as well!");
|
addTask(6, "Claiming Territory", "In order to claim a chunk of land for your clan you type {/c claim}! Notice though, your clan runs on energy! You can buy energy from the shops!");
|
||||||
addPart(7, "Buy Armor", "Head to the PvP Gear villager and purchase a set of armor! Make sure to buy a matching set to access your class skills!");
|
addTask(7, "Visit The Shops", "At the shops you can buy most things you need! Once a day you can transfer 1000 gems to 5000 clans gold here as well!");
|
||||||
addPart(8, "Equip Armor", "In order to equip a kit, you must put on the full armor set of that kit! Put on the armor set you just bought and you will have selected your kit!");
|
addTask(8, "Buy Armor", "Head to the PvP Gear villager and purchase a set of armor! Make sure to buy a matching set to access your class skills!");
|
||||||
addPart(9, "Use An Ability", "In order to use abilities you need a sword or axe. To use your sword ability, right click with your sword! To use your axe ability, right click with your axe!");
|
addTask(9, "Equip Armor", "In order to equip a kit, you must put on the full armor set of that kit! Put on the armor set you just bought and you will have selected your kit!");
|
||||||
addPart(10, "Class Customization", "To customize your class, right click an enchantment table! There you will find the GUI for all the skills in that class! Customize it to your liking!");
|
addTask(10, "Use An Ability", "In order to use abilities you need a sword or axe. To use your sword ability, right click with your sword! To use your axe ability, right click with your axe!");
|
||||||
addPart(11, "Clan Home", "In order to set a clan home, type {/c sethome}. You can only use {/c home} from the spawn island every 5 minutes to return home!");
|
addTask(11, "Class Customization", "To customize your class, right click an enchantment table! There you will find the GUI for all the skills in that class! Customize it to your liking!");
|
||||||
|
addTask(12, "Clan Home", "In order to set a clan home, type {/c sethome}. You can only use {/c home} from the spawn island every 5 minutes to return home!");
|
||||||
|
|
||||||
_doScoreboard = true;
|
_doScoreboard = true;
|
||||||
}
|
}
|
||||||
@ -48,49 +50,61 @@ public class TutorialGettingStarted extends Tutorial
|
|||||||
UtilPlayer.message(player, F.main("Tutorials", "You are now ready to play, welcome to the game."));
|
UtilPlayer.message(player, F.main("Tutorials", "You are now ready to play, welcome to the game."));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClanCreated(String caller, String name)
|
@EventHandler
|
||||||
|
public void onCommandPreprocess(final PlayerCommandPreprocessEvent event)
|
||||||
{
|
{
|
||||||
if (isInTutorial(caller) && !get(Bukkit.getPlayer(caller)).hasFinishedPart(getPart(1)))
|
if (event.getMessage().startsWith("/c help") || event.getMessage().startsWith("/clans help") || event.getMessage().startsWith("/clan help") || event.getMessage().startsWith("/factions help"))
|
||||||
{
|
{
|
||||||
getPart(1).getWaiter().consume(Bukkit.getPlayer(caller));
|
if (isInTutorial(event.getPlayer()) && !get(event.getPlayer()).hasFinishedTask(getTask(1)))
|
||||||
|
{
|
||||||
|
finishTask(event.getPlayer(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClanInfo(Player caller, String name)
|
public void onClanCreated(final String caller, final String name)
|
||||||
{
|
{
|
||||||
if (isInTutorial(caller.getName()) && get(caller).hasFinishedPart(getPart(1)) && !get(caller).hasFinishedPart(getPart(2)))
|
if (isInTutorial(caller) && get(Bukkit.getPlayer(caller)).hasFinishedTask(getTask(1)) && !get(Bukkit.getPlayer(caller)).hasFinishedTask(getTask(2)))
|
||||||
{
|
{
|
||||||
getPart(2).getWaiter().consume(caller);
|
finishTask(Bukkit.getPlayer(caller), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnterTerritory(Player player, String ownerString)
|
public void onClanInfo(final Player caller, final String name)
|
||||||
{
|
{
|
||||||
if (isInTutorial(player) && ownerString.endsWith("Spawn") && get(player).hasFinishedPart(getPart(2)) && !get(player).hasFinishedPart(getPart(3)))
|
if (isInTutorial(caller.getName()) && get(caller).hasFinishedTask(getTask(2)) && !get(caller).hasFinishedTask(getTask(3)))
|
||||||
{
|
{
|
||||||
getPart(3).getWaiter().consume(player);
|
finishTask(caller, 3);
|
||||||
}
|
|
||||||
else if (isInTutorial(player) && ownerString.endsWith("Wilderness") && get(player).hasFinishedPart(getPart(3)) && !get(player).hasFinishedPart(getPart(4)))
|
|
||||||
{
|
|
||||||
getPart(4).getWaiter().consume(player);
|
|
||||||
}
|
|
||||||
else if (isInTutorial(player) && ownerString.endsWith("Shops") && get(player).hasFinishedPart(getPart(5)) && !get(player).hasFinishedPart(getPart(6)))
|
|
||||||
{
|
|
||||||
getPart(6).getWaiter().consume(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClaim(Player caller)
|
public void onEnterTerritory(final Player player, final String ownerString)
|
||||||
{
|
{
|
||||||
if (isInTutorial(caller) && get(caller).hasFinishedPart(getPart(4)) && !get(caller).hasFinishedPart(getPart(5)))
|
if (isInTutorial(player) && ownerString.contains("Spawn") && get(player).hasFinishedTask(getTask(3)) && !get(player).hasFinishedTask(getTask(4)))
|
||||||
{
|
{
|
||||||
getPart(5).getWaiter().consume(caller);
|
finishTask(player, 4);
|
||||||
|
}
|
||||||
|
else if (isInTutorial(player) && ownerString.contains("Wilderness") && get(player).hasFinishedTask(getTask(4)) && !get(player).hasFinishedTask(getTask(5)))
|
||||||
|
{
|
||||||
|
finishTask(player, 5);
|
||||||
|
}
|
||||||
|
else if (isInTutorial(player) && ownerString.contains("Shops") && get(player).hasFinishedTask(getTask(6)) && !get(player).hasFinishedTask(getTask(7)))
|
||||||
|
{
|
||||||
|
finishTask(player, 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onItemBought(Player player, ItemStack item)
|
public void onClaim(final Player caller)
|
||||||
{
|
{
|
||||||
if (isInTutorial(player) && get(player).hasFinishedPart(getPart(6)) && !get(player).hasFinishedPart(getPart(7)))
|
if (isInTutorial(caller) && get(caller).hasFinishedTask(getTask(5)) && !get(caller).hasFinishedTask(getTask(6)))
|
||||||
|
{
|
||||||
|
finishTask(caller, 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onItemBought(final Player player, final ItemStack item)
|
||||||
|
{
|
||||||
|
if (isInTutorial(player) && get(player).hasFinishedTask(getTask(7)) && !get(player).hasFinishedTask(getTask(8)))
|
||||||
{
|
{
|
||||||
if (get(player).getData("amount", 0) < 3)
|
if (get(player).getData("amount", 0) < 3)
|
||||||
{
|
{
|
||||||
@ -98,87 +112,87 @@ public class TutorialGettingStarted extends Tutorial
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getPart(7).getWaiter().consume(player);
|
finishTask(player, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onInventoryClick(InventoryClickEvent event)
|
public void onInventoryClick(final InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
if (event.getWhoClicked() instanceof Player)
|
if (event.getWhoClicked() instanceof Player)
|
||||||
{
|
{
|
||||||
Player player = (Player) event.getWhoClicked();
|
final Player player = (Player) event.getWhoClicked();
|
||||||
|
|
||||||
if (isInTutorial(player) && get(player).hasFinishedPart(getPart(7)) && !get(player).hasFinishedPart(getPart(8)))
|
if (isInTutorial(player) && get(player).hasFinishedTask(getTask(8)) && !get(player).hasFinishedTask(getTask(9)))
|
||||||
{
|
{
|
||||||
ClientClass clientclass = _clansManager.getClassManager().Get(player);
|
final ClientClass clientclass = _clansManager.getClassManager().Get(player);
|
||||||
|
|
||||||
if (clientclass != null && clientclass.GetGameClass() != null)
|
if (clientclass != null && clientclass.GetGameClass() != null)
|
||||||
{
|
{
|
||||||
getPart(8).getWaiter().consume(player);
|
finishTask(player, 9);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onInteract(PlayerInteractEvent event)
|
public void onInteract(final PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (event.getAction().name().contains("RIGHT_CLICK"))
|
if (event.getAction().name().contains("RIGHT_CLICK"))
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
if (isInTutorial(player) && get(player).hasFinishedPart(getPart(7)) && !get(player).hasFinishedPart(getPart(8)))
|
if (isInTutorial(player) && get(player).hasFinishedTask(getTask(8)) && !get(player).hasFinishedTask(getTask(9)))
|
||||||
{
|
{
|
||||||
ClientClass clientclass = _clansManager.getClassManager().Get(player);
|
final ClientClass clientclass = _clansManager.getClassManager().Get(player);
|
||||||
|
|
||||||
if (clientclass != null && clientclass.GetGameClass() != null)
|
if (clientclass != null && clientclass.GetGameClass() != null)
|
||||||
{
|
{
|
||||||
getPart(8).getWaiter().consume(player);
|
finishTask(player, 9);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onSkillTriggered(SkillTriggerEvent event)
|
public void onSkillTriggered(final SkillTriggerEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.GetPlayer();
|
final Player player = event.GetPlayer();
|
||||||
|
|
||||||
if (isInTutorial(player) && get(player).hasFinishedPart(getPart(8)) && !get(player).hasFinishedPart(getPart(9)))
|
if (isInTutorial(player) && get(player).hasFinishedTask(getTask(9)) && !get(player).hasFinishedTask(getTask(10)))
|
||||||
{
|
{
|
||||||
getPart(9).getWaiter().consume(player);
|
finishTask(player, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onUpdate(UpdateEvent event)
|
public void onUpdate(final UpdateEvent event)
|
||||||
{
|
{
|
||||||
if (event.getType().equals(UpdateType.SEC))
|
if (event.getType().equals(UpdateType.SEC))
|
||||||
{
|
{
|
||||||
for (PlayerTutorial tut : _inTutorial.values())
|
for (final PlayerTutorial tut : _inTutorial.values())
|
||||||
{
|
{
|
||||||
if (isInTutorial(tut.getPlayer()) && get(tut.getPlayer()).hasFinishedPart(getPart(9)) && !get(tut.getPlayer()).hasFinishedPart(getPart(10)))
|
if (isInTutorial(tut.getPlayer()) && get(tut.getPlayer()).hasFinishedTask(getTask(10)) && !get(tut.getPlayer()).hasFinishedTask(getTask(11)))
|
||||||
{
|
{
|
||||||
ClientClass clientclass = _clansManager.getClassManager().Get(tut.getPlayer());
|
final ClientClass clientclass = _clansManager.getClassManager().Get(tut.getPlayer());
|
||||||
|
|
||||||
if (clientclass != null && clientclass.GetSavingCustomBuild() != null)
|
if (clientclass != null && clientclass.GetSavingCustomBuild() != null)
|
||||||
{
|
{
|
||||||
getPart(10).getWaiter().consume(tut.getPlayer());
|
finishTask(tut.getPlayer(), 11);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onHomeSet(String name)
|
public void onHomeSet(final String name)
|
||||||
{
|
{
|
||||||
Player player = Bukkit.getPlayer(name);
|
final Player player = Bukkit.getPlayer(name);
|
||||||
|
|
||||||
if (isInTutorial(player) && get(player).hasFinishedPart(getPart(10)) && !get(player).hasFinishedPart(getPart(11)))
|
if (isInTutorial(player) && get(player).hasFinishedTask(getTask(11)) && !get(player).hasFinishedTask(getTask(12)))
|
||||||
{
|
{
|
||||||
getPart(11).getWaiter().consume(player);
|
finishTask(player, 12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public class TutorialOnGoingMap extends Tutorial
|
|||||||
_doScoreboard = false;
|
_doScoreboard = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnterTerritory(Player player, String ownerString)
|
public void onEnterTerritory(final Player player, final String ownerString)
|
||||||
{
|
{
|
||||||
if (!_taskManager.hasCompletedTask(player, "ClansOnGoingOptOut"))
|
if (!_taskManager.hasCompletedTask(player, "ClansOnGoingOptOut"))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user