Finalized the getting started tutorial.

Added the last 5 tasks, and added a nice big ending (fireworks)

Added an ugly fix to the QAResetCommand, which I am really unhappy about, but can't find any other way about it. It's only a test command though, so it'll be removed in the final releases.
This commit is contained in:
NewGarbo 2015-10-21 06:17:18 +01:00
parent c6cf47ee4e
commit bd5266251b
8 changed files with 184 additions and 38 deletions

View File

@ -20,9 +20,9 @@ import mineplex.game.clans.clans.tntGenerator.TntGenerator;
import mineplex.game.clans.core.repository.ClanRepository;
import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.game.clans.core.repository.tokens.ClanToken;
import mineplex.game.clans.tutorials.TutorialGettingStarted;
import mineplex.game.clans.tutorials.TutorialManager;
import mineplex.game.clans.tutorials.TutorialType;
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
public class ClansDataAccessLayer
{
@ -607,6 +607,9 @@ public class ClansDataAccessLayer
}
});
//Tutorial
((TutorialGettingStarted) _tutorialManager.getTutorials().get(TutorialType.GETTING_STARTED)).onHomeSet(player);
//Log
_manager.log("Set Home for [" + clan.getName() + "] to " + UtilWorld.locToStrClean(loc) + " by [" + player + "].");
}

View File

@ -199,7 +199,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
DamageManager damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition);
_worldEvent = new WorldEventManager(plugin, this, damageManager, _lootManager, blockRestore);
_tutorialManager = new TutorialManager(plugin, _goldManager, new TaskManager(plugin, _clientManager, webServerAddress));
_tutorialManager = new TutorialManager(plugin, _goldManager, new TaskManager(plugin, _clientManager, webServerAddress), this);
_scoreboard = new ClansScoreboardManager(plugin, _tutorialManager, this, _warManager, _worldEvent, clientManager, donationManager);
new MurderManager(plugin, this);

View File

