Merge remote-tracking branch 'remotes/origin/clans/tutorial' into clans/beta
# Conflicts: # Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java
This commit is contained in:
commit
ffd9d98d2e
@ -0,0 +1,46 @@
|
||||
package mineplex.core.common;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class MaterialData
|
||||
{
|
||||
private final Material _material;
|
||||
private final byte _data;
|
||||
|
||||
private MaterialData(Material material, byte data)
|
||||
{
|
||||
_material = material;
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public static MaterialData of(Material material)
|
||||
{
|
||||
return new MaterialData(material, (byte) 0);
|
||||
}
|
||||
|
||||
public static MaterialData of(Material material, byte data)
|
||||
{
|
||||
return new MaterialData(material, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
MaterialData that = (MaterialData) o;
|
||||
|
||||
if (_data != that._data) return false;
|
||||
return _material == that._material;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int result = _material.hashCode();
|
||||
result = 31 * result + (int) _data;
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
package mineplex.core.common.objective;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* An Objective represents a set of goals that need to be completed to move on to the next Objective in the quest
|
||||
*/
|
||||
public abstract class Objective<Data extends ObjectiveData> implements Listener
|
||||
{
|
||||
private JavaPlugin _plugin;
|
||||
private String _name;
|
||||
private String _description;
|
||||
|
||||
private HashMap<UUID, Data> _active;
|
||||
private List<ObjectiveListener> _listeners;
|
||||
|
||||
public Objective(JavaPlugin plugin, String name, String description)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_name = name;
|
||||
_description = description;
|
||||
|
||||
_active = new HashMap<>();
|
||||
_listeners = new LinkedList<>();
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public JavaPlugin getPlugin()
|
||||
{
|
||||
return _plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this Objective
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description of this Objective
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an ObjectiveListener to this Objective
|
||||
* @param listener
|
||||
*/
|
||||
public void addListener(ObjectiveListener listener)
|
||||
{
|
||||
_listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all ObjectiveListeners from this Objective
|
||||
*/
|
||||
public void clearListeners()
|
||||
{
|
||||
_listeners.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start this Objective for a player
|
||||
* @param player
|
||||
*/
|
||||
public void start(Player player)
|
||||
{
|
||||
System.out.println(String.format("Tutorial> [%s] started objective [%s]", player.getName(), getName()));
|
||||
|
||||
Data data = createDataObject(player);
|
||||
_active.put(player.getUniqueId(), data);
|
||||
|
||||
_listeners.forEach(listener -> listener.onObjectiveStart(player, this));
|
||||
|
||||
customStart(player);
|
||||
}
|
||||
|
||||
protected abstract void customStart(Player player);
|
||||
|
||||
/**
|
||||
* Leave this objective for a specific player
|
||||
* This does not count as completing the object
|
||||
* @param player
|
||||
*/
|
||||
public final void leave(Player player)
|
||||
{
|
||||
_active.remove(player.getUniqueId());
|
||||
|
||||
customLeave(player);
|
||||
}
|
||||
|
||||
protected abstract void customLeave(Player player);
|
||||
|
||||
/**
|
||||
* Returns a new Data object for use in the active map
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
protected abstract Data createDataObject(Player player);
|
||||
|
||||
/**
|
||||
* Called by ObjectiveGoals, used to notify this Objective that a goal has been completed
|
||||
* @param goal
|
||||
* @param player
|
||||
*/
|
||||
protected abstract void completeGoal(ObjectiveGoal goal, Player player);
|
||||
|
||||
/**
|
||||
* Returns a list of all the ObjectiveGoals used by this Objective
|
||||
* Can return <code>null</code>
|
||||
*/
|
||||
protected abstract List<ObjectiveGoal> getGoals();
|
||||
|
||||
protected final void finish(Player player)
|
||||
{
|
||||
System.out.println(String.format("Tutorial> [%s] finished objective [%s]", player.getName(), getName()));
|
||||
|
||||
_active.remove(player.getUniqueId());
|
||||
|
||||
customFinish(player);
|
||||
|
||||
_listeners.forEach(listener -> listener.onObjectiveFinish(player, this));
|
||||
}
|
||||
|
||||
protected abstract void customFinish(Player player);
|
||||
|
||||
public boolean contains(Player player)
|
||||
{
|
||||
return contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
public boolean contains(UUID uuid)
|
||||
{
|
||||
return _active.containsKey(uuid);
|
||||
}
|
||||
|
||||
protected final List<UUID> getActive()
|
||||
{
|
||||
return new LinkedList<UUID>(_active.keySet());
|
||||
}
|
||||
|
||||
public Data getData(Player player)
|
||||
{
|
||||
return _active.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister all listeners associated with this Objective
|
||||
*/
|
||||
public final void unregisterAll()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
List<ObjectiveGoal> goals = getGoals();
|
||||
if (goals != null) goals.forEach(HandlerList::unregisterAll);
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package mineplex.core.common.objective;
|
||||
|
||||
public class ObjectiveData
|
||||
{
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package mineplex.core.common.objective;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public abstract class ObjectiveGoal implements Listener
|
||||
{
|
||||
private Objective _objective;
|
||||
|
||||
private HashSet<UUID> _active;
|
||||
private String _name;
|
||||
private String _description;
|
||||
|
||||
public ObjectiveGoal(Objective objective, String name, String description)
|
||||
{
|
||||
_objective = objective;
|
||||
|
||||
_active = new HashSet<>();
|
||||
_name = name;
|
||||
_description = description;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
public boolean contains(Player player)
|
||||
{
|
||||
return _active.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
public final void start(Player player)
|
||||
{
|
||||
System.out.println(String.format("Tutorial> [%s] started objective goal [%s]", player.getName(), getName()));
|
||||
|
||||
_active.add(player.getUniqueId());
|
||||
customStart(player);
|
||||
}
|
||||
|
||||
protected abstract void customStart(Player player);
|
||||
|
||||
protected abstract void customFinish(Player player);
|
||||
|
||||
protected void finish(Player player)
|
||||
{
|
||||
if (_active.contains(player.getUniqueId()))
|
||||
{
|
||||
System.out.println(String.format("Tutorial> [%s] finished objective goal [%s]", player.getName(), getName()));
|
||||
|
||||
_active.remove(player.getUniqueId());
|
||||
customFinish(player);
|
||||
|
||||
_objective.completeGoal(this, player);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package mineplex.core.common.objective;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface ObjectiveListener
|
||||
{
|
||||
public void onObjectiveStart(Player player, Objective objective);
|
||||
|
||||
public void onObjectiveFinish(Player player, Objective objective);
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package mineplex.core.common.objective;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public abstract class OrderedObjective extends Objective<OrderedObjectiveData>
|
||||
{
|
||||
private List<ObjectiveGoal> _goals;
|
||||
|
||||
public OrderedObjective(JavaPlugin plugin, String name, String description)
|
||||
{
|
||||
super(plugin, name, description);
|
||||
|
||||
_goals = new ArrayList<>();
|
||||
}
|
||||
|
||||
protected void addGoal(ObjectiveGoal goal)
|
||||
{
|
||||
_goals.add(goal);
|
||||
|
||||
getPlugin().getServer().getPluginManager().registerEvents(goal, getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OrderedObjectiveData createDataObject(Player player)
|
||||
{
|
||||
return new OrderedObjectiveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void completeGoal(ObjectiveGoal goal, Player player)
|
||||
{
|
||||
int index = _goals.indexOf(goal);
|
||||
|
||||
OrderedObjectiveData data = getData(player);
|
||||
assert index == data.getIndex();
|
||||
|
||||
if (data.getIndex() + 1 >= _goals.size())
|
||||
{
|
||||
finish(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGoal(player, data.getIndex() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
setGoal(player, 0);
|
||||
}
|
||||
|
||||
private void setGoal(Player player, int index)
|
||||
{
|
||||
OrderedObjectiveData data = getData(player); // Should never be null!
|
||||
ObjectiveGoal nextGoal = _goals.get(index);
|
||||
data.setIndex(index);
|
||||
nextGoal.start(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ObjectiveGoal> getGoals()
|
||||
{
|
||||
return _goals;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package mineplex.core.common.objective;
|
||||
|
||||
public class OrderedObjectiveData extends ObjectiveData
|
||||
{
|
||||
private int _index;
|
||||
|
||||
public OrderedObjectiveData()
|
||||
{
|
||||
_index = 0;
|
||||
}
|
||||
|
||||
public int getIndex()
|
||||
{
|
||||
return _index;
|
||||
}
|
||||
|
||||
public void setIndex(int index)
|
||||
{
|
||||
_index = index;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package mineplex.core.common.objective;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public abstract class SingleObjective extends Objective<ObjectiveData>
|
||||
{
|
||||
private final ObjectiveData _nullData;
|
||||
|
||||
public SingleObjective(JavaPlugin plugin, String name, String description)
|
||||
{
|
||||
super(plugin, name, description);
|
||||
|
||||
_nullData = new ObjectiveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ObjectiveData createDataObject(Player player)
|
||||
{
|
||||
return _nullData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void completeGoal(ObjectiveGoal goal, Player player)
|
||||
{
|
||||
// Do Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ObjectiveGoal> getGoals()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -112,8 +112,9 @@ import mineplex.game.clans.gameplay.Gameplay;
|
||||
import mineplex.game.clans.gameplay.safelog.SafeLog;
|
||||
import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
|
||||
import mineplex.game.clans.items.GearManager;
|
||||
import mineplex.game.clans.legacytutorial.Tutorial;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
import mineplex.game.clans.tutorials.TutorialManager;
|
||||
import mineplex.game.clans.tutorial.TutorialManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
|
||||
@ -167,7 +168,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
private Playtime _playTracker;
|
||||
|
||||
private TutorialManager _tutorialManager;
|
||||
private mineplex.game.clans.legacytutorial.TutorialManager _tutorialManager;
|
||||
|
||||
private ClassManager _classManager;
|
||||
|
||||
@ -316,10 +317,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
_playTracker = new Playtime(this, statsManager);
|
||||
new PvpTimer(this, _playTracker, statsManager);
|
||||
|
||||
_tutorialManager = new TutorialManager(plugin, _playTracker, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler);
|
||||
|
||||
_scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, clientManager, donationManager);
|
||||
|
||||
_tutorialManager = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler);
|
||||
TutorialManager tutorial = new TutorialManager(plugin, clientManager, donationManager);
|
||||
|
||||
_scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, tutorial, clientManager, donationManager);
|
||||
_clanDataAccess = new ClansDataAccessLayer(this, _scoreboard);
|
||||
|
||||
for (ClanToken token : _clanDataAccess.getRepository().retrieveClans())
|
||||
@ -420,7 +422,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
return _disguiseManager;
|
||||
}
|
||||
|
||||
public TutorialManager getTutorials()
|
||||
public mineplex.game.clans.legacytutorial.TutorialManager getTutorials()
|
||||
{
|
||||
return _tutorialManager;
|
||||
}
|
||||
@ -755,25 +757,25 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
public void handlePlayerChat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
// PunishClient punishclient = _punish.GetClient(event.getPlayer().getName());
|
||||
//
|
||||
//
|
||||
// if (punishclient != null && punishclient.IsMuted())
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (_chat.SilenceCheck(event.getPlayer()))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// MessageData lastMessage = _chat.lastMessage(event.getPlayer());
|
||||
// long chatSlowTime = 1000L * _chat.getChatSlow();
|
||||
// long timeDiff = System.currentTimeMillis() - lastMessage.getTimeSent();
|
||||
// if (timeDiff < chatSlowTime && !_clientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER))
|
||||
// {
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
ClientClan client = Get(event.getPlayer());
|
||||
@ -1168,14 +1170,14 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
_warPointEvasion.resetCooldown(uuid);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Pair<ClanInfo, Long> leftRecently(UUID uniqueId, long time)
|
||||
{
|
||||
if (_clanMemberLeftMap.containsKey(uniqueId) && (System.currentTimeMillis() - _clanMemberLeftMap.get(uniqueId).getRight()) <= time)
|
||||
{
|
||||
return Pair.create(_clanMemberLeftMap.get(uniqueId).getLeft(), time - (System.currentTimeMillis() - _clanMemberLeftMap.get(uniqueId).getRight()));
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -10,9 +10,9 @@ 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.tutorials.Tutorial;
|
||||
import mineplex.game.clans.tutorials.TutorialManager;
|
||||
import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted;
|
||||
import mineplex.game.clans.legacytutorial.Tutorial;
|
||||
import mineplex.game.clans.legacytutorial.TutorialManager;
|
||||
import mineplex.game.clans.legacytutorial.gettingstarted.TutorialGettingStarted;
|
||||
|
||||
public class RestartTutCommand extends CommandBase<TutorialManager>
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.OnlineRankUpdateEvent;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.scoreboard.PlayerScoreboard;
|
||||
import mineplex.core.scoreboard.ScoreboardData;
|
||||
@ -20,25 +19,25 @@ import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.scoreboard.elements.ScoreboardElementClan;
|
||||
import mineplex.game.clans.clans.scoreboard.elements.ScoreboardElementPlayer;
|
||||
import mineplex.game.clans.clans.scoreboard.elements.ScoreboardElementPlayerCount;
|
||||
import mineplex.game.clans.clans.war.WarManager;
|
||||
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
||||
import mineplex.game.clans.tutorials.Tutorial;
|
||||
import mineplex.game.clans.tutorials.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();
|
||||
}
|
||||
@ -55,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
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.tutorials;
|
||||
package mineplex.game.clans.legacytutorial;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
@ -1,9 +1,7 @@
|
||||
package mineplex.game.clans.tutorials;
|
||||
package mineplex.game.clans.legacytutorial;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.task.TaskManager;
|
||||
|
||||
public class TutorialClient
|
||||
{
|
||||
public Player Player;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.tutorials;
|
||||
package mineplex.game.clans.legacytutorial;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
@ -21,9 +21,8 @@ import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.commands.RestartTutCommand;
|
||||
import mineplex.game.clans.clans.playtime.Playtime;
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand;
|
||||
import mineplex.game.clans.tutorials.commands.SkipTutorialCommand;
|
||||
import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted;
|
||||
import mineplex.game.clans.legacytutorial.commands.DoSkipTutorialCommand;
|
||||
import mineplex.game.clans.legacytutorial.commands.SkipTutorialCommand;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
||||
|
@ -1,11 +1,10 @@
|
||||
package mineplex.game.clans.tutorials;
|
||||
package mineplex.game.clans.legacytutorial;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import mineplex.core.common.util.C;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.tutorials.commands;
|
||||
package mineplex.game.clans.legacytutorial.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -6,7 +6,7 @@ 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.tutorials.TutorialManager;
|
||||
import mineplex.game.clans.legacytutorial.TutorialManager;
|
||||
|
||||
public class DoSkipTutorialCommand extends CommandBase<TutorialManager>
|
||||
{
|
@ -1,12 +1,11 @@
|
||||
package mineplex.game.clans.tutorials.commands;
|
||||
package mineplex.game.clans.legacytutorial.commands;
|
||||
|
||||
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.tutorials.TutorialManager;
|
||||
import mineplex.game.clans.legacytutorial.TutorialManager;
|
||||
|
||||
public class SkipTutorialCommand extends CommandBase<TutorialManager>
|
||||
{
|
@ -1,12 +1,11 @@
|
||||
package mineplex.game.clans.tutorials.gettingstarted;
|
||||
package mineplex.game.clans.legacytutorial.gettingstarted;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
|
||||
import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent;
|
||||
import mineplex.game.clans.tutorials.TutorialTask;
|
||||
import mineplex.game.clans.legacytutorial.TutorialTask;
|
||||
|
||||
public class TaskClaim extends TutorialTask<TutorialGettingStarted>
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.tutorials.gettingstarted;
|
||||
package mineplex.game.clans.legacytutorial.gettingstarted;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -6,7 +6,7 @@ import org.bukkit.event.EventPriority;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.event.ClanCreatedEvent;
|
||||
import mineplex.game.clans.tutorials.TutorialTask;
|
||||
import mineplex.game.clans.legacytutorial.TutorialTask;
|
||||
|
||||
public class TaskCreateClan extends TutorialTask<TutorialGettingStarted>
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.tutorials.gettingstarted;
|
||||
package mineplex.game.clans.legacytutorial.gettingstarted;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@ -12,7 +12,7 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
import mineplex.game.clans.tutorials.TutorialTask;
|
||||
import mineplex.game.clans.legacytutorial.TutorialTask;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
|
||||
public class TaskCustomizeClass extends TutorialTask<TutorialGettingStarted>
|
@ -1,11 +1,10 @@
|
||||
package mineplex.game.clans.tutorials.gettingstarted;
|
||||
package mineplex.game.clans.legacytutorial.gettingstarted;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
|
||||
import mineplex.game.clans.tutorials.TutorialTask;
|
||||
import mineplex.game.clans.legacytutorial.TutorialTask;
|
||||
|
||||
public class TaskDisbandClan extends TutorialTask<TutorialGettingStarted>
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.tutorials.gettingstarted;
|
||||
package mineplex.game.clans.legacytutorial.gettingstarted;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -13,7 +13,7 @@ import mineplex.core.task.TaskManager;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
|
||||
import mineplex.game.clans.clans.event.ClansShopAddButtonEvent;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
import mineplex.game.clans.tutorials.TutorialTask;
|
||||
import mineplex.game.clans.legacytutorial.TutorialTask;
|
||||
import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent;
|
||||
|
||||
public class TaskEquipClass extends TutorialTask<TutorialGettingStarted>
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.tutorials.gettingstarted;
|
||||
package mineplex.game.clans.legacytutorial.gettingstarted;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@ -12,7 +12,7 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.EnergyPageBuildEvent;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
import mineplex.game.clans.tutorials.TutorialTask;
|
||||
import mineplex.game.clans.legacytutorial.TutorialTask;
|
||||
|
||||
public class TaskExploreShops extends TutorialTask<TutorialGettingStarted>
|
||||
{
|
@ -1,16 +1,14 @@
|
||||
package mineplex.game.clans.tutorials.gettingstarted;
|
||||
package mineplex.game.clans.legacytutorial.gettingstarted;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.tutorials.TutorialTask;
|
||||
import mineplex.game.clans.legacytutorial.TutorialTask;
|
||||
|
||||
public class TaskLeaveSpawn extends TutorialTask<TutorialGettingStarted>
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.tutorials.gettingstarted;
|
||||
package mineplex.game.clans.legacytutorial.gettingstarted;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -7,10 +7,9 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
import mineplex.game.clans.tutorials.TutorialTask;
|
||||
import mineplex.game.clans.legacytutorial.TutorialTask;
|
||||
|
||||
public class TaskMakingMoney extends TutorialTask<TutorialGettingStarted>
|
||||
{
|
@ -1,11 +1,11 @@
|
||||
package mineplex.game.clans.tutorials.gettingstarted;
|
||||
package mineplex.game.clans.legacytutorial.gettingstarted;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
|
||||
import mineplex.game.clans.tutorials.TutorialTask;
|
||||
import mineplex.game.clans.legacytutorial.TutorialTask;
|
||||
|
||||
public class TaskSetHome extends TutorialTask<TutorialGettingStarted>
|
||||
{
|
@ -1,8 +1,6 @@
|
||||
package mineplex.game.clans.tutorials.gettingstarted;
|
||||
package mineplex.game.clans.legacytutorial.gettingstarted;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -10,25 +8,20 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.CraftingInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautArrayList;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
|
||||
import mineplex.game.clans.clans.event.ClansShopAddButtonEvent;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
import mineplex.game.clans.tutorials.TutorialTask;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.game.clans.legacytutorial.TutorialTask;
|
||||
|
||||
public class TaskUseAbility extends TutorialTask<TutorialGettingStarted>
|
||||
{
|
@ -1,10 +1,10 @@
|
||||
package mineplex.game.clans.tutorials.gettingstarted;
|
||||
package mineplex.game.clans.legacytutorial.gettingstarted;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
|
||||
import mineplex.game.clans.tutorials.TutorialTask;
|
||||
import mineplex.game.clans.legacytutorial.TutorialTask;
|
||||
|
||||
public class TaskViewClanDetails extends TutorialTask<TutorialGettingStarted>
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
package mineplex.game.clans.tutorials.gettingstarted;
|
||||
package mineplex.game.clans.legacytutorial.gettingstarted;
|
||||
|
||||
import mineplex.game.clans.tutorials.TutorialTask;
|
||||
import mineplex.game.clans.legacytutorial.TutorialTask;
|
||||
|
||||
public class TaskWelcome extends TutorialTask<TutorialGettingStarted>
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.tutorials.gettingstarted;
|
||||
package mineplex.game.clans.legacytutorial.gettingstarted;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -15,8 +15,8 @@ import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.playtime.Playtime;
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
import mineplex.game.clans.tutorials.Tutorial;
|
||||
import mineplex.game.clans.tutorials.TutorialManager;
|
||||
import mineplex.game.clans.legacytutorial.Tutorial;
|
||||
import mineplex.game.clans.legacytutorial.TutorialManager;
|
||||
|
||||
public class TutorialGettingStarted extends Tutorial
|
||||
{
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,162 @@
|
||||
package mineplex.game.clans.tutorial;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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;
|
||||
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;
|
||||
|
||||
// GUI Data
|
||||
private Material _guiMaterial;
|
||||
private byte _guiData;
|
||||
|
||||
private List<Objective> _objectives;
|
||||
|
||||
public Tutorial(JavaPlugin plugin, ClansMessageManager message, String name, String taskIdentifier, Material guiMaterial, byte data)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_message = message;
|
||||
_name = name;
|
||||
_taskIdentifier = taskIdentifier;
|
||||
|
||||
_guiMaterial = guiMaterial;
|
||||
_guiData = data;
|
||||
|
||||
_playerSessionMap = new HashMap<>();
|
||||
_objectives = new ArrayList<>();
|
||||
}
|
||||
|
||||
protected void addObjective(Objective objective)
|
||||
{
|
||||
_objectives.add(objective);
|
||||
objective.addListener(this);
|
||||
}
|
||||
|
||||
public void start(Player player)
|
||||
{
|
||||
System.out.println(String.format("Tutorial> [%s] started tutorial [%s]", player.getName(), getName()));
|
||||
_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)
|
||||
{
|
||||
return _playerSessionMap.containsKey(player);
|
||||
}
|
||||
|
||||
public JavaPlugin getPlugin()
|
||||
{
|
||||
return _plugin;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public Material getGuiMaterial()
|
||||
{
|
||||
return _guiMaterial;
|
||||
}
|
||||
|
||||
public byte getGuiData()
|
||||
{
|
||||
return _guiData;
|
||||
}
|
||||
|
||||
public final String getTaskIdentifier()
|
||||
{
|
||||
return "clans.tutorial." + _taskIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onObjectiveFinish(Player player, Objective objective)
|
||||
{
|
||||
int index = _objectives.indexOf(objective);
|
||||
|
||||
assert index != -1;
|
||||
|
||||
if (index + 1 >= _objectives.size())
|
||||
{
|
||||
finish(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
setObjective(player, index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
_playerSessionMap.remove(player);
|
||||
|
||||
System.out.println(String.format("Tutorial> [%s] finished tutorial [%s]", player.getName(), getName()));
|
||||
|
||||
onFinish();
|
||||
}
|
||||
|
||||
protected abstract void onFinish();
|
||||
|
||||
public void unregisterAll()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
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;
|
||||
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 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
|
||||
|
||||
public TutorialManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super("Clans Tutorial", plugin);
|
||||
|
||||
_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, _clansMessageManager));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new TutorialCommand(this));
|
||||
}
|
||||
|
||||
private void addTutorial(TutorialType type, Tutorial tutorial)
|
||||
{
|
||||
if (_tutorialMap.containsKey(type))
|
||||
{
|
||||
_tutorialMap.remove(type).unregisterAll();
|
||||
}
|
||||
|
||||
_tutorialMap.put(type, tutorial);
|
||||
_shopMap.put(type, new TutorialShop(this, _clientManager, _donationManager, tutorial));
|
||||
getPlugin().getServer().getPluginManager().registerEvents(tutorial, getPlugin());
|
||||
}
|
||||
|
||||
public boolean inTutorial(Player player)
|
||||
{
|
||||
return getTutorial(player) != null;
|
||||
}
|
||||
|
||||
public Tutorial getTutorial(Player player)
|
||||
{
|
||||
for (Tutorial tutorial : _tutorialMap.values())
|
||||
{
|
||||
if (tutorial.isInTutorial(player))
|
||||
return tutorial;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package mineplex.game.clans.tutorial;
|
||||
|
||||
public class TutorialSession
|
||||
{
|
||||
private int _objectiveIndex;
|
||||
|
||||
public TutorialSession()
|
||||
{
|
||||
}
|
||||
|
||||
public int getObjectiveIndex()
|
||||
{
|
||||
return _objectiveIndex;
|
||||
}
|
||||
|
||||
public void setObjectiveIndex(int objectiveIndex)
|
||||
{
|
||||
_objectiveIndex = objectiveIndex;
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package mineplex.game.clans.tutorial;
|
||||
|
||||
public enum TutorialType
|
||||
{
|
||||
COMBAT
|
||||
}
|
@ -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.openTutorialMenu(caller, type);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Tutorial", "Invalid Tutorial: " + F.elem(args[0])));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
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");
|
||||
|
||||
AddCommand(new StartCommand(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void Help(Player caller, String[] args)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package mineplex.game.clans.tutorial.gui;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.tutorial.Tutorial;
|
||||
import mineplex.game.clans.tutorial.TutorialManager;
|
||||
import mineplex.game.clans.tutorial.gui.button.DeclineButton;
|
||||
import mineplex.game.clans.tutorial.gui.button.StartButton;
|
||||
|
||||
public class TutorialSelectPage extends ShopPageBase<TutorialManager, TutorialShop>
|
||||
{
|
||||
public TutorialSelectPage(TutorialManager plugin, TutorialShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, shop.getTutorial().getName(), player, 45);
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
Tutorial tutorial = getShop().getTutorial();
|
||||
|
||||
String name = tutorial.getName();
|
||||
Material material = tutorial.getGuiMaterial();
|
||||
byte data = tutorial.getGuiData();
|
||||
|
||||
ShopItem infoItem = new ShopItem(material, data, name, new String[0], 0, false, false);
|
||||
addItem(13, infoItem);
|
||||
|
||||
ShopItem startItem = new ShopItem(Material.EMERALD_BLOCK, "Start " + tutorial.getName(), new String[0], 0, false, false);
|
||||
addButton(27 + 6, startItem, new StartButton(tutorial));
|
||||
|
||||
ShopItem declineButton = new ShopItem(Material.REDSTONE_BLOCK, "Cancel", new String[0], 0, false, false);
|
||||
addButton(27 + 2, declineButton, new DeclineButton());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package mineplex.game.clans.tutorial.gui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.tutorial.Tutorial;
|
||||
import mineplex.game.clans.tutorial.TutorialManager;
|
||||
|
||||
public class TutorialShop extends ShopBase<TutorialManager>
|
||||
{
|
||||
private final Tutorial _tutorial;
|
||||
|
||||
public TutorialShop(TutorialManager plugin, CoreClientManager clientManager, DonationManager donationManager, Tutorial tutorial)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, tutorial.getName());
|
||||
|
||||
_tutorial = tutorial;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<TutorialManager, ? extends ShopBase<TutorialManager>> buildPagesFor(Player player)
|
||||
{
|
||||
return new TutorialSelectPage(getPlugin(), this, getClientManager(), getDonationManager(), player);
|
||||
}
|
||||
|
||||
public Tutorial getTutorial()
|
||||
{
|
||||
return _tutorial;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package mineplex.game.clans.tutorial.gui.button;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.shop.item.IButton;
|
||||
|
||||
public class DeclineButton implements IButton
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
player.closeInventory();
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package mineplex.game.clans.tutorial.gui.button;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.game.clans.tutorial.Tutorial;
|
||||
|
||||
public class StartButton implements IButton
|
||||
{
|
||||
private final Tutorial _tutorial;
|
||||
|
||||
public StartButton(Tutorial tutorial)
|
||||
{
|
||||
_tutorial = tutorial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (!_tutorial.isInTutorial(player))
|
||||
{
|
||||
_tutorial.start(player);
|
||||
}
|
||||
|
||||
player.closeInventory();
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.combat;
|
||||
|
||||
import org.bukkit.Material;
|
||||
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, ClansMessageManager message)
|
||||
{
|
||||
super(plugin, message, "Combat Tutorial", "combat", Material.DIAMOND_SWORD, (byte) 0);
|
||||
|
||||
addObjective(new EquipArmorObjective(plugin));
|
||||
addObjective(new CustomizeKitObjective(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinish()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.combat.objectives;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.objective.OrderedObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.combat.objectives.goals.OpenCustomizationGoal;
|
||||
|
||||
public class CustomizeKitObjective extends OrderedObjective
|
||||
{
|
||||
public CustomizeKitObjective(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "Customize Kit", "Customize your kit");
|
||||
|
||||
addGoal(new OpenCustomizationGoal(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
super.customStart(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customLeave(Player player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customFinish(Player player)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.combat.objectives;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.objective.SingleObjective;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class EquipArmorObjective extends SingleObjective
|
||||
{
|
||||
public EquipArmorObjective(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "Equip Armor", "Equip Armor");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
player.getInventory().addItem(new ItemStack(Material.IRON_HELMET));
|
||||
player.getInventory().addItem(new ItemStack(Material.IRON_CHESTPLATE));
|
||||
player.getInventory().addItem(new ItemStack(Material.IRON_LEGGINGS));
|
||||
player.getInventory().addItem(new ItemStack(Material.IRON_BOOTS));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customLeave(Player player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customFinish(Player player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void checkArmor(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
for (UUID uuid : getActive())
|
||||
{
|
||||
Player player = UtilPlayer.searchExact(uuid);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
System.out.println("Tutorial Error: " + getName() + " has UUID with null player: " + uuid);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isEquipped(player))
|
||||
finish(player);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEquipped(Player player)
|
||||
{
|
||||
boolean equipped = true;
|
||||
|
||||
if (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() != Material.IRON_HELMET ||
|
||||
player.getInventory().getChestplate() == null || player.getInventory().getChestplate().getType() != Material.IRON_CHESTPLATE ||
|
||||
player.getInventory().getLeggings() == null || player.getInventory().getLeggings().getType() != Material.IRON_LEGGINGS ||
|
||||
player.getInventory().getBoots() == null || player.getInventory().getBoots().getType() != Material.IRON_BOOTS)
|
||||
equipped = false;
|
||||
|
||||
return equipped;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.combat.objectives.goals;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.objective.Objective;
|
||||
import mineplex.core.common.objective.ObjectiveGoal;
|
||||
import mineplex.minecraft.game.classcombat.shop.event.OpenClassShopEvent;
|
||||
|
||||
public class OpenCustomizationGoal extends ObjectiveGoal
|
||||
{
|
||||
public OpenCustomizationGoal(Objective objective)
|
||||
{
|
||||
super(objective, "Open Customization", "Open Customization");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customFinish(Player player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onOpenClassShop(OpenClassShopEvent event)
|
||||
{
|
||||
if (contains(event.getPlayer()))
|
||||
{
|
||||
finish(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package mineplex.minecraft.game.classcombat.shop;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
@ -19,6 +20,7 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
|
||||
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
|
||||
import mineplex.minecraft.game.classcombat.shop.event.OpenClassShopEvent;
|
||||
import mineplex.minecraft.game.classcombat.shop.page.CustomBuildPage;
|
||||
|
||||
public class ClassCombatShop extends ShopBase<ClassShopManager>
|
||||
@ -47,7 +49,10 @@ public class ClassCombatShop extends ShopBase<ClassShopManager>
|
||||
}
|
||||
|
||||
protected void openShopForPlayer(Player player)
|
||||
{
|
||||
{
|
||||
OpenClassShopEvent event = new OpenClassShopEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (_gameClass != null)
|
||||
getPlugin().GetClassManager().Get(player).SetGameClass(_gameClass);
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
package mineplex.minecraft.game.classcombat.shop.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
public class OpenClassShopEvent extends PlayerEvent
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
public static HandlerList getHandlerList() { return handlers; }
|
||||
public HandlerList getHandlers() { return handlers; }
|
||||
|
||||
public OpenClassShopEvent(Player who)
|
||||
{
|
||||
super(who);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user