Done most of the tutorial ghost mechanic, and also switched from using task's indexes for referencing the tasks, instead using names now. This should allow for much more flexibility, and adding/removing tasks will not be such a pain! (Having to switch all of the task indexes around for any code referencing tasks.)
This commit is contained in:
parent
765fb4ce11
commit
8ce50d1fc7
@ -940,11 +940,12 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
// Recharge
|
||||
if (!Recharge.Instance.use(caller, "Territory Claim", 60000, true, false)) return;
|
||||
|
||||
// Tutorial
|
||||
if (!((TutorialGettingStarted) TutorialManager.Instance.getTutorials().get(TutorialType.GETTING_STARTED)).onClaim(caller)) return;
|
||||
|
||||
// Task
|
||||
Plugin.getClanDataAccess().claim(clan.getName(), chunk, caller.getName(), false);
|
||||
|
||||
// Tutorial
|
||||
((TutorialGettingStarted) TutorialManager.Instance.getTutorials().get(TutorialType.GETTING_STARTED)).onClaim(caller);
|
||||
|
||||
// Inform
|
||||
UtilPlayer.message(caller, F.main("Clans", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
|
||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.task.TaskManager;
|
||||
|
||||
public class PlayerTutorial
|
||||
@ -24,7 +25,7 @@ public class PlayerTutorial
|
||||
|
||||
public static PlayerTutorial create(final Player player, final TaskManager taskManager, final Tutorial tutorial)
|
||||
{
|
||||
PlayerTutorial user = new PlayerTutorial(player, taskManager, tutorial);
|
||||
final PlayerTutorial user = new PlayerTutorial(player, taskManager, tutorial);
|
||||
|
||||
for (final int i : tutorial.getTasks().keySet())
|
||||
{
|
||||
@ -34,7 +35,13 @@ public class PlayerTutorial
|
||||
}
|
||||
}
|
||||
|
||||
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(tutorial._manager.getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
tutorial.getTask(user._currentTask).sendDescriptionTo(player);
|
||||
}
|
||||
}, 40);
|
||||
|
||||
return user;
|
||||
}
|
||||
@ -78,7 +85,7 @@ public class PlayerTutorial
|
||||
|
||||
public <T> T getData(final String name)
|
||||
{
|
||||
return (T) _data .get(name);
|
||||
return (T) _data.get(name);
|
||||
}
|
||||
|
||||
public <T> void setData(final String name, final T value)
|
||||
|
@ -16,6 +16,7 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.scoreboard.ScoreboardManager;
|
||||
import mineplex.core.scoreboard.elements.ScoreboardElement;
|
||||
@ -40,6 +41,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
private final int _rewardAmount;
|
||||
|
||||
private final HashMap<Integer, TutorialTask> _tasks;
|
||||
private final HashMap<String, TutorialTask> _nameToTask;
|
||||
protected final HashMap<String, PlayerTutorial> _inTutorial;
|
||||
private final TutorialType _type;
|
||||
|
||||
@ -55,6 +57,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
_type = type;
|
||||
_tasks = new HashMap<>();
|
||||
_inTutorial = new HashMap<>();
|
||||
_nameToTask = new HashMap<>();
|
||||
}
|
||||
|
||||
public ArrayList<String> getLines(final ScoreboardManager manager, final Player player, final ArrayList<String> out)
|
||||
@ -97,7 +100,23 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
|
||||
protected void addTask(final int id, final String name, final String description)
|
||||
{
|
||||
_tasks.put(id, new TutorialTask(id, name, description));
|
||||
addTask(id, name, description, null);
|
||||
}
|
||||
|
||||
protected void addTask(final int id, final String name, final String description, final String finishMessage)
|
||||
{
|
||||
_tasks.put(id, new TutorialTask(id, name, description, finishMessage));
|
||||
_nameToTask.put(name, _tasks.get(id));
|
||||
}
|
||||
|
||||
protected boolean hasFinishedTask(Player player, String taskName)
|
||||
{
|
||||
return hasFinishedTask(player, _nameToTask.get(taskName).getID());
|
||||
}
|
||||
|
||||
protected boolean hasFinishedTask(Player player, int taskID)
|
||||
{
|
||||
return get(player).hasFinishedTask(_tasks.get(taskID));
|
||||
}
|
||||
|
||||
protected void finishTask(final Player player, final int taskID)
|
||||
@ -135,11 +154,21 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
}
|
||||
}
|
||||
|
||||
protected void finishTask(final Player player, final String taskName)
|
||||
{
|
||||
finishTask(player, _nameToTask.get(taskName).getID());
|
||||
}
|
||||
|
||||
public TutorialTask getTask(final int taskID)
|
||||
{
|
||||
return _tasks.get(taskID);
|
||||
}
|
||||
|
||||
public TutorialTask getTask(final String name)
|
||||
{
|
||||
return _nameToTask.get(name);
|
||||
}
|
||||
|
||||
public TutorialType getType()
|
||||
{
|
||||
return _type;
|
||||
@ -161,6 +190,12 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
_goldManager.addGold(player, _rewardAmount);
|
||||
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_rewardAmount + " Gold") + "."));
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
other.showPlayer(player);
|
||||
player.showPlayer(other);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
final int index = i;
|
||||
@ -177,19 +212,39 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
}
|
||||
}
|
||||
|
||||
// Implementation up to sub classes.
|
||||
protected void onFinished(final Player player)
|
||||
{
|
||||
}
|
||||
|
||||
// Implementation up to sub classes.
|
||||
protected void onBegin(final Player player)
|
||||
{
|
||||
}
|
||||
|
||||
public void startFor(final Player player)
|
||||
{
|
||||
_inTutorial.put(player.getName(), PlayerTutorial.create(player, _taskManager, this));
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
other.hidePlayer(player);
|
||||
player.hidePlayer(other);
|
||||
}
|
||||
|
||||
onBegin(player);
|
||||
}
|
||||
|
||||
public void cancelTutorial(final Player player)
|
||||
{
|
||||
_inTutorial.remove(player.getName());
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
other.showPlayer(player);
|
||||
player.showPlayer(other);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInTutorial(final Player player)
|
||||
|
@ -10,13 +10,15 @@ public class TutorialTask
|
||||
{
|
||||
private final String _name;
|
||||
private final String _description;
|
||||
private final String _finishMessage;
|
||||
private final int _id;
|
||||
|
||||
public TutorialTask(final int id, final String name, final String description)
|
||||
public TutorialTask(final int id, final String name, final String description, String finishMessage)
|
||||
{
|
||||
_id = id;
|
||||
_name = name;
|
||||
_description = description;
|
||||
_finishMessage = finishMessage;
|
||||
}
|
||||
|
||||
public int getID()
|
||||
@ -24,6 +26,11 @@ public class TutorialTask
|
||||
return _id;
|
||||
}
|
||||
|
||||
public String getFinishMessage()
|
||||
{
|
||||
return _finishMessage;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
@ -46,4 +53,11 @@ public class TutorialTask
|
||||
UtilPlayer.message(player, C.cGreen + UtilText.repeat("=", _name.length() + ("=== Pt." + _id + ": ===").length()));
|
||||
}
|
||||
|
||||
public void onFinish(final Player player)
|
||||
{
|
||||
UtilPlayer.message(player, C.cGreen + "==================");
|
||||
UtilPlayer.message(player, C.cYellow + _finishMessage.replace("{", C.cAqua).replace("}", C.cYellow));
|
||||
UtilPlayer.message(player, C.cGreen + "==================");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.task.TaskManager;
|
||||
@ -29,12 +30,12 @@ public class TutorialGettingStarted extends Tutorial
|
||||
{
|
||||
super(50, goldManager, taskManager, clansManager, manager, TutorialType.GETTING_STARTED);
|
||||
|
||||
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!");
|
||||
addTask(1, "Welcome", "Welcome to Clans! Before you start playing Clans, you need to create a Clan by typing {/c create [name]}! Don't worry though, at the end of this tutorial, you will be disbanding this clan.");
|
||||
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!");
|
||||
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.");
|
||||
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!");
|
||||
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.");
|
||||
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!");
|
||||
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!", "Good job! We won't claim this area just yet, you may do it again later when you find a nice location.");
|
||||
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!");
|
||||
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!");
|
||||
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!");
|
||||
@ -55,56 +56,60 @@ public class TutorialGettingStarted extends Tutorial
|
||||
{
|
||||
if (event.getMessage().startsWith("/c help") || event.getMessage().startsWith("/clans help") || event.getMessage().startsWith("/clan help") || event.getMessage().startsWith("/factions help"))
|
||||
{
|
||||
if (isInTutorial(event.getPlayer()) && !get(event.getPlayer()).hasFinishedTask(getTask(1)))
|
||||
if (isInTutorial(event.getPlayer()) && !hasFinishedTask(event.getPlayer(), "Welcome"))
|
||||
{
|
||||
finishTask(event.getPlayer(), 1);
|
||||
finishTask(event.getPlayer(), "Welcome");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onClanCreated(final String caller, final String name)
|
||||
{
|
||||
if (isInTutorial(caller) && get(Bukkit.getPlayer(caller)).hasFinishedTask(getTask(1)) && !get(Bukkit.getPlayer(caller)).hasFinishedTask(getTask(2)))
|
||||
if (isInTutorial(caller) && get(Bukkit.getPlayer(caller)).hasFinishedTask(getTask("Welcome")) && !get(Bukkit.getPlayer(caller)).hasFinishedTask(getTask("Create A Clan")))
|
||||
{
|
||||
finishTask(Bukkit.getPlayer(caller), 2);
|
||||
finishTask(Bukkit.getPlayer(caller), "Create A Clan");
|
||||
}
|
||||
}
|
||||
|
||||
public void onClanInfo(final Player caller, final String name)
|
||||
{
|
||||
if (isInTutorial(caller.getName()) && get(caller).hasFinishedTask(getTask(2)) && !get(caller).hasFinishedTask(getTask(3)))
|
||||
if (isInTutorial(caller.getName()) && get(caller).hasFinishedTask(getTask("Create A Clan")) && !get(caller).hasFinishedTask(getTask("Viewing Clan Info")))
|
||||
{
|
||||
finishTask(caller, 3);
|
||||
finishTask(caller, "Viewing Clan Info");
|
||||
}
|
||||
}
|
||||
|
||||
public void onEnterTerritory(final Player player, final String ownerString)
|
||||
{
|
||||
if (isInTutorial(player) && ownerString.contains("Spawn") && get(player).hasFinishedTask(getTask(3)) && !get(player).hasFinishedTask(getTask(4)))
|
||||
if (isInTutorial(player) && ownerString.contains("Spawn") && get(player).hasFinishedTask(getTask(3)) && !get(player).hasFinishedTask(getTask("Leave Spawn")))
|
||||
{
|
||||
finishTask(player, 4);
|
||||
finishTask(player, "Leave Spawn");
|
||||
}
|
||||
else if (isInTutorial(player) && ownerString.contains("Wilderness") && get(player).hasFinishedTask(getTask(4)) && !get(player).hasFinishedTask(getTask(5)))
|
||||
else if (isInTutorial(player) && ownerString.contains("Wilderness") && get(player).hasFinishedTask(getTask(4)) && !get(player).hasFinishedTask(getTask("Go To The Wilderness")))
|
||||
{
|
||||
finishTask(player, 5);
|
||||
finishTask(player, "Go To The Wilderness");
|
||||
}
|
||||
else if (isInTutorial(player) && ownerString.contains("Shops") && get(player).hasFinishedTask(getTask(6)) && !get(player).hasFinishedTask(getTask(7)))
|
||||
else if (isInTutorial(player) && ownerString.contains("Shops") && get(player).hasFinishedTask(getTask(6)) && !get(player).hasFinishedTask(getTask("Visit The Shops")))
|
||||
{
|
||||
finishTask(player, 7);
|
||||
finishTask(player, "Visit The Shops");
|
||||
}
|
||||
}
|
||||
|
||||
public void onClaim(final Player caller)
|
||||
public boolean onClaim(final Player caller)
|
||||
{
|
||||
if (isInTutorial(caller) && get(caller).hasFinishedTask(getTask(5)) && !get(caller).hasFinishedTask(getTask(6)))
|
||||
if (isInTutorial(caller) && get(caller).hasFinishedTask(getTask("Go To The Wilderness")) && !get(caller).hasFinishedTask(getTask("Claiming Territory")))
|
||||
{
|
||||
finishTask(caller, 6);
|
||||
finishTask(caller, "Claiming Territory");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onItemBought(final Player player, final ItemStack item)
|
||||
{
|
||||
if (isInTutorial(player) && get(player).hasFinishedTask(getTask(7)) && !get(player).hasFinishedTask(getTask(8)))
|
||||
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Visit The Shops")) && !get(player).hasFinishedTask(getTask("Buy Armor")))
|
||||
{
|
||||
if (get(player).getData("amount", 0) < 3)
|
||||
{
|
||||
@ -112,7 +117,7 @@ public class TutorialGettingStarted extends Tutorial
|
||||
}
|
||||
else
|
||||
{
|
||||
finishTask(player, 8);
|
||||
finishTask(player, "Buy Armor");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,13 +129,13 @@ public class TutorialGettingStarted extends Tutorial
|
||||
{
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
|
||||
if (isInTutorial(player) && get(player).hasFinishedTask(getTask(8)) && !get(player).hasFinishedTask(getTask(9)))
|
||||
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Buy Armor")) && !get(player).hasFinishedTask(getTask("Equip Armor")))
|
||||
{
|
||||
final ClientClass clientclass = _clansManager.getClassManager().Get(player);
|
||||
|
||||
if (clientclass != null && clientclass.GetGameClass() != null)
|
||||
{
|
||||
finishTask(player, 9);
|
||||
finishTask(player, "Equip Armor");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,13 +148,13 @@ public class TutorialGettingStarted extends Tutorial
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (isInTutorial(player) && get(player).hasFinishedTask(getTask(8)) && !get(player).hasFinishedTask(getTask(9)))
|
||||
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Buy Armor")) && !get(player).hasFinishedTask(getTask("Equip Armor")))
|
||||
{
|
||||
final ClientClass clientclass = _clansManager.getClassManager().Get(player);
|
||||
|
||||
if (clientclass != null && clientclass.GetGameClass() != null)
|
||||
{
|
||||
finishTask(player, 9);
|
||||
finishTask(player, "Equip Armor");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -160,9 +165,9 @@ public class TutorialGettingStarted extends Tutorial
|
||||
{
|
||||
final Player player = event.GetPlayer();
|
||||
|
||||
if (isInTutorial(player) && get(player).hasFinishedTask(getTask(9)) && !get(player).hasFinishedTask(getTask(10)))
|
||||
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Equip Armor")) && !get(player).hasFinishedTask(getTask("Use An Ability")))
|
||||
{
|
||||
finishTask(player, 10);
|
||||
finishTask(player, "Use An Ability");
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,13 +178,13 @@ public class TutorialGettingStarted extends Tutorial
|
||||
{
|
||||
for (final PlayerTutorial tut : _inTutorial.values())
|
||||
{
|
||||
if (isInTutorial(tut.getPlayer()) && get(tut.getPlayer()).hasFinishedTask(getTask(10)) && !get(tut.getPlayer()).hasFinishedTask(getTask(11)))
|
||||
if (isInTutorial(tut.getPlayer()) && get(tut.getPlayer()).hasFinishedTask(getTask("Use An Ability")) && !get(tut.getPlayer()).hasFinishedTask(getTask("Class Customization")))
|
||||
{
|
||||
final ClientClass clientclass = _clansManager.getClassManager().Get(tut.getPlayer());
|
||||
|
||||
if (clientclass != null && clientclass.GetSavingCustomBuild() != null)
|
||||
{
|
||||
finishTask(tut.getPlayer(), 11);
|
||||
finishTask(tut.getPlayer(), "Class Customization");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -190,10 +195,15 @@ public class TutorialGettingStarted extends Tutorial
|
||||
{
|
||||
final Player player = Bukkit.getPlayer(name);
|
||||
|
||||
if (isInTutorial(player) && get(player).hasFinishedTask(getTask(11)) && !get(player).hasFinishedTask(getTask(12)))
|
||||
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Class Customization")) && !get(player).hasFinishedTask(getTask("Clan Home")))
|
||||
{
|
||||
finishTask(player, 12);
|
||||
finishTask(player, "Clan Home");
|
||||
}
|
||||
}
|
||||
|
||||
public void onBegin(final Player player)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Tutorials", "Welcome to the " + F.elem("Getting Started Tutorial!")));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user