Fix tutorial command, add tutorial info to scoreboard, message manager, transitioning to a visual manager
This commit is contained in:
parent
9884742552
commit
3d4cd9ee27
@ -313,9 +313,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
new PvpTimer(this, _playTracker, statsManager);
|
||||
|
||||
_tutorialManager = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler);
|
||||
new TutorialManager(plugin, clientManager, donationManager);
|
||||
TutorialManager tutorial = new TutorialManager(plugin, clientManager, donationManager);
|
||||
|
||||
_scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, clientManager, donationManager);
|
||||
_scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, tutorial, clientManager, donationManager);
|
||||
_clanDataAccess = new ClansDataAccessLayer(this, _scoreboard);
|
||||
|
||||
for (ClanToken token : _clanDataAccess.getRepository().retrieveClans())
|
||||
|
@ -21,22 +21,23 @@ import mineplex.game.clans.clans.scoreboard.elements.ScoreboardElementClan;
|
||||
import mineplex.game.clans.clans.scoreboard.elements.ScoreboardElementPlayer;
|
||||
import mineplex.game.clans.clans.war.WarManager;
|
||||
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
||||
import mineplex.game.clans.legacytutorial.Tutorial;
|
||||
import mineplex.game.clans.legacytutorial.TutorialManager;
|
||||
import mineplex.game.clans.tutorial.TutorialManager;
|
||||
|
||||
public class ClansScoreboardManager extends ScoreboardManager
|
||||
{
|
||||
private ClansManager _clansManager;
|
||||
private WarManager _warManager;
|
||||
private WorldEventManager _worldEvent;
|
||||
private TutorialManager _tutorial;
|
||||
|
||||
public ClansScoreboardManager(JavaPlugin plugin, ClansManager clansManager, WarManager warManager, WorldEventManager worldEvent, CoreClientManager clientManager, DonationManager donationManager)
|
||||
public ClansScoreboardManager(JavaPlugin plugin, ClansManager clansManager, WarManager warManager, WorldEventManager worldEvent, TutorialManager tutorial, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super(plugin, clientManager, donationManager);
|
||||
|
||||
_clansManager = clansManager;
|
||||
_warManager = warManager;
|
||||
_worldEvent = worldEvent;
|
||||
_tutorial = tutorial;
|
||||
|
||||
init();
|
||||
}
|
||||
@ -53,11 +54,12 @@ public class ClansScoreboardManager extends ScoreboardManager
|
||||
|
||||
data.writeElement(_warManager);
|
||||
data.writeElement(_worldEvent);
|
||||
data.writeElement(_tutorial);
|
||||
|
||||
for (Tutorial tutorial : TutorialManager.Instance.getTutorials().values())
|
||||
{
|
||||
data.writeElement(tutorial);
|
||||
}
|
||||
// for (Tutorial tutorial : TutorialManager.Instance.getTutorials().values())
|
||||
// {
|
||||
// data.writeElement(tutorial);
|
||||
// }
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -0,0 +1,45 @@
|
||||
package mineplex.game.clans.message;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class ClansMessageManager extends MiniPlugin
|
||||
{
|
||||
private HashMap<Player, Message> _playerMessageMap;
|
||||
|
||||
public ClansMessageManager(JavaPlugin plugin)
|
||||
{
|
||||
super("Message", plugin);
|
||||
|
||||
_playerMessageMap = new HashMap<>();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void tick(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
_playerMessageMap.forEach((player, message) ->{
|
||||
message.increment();
|
||||
if (message.shouldSend())
|
||||
{
|
||||
message.send(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setMessage(Player player, String title, String description, int ticksBetween, boolean displayNow)
|
||||
{
|
||||
Message message = new Message(title, description, ticksBetween);
|
||||
_playerMessageMap.put(player, message);
|
||||
if (displayNow) message.send(player);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package mineplex.game.clans.message;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
|
||||
public class Message
|
||||
{
|
||||
private int _ticksBetweenMessage;
|
||||
private int _ticks;
|
||||
|
||||
private String _title;
|
||||
private String _description;
|
||||
|
||||
public Message(String title, String description, int ticksBetweenMessage)
|
||||
{
|
||||
_title = title;
|
||||
_description = description;
|
||||
_ticksBetweenMessage = ticksBetweenMessage;
|
||||
_ticks = 0;
|
||||
}
|
||||
|
||||
protected void send(Player player)
|
||||
{
|
||||
UtilTextMiddle.display(_title, _description, player);
|
||||
}
|
||||
|
||||
public int getTicks()
|
||||
{
|
||||
return _ticks;
|
||||
}
|
||||
|
||||
public int getTicksBetweenMessage()
|
||||
{
|
||||
return _ticksBetweenMessage;
|
||||
}
|
||||
|
||||
public void increment()
|
||||
{
|
||||
_ticks++;
|
||||
}
|
||||
|
||||
public boolean shouldSend()
|
||||
{
|
||||
return _ticks % _ticksBetweenMessage == 0;
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -12,12 +13,15 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.objective.Objective;
|
||||
import mineplex.core.common.objective.ObjectiveListener;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.game.clans.message.ClansMessageManager;
|
||||
|
||||
public abstract class Tutorial implements Listener, ObjectiveListener
|
||||
{
|
||||
private HashMap<Player, TutorialSession> _playerSessionMap;
|
||||
|
||||
private JavaPlugin _plugin;
|
||||
private ClansMessageManager _message;
|
||||
private String _name;
|
||||
private String _taskIdentifier;
|
||||
|
||||
@ -27,9 +31,10 @@ public abstract class Tutorial implements Listener, ObjectiveListener
|
||||
|
||||
private List<Objective> _objectives;
|
||||
|
||||
public Tutorial(JavaPlugin plugin, String name, String taskIdentifier, Material guiMaterial, byte data)
|
||||
public Tutorial(JavaPlugin plugin, ClansMessageManager message, String name, String taskIdentifier, Material guiMaterial, byte data)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_message = message;
|
||||
_name = name;
|
||||
_taskIdentifier = taskIdentifier;
|
||||
|
||||
@ -113,7 +118,10 @@ public abstract class Tutorial implements Listener, ObjectiveListener
|
||||
@Override
|
||||
public void onObjectiveStart(Player player, Objective objective)
|
||||
{
|
||||
|
||||
String title = objective.getName();
|
||||
String desc = objective.getDescription();
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f);
|
||||
_message.setMessage(player, title, desc, 100, true);
|
||||
}
|
||||
|
||||
private void finish(Player player)
|
||||
@ -132,4 +140,23 @@ public abstract class Tutorial implements Listener, ObjectiveListener
|
||||
HandlerList.unregisterAll(this);
|
||||
_objectives.forEach(Objective::unregisterAll);
|
||||
}
|
||||
|
||||
public List<String> getScoreboardLines(Player player)
|
||||
{
|
||||
ArrayList<String> lines = new ArrayList<>();
|
||||
TutorialSession session = _playerSessionMap.get(player);
|
||||
if (session != null)
|
||||
{
|
||||
lines.add(" ");
|
||||
|
||||
int objectiveIndex = session.getObjectiveIndex();
|
||||
Objective currentObjective = _objectives.get(objectiveIndex);
|
||||
lines.add(C.cGoldB + "Current Task (" + (objectiveIndex + 1) + "/" + _objectives.size() + ")");
|
||||
lines.add(" " + currentObjective.getName());
|
||||
|
||||
lines.add(" ");
|
||||
lines.add("Type /skip to exit tutorial");
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
package mineplex.game.clans.tutorial;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
@ -12,13 +15,18 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.scoreboard.ScoreboardManager;
|
||||
import mineplex.core.scoreboard.elements.ScoreboardElement;
|
||||
import mineplex.game.clans.message.ClansMessageManager;
|
||||
import mineplex.game.clans.tutorial.command.TutorialCommand;
|
||||
import mineplex.game.clans.tutorial.gui.TutorialShop;
|
||||
import mineplex.game.clans.tutorial.tutorials.combat.CombatTutorial;
|
||||
|
||||
public class TutorialManager extends MiniPlugin
|
||||
public class TutorialManager extends MiniPlugin implements ScoreboardElement
|
||||
{
|
||||
private CoreClientManager _clientManager;
|
||||
private DonationManager _donationManager;
|
||||
private ClansMessageManager _clansMessageManager;
|
||||
|
||||
private EnumMap<TutorialType, Tutorial> _tutorialMap;
|
||||
private EnumMap<TutorialType, TutorialShop> _shopMap; // Don't need to do anything with shops currently
|
||||
@ -29,11 +37,18 @@ public class TutorialManager extends MiniPlugin
|
||||
|
||||
_clientManager = clientManager;
|
||||
_donationManager = donationManager;
|
||||
_clansMessageManager = new ClansMessageManager(plugin);
|
||||
|
||||
_tutorialMap = new EnumMap<TutorialType, Tutorial>(TutorialType.class);
|
||||
_shopMap = new EnumMap<TutorialType, TutorialShop>(TutorialType.class);
|
||||
|
||||
addTutorial(TutorialType.COMBAT, new CombatTutorial(plugin));
|
||||
addTutorial(TutorialType.COMBAT, new CombatTutorial(plugin, _clansMessageManager));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new TutorialCommand(this));
|
||||
}
|
||||
|
||||
private void addTutorial(TutorialType type, Tutorial tutorial)
|
||||
@ -49,14 +64,19 @@ public class TutorialManager extends MiniPlugin
|
||||
}
|
||||
|
||||
public boolean inTutorial(Player player)
|
||||
{
|
||||
return getTutorial(player) != null;
|
||||
}
|
||||
|
||||
public Tutorial getTutorial(Player player)
|
||||
{
|
||||
for (Tutorial tutorial : _tutorialMap.values())
|
||||
{
|
||||
if (tutorial.isInTutorial(player))
|
||||
return true;
|
||||
return tutorial;
|
||||
}
|
||||
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean startTutorial(Player player, TutorialType type)
|
||||
@ -76,4 +96,31 @@ public class TutorialManager extends MiniPlugin
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void openTutorialMenu(Player player, TutorialType type)
|
||||
{
|
||||
if (_shopMap.containsKey(type))
|
||||
{
|
||||
_shopMap.get(type).attemptShopOpen(player);
|
||||
}
|
||||
}
|
||||
|
||||
public ClansMessageManager getMessageManager()
|
||||
{
|
||||
return _clansMessageManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLines(ScoreboardManager manager, Player player, List<String> out)
|
||||
{
|
||||
Tutorial tutorial = getTutorial(player);
|
||||
|
||||
if (tutorial != null)
|
||||
{
|
||||
out.clear();
|
||||
return tutorial.getScoreboardLines(player);
|
||||
}
|
||||
|
||||
return new ArrayList<String>(0);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class StartCommand extends CommandBase<TutorialManager>
|
||||
try
|
||||
{
|
||||
TutorialType type = TutorialType.valueOf(args[0]);
|
||||
Plugin.startTutorial(caller, type);
|
||||
Plugin.openTutorialMenu(caller, type);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
|
@ -12,6 +12,8 @@ public class TutorialCommand extends MultiCommandBase<TutorialManager>
|
||||
public TutorialCommand(TutorialManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "tutorial", "tut");
|
||||
|
||||
AddCommand(new StartCommand(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,7 @@ public class TutorialSelectPage extends ShopPageBase<TutorialManager, TutorialSh
|
||||
addButton(27 + 6, startItem, new StartButton(tutorial));
|
||||
|
||||
ShopItem declineButton = new ShopItem(Material.REDSTONE_BLOCK, "Cancel", new String[0], 0, false, false);
|
||||
addButton(27 + 3, declineButton, new DeclineButton());
|
||||
addButton(27 + 2, declineButton, new DeclineButton());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,15 +5,16 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.objective.Objective;
|
||||
import mineplex.game.clans.message.ClansMessageManager;
|
||||
import mineplex.game.clans.tutorial.Tutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.combat.objectives.CustomizeKitObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.combat.objectives.EquipArmorObjective;
|
||||
|
||||
public class CombatTutorial extends Tutorial
|
||||
{
|
||||
public CombatTutorial(JavaPlugin plugin)
|
||||
public CombatTutorial(JavaPlugin plugin, ClansMessageManager message)
|
||||
{
|
||||
super(plugin, "Combat Tutorial", "combat", Material.DIAMOND_SWORD, (byte) 0);
|
||||
super(plugin, message, "Combat Tutorial", "combat", Material.DIAMOND_SWORD, (byte) 0);
|
||||
|
||||
addObjective(new EquipArmorObjective(plugin));
|
||||
addObjective(new CustomizeKitObjective(plugin));
|
||||
|
@ -0,0 +1,35 @@
|
||||
package mineplex.game.clans.tutorial.visual;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
|
||||
public class VisualManager extends MiniPlugin
|
||||
{
|
||||
public VisualManager(JavaPlugin plugin)
|
||||
{
|
||||
super("Visual", plugin);
|
||||
}
|
||||
|
||||
public void setTitleMessage(Player player, String message, String desc, int timer, boolean displayNow)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void displayTitleMessage(Player player, String message, String desc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void playFinish(Player player)
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
|
||||
}
|
||||
|
||||
public void clear(Player player)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user