@ -25,9 +25,9 @@ import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansPlayer;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.tutorials.TutorialGettingStarted;
import mineplex.game.clans.tutorials.TutorialManager;
import mineplex.game.clans.tutorials.TutorialType;
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
public class ClansCommand extends CommandBase<ClansManager>
{

View File

@ -3,17 +3,23 @@ package mineplex.game.clans.tutorials;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.util.Vector;
import mineplex.core.common.Pair;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.economy.GoldManager;
/**
@ -23,20 +29,24 @@ import mineplex.game.clans.economy.GoldManager;
* would be too long of a class name, so I'll stick with "Tutorial" for now.
*
*/
public abstract class Tutorial implements ScoreboardElement
public abstract class Tutorial implements ScoreboardElement, Listener
{
protected final TutorialManager _manager;
private final TaskManager _taskManager;
protected final GoldManager _goldManager;
protected final ClansManager _clansManager;
private final TaskManager _taskManager;
private final int _rewardAmount;
private final HashMap<Integer, Pair<TutorialPart, Consumer<Player>>> _parts;
private final HashMap<String, PlayerTutorial> _inTutorial;
protected final HashMap<String, PlayerTutorial> _inTutorial;
private final TutorialType _type;
public Tutorial(final int rewardAmount, final GoldManager goldManager, final TaskManager taskManager, final TutorialManager manager, final TutorialType type)
protected boolean _doScoreboard;
public Tutorial(final int rewardAmount, final GoldManager goldManager, final TaskManager taskManager, final ClansManager clansManager, final TutorialManager manager, final TutorialType type)
{
_clansManager = clansManager;
_goldManager = goldManager;
_taskManager = taskManager;
_rewardAmount = rewardAmount;
@ -48,15 +58,15 @@ public abstract class Tutorial implements ScoreboardElement
public ArrayList<String> getLines(ScoreboardManager manager, Player player, ArrayList<String> out)
{
out.clear();
ArrayList<String> lines = new ArrayList<>();
if (!isInTutorial(player))
if (!isInTutorial(player) && _doScoreboard)
{
return lines;
}
out.clear();
PlayerTutorial ptutorial = _inTutorial.get(player.getName());
lines.add(C.cAqua + _type.getFriendlyName() + " Tutorial");
@ -107,7 +117,7 @@ public abstract class Tutorial implements ScoreboardElement
{
public void run(Boolean completed)
{
UtilPlayer.message(player, F.main("Tutorials", "You have completed task " + F.elem(partID + " (" + part.getLeft().getName() + ")") + "."));
UtilPlayer.message(player, F.main("Tutorials", "You have completed task " + F.elem(partID + " (" + part.getLeft().getName() + ")") + ". " + (_parts.size() - partID) + " tasks to go!"));
if (partID == _parts.size())
{
@ -131,7 +141,9 @@ public abstract class Tutorial implements ScoreboardElement
}
}
protected void newPart(int partID) { }
protected void newPart(int partID)
{
}
public TutorialPart getPart(final int partID)
{
@ -147,7 +159,9 @@ public abstract class Tutorial implements ScoreboardElement
{
_inTutorial.remove(player.getName());
UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, Color.LIME, false, false, new Vector(0, 0, 0), 1);
UtilPlayer.message(player, F.main("Tutorials", "You have completed the " + F.elem(_type.getFriendlyName() + " Tutorial") + "."));
onFinished(player);
if (!_taskManager.hasCompletedTask(player, _type.getId()))
{
_taskManager.completedTask(new Callback<Boolean>()
@ -155,11 +169,28 @@ public abstract class Tutorial implements ScoreboardElement
public void run(Boolean completed)
{
_goldManager.addGold(player, _rewardAmount);
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_rewardAmount + " Gold") + "."));
for (int i = 0; i < 5; i++)
{
final int index = i;
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
{
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);
}
}, i * 30);
}
}
}, player, _type.getId());
}
}
protected void onFinished(final Player player)
{
}
public void startFor(final Player player)
{
_inTutorial.put(player.getName(), PlayerTutorial.create(player, _taskManager, this));

View File

@ -11,10 +11,12 @@ import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.tutorials.commands.EndTutorialCommand;
import mineplex.game.clans.tutorials.commands.QAResetCommand;
import mineplex.game.clans.tutorials.commands.TaskInfoCommand;
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
public class TutorialManager extends MiniPlugin
{
@ -25,7 +27,7 @@ public class TutorialManager extends MiniPlugin
private TaskManager _taskManager;
public TutorialManager(final JavaPlugin plugin, final GoldManager goldManager, final TaskManager taskManager)
public TutorialManager(final JavaPlugin plugin, final GoldManager goldManager, final TaskManager taskManager, final ClansManager clansManager)
{
super("Tutorials", plugin);
@ -33,7 +35,9 @@ public class TutorialManager extends MiniPlugin
_taskManager = taskManager;
_tutorials.put(TutorialType.GETTING_STARTED, new TutorialGettingStarted(this, goldManager, taskManager));
_tutorials.put(TutorialType.GETTING_STARTED, new TutorialGettingStarted(this, clansManager, goldManager, taskManager));
registerEvents(_tutorials.get(TutorialType.GETTING_STARTED));
}
public void addCommands()

View File

@ -1,5 +1,7 @@
package mineplex.game.clans.tutorials;
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
public enum TutorialType
{
GETTING_STARTED(TutorialGettingStarted.class, "Getting Started", "GettingStartedTutorial");

View File

@ -10,10 +10,10 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.tutorials.Consumer;
import mineplex.game.clans.tutorials.TutorialGettingStarted;
import mineplex.game.clans.tutorials.TutorialManager;
import mineplex.game.clans.tutorials.TutorialPart;
import mineplex.game.clans.tutorials.TutorialType;
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
// temp command
public class QAResetCommand extends CommandBase<TutorialManager>
@ -26,26 +26,31 @@ public class QAResetCommand extends CommandBase<TutorialManager>
@Override
public void Execute(final Player caller, final String[] args)
{
TutorialGettingStarted tutorial = (TutorialGettingStarted) Plugin.getTutorials().get(TutorialType.GETTING_STARTED);
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()));
UtilPlayer.message(caller, F.main("Tutorials", "Removed " + F.elem(tutorial.getType().getId())));
for (Pair<TutorialPart, Consumer<Player>> part : tutorial.getParts().values())
for (int i = 0; i < 11; i++) // THIS IS A VERY BAD WORK AROUND AND I AM
// SORRY, IT'S JUST A BUG THAT'S
// ANNOYING PLEASE DON'T HARM ME IT'S
// ONLY A TEMP COMMAND FOR TESTING
{
Plugin.getTaskManager().Get(caller).TasksCompleted.remove(Plugin.getTaskManager().getTaskId(tutorial.getType().getId() + part.getLeft().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()) + ")"));
TutorialGettingStarted tutorial = (TutorialGettingStarted) Plugin.getTutorials().get(TutorialType.GETTING_STARTED);
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()));
UtilPlayer.message(caller, F.main("Tutorials", "Removed " + F.elem(tutorial.getType().getId())));
for (Pair<TutorialPart, Consumer<Player>> part : tutorial.getParts().values())
{
Plugin.getTaskManager().Get(caller).TasksCompleted.remove(Plugin.getTaskManager().getTaskId(tutorial.getType().getId() + part.getLeft().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", Arrays.toString(Plugin.getTaskManager().Get(caller).TasksCompleted.toArray())));
UtilPlayer.message(caller, F.main("Tutorials", "Your Getting Started Tutorial progress has been deleted."));
TutorialManager.Instance.getTutorials().get(TutorialType.GETTING_STARTED).cancelTutorial(caller);
TutorialManager.Instance.getTutorials().get(TutorialType.GETTING_STARTED).startFor(caller);
}
UtilPlayer.message(caller, F.main("Tutorials", Arrays.toString(Plugin.getTaskManager().Get(caller).TasksCompleted.toArray())));
UtilPlayer.message(caller, F.main("Tutorials", "Your Getting Started Tutorial progress has been deleted."));
TutorialManager.Instance.getTutorials().get(TutorialType.GETTING_STARTED).cancelTutorial(caller);
TutorialManager.Instance.getTutorials().get(TutorialType.GETTING_STARTED).startFor(caller);
}
}

