From a0ae500876b1f650b73c88cf45476cb1061b5f88 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sat, 28 Nov 2015 09:03:58 +0000 Subject: [PATCH 01/16] tutorial revamp [clans] --- .../src/mineplex/core/task/TaskManager.java | 4 + .../game/clans/clans/ClanEnergyTracker.java | 2 +- .../mineplex/game/clans/clans/ClanInfo.java | 2 +- .../{tutorials/types => clans}/ClanTips.java | 3 +- .../game/clans/clans/ClansManager.java | 3 +- .../clans/clans/commands/ClansCommand.java | 11 +- .../scoreboard/ClansPlayerScoreboard.java | 31 ++ .../game/clans/clans/war/WarManager.java | 2 +- .../game/clans/gameplay/safelog/SafeLog.java | 2 +- .../game/clans/shop/energy/EnergyPage.java | 18 +- .../clans/shop/energy/EnergyShopButton.java | 6 +- .../game/clans/tutorials/DeployedTask.java | 42 ++ .../game/clans/tutorials/Tutorial.java | 151 +++---- .../game/clans/tutorials/TutorialClient.java | 71 --- .../game/clans/tutorials/TutorialManager.java | 35 +- .../game/clans/tutorials/TutorialTask.java | 145 ++++++- .../tutorials/commands/TaskInfoCommand.java | 31 -- .../tutorials/gettingstarted/TaskClaim.java | 64 +++ .../gettingstarted/TaskCreateClan.java | 49 +++ .../gettingstarted/TaskCustomizeClass.java | 57 +++ .../gettingstarted/TaskDisbandClan.java | 48 +++ .../gettingstarted/TaskEquipClass.java | 110 +++++ .../gettingstarted/TaskExploreShops.java | 89 ++++ .../gettingstarted/TaskGoToWilderness.java | 66 +++ .../gettingstarted/TaskLeaveSpawn.java | 67 +++ .../gettingstarted/TaskMakingMoney.java | 61 +++ .../tutorials/gettingstarted/TaskSetHome.java | 60 +++ .../gettingstarted/TaskUseAbility.java | 106 +++++ .../gettingstarted/TaskViewClanDetails.java | 53 +++ .../tutorials/gettingstarted/TaskWelcome.java | 21 + .../TutorialGettingStarted.java | 76 ++++ .../types/TutorialGettingStarted.java | 404 ------------------ .../game/classcombat/Class/ClientClass.java | 13 +- .../game/classcombat/Class/PvpClass.java | 2 + .../Class/event/ClassEquipEvent.java | 57 +++ 35 files changed, 1310 insertions(+), 652 deletions(-) rename Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/{tutorials/types => clans}/ClanTips.java (98%) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/DeployedTask.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/TaskInfoCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskDisbandClan.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskGoToWilderness.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskSetHome.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskWelcome.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/TutorialGettingStarted.java create mode 100644 Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/event/ClassEquipEvent.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java index 03ebb5a82..3a9e8601f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java @@ -18,6 +18,8 @@ import org.bukkit.plugin.java.JavaPlugin; public class TaskManager extends MiniDbClientPlugin { + public static TaskManager Instance; + private static Object _taskLock = new Object(); private TaskRepository _repository; @@ -27,6 +29,8 @@ public class TaskManager extends MiniDbClientPlugin { super("Task Manager", plugin, clientManager); + Instance = this; + _repository = new TaskRepository(plugin); updateTasks(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java index 36aa20305..307768c84 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java @@ -12,7 +12,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.tutorials.types.ClanTips.TipType; +import mineplex.game.clans.clans.ClanTips.TipType; public class ClanEnergyTracker extends MiniPlugin { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java index 547c55e89..dc53b6069 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java @@ -670,7 +670,7 @@ public class ClanInfo public int getEnergyMax() { // 10080 = 7 days of minutes - return Math.max(4320, getEnergyCostPerMinute() * 60 * 24 * 3); + return Math.max(10080, getEnergyCostPerMinute() * 60 * 24 * 7); } public int getEnergyCostPerMinute() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/ClanTips.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java similarity index 98% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/ClanTips.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java index 5dee42973..8c0445947 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/ClanTips.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.tutorials.types; +package mineplex.game.clans.clans; import java.util.LinkedList; @@ -13,7 +13,6 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilPlayer; import mineplex.core.preferences.PreferencesManager; -import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; 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 4c602d40b..6547e40a2 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 @@ -64,6 +64,7 @@ import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.commands.ClanManagementCommand; import mineplex.game.clans.clans.commands.ClansAllyChatCommand; @@ -103,8 +104,6 @@ import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import mineplex.game.clans.items.GearManager; import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.tutorials.TutorialManager; -import mineplex.game.clans.tutorials.types.ClanTips; -import mineplex.game.clans.tutorials.types.ClanTips.TipType; import mineplex.minecraft.game.classcombat.Class.ClassManager; import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 5f2db85d7..0a389bbfc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -25,9 +25,9 @@ import mineplex.game.clans.clans.ClansBlacklist; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.clans.ClientClan; +import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.game.clans.tutorials.TutorialManager; -import mineplex.game.clans.tutorials.types.ClanTips.TipType; import net.minecraft.server.v1_8_R3.EnumDirection; public class ClansCommand extends CommandBase @@ -777,6 +777,15 @@ public class ClansCommand extends CommandBase { ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); + // Event + ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "homeset"); + UtilServer.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return; + } + if (clan == null) { UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java index 607d5ccad..21709202d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java @@ -1,6 +1,7 @@ package mineplex.game.clans.clans.scoreboard; import org.bukkit.Bukkit; +import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; @@ -73,6 +74,36 @@ public class ClansPlayerScoreboard extends PlayerScoreboard public void add(Scoreboard scoreboard, Player otherPlayer, ClanInfo clanInfo, ClanRelation relation, int ownScore) { + if (otherPlayer.getGameMode().equals(GameMode.CREATIVE)) + { + String teamName = getTeamName(clanInfo, relation, ownScore); + Team team = scoreboard.getTeam(teamName); + if (team == null) + { + team = scoreboard.registerNewTeam(teamName); + if (clanInfo != null) + team.setPrefix(relation.getColor(true) + clanInfo.getName() + relation.getColor(false) + " "); + else + team.setPrefix(relation.getColor(false).toString()); + } + + + Objective domObjective; + if ((domObjective = scoreboard.getObjective(DisplaySlot.BELOW_NAME)) == null) + { + domObjective = scoreboard.registerNewObjective("war", "dummy"); + domObjective.setDisplayName("War Points"); + domObjective.setDisplaySlot(DisplaySlot.BELOW_NAME); + } + + if (clanInfo != null) + domObjective.getScore(otherPlayer.getName()).setScore(ownScore); + + team.addPlayer(otherPlayer); + + return; + } + String teamName = getTeamName(clanInfo, relation, ownScore); Team team = scoreboard.getTeam(teamName); if (team == null) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index 8bdc45f71..cc017df55 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -27,13 +27,13 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility; +import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.war.command.WarPointsCommand; import mineplex.game.clans.clans.war.event.WarInvasionEndEvent; import mineplex.game.clans.clans.war.event.WarInvasionStartEvent; import mineplex.game.clans.core.war.ClanWarData; -import mineplex.game.clans.tutorials.types.ClanTips.TipType; public class WarManager extends MiniPlugin implements ScoreboardElement { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java index a5ddc39ff..9539a639e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java @@ -20,8 +20,8 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; -import mineplex.game.clans.tutorials.types.ClanTips.TipType; public class SafeLog extends MiniPlugin { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java index 6dce1b82b..49824ff51 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java @@ -8,12 +8,14 @@ import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; import mineplex.game.clans.clans.ClanEnergyManager; import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; public class EnergyPage extends ShopPageBase { @@ -68,12 +70,26 @@ public class EnergyPage extends ShopPageBase boolean locked = energyAmount > clanInfo.getEnergyPurchasable() || energyAmount == 0; String itemName = "Purchase " + energyAmount + " Energy"; + ClansShopAddButtonEvent event = new ClansShopAddButtonEvent(getPlayer(), getShop(), slot, material, getPlugin().convertEnergyToGold(energyAmount), 01, data, itemName, energyAmount); + UtilServer.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return; + } + + itemName = event.getDisplayName(); + int buyPrice = event.getBuyPrice(); + slot = event.getSlot(); + material = event.getMaterial(); + data = event.getData(); + ShopItem shopItem = new ShopItem(material, itemName, lore, 1, locked, false); if (locked) setItem(slot, shopItem); else - addButton(slot, shopItem, new EnergyShopButton(getPlugin(), this, energyAmount, clanInfo)); + addButton(slot, shopItem, new EnergyShopButton(getPlugin(), this, energyAmount, clanInfo, buyPrice)); } private void buildNoClan() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java index ad8a77725..cd548e9fe 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java @@ -24,13 +24,15 @@ public class EnergyShopButton implements IButton private EnergyPage _page; private int _energyToPurchase; private ClanInfo _clanInfo; + private int _cost; - public EnergyShopButton(ClanEnergyManager energyManager, EnergyPage page, int energyToPurchase, ClanInfo clanInfo) + public EnergyShopButton(ClanEnergyManager energyManager, EnergyPage page, int energyToPurchase, ClanInfo clanInfo, int cost) { _energyManager = energyManager; _clanInfo = clanInfo; _energyToPurchase = energyToPurchase; _page = page; + _cost = cost; } @Override @@ -56,7 +58,7 @@ public class EnergyShopButton implements IButton // Notify _energyManager.getClansManager().messageClan(_clanInfo, F.main("Energy", F.name(player.getName()) + " purchased " + F.elem(_energyToPurchase + " Energy") + " for the clan")); } - }, _page, new EnergyPackage(_energyToPurchase + " Energy", _energyManager.convertEnergyToGold(_energyToPurchase)), CurrencyType.Gold, player)); + }, _page, new EnergyPackage(_energyToPurchase + " Energy", _cost), CurrencyType.Gold, player)); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/DeployedTask.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/DeployedTask.java new file mode 100644 index 000000000..1d8807999 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/DeployedTask.java @@ -0,0 +1,42 @@ +package mineplex.game.clans.tutorials; + +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +public class DeployedTask implements Listener +{ + protected Player _player; + protected boolean _finished; + + protected TutorialTask _task; + + protected boolean _dead; + + public DeployedTask(Player player, TutorialTask task) + { + _player = player; + + _task = task; + } + + public void postDeploy() + { + } + + public void finish() + { + onFinish(); + _task.finishFor(_player); + } + + public void kill() + { + _dead = true; + _player = null; + } + + public void onFinish() { + + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java index a35a85e12..0b48bda07 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java @@ -2,6 +2,7 @@ package mineplex.game.clans.tutorials; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -46,9 +47,9 @@ import mineplex.game.clans.economy.GoldManager; */ public abstract class Tutorial implements ScoreboardElement, Listener { - public static String TASK_COMPLETE_TASK = "Tutorial%sDoneTask%s"; - public static String TUTORIAL_COMPLETE_TASK = "Tutorial%sFinito"; - public static String SKIPPED_TASK = "Tutorial%sSkipito"; + public static String TASK_COMPLETE_TASK = "tutori%sTask%s"; + public static String TUTORIAL_COMPLETE_TASK = "tutori%sDone"; + public static String SKIPPED_TASK = "tutori%sSkip"; protected final TutorialManager _manager; protected final GoldManager _goldManager; @@ -56,17 +57,17 @@ public abstract class Tutorial implements ScoreboardElement, Listener protected final TaskManager _taskManager; protected final DonationManager _donationManager; - private final Map _tasks; - private final Map _nameToTask; - protected final Map _inTutorial; + protected final LinkedHashMap> _tasks; + protected final LinkedHashMap> _nameToTask; + protected final LinkedHashMap _inTutorial; protected boolean _doScoreboard; protected boolean _ghostMode; protected boolean _startOnJoin; - protected String _uniqueId; - protected String _friendlyName; + protected String _technicalName; + protected String _displayName; protected int _goldReward = -1; protected int _gemReward = -1; @@ -79,9 +80,9 @@ public abstract class Tutorial implements ScoreboardElement, Listener _donationManager = donationManager; _taskManager = taskManager; _manager = manager; - _tasks = new HashMap<>(); - _inTutorial = new HashMap<>(); - _nameToTask = new HashMap<>(); + _tasks = new LinkedHashMap<>(); + _inTutorial = new LinkedHashMap<>(); + _nameToTask = new LinkedHashMap<>(); _manager.getPluginManager().registerEvents(this, _manager.getPlugin()); } @@ -91,78 +92,72 @@ public abstract class Tutorial implements ScoreboardElement, Listener { final List lines = new ArrayList<>(); - if (!isInTutorial(player) || !_doScoreboard) + if (!isInTutorial(player)) + { + return lines; + } + + if (!_doScoreboard) + { + return lines; + } + + if (get(player).CurrentTask == null) { return lines; } out.clear(); - final TutorialClient ptutorial = _inTutorial.get(player.getName()); + final TutorialClient client = _inTutorial.get(player.getName()); - lines.add(C.cAqua + _friendlyName + " Tutorial"); + lines.add(C.cAqua + _displayName + " Tutorial"); - for (final TutorialTask task : _tasks.values()) + for (final TutorialTask task : _tasks.values()) { - if (get(player).getCurrentTask() == task.getID()) + if (get(player).CurrentTask.equals(task)) { - lines.add(C.cDAqua + task.getID() + ". " + task.getFriendlyName()); + lines.add(C.cDAqua + task.getID() + ". " + task.getDisplayName()); } - else if (ptutorial.hasFinishedTask(task)) + else if (client.CurrentTask.getID() > task.getID()) { - lines.add(C.cGreen + task.getID() + ". " + task.getFriendlyName()); + lines.add(C.cGreen + task.getID() + ". " + task.getDisplayName()); } else { - lines.add(C.cRed + task.getID() + ". " + task.getFriendlyName()); + lines.add(C.cRed + task.getID() + ". " + task.getDisplayName()); } } lines.add(C.cYellow + "To skip, type: /skiptutorial"); -// lines.add(C.cYellow + "To get info, type: /taskinfo"); return lines; } - protected void addTask(final int id, final String name, final String description) + protected void addTask(TutorialTask task) { - addTask(id, name, description, null); + _tasks.put(_tasks.size() + 1, task); + _nameToTask.put(task.getTechnicalName(), task); } - protected void addTask(final int id, final String name, final String description, final String finishMessage) + protected boolean hasFinishedTask(Player player, TutorialTask task) { - _tasks.put(id, new TutorialTask(id, name, description, finishMessage)); - _nameToTask.put(name, _tasks.get(id)); + return get(player).CurrentTask.getID() < task.getID(); } - protected boolean hasFinishedTask(Player player, String taskName) + protected void finishTask(final Player player, final TutorialTask task) { - return hasFinishedTask(player, _nameToTask.get(taskName).getID()); - } - - protected boolean hasFinishedTask(Player player, int taskID) - { - return get(player).hasFinishedTask(_tasks.get(taskID)); - } - - protected void finishTask(final Player player, final int taskID) - { - final TutorialTask task = _tasks.get(taskID); - - String taskName = task.getFriendlyName(); - onFinishTask(player, taskName); + get(player).LastDescriptionSentTime = 0; + get(player).CurrentTask.visibleFinish(player); + get(player).CurrentTask = task.equals(_tasks.get(_tasks.size())) ? null : _tasks.get(task.getID() + 1); - _inTutorial.get(player.getName()).setTaskFinished(taskID); - - if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _uniqueId, task.getUniqueId()))) + if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName()))) { _taskManager.completedTask(new Callback() { public void run(final Boolean completed) { - UtilPlayer.message(player, F.main("Tutorials", "You have completed Task " + F.elem(taskID + ": " + task.getFriendlyName()) + ". " + (_tasks.size() - taskID) + " task" + (UtilText.plural(_tasks.size() - taskID) ? "s" : "") + " to go!")); - - if (taskID == _tasks.size()) + if (task.equals(_tasks.get(_tasks.size()))) { finishFor(player); } @@ -172,30 +167,21 @@ public abstract class Tutorial implements ScoreboardElement, Listener { public void run() { - _tasks.get(taskID + 1).sendDescriptionTo(player); + get(player).CurrentTask.deploy(player); } - }, 40L); + }, 10L); } + UtilPlayer.message(player, F.main("Tutorials", "You have completed Task " + F.elem(task.getID() + ": " + task.getDisplayName()) + ". " + (_tasks.size() - task.getID()) + " task" + (UtilText.plural(_tasks.size() - task.getID()) ? "s" : "") + " to go!")); player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); } - }, player, String.format(TASK_COMPLETE_TASK, _uniqueId, task.getUniqueId())); + }, player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())); } } - protected void finishTask(final Player player, final String taskName) + public TutorialTask getTask(final String technicalName) { - finishTask(player, _nameToTask.get(taskName).getID()); - } - - public TutorialTask getTask(final int taskID) - { - return _tasks.get(taskID); - } - - public TutorialTask getTask(final String name) - { - return _nameToTask.get(name); + return _nameToTask.get(technicalName); } @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @@ -239,9 +225,9 @@ public abstract class Tutorial implements ScoreboardElement, Listener _inTutorial.remove(player.getName()); UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, Color.LIME, false, false, new Vector(0, 0, 0), 1); - UtilPlayer.message(player, F.main("Tutorials", "You have completed the " + F.elem(_friendlyName + " Tutorial") + ".")); + UtilPlayer.message(player, F.main("Tutorials", "You have completed the " + F.elem(_displayName + " Tutorial") + ".")); onFinished(player); - if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _uniqueId))) + if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName))) { _taskManager.completedTask(new Callback() { @@ -294,7 +280,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener }, i * 10); } } - }, player, String.format(TUTORIAL_COMPLETE_TASK, _uniqueId)); + }, player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); } } @@ -303,11 +289,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener { } - // Implementation left to sub classes. - protected void onFinishTask(final Player player, String task) - { - } - // Implementation left to sub classes. protected void onBegin(final Player player) { @@ -320,7 +301,10 @@ public abstract class Tutorial implements ScoreboardElement, Listener _manager._playerTutorials.put(player.getName(), this); } - _inTutorial.put(player.getName(), TutorialClient.create(player, _taskManager, this)); + _inTutorial.put(player.getName(), new TutorialClient(player, this)); + + get(player).CurrentTask.deploy(player); + player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); if (_ghostMode) @@ -335,8 +319,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener onBegin(player); } - //_playerTutorials.remove(player.getName()); - public void cancelFor(final Player player) { _inTutorial.remove(player.getName()); @@ -361,19 +343,19 @@ public abstract class Tutorial implements ScoreboardElement, Listener return _inTutorial.containsKey(player); } - public Map getTasks() + public Map> getTasks() { return _tasks; } public boolean hasCompleted(final Player player) { - return _taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _uniqueId)); + return _taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); } public boolean hasSkipped(final Player player) { - return _taskManager.hasCompletedTask(player, String.format(SKIPPED_TASK, _uniqueId)); + return _taskManager.hasCompletedTask(player, String.format(SKIPPED_TASK, _technicalName)); } public void skip(final Player player) @@ -401,7 +383,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener .click(ClickEvent.RUN_COMMAND, "/yesiconfirmiwanttoskip") .sendToPlayer(player); - } public void doSkip(final Player player) @@ -412,12 +393,12 @@ public abstract class Tutorial implements ScoreboardElement, Listener { cancelFor(player); } - }, player, String.format(SKIPPED_TASK, _uniqueId)); + }, player, String.format(SKIPPED_TASK, _technicalName)); } - public String getUniqueId() + public String getTechnicalName() { - return _uniqueId; + return _technicalName; } public TutorialClient get(final Player player) @@ -428,7 +409,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener @EventHandler public void taskInfo(final UpdateEvent evt) { - if (evt.getType() != UpdateType.SEC_30) + if (evt.getType() != UpdateType.SEC) { return; } @@ -437,7 +418,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener { if (isInTutorial(player)) { - getTask(get(player).getCurrentTask()).sendDescriptionTo(player); + get(player).CurrentTask.trySendDescription(player); } } } @@ -459,5 +440,11 @@ public abstract class Tutorial implements ScoreboardElement, Listener }, 40L); } } + + public void cleanup(Player player) + { + get(player).CurrentTask.cleanup(player); + _inTutorial.remove(player.getName()); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java deleted file mode 100644 index 8a585c53f..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java +++ /dev/null @@ -1,71 +0,0 @@ -package mineplex.game.clans.tutorials; - -import org.bukkit.entity.Player; - -import mineplex.core.common.util.UtilServer; -import mineplex.core.task.TaskManager; - -public class TutorialClient -{ - private final Tutorial _tutorial; - private final Player _player; - - private int _currentTask = 1; - - public TutorialClient(final Player player, final Tutorial tutorial) - { - _player = player; - _tutorial = tutorial; - } - - public static TutorialClient create(final Player player, final TaskManager taskManager, final Tutorial tutorial) - { - final TutorialClient user = new TutorialClient(player, tutorial); - - for (final int i : tutorial.getTasks().keySet()) - { - if (taskManager.hasCompletedTask(player, String.format(Tutorial.TASK_COMPLETE_TASK, tutorial.getUniqueId(), tutorial.getTask(i).getUniqueId()))) - { - user._currentTask = i; - } - } - - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(tutorial._manager.getPlugin(), new Runnable() - { - public void run() - { - tutorial.getTask(user._currentTask).sendDescriptionTo(player); - } - }, 40); - - return user; - } - - public int getCurrentTask() - { - return _currentTask; - } - - public Tutorial getTutorial() - { - return _tutorial; - } - - public Player getPlayer() - { - return _player; - } - - public void setTaskFinished(final int taskID) - { - _currentTask = taskID + 1; - - _tutorial.getTask(taskID).onFinish(_player); - } - - public boolean hasFinishedTask(final TutorialTask task) - { - return task != null && task.getID() < _currentTask; - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java index 04c3c35f4..948ed4705 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java @@ -1,13 +1,11 @@ package mineplex.game.clans.tutorials; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; @@ -16,14 +14,11 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; import mineplex.core.preferences.PreferencesManager; import mineplex.core.task.TaskManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand; import mineplex.game.clans.tutorials.commands.SkipTutorialCommand; -import mineplex.game.clans.tutorials.commands.TaskInfoCommand; -import mineplex.game.clans.tutorials.types.TutorialGettingStarted; +import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted; public class TutorialManager extends MiniPlugin { @@ -49,7 +44,6 @@ public class TutorialManager extends MiniPlugin { addCommand(new SkipTutorialCommand(this)); addCommand(new DoSkipTutorialCommand(this)); - addCommand(new TaskInfoCommand(this)); } public boolean startTutorial(final Class tutorial, final Player player) @@ -83,7 +77,7 @@ public class TutorialManager extends MiniPlugin _playerTutorials.remove(player.getName()); - UtilPlayer.message(player, F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._friendlyName + " Tutorial") + ".")); + UtilPlayer.message(player, F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); } } @@ -99,32 +93,17 @@ public class TutorialManager extends MiniPlugin { if (isInTutorial(player)) { - UtilPlayer.message(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._friendlyName + " Tutorial") + ".")); + UtilPlayer.message(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); getTutorial(player).doSkip(player); } } @EventHandler - public void cleanup(UpdateEvent event) + public void quit(PlayerQuitEvent event) { - if (!event.getType().equals(UpdateType.SLOW)) - { - return; - } + if (!isInTutorial(event.getPlayer())) return; - List del = new ArrayList<>(); - for (String name : _playerTutorials.keySet()) - { - if (Bukkit.getPlayer(name) == null) - { - del.add(name); - } - } - - for (String name : del) - { - _playerTutorials.remove(name); - } + getTutorial(event.getPlayer()).cleanup(event.getPlayer()); } public Tutorial getTutorial(final Player player) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java index fd916051a..4a3e56476 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java @@ -1,39 +1,111 @@ package mineplex.game.clans.tutorials; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; -public class TutorialTask +public class TutorialTask implements Listener { - private final String _name; - private final String _description; - private final String _finishMessage; - private final int _id; + private T _tutorial; - public TutorialTask(final int id, final String name, final String description, String finishMessage) + protected long _autoCompleteTime = -1; + + protected String _displayName; + protected String _technicalName; + + protected String _description; + protected String _finishMessage; + + protected long _descriptionWaitTime = 30000; + + private List _playersFinished = new ArrayList<>(); + + private Map _deployedInstances = new HashMap<>(); + + private int _id; + + public TutorialTask(T tutorial, int id) { + _tutorial = tutorial; _id = id; - _name = name; - _description = description; - _finishMessage = finishMessage; + + UtilServer.getServer().getPluginManager().registerEvents(this, _tutorial._manager.getPlugin()); } - public int getID() + protected DeployedTask deploy(final Player player) { - return _id; + DeployedTask task = customDeploy(player); + + _deployedInstances.put(player.getName(), task); + + UtilServer.getServer().getPluginManager().registerEvents(task, _tutorial._manager.getPlugin()); + + trySendDescription(player); + + if (_autoCompleteTime != -1) + { + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_tutorial._manager.getPlugin(), new Runnable(){ + public void run() + { + if (_deployedInstances.containsKey(player.getName())) + { + finishFor(player); + } + } + }, _autoCompleteTime); + } + + task.postDeploy(); + + return task; } - public String getFinishMessage() + public void trySendDescription(Player player) { - return _finishMessage; + if (!_tutorial.isInTutorial(player)) + { + return; + } + + TutorialClient client = _tutorial.get(player); + + if (System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime()) + { + UtilPlayer.message(player, C.cGreen + "==== Pt." + client.CurrentTask.getID() + ": " + client.CurrentTask.getDisplayName() + " ===="); + UtilPlayer.message(player, C.cYellow + client.CurrentTask.getDescription().replace("{", C.cAqua).replace("}", C.cYellow)); + UtilPlayer.message(player, C.cGreen + UtilText.repeat("=", client.CurrentTask.getDisplayName().length() + ("=== Pt." + client.CurrentTask.getID() + ": ===").length())); + client.LastDescriptionSentTime = System.currentTimeMillis(); + } } - public String getFriendlyName() + protected DeployedTask customDeploy(final Player player) { - return _name; + return new DeployedTask(player, this); + } + + public final void startFor(Player player) + { + deploy(player); + } + + public final boolean hasFinished(final Player player) + { + return _playersFinished.contains(player.getName()); + } + + public String getDisplayName() + { + return _displayName; } public String getDescription() @@ -41,20 +113,31 @@ public class TutorialTask return _description; } - public String getUniqueId() + public String getFinishMessage() { - return _name.replace(" ", ""); + return _finishMessage; } - public void sendDescriptionTo(final Player player) + public String getTechnicalName() { - UtilPlayer.message(player, C.cGreen + "==== Pt." + _id + ": " + _name + " ===="); - UtilPlayer.message(player, C.cYellow + _description.replace("{", C.cAqua).replace("}", C.cYellow)); - UtilPlayer.message(player, C.cGreen + UtilText.repeat("=", _name.length() + ("=== Pt." + _id + ": ===").length())); + return _technicalName; } - public void onFinish(final Player player) + public int getID() { + return _id; + } + + public void finishFor(Player player) + { + _tutorial.finishTask(player, this); + } + + public void visibleFinish(Player player) + { + _deployedInstances.get(player.getName()).kill(); + HandlerList.unregisterAll(_deployedInstances.get(player.getName())); + if (_finishMessage != null) { UtilPlayer.message(player, C.cGreen + "=================="); @@ -62,5 +145,21 @@ public class TutorialTask UtilPlayer.message(player, C.cGreen + "=================="); } } - + + public void cleanup(Player player) + { + _deployedInstances.get(player.getName()).kill(); + _deployedInstances.remove(player.getName()); + _playersFinished.remove(player.getName()); + } + + public long getDescriptionWaitTime() + { + return _descriptionWaitTime; + } + + public T getTutorial() + { + return _tutorial; + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/TaskInfoCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/TaskInfoCommand.java deleted file mode 100644 index 5e98b32c0..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/TaskInfoCommand.java +++ /dev/null @@ -1,31 +0,0 @@ -package mineplex.game.clans.tutorials.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; - -public class TaskInfoCommand extends CommandBase -{ - public TaskInfoCommand(final TutorialManager plugin) - { - super(plugin, Rank.ALL, "taskinfo", "ti"); - } - - @Override - public void Execute(final Player caller, final String[] args) - { - if (Plugin.isInTutorial(caller)) - { - Plugin.getTutorial(caller).getTask(Plugin.getTutorial(caller).get(caller).getCurrentTask()).sendDescriptionTo(caller); - } - else - { - UtilPlayer.message(caller, F.main("Tutorials", "You are not currently in a tutorial.")); - } - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java new file mode 100644 index 000000000..26a3935aa --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java @@ -0,0 +1,64 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +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.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskClaim extends TutorialTask +{ + public TaskClaim(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Claim some Territory"; + _technicalName = "ClaimTerr"; + + _description = "Clans can claim 16x16 areas of Territory! " + + "Once claimed, only your Clan can break/place blocks here. " + + "This is the perfect place to build a base and stash your items! " + + "You can only claim in the Wilderness, and not next to other Clans Territory. " + + "Claim some Territory now, by typing {/c claim}!"; + + _finishMessage = "Good job! We won't actually claim this Territory yet!"; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onClansCommand(ClansCommandExecutedEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!ClansManager.getInstance().isInClan(event.getPlayer())) + { + return; + } + + if (event.getCommand().equals("claim")) + { + _task.finishFor(_player); + event.setCancelled(true); + } + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java new file mode 100644 index 000000000..1ddf72a28 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java @@ -0,0 +1,49 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.game.clans.clans.event.ClanCreatedEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskCreateClan extends TutorialTask +{ + public TaskCreateClan(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Create a Clan"; + _technicalName = "ClanCreation"; + + _description = "Before beginning, use the {/c create } command to start up your own Clan! " + + "Alternatively, you can join a friend's Clan, if they have invited you, instead of making your own."; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onClanCreated(ClanCreatedEvent event) + { + if (!_player.equals(event.getFounder())) + { + return; + } + + _task.finishFor(_player); + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java new file mode 100644 index 000000000..42aa9f24a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java @@ -0,0 +1,57 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; +import mineplex.minecraft.game.classcombat.Class.ClientClass; + +public class TaskCustomizeClass extends TutorialTask +{ + public TaskCustomizeClass(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Customize Class"; + _technicalName = "CustomizeKlass"; + + _description = "Now that you have Equipped a Class, you can start using Abilities. " + + "Purchase an Iron Axe from the PvP Shop. (FREE) " + + "Right-Click with your Iron Axe to use your Axe Ability!"; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onUpdate(final UpdateEvent event) + { + if (!event.getType().equals(UpdateType.SEC)) + { + return; + } + + final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(_player); + + if (clientclass != null && clientclass.GetSavingCustomBuild() != null) + { + _task.finishFor(_player); + } + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskDisbandClan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskDisbandClan.java new file mode 100644 index 000000000..845a2e2e6 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskDisbandClan.java @@ -0,0 +1,48 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.game.clans.clans.event.ClanDisbandedEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskDisbandClan extends TutorialTask +{ + public TaskDisbandClan(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Disband your Clan"; + _technicalName = "DisbandClan"; + + _description = "Finally, let's disband your Clan to end the Tutorial. " + + "Simply type {/c disband} to do this. " + + "This will delete your Clan, and you'll be able to create or join a new one!"; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler + public void sell(ClanDisbandedEvent event) + { + if (!_player.equals(event.getDisbander())) + { + return; + } + + _task.finishFor(_player); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java new file mode 100644 index 000000000..0a606acae --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java @@ -0,0 +1,110 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UtilItem; +import mineplex.core.task.TaskManager; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; +import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; +import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent; + +public class TaskEquipClass extends TutorialTask +{ + public TaskEquipClass(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Equip a Class"; + _technicalName = "AuszustattenKlasse"; + + _description = "Find the PvP Gear shop, and Right-Click the Villager. " + + "Purchase Iron Armor from the PvP Shop. (FREE) " + + "Then put on your Armor to equip a Champions Class."; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + private List _bought = new ArrayList<>(); + + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler + public void onClassEquipped(ClassEquipEvent event) + { + System.out.println(event.getPlayer()); + System.out.println(ClansManager.getInstance().getClassManager().Get(_player)); + if (!ClansManager.getInstance().getClassManager().Get(_player).equals(event.getPlayer())) + { + return; + } + + _task.finishFor(_player); + } + + @EventHandler + public void button(ClansShopAddButtonEvent event) + { + if (_player.equals(event.getPlayer())) + { + return; + } + + if (!(UtilItem.isArmor(event.getMaterial()) && UtilItem.isIronProduct(event.getMaterial()))) + { + return; + } + + if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "iboughtthis" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) + { + event.setBuyPrice(0); + event.setSellPrice(0); + } + } + + @EventHandler + public void buy(final ClansPlayerBuyItemEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!(UtilItem.isArmor(event.getItem().getType()) && UtilItem.isIronProduct(event.getItem().getType()))) + { + return; + } + + if (event.getCost() == 0 && _bought.contains(event.getItem().getType())) + { + event.setCancelled(true); + return; + } + + TaskManager.Instance.completedTask(new Callback() { + @Override + public void run(Boolean data) + { + } + }, event.getPlayer(), "iboughtthis" + event.getItem().getType().name()); + _bought.add(event.getItem().getType()); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java new file mode 100644 index 000000000..07a0cd9fe --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java @@ -0,0 +1,89 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; +import mineplex.game.clans.shop.energy.EnergyShop; +import mineplex.game.clans.spawn.Spawn; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskExploreShops extends TutorialTask +{ + public TaskExploreShops(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Welcome to the Shops"; + _technicalName = "WillkommenZumGeschaft"; + + _description = "Welcome to the Shops! Here you can buy all kinds of things that you may require during your adventure. " + + "You can also sell certain items to the Villagers to make a bit of extra Gold." + + "Go to the Energy Shop and buy {7 Days} of Energy. (FREE)"; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @Override + public void postDeploy() + { + _player.teleport(Spawn.getNorthTownCenter()); + + ClansManager.getInstance().getClan(_player).adjustEnergy(-(ClansManager.getInstance().getClan(_player).getEnergyCostPerMinute() * 60)); + } + + @EventHandler + public void onItemPut(ClansShopAddButtonEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!ClansManager.getInstance().isInClan(_player)) + { + return; + } + + if (ClansManager.getInstance().getClan(_player).getEnergyPurchasable() == 0) + { + return; + } + + if (event.getShop().getClass().equals(EnergyShop.class) && event.getDisplayName().contains("Energy")) + { + event.setBuyPrice(0); + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TWOSEC) + { + return; + } + + if (ClansManager.getInstance().getClan(_player).getEnergy() == ClansManager.getInstance().getClan(_player).getEnergyMax()) + { + _task.finishFor(_player); + } + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskGoToWilderness.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskGoToWilderness.java new file mode 100644 index 000000000..cc1792b30 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskGoToWilderness.java @@ -0,0 +1,66 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskGoToWilderness extends TutorialTask +{ + public TaskGoToWilderness(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Go To The Wilderness"; + _technicalName = "GoToWildy"; + + _description = "Use your Map (Slot 9) to help find your way to the Wilderness. " + + "The Wilderness is anywhere that is not colored on the Map. " + + "If you don't have a map, you can get one at any time by typing {/map}. " + + "You can zoom in/out by Left and Right Clicking!"; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @Override + public void postDeploy() + { + if (( + ClansManager.getInstance().getClanUtility().getClaim(_player.getLocation()) == null + ) + ){ + _task.finishFor(_player); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onTerritory(final PlayerEnterTerritoryEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (event.getNewTerritory().contains("Wilderness")) + { + _task.finishFor(_player); + } + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java new file mode 100644 index 000000000..2958c29fb --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java @@ -0,0 +1,67 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskLeaveSpawn extends TutorialTask +{ + public TaskLeaveSpawn(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Leave Spawn Islands"; + _technicalName = "LeaveSpawn"; + + _description = "Now you can leave the Spawn Island. " + + "Don't worry, you won't get hurt from the fall! " + + "Once you end the tutorial, PvP will be enabled down there, so be careful!"; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @Override + public void postDeploy() + { + if (ClansManager.getInstance().getClanUtility().getClaim(_player.getLocation()) == null + || ( + ClansManager.getInstance().getClanUtility().getClaim(_player.getLocation()) != null + && !ClansManager.getInstance().getClanUtility().getClaim(_player.getLocation()).Owner.equals("Spawn") + ) + ){ + _task.finishFor(_player); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onTerritory(final PlayerEnterTerritoryEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (event.getNewTerritory().contains("Spawn")) + { + _task.finishFor(_player); + } + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java new file mode 100644 index 000000000..505221282 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java @@ -0,0 +1,61 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskMakingMoney extends TutorialTask +{ + public TaskMakingMoney(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Making Money (Farming)"; + _technicalName = "ImAFarmer"; + + _description = "We have given you a few Carrots, as a starter for your Farming career. " + + "Go to the Organic Produce Villager in one of the Shops, and sell the Carrots for Gold."; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + player.getInventory().addItem(new ItemStack(Material.CARROT_ITEM, 5)); + } + + @EventHandler + public void button(ClansPlayerSellItemEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!ClansManager.getInstance().isInClan(_player)) + { + return; + } + + if (!event.getItem().getType().equals(Material.CARROT_ITEM)) + { + return; + } + + _task.finishFor(_player); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskSetHome.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskSetHome.java new file mode 100644 index 000000000..8ee0e1e48 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskSetHome.java @@ -0,0 +1,60 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +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.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskSetHome extends TutorialTask +{ + public TaskSetHome(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Set Clan Home"; + _technicalName = "SetClanHome"; + + _description = "You are now ready to set a Clan Home. " + + "To do this, use the {/c sethome} command."; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onSetHome(ClansCommandExecutedEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!ClansManager.getInstance().isInClan(event.getPlayer())) + { + return; + } + + if (!event.getCommand().equals("homeset")) + { + return; + } + + _task.finishFor(_player); + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java new file mode 100644 index 000000000..557587308 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java @@ -0,0 +1,106 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.Callback; +import mineplex.core.task.TaskManager; +import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; +import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; + +public class TaskUseAbility extends TutorialTask +{ + public TaskUseAbility(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Use a Class Ability"; + _technicalName = "KlassAbilityUsage"; + + _description = "Now that you have Equipped a Class, you can start using Abilities. " + + "Purchase an Iron Axe from the PvP Shop. (FREE) " + + "Right-Click with your Iron Axe to use your Axe Ability!"; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + private List _bought = new ArrayList<>(); + + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler + public void onAbilityUesd(SkillTriggerEvent event) + { + if (!_player.equals(event.GetPlayer())) + { + return; + } + + _task.finishFor(_player); + } + + @EventHandler + public void button(ClansShopAddButtonEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!event.getMaterial().equals(Material.IRON_AXE)) + { + return; + } + + if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "iboughtthis" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) + { + event.setBuyPrice(0); + event.setSellPrice(0); + } + } + + @EventHandler + public void buy(final ClansPlayerBuyItemEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!event.getItem().getType().equals(Material.IRON_AXE)) + { + return; + } + + if (event.getCost() == 0 && _bought.contains(event.getItem().getType())) + { + event.setCancelled(true); + return; + } + + TaskManager.Instance.completedTask(new Callback() { + @Override + public void run(Boolean data) + { + } + }, event.getPlayer(), "iboughtthis" + event.getItem().getType().name()); + _bought.add(event.getItem().getType()); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java new file mode 100644 index 000000000..41d223047 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java @@ -0,0 +1,53 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskViewClanDetails extends TutorialTask +{ + public TaskViewClanDetails(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Viewing Clan Details"; + _technicalName = "CommandClanX"; + + _description = "Now you can view information about your Clan. " + + "To do this type {/c [Clan Name]}! " + + "You can also use any Clans name to get some information about them as well."; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onClansCommand(ClansCommandExecutedEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (event.getCommand().equals("info")) + { + _task.finishFor(_player); + } + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskWelcome.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskWelcome.java new file mode 100644 index 000000000..9b058b619 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskWelcome.java @@ -0,0 +1,21 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskWelcome extends TutorialTask +{ + public TaskWelcome(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _autoCompleteTime = 20 * 10; + + _displayName = "Welcome"; + _technicalName = "Welcome"; + + _description = "Welcome to Clans! " + + "In this game mode, you are able to create a Clan, invite your friends to the Clan, build a base, claim it to protect, and fight others with your new powerful Clan!" + + "You can also join a friend's Clan if they invite you to it!" + + "When you finish the tutorial, you will be awarded {30,000 Gold}"; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java new file mode 100644 index 000000000..6da8fec84 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java @@ -0,0 +1,76 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.donation.DonationManager; +import mineplex.core.task.TaskManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.economy.GoldManager; +import mineplex.game.clans.tutorials.Tutorial; +import mineplex.game.clans.tutorials.TutorialManager; + +public class TutorialGettingStarted extends Tutorial +{ + public TutorialGettingStarted(final TutorialManager manager, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager) + { + super(goldManager, taskManager, clansManager, donationManager, manager); + + addTask(new TaskWelcome(this, 1)); + addTask(new TaskCreateClan(this, 2)); + addTask(new TaskViewClanDetails(this, 3)); + addTask(new TaskLeaveSpawn(this, 4)); + addTask(new TaskGoToWilderness(this, 5)); + addTask(new TaskClaim(this, 6)); + addTask(new TaskSetHome(this, 7)); + addTask(new TaskExploreShops(this, 8)); + addTask(new TaskEquipClass(this, 9)); + addTask(new TaskUseAbility(this, 10)); + addTask(new TaskCustomizeClass(this, 11)); + addTask(new TaskMakingMoney(this, 12)); + addTask(new TaskDisbandClan(this, 13)); + + _doScoreboard = true; + _ghostMode = true; + _startOnJoin = true; + _goldReward = 30000; + + _technicalName = "GettingStartedTutorial"; + _displayName = "Getting Started"; + } + + @Override + public void onFinished(final Player player) + { + UtilPlayer.message(player, F.main("Tutorials", "You are now ready to play, welcome to the game.")); + player.resetPlayerTime(); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onUpdate(final UpdateEvent event) + { + if (!event.getType().equals(UpdateType.SEC)) + { + return; + } + + for (Player player : UtilServer.getPlayers()) + { + if (isInTutorial(player)) + { + for (Player other : UtilServer.getPlayers()) + { + other.hidePlayer(player.getPlayer()); + player.hidePlayer(other); + } + } + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/TutorialGettingStarted.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/TutorialGettingStarted.java deleted file mode 100644 index be8ad0bd2..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/TutorialGettingStarted.java +++ /dev/null @@ -1,404 +0,0 @@ -package mineplex.game.clans.tutorials.types; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilItem.ItemCategory; -import mineplex.core.donation.DonationManager; -import mineplex.core.task.TaskManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClanRole; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.event.ClanCreatedEvent; -import mineplex.game.clans.clans.event.ClanDisbandedEvent; -import mineplex.game.clans.clans.event.ClanJoinEvent; -import mineplex.game.clans.clans.event.ClanSetHomeEvent; -import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; -import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; -import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent; -import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; -import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; -import mineplex.game.clans.economy.GoldManager; -import mineplex.game.clans.spawn.Spawn; -import mineplex.game.clans.tutorials.Tutorial; -import mineplex.game.clans.tutorials.TutorialClient; -import mineplex.game.clans.tutorials.TutorialManager; -import mineplex.minecraft.game.classcombat.Class.ClientClass; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; - -public class TutorialGettingStarted extends Tutorial -{ - public TutorialGettingStarted(final TutorialManager manager, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager) - { - super(goldManager, taskManager, clansManager, donationManager, manager); - - addTask(1, "Welcome", - "Welcome to Clans! " - + "In this game mode, you are able to create a Clan, invite your friends to the Clan, build a base, claim it to protect, and fight others with your new powerful Clan!" - + "You can also join a friend's Clan if they invite you to it!" - + "When you finish the tutorial, you will be awarded {30,000 Gold}"); - - addTask(2, "Create a clan", - "Before beginning, use the {/c create } command to start up your own Clan!" - + "Alternatively, you can join a friend's Clan, if they have invited you, instead of making your own."); - - addTask(3, "Viewing Clan Details", - "Now you can view information about your Clan. " - + "To do this type {/c [Clan Name]}! " - + "You can also use any Clans name to get some information about them as well."); - - addTask(4, "Leave Spawn Islands", - "Now you can leave the Spawn Island. " - + "Don't worry, you won't get hurt from the fall! " - + "Once you end the tutorial, PvP will be enabled down there, so be careful!"); - - addTask(5, "Go To The Wilderness", - "Use your Map (Slot 9) to help find your way to the Wilderness. " - + "The Wilderness is anywhere that is not colored on the Map. " - + "If you don't have a map, you can get one at any time by typing {/map}. " - + "You can zoom in/out by Left and Right Clicking!"); - - addTask(6, "Claim some Territory", - "Clans can claim 16x16 areas of Territory! " - + "Once claimed, only your Clan can break/place blocks here. " - + "This is the perfect place to build a base and stash your items!" - + "You can only claim in the Wilderness, and not next to other Clans Territory. " - + "Claim some Territory now, by typing {/c claim}! ", - - "Good job! We won't actually claim this Territory yet!"); - - addTask(7, "Set Clan Home", - "You are now ready to set a Clan Home." - + "To do this, use the {/c sethome} command."); - - addTask(8, "Explore the Shops", - "You can buy all sorts of things at the Shops! " - + "You can also sell things to the Villagers for Gold! " - + "Look at your Map and take notice of where the Shops is. " - + "You can also transfer {1,000 Gems} into {32,000 Clans Gold} each day."); - - addTask(9, "Equip a Class", - "Find the PvP Gear shop, and Right-Click the Villager. " - + "Purchase Iron Armor from the PvP Shop. (FREE) " - + "Then put on your Armor to equip a Champions Class. "); - - addTask(10, "Use a Class Ability", - "Now that you have Equipped a Class, you can start using Abilities. " - + "Purchase a Sword from the PvP Shop. (FREE) " - + "Right-Click with your Sword to use your Sword Ability!"); - - addTask(11, "Class Customization", - "To customize your Class, Right-Click an Enchantment Table! " - + "There should be one nearby in the Shops!" - + "Find it, and try customizing your Class! "); - - addTask(12, "Making Money (Farming)", - "We have given you a few Carrots, as a starter for your Farming career. " - + "Go to the Organic Produce Villager in one of the Shops, and sell the Carrots for {Gold}."); - - addTask(13, "Disband your Clan", - "Finally, let's disband your Clan to end the Tutorial. " - + "Simply type {/c disband} to do this. " - + "This will delete your Clan, and you'll be able to create or join a new one!"); - - _doScoreboard = true; - _ghostMode = true; - _startOnJoin = true; - _goldReward = 30000; - - _uniqueId = "GettingStartedTutorial"; - _friendlyName = "Getting Started"; - } - - @Override - public void onFinished(final Player player) - { - UtilPlayer.message(player, F.main("Tutorials", "You are now ready to play, welcome to the game.")); - player.resetPlayerTime(); - } - - @EventHandler - public void button(ClansShopAddButtonEvent event) - { - if (get(event.getPlayer()).hasFinishedTask(getTask("Explore the Shops")) && !get(event.getPlayer()).hasFinishedTask(getTask("Equip a Class"))) - { - if (!(UtilItem.isArmor(event.getMaterial()) && UtilItem.isIronProduct(event.getMaterial()))) - { - return; - } - - if (!_taskManager.hasCompletedTask(event.getPlayer(), "GettingStartedBought" + event.getMaterial().name())) - { - event.setBuyPrice(0); - event.setSellPrice(0); - } - } - } - - @EventHandler - public void swordbutton(ClansShopAddButtonEvent event) - { - if (get(event.getPlayer()).hasFinishedTask(getTask("Equip A Class")) && !get(event.getPlayer()).hasFinishedTask(getTask("Use a Class Ability"))) - { - if (!(UtilItem.isSword(event.getMaterial()))) - { - return; - } - - if (!_taskManager.hasCompletedTask(event.getPlayer(), "GettingStartedBoughtSword")) - { - event.setBuyPrice(0); - event.setSellPrice(0); - } - } - } - - @EventHandler - public void buy(final ClansPlayerBuyItemEvent event) - { - if (get(event.getPlayer()).hasFinishedTask(getTask("Explore the Shops")) && !get(event.getPlayer()).hasFinishedTask(getTask("Equip a Class"))) - { - if (!(UtilItem.isArmor(event.getItem().getType()) && UtilItem.isIronProduct(event.getItem().getType()))) - { - return; - } - - _taskManager.completedTask(new Callback(){ - @Override - public void run(Boolean data) - { - } - }, event.getPlayer(), "GettingStartedBought" + event.getItem().getType().name()); - } - } - - @EventHandler - public void buysword(final ClansPlayerBuyItemEvent event) - { - if (get(event.getPlayer()).hasFinishedTask(getTask("Equip A Class")) && !get(event.getPlayer()).hasFinishedTask(getTask("Use a Class Ability"))) - { - if (UtilItem.isSword(event.getItem().getType())) - { - _taskManager.completedTask(new Callback() { - @Override - public void run(Boolean data) - { - } - }, event.getPlayer(), "GettingStartedBoughtSword"); - } - } - } - - @EventHandler - public void sell(ClansPlayerSellItemEvent event) - { - if (get(event.getPlayer()).hasFinishedTask(getTask("Class Customization")) && !get(event.getPlayer()).hasFinishedTask(getTask("Making Money (Farming)"))) - { - finishTask(event.getPlayer(), "Making Money (Farming)"); - } - } - - @Override - public void onBegin(final Player player) - { - UtilPlayer.message(player, F.main("Tutorials", "Welcome to the " + F.elem("Getting Started Tutorial!"))); - - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), new Runnable() { - public void run() - { - finishTask(player, "Welcome"); - - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), new Runnable() { - public void run() - { - if (_clansManager.isInClan(player) && _clansManager.getClan(player).getClansPlayerFromName(player.getName()).getRole().has(ClanRole.ADMIN)) - { - finishTask(player, "Create a clan"); - } - } - }, 20L); - } - }, 80L); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onClanCreated(ClanCreatedEvent event) - { - if (event.getFounder() == null) - { - return; - } - - if (isInTutorial(event.getFounder()) && get(event.getFounder()).hasFinishedTask(getTask("Welcome")) && !get(event.getFounder()).hasFinishedTask(getTask("Create a clan"))) - { - finishTask(event.getFounder(), "Create a clan"); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onClanJoined(ClanJoinEvent event) - { - if (event.getPlayer() == null) - { - return; - } - - if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Welcome")) && !get(event.getPlayer()).hasFinishedTask(getTask("Create a clan"))) - { - finishTask(event.getPlayer(), "Create a clan"); - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void handlePlayerChat(AsyncPlayerChatEvent event) - { - for (TutorialClient player : _inTutorial.values()) - { - if (event.getPlayer().equals(player.getPlayer())) - { - event.setCancelled(true); - continue; - } - - event.getRecipients().remove(player.getPlayer()); - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onClansCommand(ClansCommandExecutedEvent event) - { - if (event.getCommand().equals("info")) - { - if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Create a clan")) && !get(event.getPlayer()).hasFinishedTask(getTask("Viewing Clan Details"))) - { - finishTask(event.getPlayer(), "Viewing Clan Details"); - } - } - else if (event.getCommand().equals("claim")) - { - if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Go To The Wilderness")) && !get(event.getPlayer()).hasFinishedTask(getTask("Claiming Territory"))) - { - finishTask(event.getPlayer(), "Claim some Territory"); - event.getPlayer().teleport(Spawn.getNorthTown()); - event.setCancelled(true); - } - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onSethome(ClanSetHomeEvent event) - { - if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Claim some Territory")) && !get(event.getPlayer()).hasFinishedTask(getTask("Set Clan Home"))) - { - finishTask(event.getPlayer(), "Set Clan Home"); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onTerritory(final PlayerEnterTerritoryEvent event) - { - final Player player = event.getPlayer(); - final String newTerritory = event.getNewTerritory(); - - if (isInTutorial(player) && newTerritory.contains("Spawn") && get(player).hasFinishedTask(getTask("Viewing Clan Details")) && !get(player).hasFinishedTask(getTask("Leave Spawn Islands"))) - { - finishTask(player, "Leave Spawn Islands"); - } - else if (isInTutorial(player) && newTerritory.contains("Wilderness") && get(player).hasFinishedTask(getTask("Leave Spawn Islands")) && !get(player).hasFinishedTask(getTask("Go To The Wilderness"))) - { - finishTask(player, "Go To The Wilderness"); - } - else if (isInTutorial(player) && newTerritory.contains("Shops") && get(player).hasFinishedTask(getTask("Claim some Territory")) && !get(player).hasFinishedTask(getTask("Explore the Shops"))) - { - finishTask(player, "Explore the Shops"); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onSkillTriggered(final SkillTriggerEvent event) - { - final Player player = event.GetPlayer(); - - if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Equip a Class")) && !get(player).hasFinishedTask(getTask("Use a Class Ability"))) - { - finishTask(player, "Use a Class Ability"); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onUpdated(final UpdateEvent event) - { - for (Player player : UtilServer.getPlayers()) - { - if (!isInTutorial(player)) - { - continue; - } - - ClientClass client = _clansManager.getClassManager().Get(player); - - if (client == null) - { - continue; - } - - if (client.GetGameClass() == null) - { - return; - } - - if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Explore the Shops")) && !get(player).hasFinishedTask(getTask("Equip a Class"))) - { - finishTask(player, "Use a Class Ability"); - } - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onUpdate(final UpdateEvent event) - { - if (!event.getType().equals(UpdateType.SEC)) - { - return; - } - - for (final TutorialClient client : _inTutorial.values()) - { - if (isInTutorial(client.getPlayer())) - { - client.getPlayer().setPlayerTime(6000, false); - - if (get(client.getPlayer()).hasFinishedTask(getTask("Equip a Class")) && !get(client.getPlayer()).hasFinishedTask(getTask("Class Customization"))) - { - final ClientClass clientclass = _clansManager.getClassManager().Get(client.getPlayer()); - - if (clientclass != null && clientclass.GetSavingCustomBuild() != null) - { - finishTask(client.getPlayer(), "Class Customization"); - client.getPlayer().getInventory().addItem(new ItemStack(Material.CARROT_ITEM, 5)); - } - } - } - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onDeletedClan(final ClanDisbandedEvent event) - { - if (isInTutorial(event.getDisbander()) && get(event.getDisbander()).hasFinishedTask(getTask("Making Money (Farming)")) && !get(event.getDisbander()).hasFinishedTask(getTask("Disband your Clan"))) - { - finishTask(event.getDisbander(), "Disband your Clan"); - } - } - -} diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index f1c81cb0a..1bc32cef6 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -17,9 +17,11 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.donation.Donor; import mineplex.core.itemstack.ItemStackFactory; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent; import mineplex.minecraft.game.classcombat.Class.repository.token.ClientClassToken; import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; import mineplex.minecraft.game.classcombat.Class.repository.token.SlotToken; @@ -343,7 +345,16 @@ public class ClientClass } ResetToDefaults(!skillsOnly, !skillsOnly); - + + // Event + ClassEquipEvent event = new ClassEquipEvent(this, customBuild); + UtilServer.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return; + } + if (notify) { ListSkills(_client.GetPlayer()); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/PvpClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/PvpClass.java index 4c28f55eb..488942a3e 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/PvpClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/PvpClass.java @@ -5,8 +5,10 @@ import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilServer; import mineplex.core.gadget.types.GadgetType; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent; import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; import mineplex.minecraft.game.classcombat.Skill.ISkill; diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/event/ClassEquipEvent.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/event/ClassEquipEvent.java new file mode 100644 index 000000000..74f2c5fab --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/event/ClassEquipEvent.java @@ -0,0 +1,57 @@ +package mineplex.minecraft.game.classcombat.Class.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.minecraft.game.classcombat.Class.ClientClass; +import mineplex.minecraft.game.classcombat.Class.PvpClass; +import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; + +public class ClassEquipEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private ClientClass _client; + + private CustomBuildToken _build; + + private boolean _cancelled; + + public ClassEquipEvent(ClientClass client, CustomBuildToken build) + { + _client = client; + _build = build; + } + + public ClientClass getPlayer() + { + return _client; + } + + public CustomBuildToken getBuild() + { + return _build; + } + + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} \ No newline at end of file From d8ae035f846947724c88338812f74882e804a813 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sat, 28 Nov 2015 09:20:42 +0000 Subject: [PATCH 02/16] creative scoreboard team. and fixed npe in tutorials --- .../src/mineplex/core/common/Rank.java | 8 +++++ .../mineplex/core/common/util/UtilText.java | 4 +++ .../scoreboard/ClansPlayerScoreboard.java | 11 +++---- .../game/clans/tutorials/TutorialClient.java | 32 +++++++++++++++++++ 4 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 45fd28921..9eeda0347 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -116,4 +116,12 @@ public enum Rank { return _donor; } + + public String getRawTag() + { + if (Name.equalsIgnoreCase("ALL")) + return ""; + + return Name; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java index d5c8f563e..8bbac15bc 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java @@ -106,4 +106,8 @@ public class UtilText { return x <= 0 ? true : x > 1; } + public static String trim(int maxLength, String s) { + return s.length() <= maxLength ? s : s.substring(0, maxLength); + } + } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java index 21709202d..74748387b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java @@ -1,6 +1,7 @@ package mineplex.game.clans.clans.scoreboard; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; @@ -11,6 +12,7 @@ import org.bukkit.scoreboard.Team; import net.minecraft.server.v1_8_R3.ScoreboardTeam; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilText; import mineplex.core.scoreboard.PlayerScoreboard; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.game.clans.clans.ClanInfo; @@ -76,17 +78,14 @@ public class ClansPlayerScoreboard extends PlayerScoreboard { if (otherPlayer.getGameMode().equals(GameMode.CREATIVE)) { - String teamName = getTeamName(clanInfo, relation, ownScore); + String teamName = UtilText.trim(16, _clansManager.getClientManager().Get(otherPlayer).GetRank().getRawTag() + "CREATIVE"); Team team = scoreboard.getTeam(teamName); if (team == null) { team = scoreboard.registerNewTeam(teamName); - if (clanInfo != null) - team.setPrefix(relation.getColor(true) + clanInfo.getName() + relation.getColor(false) + " "); - else - team.setPrefix(relation.getColor(false).toString()); + team.setPrefix(UtilText.trim(16, _clansManager.getClientManager().Get(otherPlayer).GetRank().getTag(true, true) + ChatColor.RESET + " ")); + team.setSuffix(C.cRed + " CREATIVE"); } - Objective domObjective; if ((domObjective = scoreboard.getObjective(DisplaySlot.BELOW_NAME)) == null) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java new file mode 100644 index 000000000..5229aaf24 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java @@ -0,0 +1,32 @@ +package mineplex.game.clans.tutorials; + +import org.bukkit.entity.Player; + +import mineplex.core.task.TaskManager; + +public class TutorialClient +{ + public Player Player; + public TutorialTask CurrentTask; + public long LastDescriptionSentTime = 0; + + public TutorialClient(Player player, Tutorial tutorial) + { + Player = player; + + CurrentTask = tutorial._tasks.get(1); + + for (TutorialTask task : tutorial._tasks.values()) + { + if (TaskManager.Instance.hasCompletedTask(player, String.format( + Tutorial.TASK_COMPLETE_TASK, + task.getTutorial().getTechnicalName(), task.getTechnicalName()))) + { + if (CurrentTask.getID() <= task.getID()) + { + CurrentTask = task.getTutorial().getTasks().get(Math.min(task.getTutorial().getTasks().size(), task.getID() + 1)); + } + } + } + } +} From f5384a138214cd661d23342e2ed3a348efb1ab5c Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sat, 28 Nov 2015 09:31:18 +0000 Subject: [PATCH 03/16] staff mode --- .../game/clans/clans/scoreboard/ClansPlayerScoreboard.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java index 74748387b..4fc9e80ab 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java @@ -84,7 +84,7 @@ public class ClansPlayerScoreboard extends PlayerScoreboard { team = scoreboard.registerNewTeam(teamName); team.setPrefix(UtilText.trim(16, _clansManager.getClientManager().Get(otherPlayer).GetRank().getTag(true, true) + ChatColor.RESET + " ")); - team.setSuffix(C.cRed + " CREATIVE"); + team.setSuffix(C.cRed + " STAFF MODE"); } Objective domObjective; From 75ef42d8c97c0e24cb3360cb1cd1562c41248f4c Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sat, 28 Nov 2015 19:37:03 +0000 Subject: [PATCH 04/16] fixed the clan claim box check --- .../mineplex/game/clans/clans/ClansUtility.java | 17 +++++++++-------- .../clans/observer/command/ObserverCommand.java | 2 +- .../mineplex/game/clans/shop/ClansShopPage.java | 2 ++ .../src/mineplex/game/clans/shop/PvpItem.java | 14 +++++++++++++- .../game/clans/shop/ShopItemButton.java | 3 ++- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index 54d142720..7c72b0c2a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -724,11 +724,11 @@ public class ClansUtility } } - if (clan.getClaims() >= clan.getClaimsMax()) - { - UtilPlayer.message(caller, F.main("Clans", "Your Clan cannot claim more Territory.")); - return false; - } +// if (clan.getClaims() >= clan.getClaimsMax()) +// { +// UtilPlayer.message(caller, F.main("Clans", "Your Clan cannot claim more Territory.")); +// return false; +// } // Adjacent boolean selfAdj = false; @@ -737,6 +737,7 @@ public class ClansUtility for (int z = -1; z <= 1; z++) { if (x == 0 && z == 0) continue; + if (Math.abs(x) == 1 && Math.abs(z) == 1) continue; String other = UtilWorld.chunkToStr(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z)); @@ -837,10 +838,10 @@ public class ClansUtility int boxed = 0; // This is bad. I know. But the other way doesn't seem to work. - String down = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ() + 1)); - String up = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() -1 )); + String down = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 0, chunk.getZ() + 1)); + String up = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1)); String right = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ())); - String left = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ() + 0)); + String left = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ())); ClanInfo downClan = getOwner(down); ClanInfo upClan = getOwner(up); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/command/ObserverCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/command/ObserverCommand.java index 0a236a669..e4a016c1f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/command/ObserverCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/command/ObserverCommand.java @@ -14,7 +14,7 @@ public class ObserverCommand extends CommandBase { public ObserverCommand(ObserverManager plugin) { - super(plugin, Rank.ALL, "observer", "o"); + super(plugin, Rank.HELPER, "observer", "o"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java index 0d67e5689..c470e2e90 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java @@ -4,6 +4,7 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilServer; import mineplex.core.donation.DonationManager; import mineplex.core.shop.ShopBase; @@ -88,6 +89,7 @@ public abstract class ClansShopPage> extends Sh addShopItem(index, item, (byte) 0, displayName, 1); } + public void addShopItem(int index, ClansShopItem item) { addShopItem(index, item, (byte) 0); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java index 7482dde82..97d9534e7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java @@ -3,6 +3,7 @@ package mineplex.game.clans.shop; import org.bukkit.Material; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilItem; import mineplex.core.shop.item.ShopItem; public class PvpItem extends ShopItem @@ -25,7 +26,18 @@ public class PvpItem extends ShopItem public PvpItem(Material type, byte data, int displayAmount, String name, int buyPrice, int sellPrice, int bulkCount) { - super(type, data, name, new String[] { C.cWhite + " ", LEFT_CLICK_BUY, C.cWhite + "Costs " + C.cGreen + buyPrice + "g", C.cWhite + " ", C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount, C.cWhite + "Costs " + C.cGreen + (buyPrice * bulkCount) + "g", C.cWhite + " ", RIGHT_CLICK_SELL, C.cWhite + "Earns " + C.cGreen + sellPrice + "g", C.cWhite + " ", C.cYellow + "Shift Right-Click" + C.cWhite + " to Sell " + C.cGreen + "All", }, 0, false, false); + super(type, data, name, new String[] { + C.cWhite + " ", + LEFT_CLICK_BUY, + C.cWhite + "Costs " + C.cGreen + buyPrice + "g", + C.cWhite + " ", + UtilItem.isArmor(type) || UtilItem.isTool(type) ? "" : C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount, + UtilItem.isArmor(type) || UtilItem.isTool(type) ? "" : C.cWhite + "Costs " + C.cGreen + (buyPrice * bulkCount) + "g", C.cWhite + " ", + RIGHT_CLICK_SELL, + C.cWhite + "Earns " + C.cGreen + sellPrice + "g", + C.cWhite + " ", + C.cYellow + "Shift Right-Click" + C.cWhite + " to Sell " + C.cGreen + "All", + }, 0, false, false); _price = buyPrice; _sellPrice = sellPrice; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java index ad4359652..a29c0a8d9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java @@ -9,6 +9,7 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.InventoryUtil; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.shop.item.IButton; @@ -78,7 +79,7 @@ public class ShopItemButton> implements IButton } else if (clickType == ClickType.SHIFT_LEFT || clickType == ClickType.LEFT) { - final int amount = shiftClick ? 64 : 1; + final int amount = !(UtilItem.isArmor(_item.getType()) || UtilItem.isTool(_item.getType())) && shiftClick ? 64 : 1; final int cost = amount * _buyPrice; int goldCount = GoldManager.getInstance().getGold(player); From afbccba36fd3b1b3319af9cb865cd3d2dda046d7 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sat, 28 Nov 2015 19:56:47 +0000 Subject: [PATCH 05/16] added force join command for ADMIN+ --- .../clans/clans/commands/ClansCommand.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 0a389bbfc..2f10880ad 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -114,7 +114,9 @@ public class ClansCommand extends CommandBase else if (args[0].equalsIgnoreCase("who") || args[0].equalsIgnoreCase("w")) { - if (args.length > 1) + if (args.length > 2 && args[2].equals("join")) + forceJoinClan(caller, args[1]); + else if (args.length == 2) infoClan(caller, args[1]); else infoClan(caller, null); @@ -863,6 +865,35 @@ public class ClansCommand extends CommandBase _manager.getClanShop().openClanWho(caller, clan); } + public void forceJoinClan(Player caller, String search) + { + if (_manager.getClientManager().hasRank(caller, Rank.ADMIN)) + { + UtilPlayer.message(caller, F.main("Clans", "No no no, this command is not for you ;-)")); + return; + } + + if (search == null) + { + UtilPlayer.message(caller, F.main("Clans", "You did not input a search parameter.")); + return; + } + + ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "info", search); + UtilServer.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return; + } + + ClanInfo clan = Plugin.getClanUtility().searchClanPlayer(caller, search, true); + if (clan == null) return; + + _manager.getClanUtility().join(caller, clan); + } + + public void infoTerritory(Player caller, String[] args) { ClanInfo clan; From ace4548b1ec18353a457e53669ca4de0324d4b19 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sat, 28 Nov 2015 20:14:48 +0000 Subject: [PATCH 06/16] don't cull an entity if a player is nearby --- .../game/clans/clans/ClansUtility.java | 9 ++++++-- .../clans/clans/commands/ClansCommand.java | 1 + .../game/clans/world/WorldManager.java | 21 ++++++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index 7c72b0c2a..d1705911d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -736,8 +736,13 @@ public class ClansUtility { for (int z = -1; z <= 1; z++) { - if (x == 0 && z == 0) continue; - if (Math.abs(x) == 1 && Math.abs(z) == 1) continue; + if ((x == 1 && z == 1) + || (x == -1 && z == 1) + || (x == -1 && z == -1) + || (x == 1 && z == -1) + || (x == 0 && z == 0)) { + continue; + } String other = UtilWorld.chunkToStr(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 2f10880ad..434a1729a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -891,6 +891,7 @@ public class ClansCommand extends CommandBase if (clan == null) return; _manager.getClanUtility().join(caller, clan); + _manager.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.LEADER); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java index 408e33924..f2761bab3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java @@ -3,9 +3,12 @@ package mineplex.game.clans.world; import java.util.ArrayList; import java.util.HashMap; +import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; @@ -38,7 +41,23 @@ public class WorldManager extends MiniPlugin for (Entity ent : world.getEntities()) { if (ent.getCustomName() == null) - _ents.get(ent.getType()).add(ent); + { + boolean cull = true; + + for (Player player : world.getPlayers()) + { + if (player.getLocation().distance(ent.getLocation()) <= 64) + { + cull = false; + break; + } + } + + if (cull) + { + _ents.get(ent.getType()).add(ent); + } + } } for (EntityType type : _ents.keySet()) From e1be0b1dbdd67a6eb8f4c035736bb4918796f9ca Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sat, 28 Nov 2015 23:34:41 +0000 Subject: [PATCH 07/16] dupe fix --- .../minecraft/game/classcombat/Skill/Brute/BlockToss.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java index 135c0278b..bdda29bd0 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java @@ -170,6 +170,8 @@ public class BlockToss extends SkillCharge implements IThrown return; } + event.getClickedBlock().setType(Material.AIR); + //Block to Item FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation(), event.getClickedBlock().getType(), event.getClickedBlock().getData()); From 9ff9724fc80d51c10cb2a401d24d63102416f296 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sun, 29 Nov 2015 02:10:39 +0000 Subject: [PATCH 08/16] tutorial revamp 2.0 --- .../core/gadget/gadgets/MorphTitan.java | 1 + .../core/shop/page/ConfirmationPage.java | 3 +- .../mineplex/game/clans/clans/ClanTips.java | 11 ++++ .../game/clans/clans/event/ClanTipEvent.java | 55 ++++++++++++++++++ .../clans/event/EnergyPageBuildEvent.java | 58 +++++++++++++++++++ .../game/clans/clans/stuck/StuckManager.java | 2 +- .../game/clans/shop/ClansShopPage.java | 2 +- .../src/mineplex/game/clans/shop/PvpItem.java | 4 +- .../game/clans/shop/ShopItemButton.java | 20 ++++++- .../game/clans/shop/energy/EnergyPage.java | 29 ++++------ .../game/clans/tutorials/DeployedTask.java | 6 +- .../game/clans/tutorials/Tutorial.java | 56 ++++++++++++++---- .../game/clans/tutorials/TutorialClient.java | 2 +- .../game/clans/tutorials/TutorialTask.java | 56 ++++++++++++++---- .../tutorials/gettingstarted/TaskClaim.java | 2 - .../gettingstarted/TaskCustomizeClass.java | 18 +++++- .../gettingstarted/TaskEquipClass.java | 20 ++++--- .../gettingstarted/TaskExploreShops.java | 18 +++--- .../gettingstarted/TaskGoToWilderness.java | 11 ---- .../gettingstarted/TaskLeaveSpawn.java | 22 +++---- .../gettingstarted/TaskMakingMoney.java | 16 ++++- .../gettingstarted/TaskUseAbility.java | 10 ++-- .../TutorialGettingStarted.java | 49 +++++++++++----- 23 files changed, 359 insertions(+), 112 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/ClanTipEvent.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/EnergyPageBuildEvent.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphTitan.java index 1396d82e3..0c9fa96a7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphTitan.java @@ -239,3 +239,4 @@ public class MorphTitan extends MorphGadget } } } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java index 3b7c39b97..b253a4ea7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java @@ -79,7 +79,7 @@ public class ConfirmationPage { - public static final long UNSTICK_WAIT_TIME = UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + public static final long UNSTICK_WAIT_TIME = UtilTime.convert(0, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); public StuckManager(ClansManager clans) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java index c470e2e90..78169ea47 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java @@ -80,7 +80,7 @@ public abstract class ClansShopPage> extends Sh if (!event.isCancelled()) { PvpItem item = new PvpItem(material, data, 1, displayName, buyPrice, sellPrice, 64); - addButton(slot, item, new ShopItemButton>(this, buyPrice, sellPrice, material, data, amount)); + addButton(slot, item, new ShopItemButton>(this, buyPrice, sellPrice, material, data, amount, displayName)); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java index 97d9534e7..1dd6c2183 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java @@ -29,12 +29,12 @@ public class PvpItem extends ShopItem super(type, data, name, new String[] { C.cWhite + " ", LEFT_CLICK_BUY, - C.cWhite + "Costs " + C.cGreen + buyPrice + "g", + C.cWhite + "Costs " + C.cGreen + (buyPrice == 0 ? "Free" : buyPrice + "g"), C.cWhite + " ", UtilItem.isArmor(type) || UtilItem.isTool(type) ? "" : C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount, UtilItem.isArmor(type) || UtilItem.isTool(type) ? "" : C.cWhite + "Costs " + C.cGreen + (buyPrice * bulkCount) + "g", C.cWhite + " ", RIGHT_CLICK_SELL, - C.cWhite + "Earns " + C.cGreen + sellPrice + "g", + C.cWhite + "Earns " + C.cGreen + (sellPrice == 0 ? "Free" : sellPrice + ""), C.cWhite + " ", C.cYellow + "Shift Right-Click" + C.cWhite + " to Sell " + C.cGreen + "All", }, 0, false, false); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java index a29c0a8d9..5b879737a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java @@ -1,11 +1,14 @@ package mineplex.game.clans.shop; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.InventoryUtil; @@ -25,17 +28,30 @@ public class ShopItemButton> implements IButton private ItemStack _item; private T _page; - public ShopItemButton(T page, int buyPrice, int sellPrice, Material material, byte data, int amount) + public ShopItemButton(T page, int buyPrice, int sellPrice, Material material, byte data, int amount, String displayName) { _page = page; _sellPrice = sellPrice; _buyPrice = buyPrice; _item = new ItemStack(material, amount, data); + + if (displayName != null) + { + ItemMeta meta = _item.getItemMeta(); + if (meta == null) + { + meta = Bukkit.getItemFactory().getItemMeta(material); + } + + meta.setDisplayName(C.Reset + displayName); + + _item.setItemMeta(meta); + } } public ShopItemButton(T page, int buyPrice, int sellPrice, Material material) { - this(page, buyPrice, sellPrice, material, (byte) 0, 1); + this(page, buyPrice, sellPrice, material, (byte) 0, 1, null); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java index 49824ff51..4e63d4b90 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java @@ -16,6 +16,7 @@ import mineplex.core.shop.page.ShopPageBase; import mineplex.game.clans.clans.ClanEnergyManager; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; +import mineplex.game.clans.clans.event.EnergyPageBuildEvent; public class EnergyPage extends ShopPageBase { @@ -46,9 +47,13 @@ public class EnergyPage extends ShopPageBase int oneDayEnergy = oneHourEnergy * 24; int maxEnergy = clanInfo.getEnergyPurchasable(); - addButton(clanInfo, 11, oneHourEnergy, Material.REDSTONE, (byte) 0, " ", ChatColor.RESET + "1 Hour of Energy", " ", ChatColor.RESET + "Costs " + C.cGreen + getPlugin().convertEnergyToGold(oneHourEnergy) + "g"); - addButton(clanInfo, 13, oneDayEnergy, Material.REDSTONE_BLOCK, (byte) 0, " ", ChatColor.RESET + "1 Day of Energy", " ", ChatColor.RESET + "Costs " + C.cGreen + getPlugin().convertEnergyToGold(oneDayEnergy) + "g"); - addButton(clanInfo, 15, maxEnergy, Material.FURNACE, (byte) 0, " ", ChatColor.RESET + "Maxed Out Energy", " ", ChatColor.RESET + "Costs " + C.cGreen + getPlugin().convertEnergyToGold(maxEnergy) + "g"); + EnergyPageBuildEvent event = new EnergyPageBuildEvent(getPlayer()); + + UtilServer.getServer().getPluginManager().callEvent(event); + + addButton(clanInfo, 11, oneHourEnergy, Material.REDSTONE, (byte) 0, event.free(), " ", ChatColor.RESET + "Purchase 1 Hour of Energy for your Clan", " ", ChatColor.RESET + (event.free() ? "FREE! (Tutorial)" : "Costs " + C.cGreen + getPlugin().convertEnergyToGold(oneHourEnergy) + "g")); + addButton(clanInfo, 13, oneDayEnergy, Material.REDSTONE_BLOCK, (byte) 0, event.free(), " ", ChatColor.RESET + "Purchase 1 Day of Energy for your Clan", " ", ChatColor.RESET + (event.free() ? "FREE! (Tutorial)" : "Costs " + C.cGreen + getPlugin().convertEnergyToGold(oneDayEnergy) + "g")); + addButton(clanInfo, 15, maxEnergy, Material.FURNACE, (byte) 0, event.free(), " ", ChatColor.RESET + "Max Out your Clan's Energy", " ", ChatColor.RESET + (event.free() ? "FREE! (Tutorial)" : "Costs " + C.cGreen + getPlugin().convertEnergyToGold(maxEnergy) + "g")); } private void addInfo(ClanInfo clanInfo, int slot) @@ -65,31 +70,17 @@ public class EnergyPage extends ShopPageBase setItem(slot, shopItem); } - private void addButton(ClanInfo clanInfo, int slot, int energyAmount, Material material, byte data, String... lore) + private void addButton(ClanInfo clanInfo, int slot, int energyAmount, Material material, byte data, boolean free, String... lore) { boolean locked = energyAmount > clanInfo.getEnergyPurchasable() || energyAmount == 0; String itemName = "Purchase " + energyAmount + " Energy"; - ClansShopAddButtonEvent event = new ClansShopAddButtonEvent(getPlayer(), getShop(), slot, material, getPlugin().convertEnergyToGold(energyAmount), 01, data, itemName, energyAmount); - UtilServer.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) - { - return; - } - - itemName = event.getDisplayName(); - int buyPrice = event.getBuyPrice(); - slot = event.getSlot(); - material = event.getMaterial(); - data = event.getData(); - ShopItem shopItem = new ShopItem(material, itemName, lore, 1, locked, false); if (locked) setItem(slot, shopItem); else - addButton(slot, shopItem, new EnergyShopButton(getPlugin(), this, energyAmount, clanInfo, buyPrice)); + addButton(slot, shopItem, new EnergyShopButton(getPlugin(), this, energyAmount, clanInfo, free ? 0 : getPlugin().convertEnergyToGold(energyAmount))); } private void buildNoClan() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/DeployedTask.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/DeployedTask.java index 1d8807999..02d6a46c9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/DeployedTask.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/DeployedTask.java @@ -23,6 +23,11 @@ public class DeployedTask implements Listener { } + public boolean checkForDeath() + { + return _dead || _player == null; + } + public void finish() { onFinish(); @@ -36,7 +41,6 @@ public class DeployedTask implements Listener } public void onFinish() { - } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java index 0b48bda07..66568e0ca 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java @@ -1,7 +1,7 @@ package mineplex.game.clans.tutorials; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -15,6 +15,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; @@ -28,7 +29,6 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilText; import mineplex.core.donation.DonationManager; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.scoreboard.elements.ScoreboardElement; @@ -36,6 +36,7 @@ import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClanTipEvent; import mineplex.game.clans.economy.GoldManager; /** @@ -47,9 +48,9 @@ import mineplex.game.clans.economy.GoldManager; */ public abstract class Tutorial implements ScoreboardElement, Listener { - public static String TASK_COMPLETE_TASK = "tutori%sTask%s"; - public static String TUTORIAL_COMPLETE_TASK = "tutori%sDone"; - public static String SKIPPED_TASK = "tutori%sSkip"; + public static String TASK_COMPLETE_TASK = "tutorialboughtought%sTask%s"; + public static String TUTORIAL_COMPLETE_TASK = "tutorialboughtought%sDone"; //do not change + public static String SKIPPED_TASK = "tutorialboughtought%sSkip"; protected final TutorialManager _manager; protected final GoldManager _goldManager; @@ -111,7 +112,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener final TutorialClient client = _inTutorial.get(player.getName()); - lines.add(C.cAqua + _displayName + " Tutorial"); + lines.add(C.cAqua + "Tutorial"); for (final TutorialTask task : _tasks.values()) { @@ -172,7 +173,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener }, 10L); } - UtilPlayer.message(player, F.main("Tutorials", "You have completed Task " + F.elem(task.getID() + ": " + task.getDisplayName()) + ". " + (_tasks.size() - task.getID()) + " task" + (UtilText.plural(_tasks.size() - task.getID()) ? "s" : "") + " to go!")); player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); } }, player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())); @@ -327,7 +327,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener { for (Player other : UtilServer.getPlayers()) { - other.showPlayer(player); + if (!isInTutorial(other)) other.showPlayer(player); player.showPlayer(other); } } @@ -378,9 +378,13 @@ public abstract class Tutorial implements ScoreboardElement, Listener new JsonMessage( F.main( "Tutorial", - "Click here to confirm you want to skip the tutorial!" + "Click " )) - .click(ClickEvent.RUN_COMMAND, "/yesiconfirmiwanttoskip") + .extra("here") + .color("aqua") + .click(ClickEvent.RUN_COMMAND, "/yesiconfirmiwanttoskip") + .extra(" here to confirm you want to skip the tutorial!") + .color("gray") .sendToPlayer(player); } @@ -406,6 +410,15 @@ public abstract class Tutorial implements ScoreboardElement, Listener return _inTutorial.get(player.getName()); } + @EventHandler + public void onClanTip(ClanTipEvent event) + { + if (isInTutorial(event.getPlayer())) + { + event.setCancelled(true); + } + } + @EventHandler public void taskInfo(final UpdateEvent evt) { @@ -422,6 +435,27 @@ public abstract class Tutorial implements ScoreboardElement, Listener } } } + + @EventHandler + public void chat(final AsyncPlayerChatEvent evt) + { + if (!isInTutorial(evt.getPlayer())) + { + return; + } + + Iterator iterator = evt.getRecipients().iterator(); + + while (iterator.hasNext()) + { + if (isInTutorial(iterator.next())) + { + iterator.remove(); + } + } + + evt.setCancelled(true); + } @EventHandler public void onPlayerJoin(final PlayerJoinEvent evt) @@ -443,7 +477,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener public void cleanup(Player player) { - get(player).CurrentTask.cleanup(player); + if (get(player).CurrentTask != null) get(player).CurrentTask.cleanup(player); _inTutorial.remove(player.getName()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java index 5229aaf24..c6071420e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java @@ -8,7 +8,7 @@ public class TutorialClient { public Player Player; public TutorialTask CurrentTask; - public long LastDescriptionSentTime = 0; + public long LastDescriptionSentTime = System.currentTimeMillis() - 3000; public TutorialClient(Player player, Tutorial tutorial) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java index 4a3e56476..8c609b160 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java @@ -2,17 +2,20 @@ package mineplex.game.clans.tutorials; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilText; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class TutorialTask implements Listener { @@ -31,6 +34,7 @@ public class TutorialTask implements Listener private List _playersFinished = new ArrayList<>(); private Map _deployedInstances = new HashMap<>(); + private List _toCull = new ArrayList<>(); private int _id; @@ -81,9 +85,15 @@ public class TutorialTask implements Listener if (System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime()) { - UtilPlayer.message(player, C.cGreen + "==== Pt." + client.CurrentTask.getID() + ": " + client.CurrentTask.getDisplayName() + " ===="); - UtilPlayer.message(player, C.cYellow + client.CurrentTask.getDescription().replace("{", C.cAqua).replace("}", C.cYellow)); - UtilPlayer.message(player, C.cGreen + UtilText.repeat("=", client.CurrentTask.getDisplayName().length() + ("=== Pt." + client.CurrentTask.getID() + ": ===").length())); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cYellowB + "Part " + _id + ": " + _displayName); + UtilPlayer.message(player, C.cWhite + _description.replace("{", C.cAqua).replace("}", C.cWhite)); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); client.LastDescriptionSentTime = System.currentTimeMillis(); } } @@ -136,20 +146,46 @@ public class TutorialTask implements Listener public void visibleFinish(Player player) { _deployedInstances.get(player.getName()).kill(); - HandlerList.unregisterAll(_deployedInstances.get(player.getName())); + _toCull.add(_deployedInstances.get(player.getName())); + _deployedInstances.remove(player.getName()); if (_finishMessage != null) { - UtilPlayer.message(player, C.cGreen + "=================="); - UtilPlayer.message(player, C.cYellow + _finishMessage.replace("{", C.cAqua).replace("}", C.cYellow)); - UtilPlayer.message(player, C.cGreen + "=================="); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cWhite + _finishMessage.replace("{", C.cAqua).replace("}", C.cWhite)); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); } } - + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + Iterator iterator = _toCull.iterator(); + + while(iterator.hasNext()) + { + DeployedTask task = iterator.next(); + + task.kill(); + HandlerList.unregisterAll(task); + iterator.remove(); + } + } + public void cleanup(Player player) { _deployedInstances.get(player.getName()).kill(); - _deployedInstances.remove(player.getName()); + _toCull.add(_deployedInstances.get(player.getName())); _playersFinished.remove(player.getName()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java index 26a3935aa..9102fe525 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java @@ -23,8 +23,6 @@ public class TaskClaim extends TutorialTask + "This is the perfect place to build a base and stash your items! " + "You can only claim in the Wilderness, and not next to other Clans Territory. " + "Claim some Territory now, by typing {/c claim}!"; - - _finishMessage = "Good job! We won't actually claim this Territory yet!"; } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java index 42aa9f24a..84ca86e7c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java @@ -1,5 +1,6 @@ package mineplex.game.clans.tutorials.gettingstarted; +import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -7,6 +8,7 @@ import org.bukkit.event.EventPriority; 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.DeployedTask; import mineplex.game.clans.tutorials.TutorialTask; import mineplex.minecraft.game.classcombat.Class.ClientClass; @@ -20,9 +22,8 @@ public class TaskCustomizeClass extends TutorialTask _displayName = "Customize Class"; _technicalName = "CustomizeKlass"; - _description = "Now that you have Equipped a Class, you can start using Abilities. " - + "Purchase an Iron Axe from the PvP Shop. (FREE) " - + "Right-Click with your Iron Axe to use your Axe Ability!"; + _description = "Now that you have Equipped a Class, use this enchantment table to customize your Class Builds. " + + "Click on the enchantment table, and click the Edit Build button."; } @Override @@ -38,6 +39,12 @@ public class TaskCustomizeClass extends TutorialTask super(player, task); } + @Override + public void postDeploy() + { + _player.teleport(new Location(Spawn.getSpawnWorld(), 6, 66, -300, -180f, 0f)); + } + @EventHandler(priority = EventPriority.MONITOR) public void onUpdate(final UpdateEvent event) { @@ -46,6 +53,11 @@ public class TaskCustomizeClass extends TutorialTask return; } + if (checkForDeath()) + { + return; + } + final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(_player); if (clientclass != null && clientclass.GetSavingCustomBuild() != null) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java index 0a606acae..fa8cc3ee7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java @@ -3,6 +3,7 @@ package mineplex.game.clans.tutorials.gettingstarted; import java.util.ArrayList; import java.util.List; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -13,6 +14,7 @@ import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.ClansManager; 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.DeployedTask; import mineplex.game.clans.tutorials.TutorialTask; import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent; @@ -26,8 +28,8 @@ public class TaskEquipClass extends TutorialTask _displayName = "Equip a Class"; _technicalName = "AuszustattenKlasse"; - _description = "Find the PvP Gear shop, and Right-Click the Villager. " - + "Purchase Iron Armor from the PvP Shop. (FREE) " + _description = "Use the PvP Gear shop, and Right-Click the Villager. " + + "Purchase Iron Armor from the PvP Shop. " + "Then put on your Armor to equip a Champions Class."; } @@ -46,11 +48,15 @@ public class TaskEquipClass extends TutorialTask super(player, task); } + @Override + public void postDeploy() + { + _player.teleport(new Location(Spawn.getSpawnWorld(), 19.536, 66, -305.844, -100f, 0f)); + } + @EventHandler public void onClassEquipped(ClassEquipEvent event) { - System.out.println(event.getPlayer()); - System.out.println(ClansManager.getInstance().getClassManager().Get(_player)); if (!ClansManager.getInstance().getClassManager().Get(_player).equals(event.getPlayer())) { return; @@ -62,7 +68,7 @@ public class TaskEquipClass extends TutorialTask @EventHandler public void button(ClansShopAddButtonEvent event) { - if (_player.equals(event.getPlayer())) + if (!_player.equals(event.getPlayer())) { return; } @@ -72,7 +78,7 @@ public class TaskEquipClass extends TutorialTask return; } - if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "iboughtthis" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) + if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tutorialboughtought" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) { event.setBuyPrice(0); event.setSellPrice(0); @@ -103,7 +109,7 @@ public class TaskEquipClass extends TutorialTask public void run(Boolean data) { } - }, event.getPlayer(), "iboughtthis" + event.getItem().getType().name()); + }, event.getPlayer(), "tutorialboughtought" + event.getItem().getType().name()); _bought.add(event.getItem().getType()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java index 07a0cd9fe..cc332b10c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java @@ -1,13 +1,13 @@ package mineplex.game.clans.tutorials.gettingstarted; +import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; -import mineplex.game.clans.shop.energy.EnergyShop; +import mineplex.game.clans.clans.event.EnergyPageBuildEvent; import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.tutorials.DeployedTask; import mineplex.game.clans.tutorials.TutorialTask; @@ -22,8 +22,8 @@ public class TaskExploreShops extends TutorialTask _technicalName = "WillkommenZumGeschaft"; _description = "Welcome to the Shops! Here you can buy all kinds of things that you may require during your adventure. " - + "You can also sell certain items to the Villagers to make a bit of extra Gold." - + "Go to the Energy Shop and buy {7 Days} of Energy. (FREE)"; + + "You can also sell certain items to the Villagers to make a bit of extra Gold. " + + "Go to the Energy Shop and buy {Max Energy}. (FREE)"; } @Override @@ -42,13 +42,13 @@ public class TaskExploreShops extends TutorialTask @Override public void postDeploy() { - _player.teleport(Spawn.getNorthTownCenter()); + _player.teleport(new Location(Spawn.getSpawnWorld(), 17, 66.5, -330, -180f, 0f)); ClansManager.getInstance().getClan(_player).adjustEnergy(-(ClansManager.getInstance().getClan(_player).getEnergyCostPerMinute() * 60)); } @EventHandler - public void onItemPut(ClansShopAddButtonEvent event) + public void onItemPut(EnergyPageBuildEvent event) { if (!_player.equals(event.getPlayer())) { @@ -62,13 +62,11 @@ public class TaskExploreShops extends TutorialTask if (ClansManager.getInstance().getClan(_player).getEnergyPurchasable() == 0) { + _task.finishFor(_player); return; } - if (event.getShop().getClass().equals(EnergyShop.class) && event.getDisplayName().contains("Energy")) - { - event.setBuyPrice(0); - } + event.setFree(true); } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskGoToWilderness.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskGoToWilderness.java index cc1792b30..6f3a5a92e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskGoToWilderness.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskGoToWilderness.java @@ -37,17 +37,6 @@ public class TaskGoToWilderness extends TutorialTask super(player, task); } - @Override - public void postDeploy() - { - if (( - ClansManager.getInstance().getClanUtility().getClaim(_player.getLocation()) == null - ) - ){ - _task.finishFor(_player); - } - } - @EventHandler(priority = EventPriority.MONITOR) public void onTerritory(final PlayerEnterTerritoryEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java index 2958c29fb..145d9eef2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java @@ -4,6 +4,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; import mineplex.game.clans.tutorials.DeployedTask; @@ -39,26 +41,26 @@ public class TaskLeaveSpawn extends TutorialTask @Override public void postDeploy() { - if (ClansManager.getInstance().getClanUtility().getClaim(_player.getLocation()) == null - || ( - ClansManager.getInstance().getClanUtility().getClaim(_player.getLocation()) != null - && !ClansManager.getInstance().getClanUtility().getClaim(_player.getLocation()).Owner.equals("Spawn") - ) - ){ + if (_player.getLocation().getY() < 100) + { _task.finishFor(_player); } } - @EventHandler(priority = EventPriority.MONITOR) - public void onTerritory(final PlayerEnterTerritoryEvent event) + @EventHandler + public void update(UpdateEvent event) { - if (!_player.equals(event.getPlayer())) + if (event.getType() != UpdateType.SEC) { return; } - if (event.getNewTerritory().contains("Spawn")) + if (checkForDeath()) { + return; + } + + if (_player.getLocation().getY() < 100){ _task.finishFor(_player); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java index 505221282..7c05ec2da 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java @@ -1,5 +1,6 @@ package mineplex.game.clans.tutorials.gettingstarted; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -7,6 +8,7 @@ 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.DeployedTask; import mineplex.game.clans.tutorials.TutorialTask; @@ -19,8 +21,8 @@ public class TaskMakingMoney extends TutorialTask _displayName = "Making Money (Farming)"; _technicalName = "ImAFarmer"; - _description = "We have given you a few Carrots, as a starter for your Farming career. " - + "Go to the Organic Produce Villager in one of the Shops, and sell the Carrots for Gold."; + _description = "We have given you a carrot to sell in the Organic Produce Shop. " + + "Click on the Villager, and {Right-Click} the carrot to sell your carrots in exchange for Gold."; } @Override @@ -31,10 +33,18 @@ public class TaskMakingMoney extends TutorialTask class Deployed extends DeployedTask { + private int _carrotsSold; + public Deployed(Player player, TutorialTask task) { super(player, task); - player.getInventory().addItem(new ItemStack(Material.CARROT_ITEM, 5)); + player.getInventory().addItem(new ItemStack(Material.CARROT_ITEM, 1)); + } + + @Override + public void postDeploy() + { + _player.teleport(new Location(Spawn.getSpawnWorld(), 25.536, 66, -316.844, -100f, 0f)); } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java index 557587308..2314722e3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java @@ -25,7 +25,7 @@ public class TaskUseAbility extends TutorialTask _technicalName = "KlassAbilityUsage"; _description = "Now that you have Equipped a Class, you can start using Abilities. " - + "Purchase an Iron Axe from the PvP Shop. (FREE) " + + "Purchase an Iron Axe from the PvP Shop. " + "Right-Click with your Iron Axe to use your Axe Ability!"; } @@ -62,13 +62,15 @@ public class TaskUseAbility extends TutorialTask { return; } - + + System.out.println(event.getDisplayName()); + if (!event.getMaterial().equals(Material.IRON_AXE)) { return; } - if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "iboughtthis" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) + if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tutorialboughtought" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) { event.setBuyPrice(0); event.setSellPrice(0); @@ -99,7 +101,7 @@ public class TaskUseAbility extends TutorialTask public void run(Boolean data) { } - }, event.getPlayer(), "iboughtthis" + event.getItem().getType().name()); + }, event.getPlayer(), "tutorialboughtought" + event.getItem().getType().name()); _bought.add(event.getItem().getType()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java index 6da8fec84..e690c2d5c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -22,19 +23,23 @@ public class TutorialGettingStarted extends Tutorial { super(goldManager, taskManager, clansManager, donationManager, manager); - addTask(new TaskWelcome(this, 1)); - addTask(new TaskCreateClan(this, 2)); - addTask(new TaskViewClanDetails(this, 3)); - addTask(new TaskLeaveSpawn(this, 4)); - addTask(new TaskGoToWilderness(this, 5)); - addTask(new TaskClaim(this, 6)); - addTask(new TaskSetHome(this, 7)); - addTask(new TaskExploreShops(this, 8)); - addTask(new TaskEquipClass(this, 9)); - addTask(new TaskUseAbility(this, 10)); - addTask(new TaskCustomizeClass(this, 11)); - addTask(new TaskMakingMoney(this, 12)); - addTask(new TaskDisbandClan(this, 13)); +// addTask(new TaskWelcome(this, 1)); + + int id = 0; + addTask(new TaskCreateClan(this, ++id)); + addTask(new TaskViewClanDetails(this, ++id)); + addTask(new TaskLeaveSpawn(this, ++id)); + addTask(new TaskGoToWilderness(this, ++id)); + addTask(new TaskClaim(this, ++id)); + addTask(new TaskSetHome(this, ++id)); + addTask(new TaskExploreShops(this, ++id)); + addTask(new TaskEquipClass(this, ++id)); + addTask(new TaskUseAbility(this, ++id)); + addTask(new TaskCustomizeClass(this, ++id)); + addTask(new TaskMakingMoney(this, ++id)); + addTask(new TaskDisbandClan(this, ++id)); + + _doScoreboard = true; _ghostMode = true; @@ -52,6 +57,24 @@ public class TutorialGettingStarted extends Tutorial player.resetPlayerTime(); } + @Override + public void onBegin(final Player player) + { + UtilPlayer.message(player, " "); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cYellowB + "Getting Started"); + UtilPlayer.message(player, C.cWhite + "Welcome to Clans! " + + "In this game mode, you are able to create a Clan, invite your friends to the Clan, build a base, claim it to protect, and fight others with your new powerful Clan! " + + "You can also join a friend's Clan if they invite you to it! " + + "When you finish the tutorial, you will be awarded " + C.cAqua + "30,000 Gold"); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + } + + @EventHandler(priority = EventPriority.MONITOR) public void onUpdate(final UpdateEvent event) { From 8dca384d35b28022c70c43cd7e1a0fd50835e7af Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sun, 29 Nov 2015 02:31:14 +0000 Subject: [PATCH 09/16] force join command --- .../mineplex/game/clans/clans/commands/ClansCommand.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 434a1729a..f310656bf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -111,12 +111,12 @@ public class ClansCommand extends CommandBase else if (args[0].equalsIgnoreCase("territory") || args[0].equalsIgnoreCase("t")) infoTerritory(caller, args); - + else if (args[0].equalsIgnoreCase("forcejoin")) + if (args.length == 2) + forceJoinClan(caller, args[1]); else if (args[0].equalsIgnoreCase("who") || args[0].equalsIgnoreCase("w")) { - if (args.length > 2 && args[2].equals("join")) - forceJoinClan(caller, args[1]); - else if (args.length == 2) + if (args.length == 2) infoClan(caller, args[1]); else infoClan(caller, null); From dc5aec33b4d961d27b247f58aa356366402d1d67 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sun, 29 Nov 2015 02:37:20 +0000 Subject: [PATCH 10/16] tutorial ending message --- .../src/mineplex/game/clans/tutorials/Tutorial.java | 1 - .../gettingstarted/TutorialGettingStarted.java | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java index 66568e0ca..b1df068e3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java @@ -225,7 +225,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener _inTutorial.remove(player.getName()); UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, Color.LIME, false, false, new Vector(0, 0, 0), 1); - UtilPlayer.message(player, F.main("Tutorials", "You have completed the " + F.elem(_displayName + " Tutorial") + ".")); onFinished(player); if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName))) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java index e690c2d5c..c05b976ef 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java @@ -14,6 +14,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.economy.GoldManager; +import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.tutorials.Tutorial; import mineplex.game.clans.tutorials.TutorialManager; @@ -53,8 +54,15 @@ public class TutorialGettingStarted extends Tutorial @Override public void onFinished(final Player player) { - UtilPlayer.message(player, F.main("Tutorials", "You are now ready to play, welcome to the game.")); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + UtilPlayer.message(player, C.cYellowB + "CONGRATULATIONS"); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cWhite + "You have completed the CLANS basic tutorial and have been awarded {30,000 Gold}."); + UtilPlayer.message(player, C.cWhite + "You can now begin your adventure but do take a moment to read the signs around spawn for more information."); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + player.resetPlayerTime(); + player.teleport(Spawn.getEastSpawn()); } @Override From d7658f3838093aa3cba7cbe19821f0127da22e73 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sun, 29 Nov 2015 02:39:09 +0000 Subject: [PATCH 11/16] fixed stuck manager taking 0 seconds --- .../src/mineplex/game/clans/clans/stuck/StuckManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/StuckManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/StuckManager.java index 7300f79e1..4dd767615 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/StuckManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/StuckManager.java @@ -19,7 +19,7 @@ import mineplex.game.clans.spawn.Spawn; public class StuckManager extends MiniClientPlugin { - public static final long UNSTICK_WAIT_TIME = UtilTime.convert(0, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + public static final long UNSTICK_WAIT_TIME = UtilTime.convert(35, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); public StuckManager(ClansManager clans) { From 392ab601c279804f11b289f002d28cbab058c816 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sun, 29 Nov 2015 02:43:12 +0000 Subject: [PATCH 12/16] tutorial tasks reset --- .../src/mineplex/game/clans/tutorials/Tutorial.java | 6 +++--- .../game/clans/tutorials/gettingstarted/TaskEquipClass.java | 4 ++-- .../game/clans/tutorials/gettingstarted/TaskUseAbility.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java index b1df068e3..a771c7b75 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java @@ -48,9 +48,9 @@ import mineplex.game.clans.economy.GoldManager; */ public abstract class Tutorial implements ScoreboardElement, Listener { - public static String TASK_COMPLETE_TASK = "tutorialboughtought%sTask%s"; - public static String TUTORIAL_COMPLETE_TASK = "tutorialboughtought%sDone"; //do not change - public static String SKIPPED_TASK = "tutorialboughtought%sSkip"; + public static String TASK_COMPLETE_TASK = "TuToRialEE%sTask%s"; + public static String TUTORIAL_COMPLETE_TASK = "TuToRialEE%sDone"; //do not change + public static String SKIPPED_TASK = "TuToRialEE%sSkip"; protected final TutorialManager _manager; protected final GoldManager _goldManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java index fa8cc3ee7..85aba2261 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java @@ -78,7 +78,7 @@ public class TaskEquipClass extends TutorialTask return; } - if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tutorialboughtought" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) + if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "TuToRialEE" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) { event.setBuyPrice(0); event.setSellPrice(0); @@ -109,7 +109,7 @@ public class TaskEquipClass extends TutorialTask public void run(Boolean data) { } - }, event.getPlayer(), "tutorialboughtought" + event.getItem().getType().name()); + }, event.getPlayer(), "TuToRialEE" + event.getItem().getType().name()); _bought.add(event.getItem().getType()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java index 2314722e3..040b34b15 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java @@ -70,7 +70,7 @@ public class TaskUseAbility extends TutorialTask return; } - if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tutorialboughtought" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) + if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "TuToRialEE" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) { event.setBuyPrice(0); event.setSellPrice(0); @@ -101,7 +101,7 @@ public class TaskUseAbility extends TutorialTask public void run(Boolean data) { } - }, event.getPlayer(), "tutorialboughtought" + event.getItem().getType().name()); + }, event.getPlayer(), "TuToRialEE" + event.getItem().getType().name()); _bought.add(event.getItem().getType()); } } From 84303234fddd9685dff9636ba26f0bb25e158b5a Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sun, 29 Nov 2015 02:48:03 +0000 Subject: [PATCH 13/16] fixed task 2 --- .../src/mineplex/game/clans/clans/commands/ClansCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index f310656bf..1c176413e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -116,7 +116,7 @@ public class ClansCommand extends CommandBase forceJoinClan(caller, args[1]); else if (args[0].equalsIgnoreCase("who") || args[0].equalsIgnoreCase("w")) { - if (args.length == 2) + if (args.length > 1) infoClan(caller, args[1]); else infoClan(caller, null); From a9afe1f0688b8868ecad737b81e73940a6821ea1 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sun, 29 Nov 2015 02:54:40 +0000 Subject: [PATCH 14/16] added self clan create/delete messages --- .../src/mineplex/game/clans/clans/ClansUtility.java | 3 +++ .../src/mineplex/game/clans/clans/commands/ClansCommand.java | 3 +++ .../game/clans/tutorials/gettingstarted/TaskEquipClass.java | 4 ++-- .../game/clans/tutorials/gettingstarted/TaskUseAbility.java | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index d1705911d..8625d5b62 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -674,6 +674,9 @@ public class ClansUtility if (!data) { UtilPlayer.message(caller, F.main("Clans", "There was an error processing your request. Try again later")); + }else + { + UtilPlayer.message(caller, F.main("Clans", "You disbanded your Clan.")); } } }); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 1c176413e..13a140376 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -276,6 +276,9 @@ public class ClansCommand extends CommandBase { // Hopefully shouldn't happen! UtilPlayer.message(caller, F.main("Clans", "There was an error creating the clan. Please try again")); + }else + { + UtilPlayer.message(caller, F.main("Clans", "You created Clan " + C.cYellow + data.getName() + C.cGray + ".")); } } }); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java index 85aba2261..bcb982621 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java @@ -78,7 +78,7 @@ public class TaskEquipClass extends TutorialTask return; } - if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "TuToRialEE" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) + if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) { event.setBuyPrice(0); event.setSellPrice(0); @@ -109,7 +109,7 @@ public class TaskEquipClass extends TutorialTask public void run(Boolean data) { } - }, event.getPlayer(), "TuToRialEE" + event.getItem().getType().name()); + }, event.getPlayer(), "tuttoooooe" + event.getItem().getType().name()); _bought.add(event.getItem().getType()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java index 040b34b15..53733071d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java @@ -70,7 +70,7 @@ public class TaskUseAbility extends TutorialTask return; } - if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "TuToRialEE" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) + if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) { event.setBuyPrice(0); event.setSellPrice(0); @@ -101,7 +101,7 @@ public class TaskUseAbility extends TutorialTask public void run(Boolean data) { } - }, event.getPlayer(), "TuToRialEE" + event.getItem().getType().name()); + }, event.getPlayer(), "tuttoooooe" + event.getItem().getType().name()); _bought.add(event.getItem().getType()); } } From c870d99e0e6de087a0df16075b0d89a03a6209f8 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sun, 29 Nov 2015 02:55:45 +0000 Subject: [PATCH 15/16] teleport stuff --- .../src/mineplex/game/clans/clans/commands/ClansCommand.java | 3 ++- .../game/clans/tutorials/gettingstarted/TaskEquipClass.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 13a140376..865bb364a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -276,7 +276,8 @@ public class ClansCommand extends CommandBase { // Hopefully shouldn't happen! UtilPlayer.message(caller, F.main("Clans", "There was an error creating the clan. Please try again")); - }else + } + else { UtilPlayer.message(caller, F.main("Clans", "You created Clan " + C.cYellow + data.getName() + C.cGray + ".")); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java index bcb982621..4ea5a6e66 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java @@ -51,7 +51,7 @@ public class TaskEquipClass extends TutorialTask @Override public void postDeploy() { - _player.teleport(new Location(Spawn.getSpawnWorld(), 19.536, 66, -305.844, -100f, 0f)); + _player.teleport(new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f)); } @EventHandler From b88a842f1cb06a819d22ff58c82c49894adc29f5 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sun, 29 Nov 2015 03:22:52 +0000 Subject: [PATCH 16/16] stuff --- .../clans/clans/commands/ClansCommand.java | 12 +++------ .../clans/commands/RestartTutCommand.java | 25 +++++++++++++++++++ .../game/clans/tutorials/Tutorial.java | 6 ++--- .../game/clans/tutorials/TutorialManager.java | 4 ++- .../gettingstarted/TaskCreateClan.java | 3 +-- 5 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 865bb364a..19dd24bd1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -16,16 +16,14 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.recharge.Recharge; import mineplex.core.common.util.UtilWorld; -import mineplex.game.clans.Clans; +import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanRole; +import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansBlacklist; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.clans.ClientClan; -import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.game.clans.tutorials.TutorialManager; import net.minecraft.server.v1_8_R3.EnumDirection; @@ -111,9 +109,7 @@ public class ClansCommand extends CommandBase else if (args[0].equalsIgnoreCase("territory") || args[0].equalsIgnoreCase("t")) infoTerritory(caller, args); - else if (args[0].equalsIgnoreCase("forcejoin")) - if (args.length == 2) - forceJoinClan(caller, args[1]); + else if (args[0].equalsIgnoreCase("who") || args[0].equalsIgnoreCase("w")) { if (args.length > 1) @@ -848,7 +844,7 @@ public class ClansCommand extends CommandBase } public void infoClan(Player caller, String search) - { + {System.out.println(search); if (search == null) { UtilPlayer.message(caller, F.main("Clans", "You did not input a search parameter.")); 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 new file mode 100644 index 000000000..63dce8c34 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java @@ -0,0 +1,25 @@ +package mineplex.game.clans.clans.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.task.TaskManager; +import mineplex.game.clans.tutorials.TutorialManager; +import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted; + +public class RestartTutCommand extends CommandBase +{ + public RestartTutCommand(TutorialManager plugin) + { + super(plugin, Rank.ALL, "rst", "rstut"); + } + + @Override + public void Execute(Player caller, String[] args) + { + TaskManager.Instance.Get(caller).TasksCompleted.clear(); + TutorialManager.Instance.cancelTutorial(caller); + TutorialManager.Instance.startTutorial(TutorialGettingStarted.class, caller); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java index a771c7b75..131401037 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java @@ -48,9 +48,9 @@ import mineplex.game.clans.economy.GoldManager; */ public abstract class Tutorial implements ScoreboardElement, Listener { - public static String TASK_COMPLETE_TASK = "TuToRialEE%sTask%s"; - public static String TUTORIAL_COMPLETE_TASK = "TuToRialEE%sDone"; //do not change - public static String SKIPPED_TASK = "TuToRialEE%sSkip"; + public static String TASK_COMPLETE_TASK = "tttatatta%sTask%s"; + public static String TUTORIAL_COMPLETE_TASK = "tatatatatat%sDone"; //do not change + public static String SKIPPED_TASK = "tatatatata%sSkip"; protected final TutorialManager _manager; protected final GoldManager _goldManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java index 948ed4705..ad4dc21eb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java @@ -15,6 +15,7 @@ import mineplex.core.donation.DonationManager; import mineplex.core.preferences.PreferencesManager; import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.commands.RestartTutCommand; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand; import mineplex.game.clans.tutorials.commands.SkipTutorialCommand; @@ -44,6 +45,7 @@ public class TutorialManager extends MiniPlugin { addCommand(new SkipTutorialCommand(this)); addCommand(new DoSkipTutorialCommand(this)); + addCommand(new RestartTutCommand(this)); } public boolean startTutorial(final Class tutorial, final Player player) @@ -75,9 +77,9 @@ public class TutorialManager extends MiniPlugin { getTutorial(player).cancelFor(player); - _playerTutorials.remove(player.getName()); UtilPlayer.message(player, F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); + _playerTutorials.remove(player.getName()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java index 1ddf72a28..c8b3292ad 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java @@ -17,8 +17,7 @@ public class TaskCreateClan extends TutorialTask _displayName = "Create a Clan"; _technicalName = "ClanCreation"; - _description = "Before beginning, use the {/c create } command to start up your own Clan! " - + "Alternatively, you can join a friend's Clan, if they have invited you, instead of making your own."; + _description = "Before beginning, use the {/c create } command to start up your own Clan! "; } @Override