diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/MaterialData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/MaterialData.java new file mode 100644 index 000000000..cf8210198 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/MaterialData.java @@ -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; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/Objective.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/Objective.java new file mode 100644 index 000000000..262c26513 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/Objective.java @@ -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 implements Listener +{ + private JavaPlugin _plugin; + private String _name; + private String _description; + + private HashMap _active; + private List _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 null + */ + protected abstract List 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 getActive() + { + return new LinkedList(_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 goals = getGoals(); + if (goals != null) goals.forEach(HandlerList::unregisterAll); + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/ObjectiveData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/ObjectiveData.java new file mode 100644 index 000000000..35a9d72f9 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/ObjectiveData.java @@ -0,0 +1,5 @@ +package mineplex.core.common.objective; + +public class ObjectiveData +{ +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/ObjectiveGoal.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/ObjectiveGoal.java new file mode 100644 index 000000000..230c73235 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/ObjectiveGoal.java @@ -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 _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); + + } + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/ObjectiveListener.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/ObjectiveListener.java new file mode 100644 index 000000000..3e528a73c --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/ObjectiveListener.java @@ -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); +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/OrderedObjective.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/OrderedObjective.java new file mode 100644 index 000000000..407eb7f6d --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/OrderedObjective.java @@ -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 +{ + private List _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 getGoals() + { + return _goals; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/OrderedObjectiveData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/OrderedObjectiveData.java new file mode 100644 index 000000000..8626f7161 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/OrderedObjectiveData.java @@ -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; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/SingleObjective.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/SingleObjective.java new file mode 100644 index 000000000..0de525913 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/objective/SingleObjective.java @@ -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 +{ + 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 getGoals() + { + return null; + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/EnclosedObject.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/EnclosedObject.java index d985c1b13..37038f8ca 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/EnclosedObject.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/EnclosedObject.java @@ -6,7 +6,7 @@ public class EnclosedObject public EnclosedObject() { - this(null); + this((T) null); } public EnclosedObject(T t) @@ -23,4 +23,90 @@ public class EnclosedObject { return _value = value; } + + public String toString() + { + return _value.toString(); + } + + // Arithmetic operations, will only work if T is an instance of Number + public long Add(Number number) + { + if (!(_value instanceof Number)) + { + throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); + } + + return ((Number) _value).longValue() + number.longValue(); + } + + public long Subtract(Number number) + { + if (!(_value instanceof Number)) + { + throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); + } + + return ((Number) _value).longValue() - number.longValue(); + } + + public long Multiply(Number number) + { + if (!(_value instanceof Number)) + { + throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); + } + + return ((Number) _value).longValue() * number.longValue(); + } + + public long Divide(Number number) + { + if (!(_value instanceof Number)) + { + throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); + } + + return ((Number) _value).longValue() / number.longValue(); + } + + public double PreciseAdd(Number number) + { + if (!(_value instanceof Number)) + { + throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); + } + + return ((Number) _value).doubleValue() + number.doubleValue(); + } + + public double PreciseSubtract(Number number) + { + if (!(_value instanceof Number)) + { + throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); + } + + return ((Number) _value).doubleValue() - number.doubleValue(); + } + + public double PreciseMultiply(Number number) + { + if (!(_value instanceof Number)) + { + throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); + } + + return ((Number) _value).doubleValue() * number.doubleValue(); + } + + public double PreciseDivide(Number number) + { + if (!(_value instanceof Number)) + { + throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); + } + + return ((Number) _value).doubleValue() / number.doubleValue(); + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java index 5e4c2bbec..baf55b536 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java @@ -113,7 +113,7 @@ public class UtilServer return getServer().getPluginManager(); } - public static T callEvent(T event) + public static void callEvent(T event) { getPluginManager().callEvent(event); return event; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java index 44f2086be..5e76bf104 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java @@ -87,7 +87,8 @@ public class PacketHandler extends MiniPlugin return _playerVerifierMap.get(player); } - public void addPacketHandler(IPacketHandler packetHandler, Class... packetsToListen) + @SafeVarargs + public final void addPacketHandler(IPacketHandler packetHandler, Class... packetsToListen) { if (packetsToListen.length == 0) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/vanish/Vanish.java b/Plugins/Mineplex.Core/src/mineplex/core/vanish/Vanish.java index 54df46561..e5464178a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/vanish/Vanish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/vanish/Vanish.java @@ -1,27 +1,31 @@ package mineplex.core.vanish; -import java.sql.ResultSet; -import java.sql.SQLException; - import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.AsyncPlayerPreLoginEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.account.event.ClientWebResponseEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.packethandler.PacketHandler; import mineplex.core.vanish.commands.VanishCommand; import mineplex.core.vanish.events.PreVanishEvent; import mineplex.core.vanish.repository.VanishClient; import mineplex.core.vanish.repository.VanishRepository; +import net.md_5.bungee.api.ChatColor; +import net.minecraft.server.v1_8_R3.PacketPlayOutChat; public class Vanish extends MiniClientPlugin { private CoreClientManager _clientManager; private VanishRepository _repository; - public Vanish(JavaPlugin plugin, CoreClientManager clientManager) + public Vanish(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler) { super("Vanish", plugin); @@ -44,18 +48,35 @@ public class Vanish extends MiniClientPlugin if (event.isCancelled()) { - return; + return false; } Get(caller).State = enabled; return enabled; } - - @EventHandler - public void ClientLoad(ClientWebResponseEvent event) + + @EventHandler(priority = EventPriority.LOWEST) + public void ClientLoad(AsyncPlayerPreLoginEvent event) { - Get(event.get + _clientManager.getRepository().getAccountId(event.getUniqueId(), accountId -> { + Get(event.getName()).State = _repository.getStatus(accountId.intValue()); + }); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void ClientLoad(PlayerJoinEvent event) + { + if (Get(event.getPlayer()).State) + { + event.setJoinMessage(null); + informVanished(event.getPlayer()); + } + } + + private void informVanished(Player player) + { + UtilPlayer.message(player, C.cGold + ""); } public String getQuery(int accountId, String uuid, String name) @@ -63,15 +84,8 @@ public class Vanish extends MiniClientPlugin return "CREATE TABLE IF NOT EXISTS incognitoStaff (accountId INT NOT NULL, enabled TINYINT(1) NOT NULL, enabledTime BIGINT)"; } - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException - { - int accountId = resultSet.getInt("accountId"); - boolean enabled = resultSet.getBoolean("enabled"); - } - protected VanishClient AddPlayer(String player) { return new VanishClient(); } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/vanish/repository/VanishRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/vanish/repository/VanishRepository.java index 1d3cf0239..cf6270297 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/vanish/repository/VanishRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/vanish/repository/VanishRepository.java @@ -38,7 +38,7 @@ public class VanishRepository extends MinecraftRepository status.Set(Boolean.FALSE); }, new ColumnInt("accountId", accountId)); - return status.GetDispose().booleanValue(); + return status.Get().booleanValue(); } protected void initialize() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 33896b83b..705380b21 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -82,9 +82,9 @@ import mineplex.game.clans.clans.commands.RegionsCommand; import mineplex.game.clans.clans.data.PlayerClan; import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.gui.ClanShop; -import mineplex.game.clans.clans.invsee.Invsee; import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.map.ItemMapManager; +import mineplex.game.clans.clans.nether.NetherManager; import mineplex.game.clans.clans.observer.ObserverManager; import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.potato.PotatoManager; @@ -111,8 +111,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; @@ -162,11 +163,12 @@ public class ClansManager extends MiniClientPluginimplements IRelati private GearManager _gearManager; private LootManager _lootManager; private DonationManager _donationManager; -// private NetherManager _netherManager; - + private NetherManager _netherManager; + private DamageManager _damageManager; + private Playtime _playTracker; - private TutorialManager _tutorialManager; + private mineplex.game.clans.legacytutorial.TutorialManager _tutorialManager; private ClassManager _classManager; @@ -206,8 +208,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati private NautHashMap _claimMap = new NautHashMap(); private NautHashMap _unclaimMap = new NautHashMap(); - private DamageManager _damageManager; - public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator; public ClanTips ClanTips; @@ -259,9 +259,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _itemMapManager = new ItemMapManager(this, _worldEvent); new TntGeneratorManager(plugin, this); new SupplyDropManager(plugin, this); - - new Invsee(this); - + _explosion = new Explosion(plugin, blockRestore); _warPointEvasion = new WarPointEvasion(plugin); @@ -282,6 +280,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _observerManager = new ObserverManager(plugin, _condition, this); new ClanEnergyTracker(plugin, this); +// new StuckManager(this); // new ClansAlphaManager(this, taskManager); @@ -318,10 +317,11 @@ public class ClansManager extends MiniClientPluginimplements 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()) @@ -384,11 +384,11 @@ public class ClansManager extends MiniClientPluginimplements IRelati ); hologram.start(); } - + Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict"); - + new SiegeManager(this); -// _netherManager = new NetherManager(this); + _netherManager = new NetherManager(this); } @Override @@ -422,7 +422,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati return _disguiseManager; } - public TutorialManager getTutorials() + public mineplex.game.clans.legacytutorial.TutorialManager getTutorials() { return _tutorialManager; } @@ -600,7 +600,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati runSyncLater(() -> { player.getInventory().setHelmet(helmet); }, 20L); - } + } } @EventHandler @@ -652,19 +652,19 @@ public class ClansManager extends MiniClientPluginimplements IRelati public void commandPreProcess(PlayerCommandPreprocessEvent event) { String[] messages = { "ver", "version", "pl", "plugins"}; - + for (String message : messages) { if (!event.getMessage().equalsIgnoreCase("/" + message) && !event.getMessage().startsWith("/" + message + " ")) { continue; } - + UtilPlayer.message(event.getPlayer(), F.main("Clans", "Server is on version: " + F.elem(Clans.version()))); event.setCancelled(true); } } - + @EventHandler public void quit(PlayerQuitEvent event) { @@ -757,25 +757,25 @@ public class ClansManager extends MiniClientPluginimplements 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()); @@ -1061,12 +1061,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati public void onJoin(PlayerLoginEvent event) { Rank rank = _clientManager.Get(event.getPlayer()).GetRank(); - - if (_serverName.equals("GClans-1")) - { - return; - } - if (!event.getPlayer().isWhitelisted() && !rank.has(Rank.LEGEND)) { event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Clans is currently in Legend+ only Alpha!"); @@ -1176,30 +1170,32 @@ public class ClansManager extends MiniClientPluginimplements IRelati _warPointEvasion.resetCooldown(uuid); } - + public Pair 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; } - public ObserverManager getObserverManager() + + public ObserverManager getObserverManager() { return _observerManager; } - + + public int getServerId() { return _clanDataAccess.getRepository().getServerId(); } -// public NetherManager getNetherManager() -// { -// return _netherManager; -// } + public NetherManager getNetherManager() + { + return _netherManager; + } public void message(Player player, String message) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java index 287d3c1de..0e2449ea6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java @@ -6,14 +6,13 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; -import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.account.CoreClient; import mineplex.core.common.util.Callback; -import mineplex.core.common.util.NonFinalInteger; +import mineplex.core.common.util.EnclosedObject; +import mineplex.core.database.MinecraftRepository; import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.ResultSetCallable; import mineplex.serverdata.database.column.ColumnBoolean; import mineplex.serverdata.database.column.ColumnInt; @@ -127,7 +126,7 @@ public class ClansBanRepository extends MinecraftRepository public void processResultSet(ResultSet resultSet) throws SQLException { final List clients = new ArrayList<>(); - final NonFinalInteger resultsProcessed = new NonFinalInteger(); + final EnclosedObject resultsProcessed = new EnclosedObject<>(); int resultsFound = 0; while (resultSet.next()) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java index a37102d7b..86d794582 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java index 9f12d8a66..3794ba5fe 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java @@ -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 diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index 332ec8f47..15ddf2aa9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -27,9 +27,9 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.ColorFader; +import mineplex.core.common.util.EnclosedObject; import mineplex.core.common.util.F; import mineplex.core.common.util.LoopIterator; -import mineplex.core.common.util.NonFinalInteger; import mineplex.core.common.util.RGBData; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; @@ -543,18 +543,18 @@ public class Outpost implements Listener { _state = OutpostState.DESTRUCTING; - NonFinalInteger wait = new NonFinalInteger(0); + EnclosedObject wait = new EnclosedObject<>(0); _blocks.values().stream().filter(block -> UtilMath.random.nextBoolean() && UtilMath.random.nextBoolean()).filter(block -> UtilMath.random.nextBoolean()).limit(13).forEach(block -> _outpostManager.runSyncLater(() -> { UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, block.getLocation(), new Vector(0,0,0), 1f, 1, ViewDist.MAX); _origin.getWorld().playSound(block.getLocation(), Sound.EXPLODE, 1.0f, 1.0f); - }, wait.add(4 + UtilMath.random.nextInt(4)).get()) + }, wait.Add(Integer.valueOf(4 + UtilMath.random.nextInt(4)))) ); _outpostManager.runSyncLater(() -> { _blocks.values().stream().forEach(OutpostBlock::restore); - }, wait.get() + 5L); + }, wait.Get().intValue() + 5L); _outpostManager.runSyncLater(() -> { _blocks.values().stream().forEach(block -> { @@ -578,7 +578,7 @@ public class Outpost implements Listener }); cleanup(); - }, wait.get() + 6L); + }, wait.Get().intValue() + 6L); if (_lifetimeLeft != null) _lifetimeLeft.stop(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/OutpostRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/OutpostRepository.java index 70ca881d0..4eb471c1c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/OutpostRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/OutpostRepository.java @@ -11,19 +11,19 @@ import com.google.common.collect.Lists; import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilWorld; +import mineplex.core.database.MinecraftRepository; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.siege.outpost.OutpostManager; import mineplex.game.clans.clans.siege.outpost.OutpostState; import mineplex.game.clans.clans.siege.outpost.OutpostType; import mineplex.game.clans.clans.siege.repository.tokens.OutpostToken; import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnByte; import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnTimestamp; import mineplex.serverdata.database.column.ColumnVarChar; -public class OutpostRepository extends RepositoryBase +public class OutpostRepository extends MinecraftRepository { private OutpostManager _manager; @@ -46,7 +46,7 @@ public class OutpostRepository extends RepositoryBase public OutpostRepository(JavaPlugin plugin, OutpostManager manager) { - super(DBPool.getAccount()); + super(plugin, DBPool.getAccount()); _manager = manager; } @@ -121,7 +121,7 @@ public class OutpostRepository extends RepositoryBase public void updateOutpost(OutpostToken token) { - executeUpdate(UPDATE_OUTPOST, + executeUpdate(UPDATE_OUTPOST, new ColumnByte("outpostState", Byte.valueOf(token.OutpostState.getId())), new ColumnInt("uniqueId", token.UniqueId)); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java index 84217c157..a7d0ab3cb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java @@ -11,16 +11,16 @@ import com.google.common.collect.Lists; import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilWorld; +import mineplex.core.database.MinecraftRepository; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnTimestamp; import mineplex.serverdata.database.column.ColumnVarChar; -public class SiegeWeaponRepository extends RepositoryBase +public class SiegeWeaponRepository extends MinecraftRepository { private SiegeManager _manager; @@ -44,7 +44,7 @@ public class SiegeWeaponRepository extends RepositoryBase public SiegeWeaponRepository(JavaPlugin plugin, SiegeManager manager) { - super(DBPool.getAccount()); + super(plugin, DBPool.getAccount()); _manager = manager; } @@ -116,7 +116,7 @@ public class SiegeWeaponRepository extends RepositoryBase public void updateWeapon(SiegeWeaponToken token) { - executeUpdate(UPDATE_WEAPON, + executeUpdate(UPDATE_WEAPON, new ColumnInt("health", token.Health), new ColumnInt("yaw", token.Yaw), new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)), diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java similarity index 99% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java index ac0f637e4..be8cf6cbe 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.tutorials; +package mineplex.game.clans.legacytutorial; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialClient.java similarity index 92% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialClient.java index ac44d52a1..a73f4fdd6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialClient.java @@ -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; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialManager.java similarity index 96% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialManager.java index 02bcc6899..36bfabcd3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialManager.java @@ -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; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialTask.java similarity index 98% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialTask.java index 6b4d2a332..929f5ea7d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialTask.java @@ -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; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/DoSkipTutorialCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/DoSkipTutorialCommand.java similarity index 85% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/DoSkipTutorialCommand.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/DoSkipTutorialCommand.java index 2d9025081..599a875c5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/DoSkipTutorialCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/DoSkipTutorialCommand.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/SkipTutorialCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/SkipTutorialCommand.java similarity index 80% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/SkipTutorialCommand.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/SkipTutorialCommand.java index 87caf4ce3..8fb7ca99f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/SkipTutorialCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/SkipTutorialCommand.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskClaim.java similarity index 87% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskClaim.java index 23edfed24..c0b966649 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskClaim.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCreateClan.java similarity index 91% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCreateClan.java index 26cb07f65..97cfa9ba2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCreateClan.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCustomizeClass.java similarity index 93% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCustomizeClass.java index 91f065320..c591dae4f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCustomizeClass.java @@ -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 diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskDisbandClan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskDisbandClan.java similarity index 86% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskDisbandClan.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskDisbandClan.java index a294434cb..8fbc07f2c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskDisbandClan.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskDisbandClan.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskEquipClass.java similarity index 96% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskEquipClass.java index 458e04bb4..a2896c445 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskEquipClass.java @@ -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 diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskExploreShops.java similarity index 95% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskExploreShops.java index d34c2129e..eb4b8cb6b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskExploreShops.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskLeaveSpawn.java similarity index 90% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskLeaveSpawn.java index 5f0f7926c..5a812ce65 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskLeaveSpawn.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskMakingMoney.java similarity index 92% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskMakingMoney.java index 6ff1d9b4e..7b33cd35a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskMakingMoney.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskSetHome.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskSetHome.java similarity index 90% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskSetHome.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskSetHome.java index ca14eaf8c..42a185e30 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskSetHome.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskSetHome.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskUseAbility.java similarity index 90% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskUseAbility.java index c94324660..6c180ae03 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskUseAbility.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskViewClanDetails.java similarity index 89% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskViewClanDetails.java index 9ece47104..d0af8ac05 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskViewClanDetails.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskWelcome.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskWelcome.java similarity index 84% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskWelcome.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskWelcome.java index 9b058b619..1100966bc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskWelcome.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskWelcome.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TutorialGettingStarted.java similarity index 95% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TutorialGettingStarted.java index 6e924c468..5ed4ea8e0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TutorialGettingStarted.java @@ -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 { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/message/ClansMessageManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/message/ClansMessageManager.java new file mode 100644 index 000000000..4fe380cee --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/message/ClansMessageManager.java @@ -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 _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); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/message/Message.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/message/Message.java new file mode 100644 index 000000000..56910d733 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/message/Message.java @@ -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; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/Tutorial.java new file mode 100644 index 000000000..6730a1a5a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/Tutorial.java @@ -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 _playerSessionMap; + + private JavaPlugin _plugin; + private ClansMessageManager _message; + private String _name; + private String _taskIdentifier; + + // GUI Data + private Material _guiMaterial; + private byte _guiData; + + private List _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 getScoreboardLines(Player player) + { + ArrayList 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; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java new file mode 100644 index 000000000..4a714b0ad --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java @@ -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 _tutorialMap; + private EnumMap _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.class); + _shopMap = new EnumMap(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 getLines(ScoreboardManager manager, Player player, List out) + { + Tutorial tutorial = getTutorial(player); + + if (tutorial != null) + { + out.clear(); + return tutorial.getScoreboardLines(player); + } + + return new ArrayList(0); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialSession.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialSession.java new file mode 100644 index 000000000..b14ff8577 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialSession.java @@ -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; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialType.java new file mode 100644 index 000000000..93d5b38fe --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialType.java @@ -0,0 +1,6 @@ +package mineplex.game.clans.tutorial; + +public enum TutorialType +{ + COMBAT +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/StartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/StartCommand.java new file mode 100644 index 000000000..d6d509a2c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/StartCommand.java @@ -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 +{ + 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 ")); + 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]))); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java new file mode 100644 index 000000000..68429b81f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java @@ -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 +{ + public TutorialCommand(TutorialManager plugin) + { + super(plugin, Rank.ADMIN, "tutorial", "tut"); + + AddCommand(new StartCommand(plugin)); + } + + @Override + protected void Help(Player caller, String[] args) + { + + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/gui/TutorialSelectPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/gui/TutorialSelectPage.java new file mode 100644 index 000000000..6265bd797 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/gui/TutorialSelectPage.java @@ -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 +{ + 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()); + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/gui/TutorialShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/gui/TutorialShop.java new file mode 100644 index 000000000..29a8c62f7 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/gui/TutorialShop.java @@ -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 +{ + 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> buildPagesFor(Player player) + { + return new TutorialSelectPage(getPlugin(), this, getClientManager(), getDonationManager(), player); + } + + public Tutorial getTutorial() + { + return _tutorial; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/gui/button/DeclineButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/gui/button/DeclineButton.java new file mode 100644 index 000000000..e1b283fae --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/gui/button/DeclineButton.java @@ -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(); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/gui/button/StartButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/gui/button/StartButton.java new file mode 100644 index 000000000..8461ea669 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/gui/button/StartButton.java @@ -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(); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/combat/CombatTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/combat/CombatTutorial.java new file mode 100644 index 000000000..90d157f75 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/combat/CombatTutorial.java @@ -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() + { + + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/combat/objectives/CustomizeKitObjective.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/combat/objectives/CustomizeKitObjective.java new file mode 100644 index 000000000..367129fc1 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/combat/objectives/CustomizeKitObjective.java @@ -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) + { + + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/combat/objectives/EquipArmorObjective.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/combat/objectives/EquipArmorObjective.java new file mode 100644 index 000000000..1a908a2cf --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/combat/objectives/EquipArmorObjective.java @@ -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; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/combat/objectives/goals/OpenCustomizationGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/combat/objectives/goals/OpenCustomizationGoal.java new file mode 100644 index 000000000..7e0b8476d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/combat/objectives/goals/OpenCustomizationGoal.java @@ -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()); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/visual/VisualManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/visual/VisualManager.java new file mode 100644 index 000000000..9fd96caf5 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/visual/VisualManager.java @@ -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) + { + + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java index 5696309d3..cab66ec23 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java @@ -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 @@ -47,7 +49,10 @@ public class ClassCombatShop extends ShopBase } protected void openShopForPlayer(Player player) - { + { + OpenClassShopEvent event = new OpenClassShopEvent(player); + Bukkit.getServer().getPluginManager().callEvent(event); + if (_gameClass != null) getPlugin().GetClassManager().Get(player).SetGameClass(_gameClass); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/event/OpenClassShopEvent.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/event/OpenClassShopEvent.java new file mode 100644 index 000000000..cd52d54e1 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/event/OpenClassShopEvent.java @@ -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); + } + +}