View File

@ -1,17 +1,32 @@
package mineplex.game.clans.tutorials;
package mineplex.game.clans.tutorials.types;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.tutorials.PlayerTutorial;
import mineplex.game.clans.tutorials.Tutorial;
import mineplex.game.clans.tutorials.TutorialManager;
import mineplex.game.clans.tutorials.TutorialType;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
public class TutorialGettingStarted extends Tutorial
{
public TutorialGettingStarted(final TutorialManager manager, final GoldManager goldManager, final TaskManager taskManager)
public TutorialGettingStarted(final TutorialManager manager, final ClansManager clansManager, final GoldManager goldManager, final TaskManager taskManager)
{
super(50, goldManager, taskManager, 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]}. Dont worry about being though, you can always disband this clan and join another later if you need to!");
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.");
@ -24,6 +39,13 @@ public class TutorialGettingStarted extends Tutorial
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!");
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!");
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!");
_doScoreboard = true;
}
public void onFinished(final Player player)
{
UtilPlayer.message(player, F.main("Tutorials", "You are now ready to play, welcome to the game."));
}
public void onClanCreated(String caller, String name)
@ -81,4 +103,83 @@ public class TutorialGettingStarted extends Tutorial
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onInventoryClick(InventoryClickEvent event)
{
if (event.getWhoClicked() instanceof Player)
{
Player player = (Player) event.getWhoClicked();
if (isInTutorial(player) && get(player).hasFinishedPart(getPart(7)) && !get(player).hasFinishedPart(getPart(8)))
{
ClientClass clientclass = _clansManager.getClassManager().Get(player);
if (clientclass != null && clientclass.GetGameClass() != null)
{
getPart(8).getWaiter().consume(player);
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onInteract(PlayerInteractEvent event)
{
if (event.getAction().name().contains("RIGHT_CLICK"))
{
Player player = event.getPlayer();
if (isInTutorial(player) && get(player).hasFinishedPart(getPart(7)) && !get(player).hasFinishedPart(getPart(8)))
{
ClientClass clientclass = _clansManager.getClassManager().Get(player);
if (clientclass != null && clientclass.GetGameClass() != null)
{
getPart(8).getWaiter().consume(player);
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onSkillTriggered(SkillTriggerEvent event)
{
Player player = event.GetPlayer();
if (isInTutorial(player) && get(player).hasFinishedPart(getPart(8)) && !get(player).hasFinishedPart(getPart(9)))
{
getPart(9).getWaiter().consume(player);
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onUpdate(UpdateEvent event)
{
if (event.getType().equals(UpdateType.SEC))
{
for (PlayerTutorial tut : _inTutorial.values())
{
if (isInTutorial(tut.getPlayer()) && get(tut.getPlayer()).hasFinishedPart(getPart(9)) && !get(tut.getPlayer()).hasFinishedPart(getPart(10)))
{
ClientClass clientclass = _clansManager.getClassManager().Get(tut.getPlayer());
if (clientclass != null && clientclass.GetSavingCustomBuild() != null)
{
getPart(10).getWaiter().consume(tut.getPlayer());
}
}
}
}
}
public void onHomeSet(String name)
{
Player player = Bukkit.getPlayer(name);
if (isInTutorial(player) && get(player).hasFinishedPart(getPart(10)) && !get(player).hasFinishedPart(getPart(11)))
{
getPart(11).getWaiter().consume(player);
}
}
}