From be727e6e26afd5a3d1845fd9685f4f5c140fc237 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sun, 29 Nov 2015 19:46:08 +0000 Subject: [PATCH 01/23] fixed deployed tasks not being deregistered as Listeners after being adding to Cull --- .../src/mineplex/game/clans/tutorials/DeployedTask.java | 2 ++ .../src/mineplex/game/clans/tutorials/TutorialTask.java | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) 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 02d6a46c9..a75f6778c 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 @@ -1,6 +1,7 @@ package mineplex.game.clans.tutorials; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; public class DeployedTask implements Listener @@ -38,6 +39,7 @@ public class DeployedTask implements Listener { _dead = true; _player = null; + HandlerList.unregisterAll(this); } public void onFinish() { 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 8c609b160..2806981ae 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 @@ -177,7 +177,6 @@ public class TutorialTask implements Listener DeployedTask task = iterator.next(); task.kill(); - HandlerList.unregisterAll(task); iterator.remove(); } } From 8026ad891d6976597da00df87ed7860996914da0 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sun, 29 Nov 2015 21:09:18 +0000 Subject: [PATCH 02/23] fixed king of the hill --- .../game/clans/clans/worldevent/kinghill/HillData.java | 2 +- .../game/clans/clans/worldevent/kinghill/KingHill.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/HillData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/HillData.java index ecd2c28c8..7ed32b8b4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/HillData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/HillData.java @@ -41,7 +41,7 @@ public class HillData public boolean isOnHill(Location location, Location eventLocation) { - return location.getWorld().equals(eventLocation.getWorld()) && UtilMath.offset(location, eventLocation) <= 36; + return location.getWorld().equals(eventLocation.getWorld()) && UtilMath.offset(location, eventLocation.clone().add(0, 12, 0)) <= 7.5; } public Location getHillCenter(Location eventLocation) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java index f7829f999..dfe1d6d27 100755 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java @@ -114,10 +114,11 @@ public class KingHill extends WorldEvent for (Player player : UtilServer.getPlayers()) { + System.out.println(getCenterLocation()); if (_hill.isOnHill(player.getLocation(), getCenterLocation())) { ClanInfo playerClan = _clansManager.getClan(player); - if (playerClan != null) + if (playerClan != null && !playerClan.equals(lastClan)) { clanCount++; lastClan = playerClan; From f528531b82ff33d9fd91635564a6f12dfcb99f17 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Mon, 30 Nov 2015 07:06:36 +0000 Subject: [PATCH 03/23] removed some testing stuff --- .../src/mineplex/game/clans/clans/ClansGame.java | 10 ---------- .../src/mineplex/game/clans/clans/ClansUtility.java | 3 ++- .../game/clans/clans/commands/RegionsCommand.java | 2 +- .../game/clans/items/commands/GearCommand.java | 2 +- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index 4c53f5dfc..c0552c45e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -494,16 +494,6 @@ public class ClansGame extends MiniPlugin } } - @EventHandler - public void TURTLEZ(PlayerCommandPreprocessEvent event) - { - if (event.getPlayer().getName().equals("SamitoD") && event.getMessage().equals("/gear")) - { - UtilPlayer.message(event.getPlayer(), "UR SPECIAL!!!"); - _clans.getGearManager().openShop(event.getPlayer()); - } - } - @EventHandler public void Quit(PlayerQuitEvent event) { 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 8625d5b62..4031496a1 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,9 +674,10 @@ 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.")); + //(caller, F.main("Clans", "You disbanded your Clan.")); } } }); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RegionsCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RegionsCommand.java index 16d2c14bf..573c5a177 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RegionsCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RegionsCommand.java @@ -16,7 +16,7 @@ public class RegionsCommand extends CommandBase public RegionsCommand(ClansManager plugin) { - super(plugin, Rank.ADMIN, new Rank[]{Rank.JNR_DEV},"region-reset"); + super(plugin, Rank.ADMIN,"region-reset"); _manager = plugin; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/GearCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/GearCommand.java index 9593b2666..8309d5fc5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/GearCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/GearCommand.java @@ -12,7 +12,7 @@ public class GearCommand extends CommandBase public GearCommand(GearManager plugin) { - super(plugin, Rank.ADMIN, new Rank[]{Rank.JNR_DEV}, "gear", "custom-gear"); + super(plugin, Rank.ADMIN, "gear", "custom-gear"); _gearManager = plugin; } From 0862cfce720a734b05bf6598f5329cd25960a1c7 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Mon, 30 Nov 2015 07:26:02 +0000 Subject: [PATCH 04/23] fixed doors getting placed in spawn and shops --- .../mineplex/game/clans/clans/ClansGame.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index c0552c45e..9db1f9d2e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -459,6 +459,27 @@ public class ClansGame extends MiniPlugin } } + @EventHandler(priority = EventPriority.LOWEST) + public void doorPlaced(BlockPlaceEvent event) + { + if (event.getBlockPlaced().getType().equals(Material.ACACIA_DOOR) + || event.getBlockPlaced().getType().equals(Material.WOODEN_DOOR) + || event.getBlockPlaced().getType().equals(Material.BIRCH_DOOR) + || event.getBlockPlaced().getType().equals(Material.DARK_OAK_DOOR) + || event.getBlockPlaced().getType().equals(Material.JUNGLE_DOOR) + || event.getBlockPlaced().getType().equals(Material.SPRUCE_DOOR) + || event.getBlockPlaced().getType().equals(Material.WOOD_DOOR) + || event.getBlockPlaced().getType().equals(Material.IRON_DOOR_BLOCK)) + { + ClanTerritory claim = _clans.getClanUtility().getClaim(event.getBlockPlaced().getLocation()); + + if (claim != null && (claim.Owner.equals("Spawn") || claim.Owner.equals("Shops"))) + { + event.setCancelled(true); + } + } + } + @EventHandler(priority = EventPriority.LOWEST) public void Piston(BlockPistonExtendEvent event) { From 813e7ee789ed4de0163b6e220985f6f0e814e309 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Mon, 30 Nov 2015 19:08:16 +0000 Subject: [PATCH 05/23] made it so that no messages are shown when in tutorial --- .../game/clans/clans/ClansManager.java | 2 +- .../game/clans/tutorials/Tutorial.java | 33 ++++++++++++++-- .../game/clans/tutorials/TutorialManager.java | 9 +++-- .../game/clans/tutorials/TutorialTask.java | 18 ++++----- .../TutorialGettingStarted.java | 39 +++++++++---------- 5 files changed, 62 insertions(+), 39 deletions(-) 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 d9d7233e4..1ac1d7d4d 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 @@ -227,7 +227,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati TaskManager taskManager = new TaskManager(plugin, _clientManager, webServerAddress); - _tutorialManager = new TutorialManager(plugin, _goldManager, taskManager, donationManager, preferencesManager, this); + _tutorialManager = new TutorialManager(plugin, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler); ClanTips = new ClanTips(plugin, this, preferencesManager); 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 afbaecaf6..ac645422f 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 @@ -30,6 +30,9 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.donation.DonationManager; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.packethandler.PacketInfo; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.scoreboard.elements.ScoreboardElement; import mineplex.core.task.TaskManager; @@ -38,6 +41,7 @@ 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; +import net.minecraft.server.v1_8_R3.PacketPlayOutChat; /** * @@ -53,6 +57,8 @@ public abstract class Tutorial implements ScoreboardElement, Listener public static String TUTORIAL_REWARD_TASK = "tatatatatat%sRewardGiven"; //do not change public static String SKIPPED_TASK = "tatatatata%sSkip"; + public static String ALLOWED_MESSAGE_CODE = C.cPurpleB . C.cGold . C.cYellowB . C.cBlueB . C.cDBlueB . C.cRed . C.cDRedB . C.cWhite . C.Reset; + protected final TutorialManager _manager; protected final GoldManager _goldManager; protected final ClansManager _clansManager; @@ -75,7 +81,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener protected int _gemReward = -1; protected int _coinReward = -1; - public Tutorial(final GoldManager goldManager, final TaskManager taskManager, final ClansManager clansManager, final DonationManager donationManager, final TutorialManager manager) + public Tutorial(final GoldManager goldManager, final TaskManager taskManager, final ClansManager clansManager, final DonationManager donationManager, final TutorialManager manager, final PacketHandler packetHandler) { _clansManager = clansManager; _goldManager = goldManager; @@ -86,6 +92,19 @@ public abstract class Tutorial implements ScoreboardElement, Listener _inTutorial = new LinkedHashMap<>(); _nameToTask = new LinkedHashMap<>(); + packetHandler.addPacketHandler(new IPacketHandler(){ + public void handle(PacketInfo packet) + { + if (packet.getPacket() instanceof PacketPlayOutChat) + { + if (!((PacketPlayOutChat) packet.getPacket()).a.c().startsWith(ALLOWED_MESSAGE_CODE)) + { + packet.setCancelled(true); + } + } + } + }, PacketPlayOutChat.class); + _manager.getPluginManager().registerEvents(this, _manager.getPlugin()); } @@ -238,7 +257,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener if (_goldReward != -1) { _goldManager.addGold(player, _goldReward); - UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + ".")); + msg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + ".")); } if (_gemReward != -1) @@ -246,7 +265,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener _donationManager.RewardGems(new Callback() { public void run(Boolean data) { - UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gems") + ".")); + msg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gems") + ".")); } }, "Clans", player.getName(), player.getUniqueId(), _gemReward); } @@ -256,7 +275,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener _donationManager.RewardCoins(new Callback() { public void run(Boolean data) { - UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_coinReward + " Coins") + ".")); + msg(player, F.main("Tutorials", "You have been awarded " + F.elem(_coinReward + " Coins") + ".")); } }, "Clans", player.getName(), _clansManager.getClientManager().getAccountId(player), _coinReward); } @@ -373,6 +392,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener public void skip(final Player player) { new JsonMessage( + ALLOWED_MESSAGE_CODE . F.main( "Tutorial", "Are you sure you want to skip the tutorial? We " @@ -494,4 +514,9 @@ public abstract class Tutorial implements ScoreboardElement, Listener _inTutorial.remove(player.getName()); } + + protected void msg(Player player, String msg) + { + UtilPlayer.message(player, ALLOWED_MESSAGE_CODE . msg); + } } 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 0ccf063ae..3634c37ce 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 @@ -12,6 +12,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; +import mineplex.core.packethandler.PacketHandler; import mineplex.core.preferences.PreferencesManager; import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.ClansManager; @@ -30,7 +31,7 @@ public class TutorialManager extends MiniPlugin private final TaskManager _taskManager; - public TutorialManager(final JavaPlugin plugin, final GoldManager goldManager, final TaskManager taskManager, final DonationManager donationManager, final PreferencesManager preferencesManager, final ClansManager clansManager) + public TutorialManager(final JavaPlugin plugin, final GoldManager goldManager, final TaskManager taskManager, final DonationManager donationManager, final PreferencesManager preferencesManager, final ClansManager clansManager, final PacketHandler packetHandler) { super("Tutorials", plugin); @@ -38,7 +39,7 @@ public class TutorialManager extends MiniPlugin _taskManager = taskManager; - _tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, clansManager, donationManager, goldManager,taskManager)); + _tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, clansManager, donationManager, goldManager, taskManager, packetHandler)); } public void addCommands() @@ -78,7 +79,7 @@ public class TutorialManager extends MiniPlugin getTutorial(player).cancelFor(player); - UtilPlayer.message(player, F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); + UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); _playerTutorials.remove(player.getName()); } } @@ -95,7 +96,7 @@ public class TutorialManager extends MiniPlugin { if (isInTutorial(player)) { - UtilPlayer.message(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); + UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); getTutorial(player).doSkip(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 2806981ae..30d65beba 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 @@ -85,15 +85,15 @@ public class TutorialTask implements Listener if (System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime()) { - 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 + "---------------------------------------------"); + UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " "); + UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " "); + UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " "); + UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + C.cDGreenB + C.Strike + "---------------------------------------------"); + UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " "); + UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + C.cYellowB + "Part " + _id + ": " + _displayName); + UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + C.cWhite + _description.replace("{", C.cAqua).replace("}", C.cWhite)); + UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " "); + UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + C.cDGreenB + C.Strike + "---------------------------------------------"); client.LastDescriptionSentTime = System.currentTimeMillis(); } } 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 8a0e797e8..1e0b5a9a4 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 @@ -5,10 +5,9 @@ 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; import mineplex.core.donation.DonationManager; +import mineplex.core.packethandler.PacketHandler; import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -20,9 +19,9 @@ 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) + public TutorialGettingStarted(final TutorialManager manager, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager, final PacketHandler packetHandler) { - super(goldManager, taskManager, clansManager, donationManager, manager); + super(goldManager, taskManager, clansManager, donationManager, manager, packetHandler); // addTask(new TaskWelcome(this, 1)); @@ -40,8 +39,6 @@ public class TutorialGettingStarted extends Tutorial addTask(new TaskMakingMoney(this, ++id)); addTask(new TaskDisbandClan(this, ++id)); - - _doScoreboard = true; _ghostMode = true; _startOnJoin = true; @@ -54,12 +51,12 @@ public class TutorialGettingStarted extends Tutorial @Override public void onFinished(final Player player) { - 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 " + C.cAqua + "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 + "---------------------------------------------"); + msg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + msg(player, C.cYellowB + "CONGRATULATIONS"); + msg(player, " "); + msg(player, C.cWhite + "You have completed the Clans basic tutorial and have been awarded " + C.cAqua + "30,000 Gold"); + msg(player, C.cWhite + "You can now begin your adventure, but do take a moment to read the signs around spawn for more information!"); + msg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); player.resetPlayerTime(); player.teleport(Spawn.getEastSpawn()); @@ -68,17 +65,17 @@ public class TutorialGettingStarted extends Tutorial @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! " + msg(player, " "); + msg(player, " "); + msg(player, " "); + msg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + msg(player, " "); + msg(player, C.cYellowB + "Getting Started"); + msg(player, C.cWhite + "Welcome to Clans! " + "In this game mode you are able to create a clan, invite your friends to play with you, build a base, and wage war against others! " + "When you finish the tutorial, you will be awarded " + C.cAqua + "30,000 Gold"); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + msg(player, " "); + msg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); } From 6eb44ed87b8195f20ef8b4657318b4b7dc40eae6 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Mon, 30 Nov 2015 19:11:18 +0000 Subject: [PATCH 06/23] whoops.. this isn't php hehe --- .../src/mineplex/game/clans/tutorials/Tutorial.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 ac645422f..2ac9611cd 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 @@ -57,7 +57,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener public static String TUTORIAL_REWARD_TASK = "tatatatatat%sRewardGiven"; //do not change public static String SKIPPED_TASK = "tatatatata%sSkip"; - public static String ALLOWED_MESSAGE_CODE = C.cPurpleB . C.cGold . C.cYellowB . C.cBlueB . C.cDBlueB . C.cRed . C.cDRedB . C.cWhite . C.Reset; + public static String ALLOWED_MESSAGE_CODE = C.cPurpleB + C.cGold + C.cYellowB + C.cBlueB + C.cDBlueB + C.cRed + C.cDRedB + C.cWhite + C.Reset; protected final TutorialManager _manager; protected final GoldManager _goldManager; @@ -92,7 +92,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener _inTutorial = new LinkedHashMap<>(); _nameToTask = new LinkedHashMap<>(); - packetHandler.addPacketHandler(new IPacketHandler(){ + packetHandler.addPacketHandler(new IPacketHandler() { public void handle(PacketInfo packet) { if (packet.getPacket() instanceof PacketPlayOutChat) @@ -392,7 +392,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener public void skip(final Player player) { new JsonMessage( - ALLOWED_MESSAGE_CODE . + ALLOWED_MESSAGE_CODE + F.main( "Tutorial", "Are you sure you want to skip the tutorial? We " @@ -517,6 +517,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener protected void msg(Player player, String msg) { - UtilPlayer.message(player, ALLOWED_MESSAGE_CODE . msg); + UtilPlayer.message(player, ALLOWED_MESSAGE_CODE + msg); } } From 1a851679c463253b9f6f9de289c9ae08aa0f4a69 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Mon, 30 Nov 2015 20:40:30 +0000 Subject: [PATCH 07/23] made it so players cannot see chat whilst in tutorial --- .../clans/commands/RestartTutCommand.java | 2 +- .../game/clans/tutorials/Tutorial.java | 34 ++++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java index d8112e13a..2b599831f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java @@ -15,7 +15,7 @@ public class RestartTutCommand extends CommandBase { public RestartTutCommand(TutorialManager plugin) { - super(plugin, Rank.ALL, "rst", "rstut"); + super(plugin, Rank.ALL, "rst", "rstut", "reset"); } @Override 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 2ac9611cd..ca93876c0 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 @@ -41,6 +41,8 @@ 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; +import net.md_5.bungee.api.chat.BaseComponent; +import net.minecraft.server.v1_8_R3.IChatBaseComponent; import net.minecraft.server.v1_8_R3.PacketPlayOutChat; /** @@ -57,7 +59,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener public static String TUTORIAL_REWARD_TASK = "tatatatatat%sRewardGiven"; //do not change public static String SKIPPED_TASK = "tatatatata%sSkip"; - public static String ALLOWED_MESSAGE_CODE = C.cPurpleB + C.cGold + C.cYellowB + C.cBlueB + C.cDBlueB + C.cRed + C.cDRedB + C.cWhite + C.Reset; + public static String ALLOWED_MESSAGE_CODE = "-TUTORIALMESSAGE-"; protected final TutorialManager _manager; protected final GoldManager _goldManager; @@ -95,11 +97,25 @@ public abstract class Tutorial implements ScoreboardElement, Listener packetHandler.addPacketHandler(new IPacketHandler() { public void handle(PacketInfo packet) { + if (!isInTutorial(packet.getPlayer())) + { + return; + } + if (packet.getPacket() instanceof PacketPlayOutChat) { - if (!((PacketPlayOutChat) packet.getPacket()).a.c().startsWith(ALLOWED_MESSAGE_CODE)) + PacketPlayOutChat chat = (PacketPlayOutChat) packet.getPacket(); + + if (chat.b == 1) { - packet.setCancelled(true); + if (!chat.a.a().get(0).c().equals(ALLOWED_MESSAGE_CODE)) + { + packet.setCancelled(true); + } + else + { + chat.a.a().remove(0); + } } } } @@ -170,6 +186,8 @@ public abstract class Tutorial implements ScoreboardElement, Listener { get(player).LastDescriptionSentTime = 0; get(player).CurrentTask.visibleFinish(player); + + // Cycle to next task, or null if last task. get(player).CurrentTask = task.equals(_tasks.get(_tasks.size())) ? null : _tasks.get(task.getID() + 1); if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName()))) @@ -178,6 +196,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener { public void run(final Boolean completed) { + // If last task, end tutorial. if (task.equals(_tasks.get(_tasks.size()))) { finishFor(player); @@ -244,9 +263,13 @@ public abstract class Tutorial implements ScoreboardElement, Listener { _inTutorial.remove(player.getName()); + // Fireworks UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, Color.LIME, false, false, new Vector(0, 0, 0), 1); + + // Custom Finish Method (usually messages) onFinished(player); - + + // Do Reward if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_REWARD_TASK, _technicalName))) { _taskManager.completedTask(new Callback() @@ -283,7 +306,8 @@ public abstract class Tutorial implements ScoreboardElement, Listener }, player, String.format(TUTORIAL_REWARD_TASK, _technicalName)); } - + + // Sets the tutorial as complete in the TaskManager and effects. if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName))) { _taskManager.completedTask(new Callback() From d32e6fdb969e38bac374152cec581f541cfb0f4d Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Tue, 1 Dec 2015 11:28:14 +0000 Subject: [PATCH 08/23] Got rid of deployed tasks. using different system now. (untested) --- .../core/common/util/NautArrayList.java | 132 ++++++++++++++ .../mineplex/core/common/util/UtilItem.java | 2 +- .../game/clans/tutorials/DeployedTask.java | 48 ----- .../game/clans/tutorials/Tutorial.java | 10 +- .../game/clans/tutorials/TutorialTask.java | 88 +++------- .../tutorials/gettingstarted/TaskClaim.java | 41 ++--- .../gettingstarted/TaskCreateClan.java | 26 +-- .../gettingstarted/TaskCustomizeClass.java | 40 ++--- .../gettingstarted/TaskDisbandClan.java | 26 +-- .../gettingstarted/TaskEquipClass.java | 143 +++++++-------- .../gettingstarted/TaskExploreShops.java | 72 ++++---- .../gettingstarted/TaskGoToWilderness.java | 30 +--- .../gettingstarted/TaskLeaveSpawn.java | 64 +++---- .../gettingstarted/TaskMakingMoney.java | 47 ++--- .../tutorials/gettingstarted/TaskSetHome.java | 43 ++--- .../gettingstarted/TaskUseAbility.java | 165 +++++++++--------- .../gettingstarted/TaskViewClanDetails.java | 29 +-- .../game/classcombat/Class/ClientClass.java | 2 +- .../Class/event/ClassEquipEvent.java | 11 +- 19 files changed, 463 insertions(+), 556 deletions(-) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautArrayList.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/DeployedTask.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautArrayList.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautArrayList.java new file mode 100644 index 000000000..29235ec86 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautArrayList.java @@ -0,0 +1,132 @@ +package mineplex.core.common.util; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +public class NautArrayList +{ + private ArrayList _wrappedArrayList = new ArrayList(); + + public boolean add(Elem elem) + { + return _wrappedArrayList.add(elem); + } + + public void add(int index, Elem elem) + { + _wrappedArrayList.add(index, elem); + } + + public boolean addAll(Collection elements) + { + return _wrappedArrayList.addAll(elements); + } + + public boolean addAll(int index, Collection elements) + { + return _wrappedArrayList.addAll(index, elements); + } + + public void clear() + { + _wrappedArrayList.clear(); + } + + public boolean contains(Elem elem) + { + return _wrappedArrayList.contains(elem); + } + + public boolean containsAll(Collection elements) + { + return _wrappedArrayList.containsAll(elements); + } + + public Elem get(int index) + { + return _wrappedArrayList.get(index); + } + + public boolean equals(Object o) + { + return _wrappedArrayList.equals(o); + } + + public int hashCode() + { + return _wrappedArrayList.hashCode(); + } + + public int indexOf(Elem elem) + { + return _wrappedArrayList.indexOf(elem); + } + + public boolean isEmpty() + { + return _wrappedArrayList.isEmpty(); + } + + public Iterator iterator() + { + return _wrappedArrayList.iterator(); + } + + public int lastIndexOf(Elem elem) + { + return _wrappedArrayList.lastIndexOf(elem); + } + + public ListIterator listIterator() + { + return _wrappedArrayList.listIterator(); + } + + public ListIterator listIterator(int index) + { + return _wrappedArrayList.listIterator(index); + } + + public Elem remove(int index) + { + return _wrappedArrayList.remove(index); + } + + public boolean remove(Elem element) + { + return _wrappedArrayList.remove(element); + } + + public boolean removeAll(Collection elements) + { + return _wrappedArrayList.removeAll(elements); + } + + public boolean retainAll(Collection elements) + { + return _wrappedArrayList.retainAll(elements); + } + + public Elem set(int index, Elem element) + { + return _wrappedArrayList.set(index, element); + } + + public int size() + { + return _wrappedArrayList.size(); + } + + public List subList(int begin, int end) + { + return _wrappedArrayList.subList(begin, end); + } + + public Object[] toArray() + { + return _wrappedArrayList.toArray(); + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index fab4e078b..4a0745708 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -25,8 +25,8 @@ public class UtilItem _materials.put(Material.AIR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS)); _materials.put(Material.STONE, EnumSet.of(ItemCategory.BLOCK)); - _materials.put(Material.DIRT, EnumSet.of(ItemCategory.BLOCK)); _materials.put(Material.GRASS, EnumSet.of(ItemCategory.BLOCK)); + _materials.put(Material.DIRT, EnumSet.of(ItemCategory.BLOCK)); _materials.put(Material.COBBLESTONE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.STONE)); _materials.put(Material.WOOD, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD)); _materials.put(Material.SAPLING, EnumSet.of(ItemCategory.BLOCK)); 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 deleted file mode 100644 index a75f6778c..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/DeployedTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package mineplex.game.clans.tutorials; - -import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; -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 boolean checkForDeath() - { - return _dead || _player == null; - } - - public void finish() - { - onFinish(); - _task.finishFor(_player); - } - - public void kill() - { - _dead = true; - _player = null; - HandlerList.unregisterAll(this); - } - - 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 ca93876c0..387761ed4 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 @@ -184,6 +184,11 @@ public abstract class Tutorial implements ScoreboardElement, Listener protected void finishTask(final Player player, final TutorialTask task) { + if (player == null) + { + return; + } + get(player).LastDescriptionSentTime = 0; get(player).CurrentTask.visibleFinish(player); @@ -203,11 +208,12 @@ public abstract class Tutorial implements ScoreboardElement, Listener } else { + // Start next task in 1.5 Seconds (just to give a more smooth feel to the tutorial) _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() { public void run() { - get(player).CurrentTask.deploy(player); + get(player).CurrentTask.startFor(player); } }, 10L); } @@ -358,7 +364,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener _inTutorial.put(player.getName(), new TutorialClient(player, this)); - get(player).CurrentTask.deploy(player); + get(player).CurrentTask.startFor(player); player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); 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 30d65beba..18b50d2ca 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,25 +1,16 @@ 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.NautArrayList; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; public class TutorialTask implements Listener { - private T _tutorial; + protected T _tutorial; protected long _autoCompleteTime = -1; @@ -31,10 +22,8 @@ public class TutorialTask implements Listener protected long _descriptionWaitTime = 30000; - private List _playersFinished = new ArrayList<>(); - - private Map _deployedInstances = new HashMap<>(); - private List _toCull = new ArrayList<>(); + protected NautArrayList _playersFinished = new NautArrayList<>(); + protected NautArrayList _inTask = new NautArrayList<>(); private int _id; @@ -46,32 +35,39 @@ public class TutorialTask implements Listener UtilServer.getServer().getPluginManager().registerEvents(this, _tutorial._manager.getPlugin()); } - protected DeployedTask deploy(final Player player) + protected void customStartFor(final Player player) { - DeployedTask task = customDeploy(player); - - _deployedInstances.put(player.getName(), task); - - UtilServer.getServer().getPluginManager().registerEvents(task, _tutorial._manager.getPlugin()); + } + + protected void customEndFor(final Player player) + { + } + + protected final void startFor(final Player player) + { + _inTask.add(player.getName()); trySendDescription(player); + customStartFor(player); + if (_autoCompleteTime != -1) { UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_tutorial._manager.getPlugin(), new Runnable(){ public void run() { - if (_deployedInstances.containsKey(player.getName())) + if (isDoing(player)) { finishFor(player); } } }, _autoCompleteTime); } - - task.postDeploy(); - - return task; + } + + public boolean isDoing(Player player) + { + return _inTask != null && player != null && _inTask.contains(player.getName()); } public void trySendDescription(Player player) @@ -98,19 +94,10 @@ public class TutorialTask implements Listener } } - protected DeployedTask customDeploy(final Player player) - { - 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()); + // CurrentTask will be null if player has finished tutorial + return _tutorial.get(player).CurrentTask == null || _tutorial.get(player).CurrentTask.getID() < getID(); } public String getDisplayName() @@ -140,14 +127,13 @@ public class TutorialTask implements Listener public void finishFor(Player player) { + customEndFor(player); _tutorial.finishTask(player, this); } public void visibleFinish(Player player) { - _deployedInstances.get(player.getName()).kill(); - _toCull.add(_deployedInstances.get(player.getName())); - _deployedInstances.remove(player.getName()); + _inTask.remove(player.getName()); if (_finishMessage != null) { @@ -162,29 +148,9 @@ public class TutorialTask implements Listener } } - @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(); - iterator.remove(); - } - } - public void cleanup(Player player) { - _deployedInstances.get(player.getName()).kill(); - _toCull.add(_deployedInstances.get(player.getName())); + _inTask.remove(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 9102fe525..802777151 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 @@ -1,12 +1,10 @@ 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 @@ -25,38 +23,23 @@ public class TaskClaim extends TutorialTask + "Claim some Territory now, by typing {/c claim}!"; } - @Override - public DeployedTask customDeploy(Player player) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onClansCommand(ClansCommandExecutedEvent event) { - return new Deployed(player, this); - } - - class Deployed extends DeployedTask - { - public Deployed(Player player, TutorialTask task) + if (isDoing(event.getPlayer())) { - super(player, task); + return; } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onClansCommand(ClansCommandExecutedEvent event) + if (!ClansManager.getInstance().isInClan(event.getPlayer())) { - if (!_player.equals(event.getPlayer())) - { - return; - } - - if (!ClansManager.getInstance().isInClan(event.getPlayer())) - { - return; - } - - if (event.getCommand().equals("claim")) - { - _task.finishFor(_player); - event.setCancelled(true); - } + return; + } + + if (event.getCommand().equals("claim")) + { + finishFor(event.getPlayer()); + 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 index c8b3292ad..40847ce70 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 @@ -1,11 +1,9 @@ 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 @@ -20,29 +18,15 @@ public class TaskCreateClan extends TutorialTask _description = "Before beginning, use the {/c create } command to start up your own Clan! "; } - @Override - public DeployedTask customDeploy(Player player) + @EventHandler(priority = EventPriority.MONITOR) + public void onClanCreated(ClanCreatedEvent event) { - return new Deployed(player, this); - } - - class Deployed extends DeployedTask - { - public Deployed(Player player, TutorialTask task) + if (isDoing(event.getFounder())) { - super(player, task); + return; } - @EventHandler(priority = EventPriority.MONITOR) - public void onClanCreated(ClanCreatedEvent event) - { - if (!_player.equals(event.getFounder())) - { - return; - } - - _task.finishFor(_player); - } + finishFor(event.getFounder()); } } 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 b5e290e1a..802750575 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,8 @@ package mineplex.game.clans.tutorials.gettingstarted; +import java.util.Iterator; + +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -9,7 +12,6 @@ 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; @@ -27,42 +29,28 @@ public class TaskCustomizeClass extends TutorialTask } @Override - public DeployedTask customDeploy(Player player) + public void customStartFor(Player player) { - return new Deployed(player, this); + player.teleport(new Location(Spawn.getSpawnWorld(), 6, 66, -300, -180f, 0f)); } - class Deployed extends DeployedTask + @EventHandler(priority = EventPriority.MONITOR) + public void onUpdate(final UpdateEvent event) { - public Deployed(Player player, TutorialTask task) + if (!event.getType().equals(UpdateType.SEC)) { - super(player, task); + return; } - @Override - public void postDeploy() + Iterator iterator = _inTask.iterator(); + while (iterator.hasNext()) { - _player.teleport(new Location(Spawn.getSpawnWorld(), 6, 66, -300, -180f, 0f)); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onUpdate(final UpdateEvent event) - { - if (!event.getType().equals(UpdateType.SEC)) - { - return; - } - - if (checkForDeath()) - { - return; - } - - final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(_player); + Player player = Bukkit.getPlayer(iterator.next()); + final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(player); if (clientclass != null && clientclass.GetSavingCustomBuild() != null) { - _task.finishFor(_player); + 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 index 845a2e2e6..0f21acf56 100644 --- 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 @@ -1,10 +1,8 @@ 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 @@ -21,28 +19,14 @@ public class TaskDisbandClan extends TutorialTask + "This will delete your Clan, and you'll be able to create or join a new one!"; } - @Override - public DeployedTask customDeploy(Player player) + @EventHandler + public void sell(ClanDisbandedEvent event) { - return new Deployed(player, this); - } - - class Deployed extends DeployedTask - { - public Deployed(Player player, TutorialTask task) + if (!isDoing(event.getDisbander())) { - super(player, task); + return; } - @EventHandler - public void sell(ClanDisbandedEvent event) - { - if (!_player.equals(event.getDisbander())) - { - return; - } - - _task.finishFor(_player); - } + finishFor(event.getDisbander()); } } 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 f56e3b09b..697ed3a9d 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 @@ -1,21 +1,18 @@ package mineplex.game.clans.tutorials.gettingstarted; -import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; -import org.bukkit.Location; 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.NautArrayList; +import mineplex.core.common.util.NautHashMap; 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.spawn.Spawn; -import mineplex.game.clans.tutorials.DeployedTask; import mineplex.game.clans.tutorials.TutorialTask; import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent; @@ -33,84 +30,78 @@ public class TaskEquipClass extends TutorialTask + "Then put on your armor to equip a Champion’s Class."; } - @Override - public DeployedTask customDeploy(Player player) + private NautHashMap> _bought = new NautHashMap<>(); + + @EventHandler + public void onClassEquipped(ClassEquipEvent event) { - return new Deployed(player, this); + if (!isDoing(event.getUser())) + { + return; + } + + finishFor(event.getUser()); } - class Deployed extends DeployedTask + @Override + public void customEndFor(Player player) { - private List _bought = new ArrayList<>(); - - public Deployed(Player player, TutorialTask task) + _bought.get(player.getName()).clear(); + _bought.remove(player.getName()); + } + + @Override + public void customStartFor(Player player) + { + _bought.put(player.getName(), new NautArrayList()); + } + + @EventHandler + public void button(ClansShopAddButtonEvent event) + { + if (isDoing(event.getPlayer())) { - super(player, task); + return; + } + + if (!(UtilItem.isArmor(event.getMaterial()) && UtilItem.isIronProduct(event.getMaterial()))) + { + return; } - @Override - public void postDeploy() + if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + event.getMaterial().name()) && !_bought.get(event.getPlayer().getName()).contains(event.getMaterial())) { - _player.teleport(new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f)); - } - - @EventHandler - public void onClassEquipped(ClassEquipEvent event) - { - 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(), "tuttoooooe" + 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(), "tuttoooooe" + event.getItem().getType().name()); - _bought.add(event.getItem().getType()); + event.setBuyPrice(0); + event.setSellPrice(0); } } + + @EventHandler + public void buy(final ClansPlayerBuyItemEvent event) + { + if (!isDoing(event.getPlayer())) + { + return; + } + + if (!(UtilItem.isArmor(event.getItem().getType()) && UtilItem.isIronProduct(event.getItem().getType()))) + { + return; + } + + if (event.getCost() == 0 && _bought.get(event.getPlayer().getName()).contains(event.getItem().getType())) + { + event.setCancelled(true); + return; + } + + TaskManager.Instance.completedTask(new Callback() { + @Override + public void run(Boolean data) + { + } + }, event.getPlayer(), "tuttoooooe" + event.getItem().getType().name()); + + _bought.get(event.getPlayer().getName()).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 cc332b10c..ee10b2da4 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,5 +1,8 @@ package mineplex.game.clans.tutorials.gettingstarted; +import java.util.Iterator; + +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -9,7 +12,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.EnergyPageBuildEvent; import mineplex.game.clans.spawn.Spawn; -import mineplex.game.clans.tutorials.DeployedTask; import mineplex.game.clans.tutorials.TutorialTask; public class TaskExploreShops extends TutorialTask @@ -27,61 +29,51 @@ public class TaskExploreShops extends TutorialTask } @Override - public DeployedTask customDeploy(Player player) + public void customStartFor(Player player) { - return new Deployed(player, this); + player.teleport(new Location(Spawn.getSpawnWorld(), 17, 66.5, -330, -180f, 0f)); + + ClansManager.getInstance().getClan(player).adjustEnergy(-(ClansManager.getInstance().getClan(player).getEnergyCostPerMinute() * 60)); } - class Deployed extends DeployedTask + @EventHandler + public void onItemPut(EnergyPageBuildEvent event) { - public Deployed(Player player, TutorialTask task) + if (!isDoing(event.getPlayer())) { - super(player, task); + return; } - @Override - public void postDeploy() + if (!ClansManager.getInstance().isInClan(event.getPlayer())) { - _player.teleport(new Location(Spawn.getSpawnWorld(), 17, 66.5, -330, -180f, 0f)); - - ClansManager.getInstance().getClan(_player).adjustEnergy(-(ClansManager.getInstance().getClan(_player).getEnergyCostPerMinute() * 60)); + return; } - @EventHandler - public void onItemPut(EnergyPageBuildEvent event) + if (ClansManager.getInstance().getClan(event.getPlayer()).getEnergyPurchasable() == 0) { - if (!_player.equals(event.getPlayer())) - { - return; - } - - if (!ClansManager.getInstance().isInClan(_player)) - { - return; - } - - if (ClansManager.getInstance().getClan(_player).getEnergyPurchasable() == 0) - { - _task.finishFor(_player); - return; - } - - event.setFree(true); + finishFor(event.getPlayer()); + return; } - @EventHandler - public void onUpdate(UpdateEvent event) + event.setFree(true); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TWOSEC) { - if (event.getType() != UpdateType.TWOSEC) + return; + } + + Iterator iterator = _inTask.iterator(); + while (iterator.hasNext()) + { + Player player = Bukkit.getPlayer(iterator.next()); + if (ClansManager.getInstance().getClan(player).getEnergy() == ClansManager.getInstance().getClan(player).getEnergyMax()) { - return; - } - - if (ClansManager.getInstance().getClan(_player).getEnergy() == ClansManager.getInstance().getClan(_player).getEnergyMax()) - { - _task.finishFor(_player); + 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 index d470ece41..e2b85aa1c 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 @@ -1,12 +1,9 @@ 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 @@ -24,32 +21,17 @@ public class TaskGoToWilderness extends TutorialTask + "You can zoom in/out on our map by left and right clicking!"; } - @Override - public DeployedTask customDeploy(Player player) + @EventHandler(priority = EventPriority.MONITOR) + public void onTerritory(final PlayerEnterTerritoryEvent event) { - return new Deployed(player, this); - } - - class Deployed extends DeployedTask - { - public Deployed(Player player, TutorialTask task) + if (!isDoing(event.getPlayer())) { - super(player, task); + return; } - @EventHandler(priority = EventPriority.MONITOR) - public void onTerritory(final PlayerEnterTerritoryEvent event) + if (event.getNewTerritory().contains("Wilderness")) { - if (!_player.equals(event.getPlayer())) - { - return; - } - - if (event.getNewTerritory().contains("Wilderness")) - { - _task.finishFor(_player); - } + finishFor(event.getPlayer()); } } - } 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 145d9eef2..a1fbff948 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 @@ -1,14 +1,13 @@ package mineplex.game.clans.tutorials.gettingstarted; +import java.util.Iterator; + +import org.bukkit.Bukkit; 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; import mineplex.game.clans.tutorials.TutorialTask; public class TaskLeaveSpawn extends TutorialTask @@ -26,44 +25,31 @@ public class TaskLeaveSpawn extends TutorialTask } @Override - public DeployedTask customDeploy(Player player) + public void customStartFor(Player player) { - return new Deployed(player, this); - } - - class Deployed extends DeployedTask - { - public Deployed(Player player, TutorialTask task) + if (player.getLocation().getY() < 100) { - super(player, task); - } - - @Override - public void postDeploy() - { - if (_player.getLocation().getY() < 100) - { - _task.finishFor(_player); - } - } - - @EventHandler - public void update(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - { - return; - } - - if (checkForDeath()) - { - return; - } - - if (_player.getLocation().getY() < 100){ - _task.finishFor(_player); - } + finishFor(player); } } + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + Iterator iterator = _inTask.iterator(); + while (iterator.hasNext()) + { + Player player = Bukkit.getPlayer(iterator.next()); + + if (player.getLocation().getY() < 100) + { + 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 7c05ec2da..d8ca69fd4 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 @@ -4,12 +4,10 @@ import org.bukkit.Location; 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.spawn.Spawn; -import mineplex.game.clans.tutorials.DeployedTask; import mineplex.game.clans.tutorials.TutorialTask; public class TaskMakingMoney extends TutorialTask @@ -26,46 +24,29 @@ public class TaskMakingMoney extends TutorialTask } @Override - public DeployedTask customDeploy(Player player) + public void customStartFor(Player player) { - return new Deployed(player, this); + player.teleport(new Location(Spawn.getSpawnWorld(), 25.536, 66, -316.844, -100f, 0f)); } - class Deployed extends DeployedTask + @EventHandler + public void button(ClansPlayerSellItemEvent event) { - private int _carrotsSold; - - public Deployed(Player player, TutorialTask task) + if (!isDoing(event.getPlayer())) { - super(player, task); - player.getInventory().addItem(new ItemStack(Material.CARROT_ITEM, 1)); + return; } - @Override - public void postDeploy() + if (!ClansManager.getInstance().isInClan(event.getPlayer())) { - _player.teleport(new Location(Spawn.getSpawnWorld(), 25.536, 66, -316.844, -100f, 0f)); + return; + } + + if (!event.getItem().getType().equals(Material.CARROT_ITEM)) + { + return; } - @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); - } + finishFor(event.getPlayer()); } } 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 index 8ee0e1e48..ebd16ede4 100644 --- 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 @@ -1,12 +1,10 @@ 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 @@ -22,39 +20,24 @@ public class TaskSetHome extends TutorialTask + "To do this, use the {/c sethome} command."; } - @Override - public DeployedTask customDeploy(Player player) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onSetHome(ClansCommandExecutedEvent event) { - return new Deployed(player, this); - } - - class Deployed extends DeployedTask - { - public Deployed(Player player, TutorialTask task) + if (!isDoing(event.getPlayer())) { - super(player, task); + return; } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onSetHome(ClansCommandExecutedEvent event) + if (!ClansManager.getInstance().isInClan(event.getPlayer())) { - if (!_player.equals(event.getPlayer())) - { - return; - } - - if (!ClansManager.getInstance().isInClan(event.getPlayer())) - { - return; - } - - if (!event.getCommand().equals("homeset")) - { - return; - } - - _task.finishFor(_player); + return; } + + if (!event.getCommand().equals("homeset")) + { + return; + } + + finishFor(event.getPlayer()); } - } 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 af9289b7a..95b989337 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 @@ -1,8 +1,10 @@ package mineplex.game.clans.tutorials.gettingstarted; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -13,13 +15,14 @@ import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.PlayerInventory; import mineplex.core.common.util.Callback; +import mineplex.core.common.util.NautArrayList; +import mineplex.core.common.util.NautHashMap; import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; import mineplex.game.clans.spawn.Spawn; -import mineplex.game.clans.tutorials.DeployedTask; import mineplex.game.clans.tutorials.TutorialTask; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; @@ -37,93 +40,99 @@ public class TaskUseAbility extends TutorialTask + "Right-Click with your Iron Axe to use your Axe Ability!"; } + private NautHashMap> _bought = new NautHashMap<>(); + private NautHashMap _teleported = new NautHashMap<>(); + @Override - public DeployedTask customDeploy(Player player) + public void customStartFor(Player player) { - return new Deployed(player, this); + _bought.put(player.getName(), new NautArrayList()); + _teleported.put(player.getName(), false); } - class Deployed extends DeployedTask + @Override + public void customEndFor(Player player) { - private List _bought = new ArrayList<>(); - private boolean _teleported = false; + _bought.get(player.getName()).clear(); + _bought.remove(player.getName()); + _teleported.remove(player.getName()); + } + + @EventHandler + public void teleportPlayer(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) return; - public Deployed(Player player, TutorialTask task) + Iterator iterator = _inTask.iterator(); + while (iterator.hasNext()) { - super(player, task); - } - - @EventHandler - public void teleportPlayer(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) return; - - if (!_teleported && _player != null && _player.isOnline() && _player.getOpenInventory().getType() == InventoryType.CRAFTING) + Player _player = Bukkit.getPlayer(iterator.next()); + + if (!_teleported.get(_player.getName()) && _player != null && _player.isOnline() && _player.getOpenInventory().getType() == InventoryType.CRAFTING) { _player.teleport(new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f)); - _teleported = true; + _teleported.put(_player.getName(), true); } } - - @EventHandler - public void onAbilityUesd(SkillTriggerEvent event) - { - if (_player == null || !_player.equals(event.GetPlayer())) - { - return; - } - - _task.finishFor(_player); - } - - @EventHandler - public void button(ClansShopAddButtonEvent event) - { - if (!_player.equals(event.getPlayer())) - { - return; - } - - System.out.println(event.getDisplayName()); - - if (!event.getMaterial().equals(Material.IRON_AXE)) - { - return; - } - - if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + 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(), "tuttoooooe" + event.getItem().getType().name()); - _bought.add(event.getItem().getType()); - } + } + + @EventHandler + public void onAbilityUesd(SkillTriggerEvent event) + { + if (!isDoing(event.GetPlayer())) + { + return; + } + + finishFor(event.GetPlayer()); + } + + @EventHandler + public void button(ClansShopAddButtonEvent event) + { + if (!isDoing(event.getPlayer())) + { + return; + } + + if (!event.getMaterial().equals(Material.IRON_AXE)) + { + return; + } + + if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + event.getMaterial().name()) + && !_bought.get(event.getPlayer().getName()).contains(event.getMaterial())) + { + event.setBuyPrice(0); + event.setSellPrice(0); + } + } + + @EventHandler + public void buy(final ClansPlayerBuyItemEvent event) + { + if (!isDoing(event.getPlayer())) + { + return; + } + + if (!event.getItem().getType().equals(Material.IRON_AXE)) + { + return; + } + + if (event.getCost() == 0 && _bought.get(event.getPlayer().getName()).contains(event.getItem().getType())) + { + event.setCancelled(true); + return; + } + + TaskManager.Instance.completedTask(new Callback() { + @Override + public void run(Boolean data) + { + } + }, event.getPlayer(), "tuttoooooe" + event.getItem().getType().name()); + _bought.get(event.getPlayer().getName()).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 index f241a052e..328400559 100644 --- 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 @@ -1,11 +1,9 @@ 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 @@ -22,32 +20,17 @@ public class TaskViewClanDetails extends TutorialTask + "You can also use any clan's name to get some information about them as well."; } - @Override - public DeployedTask customDeploy(Player player) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onClansCommand(ClansCommandExecutedEvent event) { - return new Deployed(player, this); - } - - class Deployed extends DeployedTask - { - public Deployed(Player player, TutorialTask task) + if (!isDoing(event.getPlayer())) { - super(player, task); + return; } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onClansCommand(ClansCommandExecutedEvent event) + if (event.getCommand().equals("info")) { - if (!_player.equals(event.getPlayer())) - { - return; - } - - if (event.getCommand().equals("info")) - { - _task.finishFor(_player); - } + finishFor(event.getPlayer()); } } - } 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 1bc32cef6..74e19ca6d 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 @@ -347,7 +347,7 @@ public class ClientClass ResetToDefaults(!skillsOnly, !skillsOnly); // Event - ClassEquipEvent event = new ClassEquipEvent(this, customBuild); + ClassEquipEvent event = new ClassEquipEvent(this, customBuild, _client.GetPlayer()); UtilServer.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) 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 index 74f2c5fab..70d64a1b6 100644 --- 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 @@ -5,7 +5,6 @@ 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 @@ -13,15 +12,16 @@ public class ClassEquipEvent extends Event private static final HandlerList handlers = new HandlerList(); private ClientClass _client; - + private Player _user; private CustomBuildToken _build; private boolean _cancelled; - public ClassEquipEvent(ClientClass client, CustomBuildToken build) + public ClassEquipEvent(ClientClass client, CustomBuildToken build, Player user) { _client = client; _build = build; + _user = user; } public ClientClass getPlayer() @@ -34,6 +34,11 @@ public class ClassEquipEvent extends Event return _build; } + public Player getUser() + { + return _user; + } + public void setCancelled(boolean cancelled) { _cancelled = cancelled; From fbf9c8eb0c96a67e1ab8a53d90005ffb1add08f6 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Tue, 1 Dec 2015 13:37:34 +0000 Subject: [PATCH 09/23] made certain messages visible in tutorial that are actually required to be seen --- .../game/clans/clans/ClansManager.java | 5 + .../clans/clans/commands/ClansCommand.java | 193 +++++++++--------- .../game/clans/tutorials/Tutorial.java | 29 +-- .../game/clans/tutorials/TutorialManager.java | 18 +- .../game/clans/tutorials/TutorialTask.java | 36 ++-- .../TutorialGettingStarted.java | 30 +-- 6 files changed, 161 insertions(+), 150 deletions(-) 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 1ac1d7d4d..aa8efa0bb 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 @@ -402,6 +402,11 @@ public class ClansManager extends MiniClientPluginimplements IRelati return _disguiseManager; } + public TutorialManager getTutorials() + { + return _tutorialManager; + } + public NpcManager getNPCManager() { return _npcManager; 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 19dd24bd1..7555950bb 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,6 +25,7 @@ import mineplex.game.clans.clans.ClansBlacklist; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClientClan; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.tutorials.Tutorial; import mineplex.game.clans.tutorials.TutorialManager; import net.minecraft.server.v1_8_R3.EnumDirection; @@ -126,7 +127,7 @@ public class ClansCommand extends CommandBase if (args.length == 0) { Plugin.Get(caller).setClanChat(!Plugin.Get(caller).isClanChat()); - UtilPlayer.message(caller, F.main("Clans", "Clan Chat: " + F.oo(Plugin.Get(caller).isClanChat()))); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan Chat: " + F.oo(Plugin.Get(caller).isClanChat()))); return; } @@ -135,7 +136,7 @@ public class ClansCommand extends CommandBase { ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); if (clan == null) - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); else Plugin.chatClan(clan, caller, F.combine(args, 0, null, false)); } @@ -146,7 +147,7 @@ public class ClansCommand extends CommandBase if (args.length == 0) { Plugin.Get(caller).setAllyChat(!Plugin.Get(caller).isAllyChat()); - UtilPlayer.message(caller, F.main("Clans", "Ally Chat: " + F.oo(Plugin.Get(caller).isAllyChat()))); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Ally Chat: " + F.oo(Plugin.Get(caller).isAllyChat()))); return; } @@ -155,7 +156,7 @@ public class ClansCommand extends CommandBase { ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); if (clan == null) - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); else Plugin.chatAlly(clan, caller, F.combine(args, 0, null, false)); } @@ -171,30 +172,30 @@ public class ClansCommand extends CommandBase return; } - UtilPlayer.message(caller, F.main("Clans", "Commands List;")); - UtilPlayer.message(caller, F.help("/c create ", "Create new Clan", Rank.ALL)); - UtilPlayer.message(caller, F.help("/c join ", "Join a Clan", Rank.ALL)); - UtilPlayer.message(caller, F.help("/c leave ", "Leave your Clan", Rank.ALL)); - UtilPlayer.message(caller, F.help("/c map ", "View Clan Map", Rank.ALL)); - UtilPlayer.message(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL)); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Commands List;")); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c create ", "Create new Clan", Rank.ALL)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c join ", "Join a Clan", Rank.ALL)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c leave ", "Leave your Clan", Rank.ALL)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c map ", "View Clan Map", Rank.ALL)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL)); - UtilPlayer.message(caller, F.help("/c promote ", "Promote Player in Clan", Rank.MODERATOR)); - UtilPlayer.message(caller, F.help("/c demote ", "Demote Player in Clan", Rank.MODERATOR)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c promote ", "Promote Player in Clan", Rank.MODERATOR)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c demote ", "Demote Player in Clan", Rank.MODERATOR)); - UtilPlayer.message(caller, F.help("/c home (set)", "Teleport to Clan Home", Rank.MODERATOR)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c home (set)", "Teleport to Clan Home", Rank.MODERATOR)); - UtilPlayer.message(caller, F.help("/c invite ", "Invite Player to Clan", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c kick ", "Kick Player from Clan", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c neutral ", "Request Neutrality with Clan", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c enemy ", "Declare ClanWar with Clan", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c ally ", "Send Alliance to Clan", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c trust ", "Give Trust to Clan", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c claim", "Claim Territory", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c unclaim (all)", "Unclaim Territory", Rank.ADMIN)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c invite ", "Invite Player to Clan", Rank.ADMIN)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c kick ", "Kick Player from Clan", Rank.ADMIN)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c neutral ", "Request Neutrality with Clan", Rank.ADMIN)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c enemy ", "Declare ClanWar with Clan", Rank.ADMIN)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c ally ", "Send Alliance to Clan", Rank.ADMIN)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c trust ", "Give Trust to Clan", Rank.ADMIN)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c claim", "Claim Territory", Rank.ADMIN)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c unclaim (all)", "Unclaim Territory", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c delete", "Delete your Clan", Rank.OWNER)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c delete", "Delete your Clan", Rank.OWNER)); - UtilPlayer.message(caller, F.help("/c ", "View Clan Information", Rank.ALL)); + _manager.getTutorials().sendTutorialMsg(caller, F.help("/c ", "View Clan Information", Rank.ALL)); } public void create(final Player caller, final String[] args) @@ -205,12 +206,12 @@ public class ClansCommand extends CommandBase if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId())) { - UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan.")); return; } /* - * TODO if (!client.canJoin()) { UtilPlayer.message(caller, + * TODO if (!client.canJoin()) { _manager.getTutorials().sendTutorialMsg(caller, * F.main("Clans", "You cannot join a Clan for " + C.mTime + * UtilTime.convertString(System.currentTimeMillis() - * client.getDelay(), 1, TimeUnit.FIT) + C.mBody + ".")); return; } @@ -218,37 +219,37 @@ public class ClansCommand extends CommandBase if (args.length < 2) { - UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan name.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan name.")); return; } if (!UtilInput.valid(args[1])) { - UtilPlayer.message(caller, F.main("Clans", "Invalid characters in Clan name.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Invalid characters in Clan name.")); return; } if (args[1].length() < Plugin.getNameMin()) { - UtilPlayer.message(caller, F.main("Clans", "Clan name too short. Minimum length is " + (Plugin.getNameMin()) + ".")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name too short. Minimum length is " + (Plugin.getNameMin()) + ".")); return; } if (args[1].length() > Plugin.getNameMax()) { - UtilPlayer.message(caller, F.main("Clans", "Clan name too long. Maximum length is " + (Plugin.getNameMax()) + ".")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name too long. Maximum length is " + (Plugin.getNameMax()) + ".")); return; } if (Plugin.getChat().getFilteredMessage(caller, args[1]).contains("*")) { - UtilPlayer.message(caller, F.main("Clans", "Clan name inappropriate. Please try a different name")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name inappropriate. Please try a different name")); return; } if (!ClansBlacklist.isValidClanName(args[1])) { - UtilPlayer.message(caller, F.main("Clans", "Clan name is blacklisted! Please try a different name.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name is blacklisted! Please try a different name.")); return; } @@ -259,7 +260,7 @@ public class ClansCommand extends CommandBase { if (clanExists) { - UtilPlayer.message(caller, F.main("Clans", "Clan name is already in use by another Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name is already in use by another Clan.")); } else { @@ -271,11 +272,11 @@ public class ClansCommand extends CommandBase if (data == null) { // Hopefully shouldn't happen! - UtilPlayer.message(caller, F.main("Clans", "There was an error creating the clan. Please try again")); + _manager.getTutorials().sendTutorialMsg(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 + ".")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You created Clan " + C.cYellow + data.getName() + C.cGray + ".")); } } }); @@ -295,13 +296,13 @@ public class ClansCommand extends CommandBase if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (args.length < 2) { - UtilPlayer.message(caller, F.main("Clans", "You did not input an invitee.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input an invitee.")); return; } @@ -315,25 +316,25 @@ public class ClansCommand extends CommandBase { if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId())) { - UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan.")); return; } if (!Plugin.Get(caller).canJoin()) { - UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Plugin.Get(caller).getDelay(), 1, TimeUnit.FIT) + C.mBody + ".")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Plugin.Get(caller).getDelay(), 1, TimeUnit.FIT) + C.mBody + ".")); return; } if (args.length < 2) { - UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan name.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan name.")); return; } if (!UtilInput.valid(args[1])) { - UtilPlayer.message(caller, F.main("Clans", "Invalid characters in Clan name.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Invalid characters in Clan name.")); return; } @@ -342,13 +343,13 @@ public class ClansCommand extends CommandBase if (!clan.isInvited(caller.getName())) { - UtilPlayer.message(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clan.getName()) + ".")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clan.getName()) + ".")); return; } if (clan.getSize() >= clan.getMaxSize()) { - UtilPlayer.message(caller, F.main("Clans", "The clan " + F.elem("Clan " + clan.getName()) + " is full and cannot be joined!")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "The clan " + F.elem("Clan " + clan.getName()) + " is full and cannot be joined!")); return; } @@ -361,12 +362,12 @@ public class ClansCommand extends CommandBase if (data) { // Inform - UtilPlayer.message(caller, F.main("Clans", "You joined " + F.elem("Clan " + clan.getName()) + ".")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You joined " + F.elem("Clan " + clan.getName()) + ".")); clan.inform(F.name(caller.getName()) + " has joined your Clan.", caller.getName()); } else { - UtilPlayer.message(caller, F.main("Clans", "There was an error processing your request")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request")); } } }); @@ -379,13 +380,13 @@ public class ClansCommand extends CommandBase if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER && clan.getMembers().size() > 1) { - UtilPlayer.message(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving.")); return; } @@ -399,7 +400,7 @@ public class ClansCommand extends CommandBase public void run(Boolean data) { // Inform - UtilPlayer.message(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + ".")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + ".")); clan.inform(F.name(caller.getName()) + " has left your Clan.", null); } }); @@ -416,13 +417,13 @@ public class ClansCommand extends CommandBase if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (args.length < 2) { - UtilPlayer.message(caller, F.main("Clans", "You did not input a Player to kick.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Player to kick.")); return; } @@ -437,13 +438,13 @@ public class ClansCommand extends CommandBase if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (args.length < 2) { - UtilPlayer.message(caller, F.main("Clans", "You did not input player to promote.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input player to promote.")); return; } @@ -458,13 +459,13 @@ public class ClansCommand extends CommandBase if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (args.length < 2) { - UtilPlayer.message(caller, F.main("Clans", "You did not input player to demote.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input player to demote.")); return; } @@ -479,19 +480,19 @@ public class ClansCommand extends CommandBase if (cA == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { - UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Alliances.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Alliances.")); return; } if (args.length < 2) { - UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan to ally.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan to ally.")); return; } @@ -501,31 +502,31 @@ public class ClansCommand extends CommandBase if (cA.isSelf(cB.getName())) { - UtilPlayer.message(caller, F.main("Clans", "You cannot ally with yourself.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot ally with yourself.")); return; } if (cA.isAlly(cB.getName())) { - UtilPlayer.message(caller, F.main("Clans", "You are already allies with Clan" + F.elem(cB.getName())) + "."); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already allies with Clan" + F.elem(cB.getName())) + "."); return; } if (cA.getAllies() >= cA.getAlliesMax()) { - UtilPlayer.message(caller, F.main("Clans", "You cannot have any more allies.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot have any more allies.")); return; } if (cB.getAllies() >= cB.getAlliesMax()) { - UtilPlayer.message(caller, F.main("Clans", "Clan " + F.elem(cB.getName()) + " cannot have any more allies.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan " + F.elem(cB.getName()) + " cannot have any more allies.")); return; } if (!Recharge.Instance.usable(caller, "AllyReq" + cB.getName())) { - UtilPlayer.message(caller, F.main("Clans", "Please do not spam alliance requests.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Please do not spam alliance requests.")); return; } @@ -535,7 +536,7 @@ public class ClansCommand extends CommandBase Plugin.getClanDataAccess().ally(cA, cB, caller.getName()); // Inform - UtilPlayer.message(caller, F.main("Clans", "You accepted alliance with Clan " + F.elem(cB.getName()) + ".")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You accepted alliance with Clan " + F.elem(cB.getName()) + ".")); cA.inform(F.name(caller.getName()) + " accepted alliance with Clan " + F.elem(cB.getName()) + ".", caller.getName()); cB.inform("Clan " + F.elem(cA.getName()) + " has accepted alliance with you.", null); } @@ -545,7 +546,7 @@ public class ClansCommand extends CommandBase Plugin.getClanDataAccess().requestAlly(cA, cB, caller.getName()); // Inform - UtilPlayer.message(caller, F.main("Clans", "You requested alliance with Clan " + F.elem(cB.getName()) + ".")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You requested alliance with Clan " + F.elem(cB.getName()) + ".")); cA.inform(F.name(caller.getName()) + " has requested alliance with Clan " + F.elem(cB.getName()) + ".", caller.getName()); cB.inform("Clan " + F.elem(cA.getName()) + " has requested alliance with you.", null); @@ -559,19 +560,19 @@ public class ClansCommand extends CommandBase // // if (cA == null) // { -// UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); +// _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); // return; // } // // if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) // { -// UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Trust.")); +// _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Trust.")); // return; // } // // if (args.length < 2) // { -// UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan to enemy.")); +// _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan to enemy.")); // return; // } // @@ -581,7 +582,7 @@ public class ClansCommand extends CommandBase // // if (!cA.isAlly(cB.getName())) // { -// UtilPlayer.message(caller, F.main("Clans", "You must be allied to trust a clan!")); +// _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must be allied to trust a clan!")); // return; // } // @@ -589,14 +590,14 @@ public class ClansCommand extends CommandBase // if (Plugin.getClanDataAccess().trust(cA, cB, caller.getName())) // { // // Inform -// UtilPlayer.message(caller, F.main("Clans", "You gave trust to " + F.elem("Clan " + cB.getName()) + ".")); +// _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You gave trust to " + F.elem("Clan " + cB.getName()) + ".")); // cA.inform(F.name(caller.getName()) + " has given trust to " + F.elem("Clan " + cB.getName()) + ".", caller.getName()); // cB.inform(F.elem("Clan " + cA.getName()) + " has given trust to you.", null); // } // else // { // // Inform -// UtilPlayer.message(caller, F.main("Clans", "You revoked trust to " + F.elem("Clan " + cB.getName()) + ".")); +// _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You revoked trust to " + F.elem("Clan " + cB.getName()) + ".")); // cA.inform(F.name(caller.getName()) + " has revoked trust to " + F.elem("Clan " + cB.getName()) + ".", caller.getName()); // cB.inform(F.elem("Clan " + cA.getName()) + " has revoked trust to you.", null); // } @@ -608,19 +609,19 @@ public class ClansCommand extends CommandBase if (cA == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { - UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage relationships.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage relationships.")); return; } if (args.length < 2) { - UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan to set neutrality with.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan to set neutrality with.")); return; } @@ -630,11 +631,11 @@ public class ClansCommand extends CommandBase if (cB.isSelf(cA.getName())) { - UtilPlayer.message(caller, F.main("Clans", "You prefer to think of yourself positively...")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You prefer to think of yourself positively...")); } else if (cB.isNeutral(cA.getName())) { - UtilPlayer.message(caller, F.main("Clans", "You are already neutral with " + F.elem("Clan " + cB.getName()) + ".")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already neutral with " + F.elem("Clan " + cB.getName()) + ".")); } else if (cB.isAlly(cA.getName())) { @@ -642,7 +643,7 @@ public class ClansCommand extends CommandBase Plugin.getClanDataAccess().neutral(cA, cB, caller.getName(), true); // Inform - UtilPlayer.message(caller, F.main("Clans", "You revoked alliance with " + F.elem("Clan " + cB.getName()) + ".")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You revoked alliance with " + F.elem("Clan " + cB.getName()) + ".")); cA.inform(F.name(caller.getName()) + " revoked alliance with " + F.elem("Clan " + cB.getName()) + ".", caller.getName()); cB.inform(F.elem("Clan " + cA.getName()) + " has revoked alliance with you.", null); } @@ -683,7 +684,7 @@ public class ClansCommand extends CommandBase } // Change Inform - UtilPlayer.message(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!")); // Inform UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); @@ -719,31 +720,31 @@ public class ClansCommand extends CommandBase if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (clan.getHome() == null) { - UtilPlayer.message(caller, F.main("Clans", "Your Clan has not set a Home")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan has not set a Home")); return; } if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(clan.getHome().getChunk()))) { - UtilPlayer.message(caller, F.main("Clans", "Your Clan has lost its Home Territory.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan has lost its Home Territory.")); return; } if (!Plugin.getClanUtility().isSafe(caller.getLocation())) { - UtilPlayer.message(caller, F.main("Clans", "You can only use Clan Home from Spawn.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can only use Clan Home from Spawn.")); return; } if (!Plugin.getClanUtility().isSpecial(caller.getLocation(), "Spawn")) { - UtilPlayer.message(caller, F.main("Clans", "You can only use Clan Home from Spawn.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can only use Clan Home from Spawn.")); return; } @@ -751,7 +752,7 @@ public class ClansCommand extends CommandBase if (!(home.getBlock().getType().equals(Material.BED_BLOCK) && home.add(0, 1, 0).getBlock().getType().equals(Material.AIR)) && home.add(0, 2, 0).getBlock().getType().equals(Material.AIR)) { - UtilPlayer.message(caller, F.main("Clans", "Your Clan's bed has been destroyed, or is obstructed.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan's bed has been destroyed, or is obstructed.")); return; } @@ -760,7 +761,7 @@ public class ClansCommand extends CommandBase * (Player cur : clan.GetHome().getWorld().getPlayers()) if * (client.Clan().GetRelation(cur.getName()) == ClanRelation.NEUTRAL) if * (clan.GetClaimSet().contains(UtilWorld.chunkToStr(cur.getLocation(). - * getChunk()))) { UtilPlayer.message(caller, F.main("Clans", + * getChunk()))) { _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", * "You cannot use Clan Home with enemies in your Territory.")); return; * } */ @@ -772,7 +773,7 @@ public class ClansCommand extends CommandBase Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0)); // Inform - UtilPlayer.message(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + ".")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + ".")); } public void homeSet(Player caller) @@ -790,31 +791,31 @@ public class ClansCommand extends CommandBase if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { - UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Clan Home.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Clan Home.")); return; } if (Plugin.getClanUtility().getOwner(caller.getLocation()) == null) { - UtilPlayer.message(caller, F.main("Clans", "You must set your Clan Home in your own Territory.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must set your Clan Home in your own Territory.")); return; } if (!Plugin.getClanUtility().getOwner(caller.getLocation()).isSelf(clan.getName())) { - UtilPlayer.message(caller, F.main("Clans", "You must set your Clan Home in your own Territory.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must set your Clan Home in your own Territory.")); return; } if (!(caller.getLocation().add(0, 1, 0).getBlock().getType().equals(Material.AIR) && caller.getLocation().add(0, 2, 0).getBlock().getType().equals(Material.AIR))) { - UtilPlayer.message(caller, F.main("Clans", "This is not a suitable place for a bed.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This is not a suitable place for a bed.")); return; } @@ -823,7 +824,7 @@ public class ClansCommand extends CommandBase if (!bedPlaced) { - UtilPlayer.message(caller, F.main("Clans", "This is not a suitable place for a bed.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This is not a suitable place for a bed.")); return; } @@ -839,7 +840,7 @@ public class ClansCommand extends CommandBase Plugin.ClanTips.displayTip(TipType.SETHOME, caller); // Inform - UtilPlayer.message(caller, F.main("Clans", "You set Clan Home to " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You set Clan Home to " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); clan.inform(caller.getName() + " set Clan Home to " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".", caller.getName()); } @@ -847,7 +848,7 @@ public class ClansCommand extends CommandBase {System.out.println(search); if (search == null) { - UtilPlayer.message(caller, F.main("Clans", "You did not input a search parameter.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a search parameter.")); return; } @@ -869,13 +870,13 @@ public class ClansCommand extends CommandBase { if (_manager.getClientManager().hasRank(caller, Rank.ADMIN)) { - UtilPlayer.message(caller, F.main("Clans", "No no no, this command is not for you ;-)")); + _manager.getTutorials().sendTutorialMsg(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.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a search parameter.")); return; } @@ -904,7 +905,7 @@ public class ClansCommand extends CommandBase if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } } @@ -914,6 +915,6 @@ public class ClansCommand extends CommandBase if (clan == null) return; - UtilPlayer.message(caller, clan.mTerritory()); + _manager.getTutorials().sendTutorialMsg(caller, clan.mTerritory()); } } 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 387761ed4..bff3c7c76 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 @@ -41,8 +41,6 @@ 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; -import net.md_5.bungee.api.chat.BaseComponent; -import net.minecraft.server.v1_8_R3.IChatBaseComponent; import net.minecraft.server.v1_8_R3.PacketPlayOutChat; /** @@ -59,7 +57,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener public static String TUTORIAL_REWARD_TASK = "tatatatatat%sRewardGiven"; //do not change public static String SKIPPED_TASK = "tatatatata%sSkip"; - public static String ALLOWED_MESSAGE_CODE = "-TUTORIALMESSAGE-"; + public static String AllowedMessage = C.cGold + "-=%TutorialAllowedMessage%=-" + C.Reset; protected final TutorialManager _manager; protected final GoldManager _goldManager; @@ -97,20 +95,18 @@ public abstract class Tutorial implements ScoreboardElement, Listener packetHandler.addPacketHandler(new IPacketHandler() { public void handle(PacketInfo packet) { - if (!isInTutorial(packet.getPlayer())) - { - return; - } - if (packet.getPacket() instanceof PacketPlayOutChat) { PacketPlayOutChat chat = (PacketPlayOutChat) packet.getPacket(); if (chat.b == 1) { - if (!chat.a.a().get(0).c().equals(ALLOWED_MESSAGE_CODE)) + if (!chat.a.a().get(0).c().equals(AllowedMessage)) { - packet.setCancelled(true); + if (isInTutorial(packet.getPlayer())) + { + packet.setCancelled(true); + } } else { @@ -286,7 +282,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener if (_goldReward != -1) { _goldManager.addGold(player, _goldReward); - msg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + ".")); + _manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + ".")); } if (_gemReward != -1) @@ -294,7 +290,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener _donationManager.RewardGems(new Callback() { public void run(Boolean data) { - msg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gems") + ".")); + _manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gems") + ".")); } }, "Clans", player.getName(), player.getUniqueId(), _gemReward); } @@ -304,7 +300,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener _donationManager.RewardCoins(new Callback() { public void run(Boolean data) { - msg(player, F.main("Tutorials", "You have been awarded " + F.elem(_coinReward + " Coins") + ".")); + _manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_coinReward + " Coins") + ".")); } }, "Clans", player.getName(), _clansManager.getClientManager().getAccountId(player), _coinReward); } @@ -422,7 +418,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener public void skip(final Player player) { new JsonMessage( - ALLOWED_MESSAGE_CODE + + AllowedMessage + F.main( "Tutorial", "Are you sure you want to skip the tutorial? We " @@ -544,9 +540,4 @@ public abstract class Tutorial implements ScoreboardElement, Listener _inTutorial.remove(player.getName()); } - - protected void msg(Player player, String msg) - { - UtilPlayer.message(player, ALLOWED_MESSAGE_CODE + msg); - } } 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 3634c37ce..eaec8bece 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,6 +1,7 @@ package mineplex.game.clans.tutorials; import java.util.HashMap; +import java.util.LinkedList; import java.util.Map; import org.bukkit.entity.Player; @@ -79,7 +80,7 @@ public class TutorialManager extends MiniPlugin getTutorial(player).cancelFor(player); - UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); + sendTutorialMsg(player, F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); _playerTutorials.remove(player.getName()); } } @@ -96,7 +97,7 @@ public class TutorialManager extends MiniPlugin { if (isInTutorial(player)) { - UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); + sendTutorialMsg(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); getTutorial(player).doSkip(player); } } @@ -110,6 +111,19 @@ public class TutorialManager extends MiniPlugin getTutorial(event.getPlayer()).cleanup(event.getPlayer()); } + public void sendTutorialMsg(Player player, String message) + { + player.sendMessage(Tutorial.AllowedMessage + message); + } + + public void sendTutorialMsg(Player player, LinkedList messages) + { + for (String message : messages) + { + sendTutorialMsg(player, message); + } + } + public Tutorial getTutorial(final Player player) { return _playerTutorials.get(player.getName()); 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 18b50d2ca..2b78d2dd9 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 @@ -5,7 +5,6 @@ import org.bukkit.event.Listener; import mineplex.core.common.util.C; import mineplex.core.common.util.NautArrayList; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; public class TutorialTask implements Listener @@ -81,15 +80,16 @@ public class TutorialTask implements Listener if (System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime()) { - UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " "); - UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " "); - UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " "); - UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + C.cDGreenB + C.Strike + "---------------------------------------------"); - UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " "); - UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + C.cYellowB + "Part " + _id + ": " + _displayName); - UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + C.cWhite + _description.replace("{", C.cAqua).replace("}", C.cWhite)); - UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " "); - UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + C.cDGreenB + C.Strike + "---------------------------------------------"); + _tutorial._manager.sendTutorialMsg(player, " "); + _tutorial._manager.sendTutorialMsg(player, " "); + _tutorial._manager.sendTutorialMsg(player, " "); + _tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + _tutorial._manager.sendTutorialMsg(player, " "); + _tutorial._manager.sendTutorialMsg(player, C.cYellowB + "Part " + _id + ": " + _displayName); + _tutorial._manager.sendTutorialMsg(player, C.cWhite + _description.replace("{", C.cAqua).replace("}", C.cWhite)); + _tutorial._manager.sendTutorialMsg(player, " "); + _tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + client.LastDescriptionSentTime = System.currentTimeMillis(); } } @@ -137,14 +137,14 @@ public class TutorialTask implements Listener if (_finishMessage != null) { - 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 + "---------------------------------------------"); + _tutorial._manager.sendTutorialMsg(player, " "); + _tutorial._manager.sendTutorialMsg(player, " "); + _tutorial._manager.sendTutorialMsg(player, " "); + _tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + _tutorial._manager.sendTutorialMsg(player, " "); + _tutorial._manager.sendTutorialMsg(player, C.cWhite + _finishMessage.replace("{", C.cAqua).replace("}", C.cWhite)); + _tutorial._manager.sendTutorialMsg(player, " "); + _tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); } } 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 1e0b5a9a4..1bbc4a23c 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 @@ -51,12 +51,12 @@ public class TutorialGettingStarted extends Tutorial @Override public void onFinished(final Player player) { - msg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); - msg(player, C.cYellowB + "CONGRATULATIONS"); - msg(player, " "); - msg(player, C.cWhite + "You have completed the Clans basic tutorial and have been awarded " + C.cAqua + "30,000 Gold"); - msg(player, C.cWhite + "You can now begin your adventure, but do take a moment to read the signs around spawn for more information!"); - msg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + _manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + _manager.sendTutorialMsg(player, C.cYellowB + "CONGRATULATIONS"); + _manager.sendTutorialMsg(player, " "); + _manager.sendTutorialMsg(player, C.cWhite + "You have completed the Clans basic tutorial and have been awarded " + C.cAqua + "30,000 Gold"); + _manager.sendTutorialMsg(player, C.cWhite + "You can now begin your adventure, but do take a moment to read the signs around spawn for more information!"); + _manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); player.resetPlayerTime(); player.teleport(Spawn.getEastSpawn()); @@ -65,17 +65,17 @@ public class TutorialGettingStarted extends Tutorial @Override public void onBegin(final Player player) { - msg(player, " "); - msg(player, " "); - msg(player, " "); - msg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); - msg(player, " "); - msg(player, C.cYellowB + "Getting Started"); - msg(player, C.cWhite + "Welcome to Clans! " + _manager.sendTutorialMsg(player, " "); + _manager.sendTutorialMsg(player, " "); + _manager.sendTutorialMsg(player, " "); + _manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + _manager.sendTutorialMsg(player, " "); + _manager.sendTutorialMsg(player, C.cYellowB + "Getting Started"); + _manager.sendTutorialMsg(player, C.cWhite + "Welcome to Clans! " + "In this game mode you are able to create a clan, invite your friends to play with you, build a base, and wage war against others! " + "When you finish the tutorial, you will be awarded " + C.cAqua + "30,000 Gold"); - msg(player, " "); - msg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + _manager.sendTutorialMsg(player, " "); + _manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); } From ea099d7a82607d9d2ead068c8d50fa2783d2da55 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Tue, 1 Dec 2015 18:41:33 +0000 Subject: [PATCH 10/23] fixed some annoying bugs and fixed certain messages not showing in tutorial --- .../game/clans/clans/ClansUtility.java | 122 +++++++++--------- .../game/clans/tutorials/Tutorial.java | 27 +--- .../game/clans/tutorials/TutorialManager.java | 32 ++++- .../tutorials/gettingstarted/TaskClaim.java | 2 +- .../gettingstarted/TaskCreateClan.java | 2 +- 5 files changed, 95 insertions(+), 90 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 4031496a1..f01423118 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 @@ -157,10 +157,10 @@ public class ClansUtility if (inform) { - UtilPlayer.message(caller, F.main("Clan Search", "" + C.mCount + (clanMatchList.size() + playerMatchList.size()) + C.mBody + " matches for [" + C.mElem + name + C.mBody + "]."), false); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mCount + (clanMatchList.size() + playerMatchList.size()) + C.mBody + " matches for [" + C.mElem + name + C.mBody + "].")); - UtilPlayer.message(caller, F.desc("Matches via Clan", clanMatchString), false); - UtilPlayer.message(caller, F.desc("Matches via Player", playerMatchString), false);; + Clans.getTutorials().sendTutorialMsg(caller, F.desc("Matches via Clan", clanMatchString)); + Clans.getTutorials().sendTutorialMsg(caller, F.desc("Matches via Player", playerMatchString)); } return null; @@ -183,7 +183,7 @@ public class ClansUtility if (!inform) return null; // Inform - UtilPlayer.message(caller, F.main("Clan Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem + name + C.mBody + "]."), false); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem + name + C.mBody + "].")); if (matchList.size() > 0) { @@ -191,7 +191,7 @@ public class ClansUtility for (ClanInfo cur : matchList) matchString += cur.getName() + " "; - UtilPlayer.message(caller, F.main("Clan Search", "" + C.mBody + " Matches [" + C.mElem + matchString + C.mBody + "]."), false); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mBody + " Matches [" + C.mElem + matchString + C.mBody + "].")); } return null; @@ -554,31 +554,31 @@ public class ClansUtility { if (Clans.getClanMemberUuidMap().containsKey(caller.getUniqueId())) { - UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan.")); return; } if (!Clans.Get(caller).canJoin()) { - UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Clans.Get(caller).getDelay(), 1, UtilTime.TimeUnit.FIT) + C.mBody + ".")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Clans.Get(caller).getDelay(), 1, UtilTime.TimeUnit.FIT) + C.mBody + ".")); return; } if (clanInfo == null) { - UtilPlayer.message(caller, F.main("Clans", "Error: Clan does not exist")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Error: Clan does not exist")); return; } if (!clanInfo.isInvited(caller.getName())) { - UtilPlayer.message(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clanInfo.getName()) + ".")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clanInfo.getName()) + ".")); return; } if (clanInfo.getSize() >= clanInfo.getMaxSize()) { - UtilPlayer.message(caller, F.main("Clans", "The clan " + F.elem("Clan " + clanInfo.getName()) + " is full and cannot be joined!")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "The clan " + F.elem("Clan " + clanInfo.getName()) + " is full and cannot be joined!")); return; } @@ -591,12 +591,12 @@ public class ClansUtility if (data) { // Inform - UtilPlayer.message(caller, F.main("Clans", "You joined " + F.elem("Clan " + clanInfo.getName()) + ".")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You joined " + F.elem("Clan " + clanInfo.getName()) + ".")); clanInfo.inform(F.name(caller.getName()) + " has joined your Clan.", caller.getName()); } else { - UtilPlayer.message(caller, F.main("Clans", "There was an error processing your request")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request")); } } }); @@ -609,13 +609,13 @@ public class ClansUtility if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER && clan.getMembers().size() > 1) { - UtilPlayer.message(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving.")); return; } @@ -629,7 +629,7 @@ public class ClansUtility public void run(Boolean data) { // Inform - UtilPlayer.message(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + ".")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + ".")); clan.inform(F.name(caller.getName()) + " has left your Clan.", null); } }); @@ -646,13 +646,13 @@ public class ClansUtility if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (getRole(caller) != ClanRole.LEADER) { - UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader can disband the Clan.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader can disband the Clan.")); return; } @@ -673,7 +673,7 @@ public class ClansUtility { if (!data) { - UtilPlayer.message(caller, F.main("Clans", "There was an error processing your request. Try again later")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request. Try again later")); }else { @@ -689,25 +689,25 @@ public class ClansUtility if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return false; } if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { - UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can claim Territory.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can claim Territory.")); return false; } if (!ClansManager.isClaimable(caller.getLocation())) { - UtilPlayer.message(caller, F.main("Clans", "You cannot claim territory at this location!")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim territory at this location!")); return false; } // if (clan.getEnergy() == 0) // { -// UtilPlayer.message(caller, F.main("Clans", "You must purchase energy at a shop before you can claim land.")); +// Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must purchase energy at a shop before you can claim land.")); // return false; // } @@ -723,14 +723,14 @@ public class ClansUtility } else { - UtilPlayer.message(caller, F.main("Clans", "This Territory is owned by " + mRel(Clans.getClanUtility().relPC(caller, ownerClan), ownerClan.getName(), true) + ".")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory is owned by " + mRel(Clans.getClanUtility().relPC(caller, ownerClan), ownerClan.getName(), true) + ".")); return false; } } // if (clan.getClaims() >= clan.getClaimsMax()) // { -// UtilPlayer.message(caller, F.main("Clans", "Your Clan cannot claim more Territory.")); +// Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan cannot claim more Territory.")); // return false; // } @@ -756,8 +756,8 @@ public class ClansUtility if (checkBox(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z), 3)) { - UtilPlayer.message(caller, F.main("Clans", "You cannot claim this Territory, it causes a box.")); - UtilPlayer.message(caller, F.main("Clans", "This means a Territory has all sides claimed.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim this Territory, it causes a box.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This means a Territory has all sides claimed.")); return false; } @@ -767,7 +767,7 @@ public class ClansUtility } else if (rel(clan, adjClan) != ClanRelation.SELF) { - UtilPlayer.message(caller, F.main("Clans", "You cannot claim Territory next to " + mRel(rel(ownerClan, adjClan), adjClan.getName(), true) + ".")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim Territory next to " + mRel(rel(ownerClan, adjClan), adjClan.getName(), true) + ".")); return false; } } @@ -776,21 +776,21 @@ public class ClansUtility // Boxed if (checkBox(caller.getLocation().getChunk(), 4)) { - UtilPlayer.message(caller, F.main("Clans", "You cannot claim this Territory, it causes a box.")); - UtilPlayer.message(caller, F.main("Clans", "This means a Territory has all sides claimed.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim this Territory, it causes a box.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This means a Territory has all sides claimed.")); return false; } if (isNearAdminClaim(caller.getLocation())) { - UtilPlayer.message(caller, F.main("Clans", "You cannot claim so close to administrative territory!")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim so close to administrative territory!")); return false; } // Not Next to Self if (!selfAdj && !clan.getClaimSet().isEmpty()) { - UtilPlayer.message(caller, F.main("Clans", "You must claim next to your other Territory.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must claim next to your other Territory.")); return false; } @@ -799,7 +799,7 @@ public class ClansUtility { if (!UtilTime.elapsed(Clans.getUnclaimMap().get(chunk), Clans.getReclaimTime())) { - UtilPlayer.message(caller, F.main("Clans", "This Territory cannot be claimed for " + F.time(UtilTime.convertString(Clans.getReclaimTime() - (System.currentTimeMillis() - Clans.getUnclaimMap().get(chunk)), 1, UtilTime.TimeUnit.FIT)) + ".")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory cannot be claimed for " + F.time(UtilTime.convertString(Clans.getReclaimTime() - (System.currentTimeMillis() - Clans.getUnclaimMap().get(chunk)), 1, UtilTime.TimeUnit.FIT)) + ".")); return false; } @@ -814,7 +814,7 @@ public class ClansUtility { if (UtilMath.offset(cur, caller) < 16) if (playerEnemy(caller, cur)) { - UtilPlayer.message(caller, F.main("Clans", "You cannot claim while enemies are nearby.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim while enemies are nearby.")); return false; } } @@ -836,7 +836,7 @@ public class ClansUtility Clans.getClanDataAccess().claim(clan.getName(), chunk, caller.getName(), false); // Inform - UtilPlayer.message(caller, F.main("Clans", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".")); clan.inform(F.name(caller.getName()) + " claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName()); return true; @@ -873,7 +873,7 @@ public class ClansUtility } // Change Inform - UtilPlayer.message(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!")); // Inform UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); @@ -890,7 +890,7 @@ public class ClansUtility if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } @@ -901,13 +901,13 @@ public class ClansUtility if (target.equals(caller.getName())) { - UtilPlayer.message(caller, F.main("Clans", "You cannot promote yourself.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot promote yourself.")); return; } if (self.getRole().ordinal() <= target.getRole().ordinal()) { - UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); return; } @@ -942,7 +942,7 @@ public class ClansUtility if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } @@ -953,19 +953,19 @@ public class ClansUtility if (target.equals(caller.getName())) { - UtilPlayer.message(caller, F.main("Clans", "You cannot demote yourself.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot demote yourself.")); return; } if (self.getRole().ordinal() <= target.getRole().ordinal()) { - UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); return; } if (target.getRole() == ClanRole.RECRUIT) { - UtilPlayer.message(caller, F.main("Clans", "You cannot demote " + F.name(other) + " any further.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot demote " + F.name(other) + " any further.")); return; } @@ -992,7 +992,7 @@ public class ClansUtility if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } @@ -1003,20 +1003,20 @@ public class ClansUtility if (self.getRole() != ClanRole.LEADER && self.getRole() != ClanRole.ADMIN) { - UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can kick members.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can kick members.")); return; } if (clansPlayer.getRole() == ClanRole.LEADER) { - UtilPlayer.message(caller, F.main("Clans", "Clan leaders cannot be kicked.")); - UtilPlayer.message(caller, F.main("Clans", "To disband a clan, use /c disband")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan leaders cannot be kicked.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "To disband a clan, use /c disband")); return; } if ((clansPlayer.getRole() == ClanRole.LEADER && self.getRole() == ClanRole.ADMIN) || (clansPlayer.getRole() == ClanRole.ADMIN && self.getRole() == ClanRole.ADMIN)) { - UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); return; } @@ -1028,8 +1028,8 @@ public class ClansUtility public void run(Boolean data) { // Inform - if (player != null) UtilPlayer.message(player, F.main("Clans", F.name(caller.getName()) + " kicked you from " + F.elem("Clan " + clan.getName()) + ".")); - UtilPlayer.message(caller, F.main("Clans", "You kicked " + F.name(other) + " from your Clan.")); + if (player != null) Clans.getTutorials().sendTutorialMsg(player, F.main("Clans", F.name(caller.getName()) + " kicked you from " + F.elem("Clan " + clan.getName()) + ".")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You kicked " + F.name(other) + " from your Clan.")); clan.inform(F.main("Clans", F.name(caller.getName()) + " kicked " + F.name(other) + " from your Clan."), caller.getName()); } }; @@ -1047,7 +1047,7 @@ public class ClansUtility if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return false; } @@ -1060,14 +1060,14 @@ public class ClansUtility // Role if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { - UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can unclaim Territory.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can unclaim Territory.")); return false; } // Not Claimed if (ownerClan == null || !ownerClan.equals(clan)) { - UtilPlayer.message(caller, F.main("Clans", "This Territory is not owned by you.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory is not owned by you.")); return false; } @@ -1085,7 +1085,7 @@ public class ClansUtility Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true); // Inform - UtilPlayer.message(caller, F.main("Clans", "You unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".")); clan.inform(F.name(caller.getName()) + " unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName()); return true; @@ -1097,13 +1097,13 @@ public class ClansUtility if (clan == null) { - UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return false; } if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER) { - UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader can unclaim all Territory.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader can unclaim all Territory.")); return false; } @@ -1121,7 +1121,7 @@ public class ClansUtility } // Inform - UtilPlayer.message(caller, F.main("Clans", "You unclaimed all your Clans Territory.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You unclaimed all your Clans Territory.")); clan.inform(F.name(caller.getName()) + " unclaimed all your Clans Territory.", caller.getName()); return true; @@ -1131,21 +1131,21 @@ public class ClansUtility { if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { - UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can send invites.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can send invites.")); return; } if (target.getName().equals(caller.getName())) { - UtilPlayer.message(caller, F.main("Clans", "You cannot invite yourself.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot invite yourself.")); return; } // Inform clan.inform(F.name(caller.getName()) + " invited " + F.name(target.getName()) + " to join your Clan.", caller.getName()); - UtilPlayer.message(caller, F.main("Clans", "You invited " + F.name(target.getName()) + " to join your Clan.")); - UtilPlayer.message(target, F.main("Clans", F.name(caller.getName()) + " invited you to join " + F.elem("Clan " + clan.getName()) + ".")); - UtilPlayer.message(target, F.main("Clans", "Type " + F.elem("/c join " + clan.getName()) + " to accept!")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You invited " + F.name(target.getName()) + " to join your Clan.")); + Clans.getTutorials().sendTutorialMsg(target, F.main("Clans", F.name(caller.getName()) + " invited you to join " + F.elem("Clan " + clan.getName()) + ".")); + Clans.getTutorials().sendTutorialMsg(target, F.main("Clans", "Type " + F.elem("/c join " + clan.getName()) + " to accept!")); // Task Clans.getClanDataAccess().invite(clan, target.getName(), caller.getName()); 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 bff3c7c76..cefd2bdc1 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 @@ -57,7 +57,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener public static String TUTORIAL_REWARD_TASK = "tatatatatat%sRewardGiven"; //do not change public static String SKIPPED_TASK = "tatatatata%sSkip"; - public static String AllowedMessage = C.cGold + "-=%TutorialAllowedMessage%=-" + C.Reset; + public static String AllowedMessage = C.cGold + "TutorialAllowedMessage" + C.Reset; protected final TutorialManager _manager; protected final GoldManager _goldManager; @@ -92,31 +92,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener _inTutorial = new LinkedHashMap<>(); _nameToTask = new LinkedHashMap<>(); - packetHandler.addPacketHandler(new IPacketHandler() { - public void handle(PacketInfo packet) - { - if (packet.getPacket() instanceof PacketPlayOutChat) - { - PacketPlayOutChat chat = (PacketPlayOutChat) packet.getPacket(); - - if (chat.b == 1) - { - if (!chat.a.a().get(0).c().equals(AllowedMessage)) - { - if (isInTutorial(packet.getPlayer())) - { - packet.setCancelled(true); - } - } - else - { - chat.a.a().remove(0); - } - } - } - } - }, PacketPlayOutChat.class); - _manager.getPluginManager().registerEvents(this, _manager.getPlugin()); } 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 eaec8bece..a65ec948a 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 @@ -13,7 +13,9 @@ import mineplex.core.MiniPlugin; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; +import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; +import mineplex.core.packethandler.PacketInfo; import mineplex.core.preferences.PreferencesManager; import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.ClansManager; @@ -22,6 +24,8 @@ import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand; import mineplex.game.clans.tutorials.commands.SkipTutorialCommand; import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted; +import net.md_5.bungee.api.ChatColor; +import net.minecraft.server.v1_8_R3.PacketPlayOutChat; public class TutorialManager extends MiniPlugin { @@ -41,6 +45,33 @@ public class TutorialManager extends MiniPlugin _taskManager = taskManager; _tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, clansManager, donationManager, goldManager, taskManager, packetHandler)); + + packetHandler.addPacketHandler(new IPacketHandler() { + public void handle(PacketInfo packet) + { + if (packet.getPacket() instanceof PacketPlayOutChat) + { + PacketPlayOutChat chat = (PacketPlayOutChat) packet.getPacket(); + + if (chat.b == 1) + { + if (chat.a.a().get(0).c().equals(ChatColor.stripColor(Tutorial.AllowedMessage))) + { + System.out.println("Modifying message"); + chat.a.a().remove(0); + } + else + { + if (isInTutorial(packet.getPlayer())) + { + System.out.println("Disallow message"); + packet.setCancelled(true); + } + } + } + } + } + }, PacketPlayOutChat.class); } public void addCommands() @@ -60,7 +91,6 @@ public class TutorialManager extends MiniPlugin if (_tutorials.containsKey(tutorial)) { _tutorials.get(tutorial).startFor(player); - _playerTutorials.put(player.getName(), _tutorials.get(tutorial)); return isInTutorial(player); } 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 802777151..1dee7b5c4 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 @@ -26,7 +26,7 @@ public class TaskClaim extends TutorialTask @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onClansCommand(ClansCommandExecutedEvent event) { - if (isDoing(event.getPlayer())) + if (!isDoing(event.getPlayer())) { return; } 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 40847ce70..134eec3a8 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 @@ -21,7 +21,7 @@ public class TaskCreateClan extends TutorialTask @EventHandler(priority = EventPriority.MONITOR) public void onClanCreated(ClanCreatedEvent event) { - if (isDoing(event.getFounder())) + if (!isDoing(event.getFounder())) { return; } From 35ae89ab1f4b066fc32e074236fc87a59cc07fe8 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Tue, 1 Dec 2015 19:37:53 +0000 Subject: [PATCH 11/23] fixed players from being able to eat their carrot in the making money task --- .../gettingstarted/TaskMakingMoney.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 d8ca69fd4..85964ae89 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 @@ -4,6 +4,8 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.inventory.ItemStack; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent; @@ -21,12 +23,30 @@ public class TaskMakingMoney extends TutorialTask _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."; + + _taskPos = new Location(Spawn.getSpawnWorld(), 25.536, 66, -316.844, -100f, 0f); } @Override public void customStartFor(Player player) { - player.teleport(new Location(Spawn.getSpawnWorld(), 25.536, 66, -316.844, -100f, 0f)); + player.getInventory().addItem(new ItemStack(Material.CARROT, 1)); + } + + @EventHandler + public void eat(PlayerItemConsumeEvent event) + { + if (!isDoing(event.getPlayer())) + { + return; + } + + if (!event.getItem().getType().equals(Material.CARROT)) + { + return; + } + + event.setCancelled(true); } @EventHandler From 69cb395f5a65f5831264a217ac61879e0c0868c3 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Tue, 1 Dec 2015 22:30:05 +0000 Subject: [PATCH 12/23] made entire clan know about disband --- .../src/mineplex/game/clans/clans/ClansUtility.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 f01423118..c39f1bbbe 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 @@ -665,6 +665,8 @@ public class ClansUtility return; } + Clans.messageClan(clan, C.cYellow + caller.getName() + C.cGray + " has disbanded the Clan."); + // Task Clans.getClanDataAccess().delete(clan, new Callback() { @@ -677,7 +679,7 @@ public class ClansUtility }else { - //(caller, F.main("Clans", "You disbanded your Clan.")); + Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You disbanded your Clan.")); } } }); From a7d6026c076b335abf272a5a5a95cddedc6cd0ed Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Tue, 1 Dec 2015 22:33:47 +0000 Subject: [PATCH 13/23] made skip tutorial messages be seen whilst in tutorial --- .../game/clans/tutorials/commands/SkipTutorialCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/SkipTutorialCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/SkipTutorialCommand.java index 3b69b6263..87caf4ce3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/SkipTutorialCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/SkipTutorialCommand.java @@ -24,7 +24,7 @@ public class SkipTutorialCommand extends CommandBase } else { - UtilPlayer.message(caller, F.main("Tutorials", "You are not currently in a tutorial.")); + Plugin.sendTutorialMsg(caller, F.main("Tutorials", "You are not currently in a tutorial.")); } } From cffb6bd62fd28989d2f3873049eff98c590d562d Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Tue, 1 Dec 2015 23:01:41 +0000 Subject: [PATCH 14/23] bunch o' changes --- .../elements/ScoreboardElementPlayer.java | 2 +- .../ScoreboardElementPlayerCount.java | 3 +- .../game/clans/tutorials/Tutorial.java | 167 +++++++++++------- .../game/clans/tutorials/TutorialClient.java | 8 +- .../game/clans/tutorials/TutorialManager.java | 7 +- .../game/clans/tutorials/TutorialTask.java | 47 +++++ .../gettingstarted/TaskCreateClan.java | 22 ++- .../gettingstarted/TaskCustomizeClass.java | 8 +- .../gettingstarted/TaskDisbandClan.java | 22 ++- .../gettingstarted/TaskEquipClass.java | 10 +- .../gettingstarted/TaskGoToWilderness.java | 37 ---- .../gettingstarted/TaskLeaveSpawn.java | 3 +- .../tutorials/gettingstarted/TaskSetHome.java | 3 +- .../gettingstarted/TaskUseAbility.java | 2 + .../TutorialGettingStarted.java | 1 - 15 files changed, 219 insertions(+), 123 deletions(-) delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskGoToWilderness.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index 36d4ac271..71cff03d0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -45,7 +45,7 @@ public class ScoreboardElementPlayer implements ScoreboardElement regionString += C.mBody + "(" + C.mElem + "Trusted" + C.mBody + ")"; } - output.add(regionString); + output.add(C.cYellow + "Territory " + C.Reset + regionString); return output; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java index 7a95cfdd2..81767e13e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java @@ -27,8 +27,9 @@ public class ScoreboardElementPlayerCount implements ScoreboardElement public List getLines(ScoreboardManager manager, Player player, List out) { List output = new ArrayList(); - output.add(C.cYellow + "Players Online: " + UtilServer.getPlayers().length + "/100"); + output.add(""); + output.add(C.cYellow + "Players Online " + C.cWhite + UtilServer.getPlayers().length + "/100"); return output; } 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 cefd2bdc1..c6ced2b04 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 @@ -29,6 +29,7 @@ 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.UtilTextMiddle; import mineplex.core.donation.DonationManager; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; @@ -150,6 +151,11 @@ public abstract class Tutorial implements ScoreboardElement, Listener protected boolean hasFinishedTask(Player player, TutorialTask task) { + if (get(player).QueuedFinish) + { + return true; + } + return get(player).CurrentTask.getID() < task.getID(); } @@ -238,82 +244,98 @@ public abstract class Tutorial implements ScoreboardElement, Listener private void finishFor(final Player player) { + if (player.getOpenInventory() != null) + { + _inTutorial.get(player.getName()).QueuedFinish = true; + return; + } + _inTutorial.remove(player.getName()); - // Fireworks - UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, Color.LIME, false, false, new Vector(0, 0, 0), 1); + UtilTextMiddle.display(C.cWhite + "Clans Tutorial", C.cGreen + "You have completed the Clans Tutorial!", 20, 20 * 3, 20); - // Custom Finish Method (usually messages) - onFinished(player); - - // Do Reward - if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_REWARD_TASK, _technicalName))) + _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() { - _taskManager.completedTask(new Callback() + public void run() { - @Override - public void run(Boolean data) + // Custom Finish Method (usually messages) + onFinished(player); + + // Do Reward + if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_REWARD_TASK, _technicalName))) { - if (_goldReward != -1) + _taskManager.completedTask(new Callback() { - _goldManager.addGold(player, _goldReward); - _manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + ".")); - } - - if (_gemReward != -1) - { - _donationManager.RewardGems(new Callback() { - public void run(Boolean data) - { - _manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gems") + ".")); - } - }, "Clans", player.getName(), player.getUniqueId(), _gemReward); - } - - if (_coinReward != -1) - { - _donationManager.RewardCoins(new Callback() { - public void run(Boolean data) - { - _manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_coinReward + " Coins") + ".")); - } - }, "Clans", player.getName(), _clansManager.getClientManager().getAccountId(player), _coinReward); - } - } - }, player, String.format(TUTORIAL_REWARD_TASK, _technicalName)); - - } - - // Sets the tutorial as complete in the TaskManager and effects. - if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName))) - { - _taskManager.completedTask(new Callback() - { - public void run(final Boolean completed) - { - if (_ghostMode) - { - for (Player other : UtilServer.getPlayers()) + @Override + public void run(Boolean data) { - other.showPlayer(player); - player.showPlayer(other); + if (_goldReward != -1) + { + _goldManager.addGold(player, _goldReward); + _manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + ".")); + } + + if (_gemReward != -1) + { + _donationManager.RewardGems(new Callback() { + public void run(Boolean data) + { + _manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gems") + ".")); + } + }, "Clans", player.getName(), player.getUniqueId(), _gemReward); + } + + if (_coinReward != -1) + { + _donationManager.RewardCoins(new Callback() { + public void run(Boolean data) + { + _manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_coinReward + " Coins") + ".")); + } + }, "Clans", player.getName(), _clansManager.getClientManager().getAccountId(player), _coinReward); + } + } + }, player, String.format(TUTORIAL_REWARD_TASK, _technicalName)); + } + + _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() + { + public void run() + { + // Sets the tutorial as complete in the TaskManager and effects. + if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName))) + { + _taskManager.completedTask(new Callback() + { + public void run(final Boolean completed) + { + if (_ghostMode) + { + for (Player other : UtilServer.getPlayers()) + { + other.showPlayer(player); + player.showPlayer(other); + } + } + + for (int i = 0; i < 8; i++) + { + final int index = i; + _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() + { + public void run() + { + UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, (index % 2 == 0) ? Color.RED : Color.LIME, false, false, new Vector(0, 0, 0), 0); + } + }, i * 10); + } + } + }, player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); } } - - for (int i = 0; i < 8; i++) - { - final int index = i; - _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() - { - public void run() - { - UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, (index % 2 == 0) ? Color.RED : Color.LIME, false, false, new Vector(0, 0, 0), 0); - } - }, i * 10); - } - } - }, player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); - } + }, 20 * 2); + } + }, 20 * 4); } // Implementation left to sub classes. @@ -464,6 +486,19 @@ public abstract class Tutorial implements ScoreboardElement, Listener { if (isInTutorial(player)) { + if (get(player).QueuedFinish) + { + if (player.getOpenInventory() == null) + { + get(player).QueuedFinish = false; + finishFor(player); + } + else + { + continue; + } + } + get(player).CurrentTask.trySendDescription(player); } } 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 c6071420e..043647117 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 @@ -9,6 +9,8 @@ public class TutorialClient public Player Player; public TutorialTask CurrentTask; public long LastDescriptionSentTime = System.currentTimeMillis() - 3000; + public boolean InClanOnStart; + public boolean QueuedFinish; public TutorialClient(Player player, Tutorial tutorial) { @@ -16,11 +18,15 @@ public class TutorialClient CurrentTask = tutorial._tasks.get(1); + InClanOnStart = tutorial._clansManager.isInClan(player); + for (TutorialTask task : tutorial._tasks.values()) { if (TaskManager.Instance.hasCompletedTask(player, String.format( Tutorial.TASK_COMPLETE_TASK, - task.getTutorial().getTechnicalName(), task.getTechnicalName()))) + task.getTutorial().getTechnicalName(), + task.getTechnicalName() + ))) { if (CurrentTask.getID() <= task.getID()) { 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 a65ec948a..7a637f7ba 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 @@ -55,16 +55,19 @@ public class TutorialManager extends MiniPlugin if (chat.b == 1) { + if (chat.a.a().isEmpty()) + { + return; + } + if (chat.a.a().get(0).c().equals(ChatColor.stripColor(Tutorial.AllowedMessage))) { - System.out.println("Modifying message"); chat.a.a().remove(0); } else { if (isInTutorial(packet.getPlayer())) { - System.out.println("Disallow message"); packet.setCancelled(true); } } 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 2b78d2dd9..90bd0cecf 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,11 +1,13 @@ package mineplex.game.clans.tutorials; +import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import mineplex.core.common.util.C; import mineplex.core.common.util.NautArrayList; import mineplex.core.common.util.UtilServer; +import mineplex.game.clans.clans.ClansManager; public class TutorialTask implements Listener { @@ -19,11 +21,17 @@ public class TutorialTask implements Listener protected String _description; protected String _finishMessage; + protected Location _taskPos; + + // How much time after the beginning the task/last teleport it should take to teleport back to _taskPos. + protected int _taskTpDelay = 2 * 60 * 20; + protected long _descriptionWaitTime = 30000; protected NautArrayList _playersFinished = new NautArrayList<>(); protected NautArrayList _inTask = new NautArrayList<>(); + private long _lastTaskTp; private int _id; public TutorialTask(T tutorial, int id) @@ -50,6 +58,25 @@ public class TutorialTask implements Listener customStartFor(player); + if (_taskPos != null) + { + player.teleport(_taskPos); + _lastTaskTp = System.currentTimeMillis(); + if (_taskTpDelay != -1) + { + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_tutorial._manager.getPlugin(), new Runnable(){ + public void run() + { + if (isDoing(player)) + { + player.teleport(_taskPos); + _lastTaskTp = System.currentTimeMillis(); + } + } + }, _taskTpDelay); + } + } + if (_autoCompleteTime != -1) { UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_tutorial._manager.getPlugin(), new Runnable(){ @@ -78,6 +105,11 @@ public class TutorialTask implements Listener TutorialClient client = _tutorial.get(player); + if (client.QueuedFinish) + { + return; + } + if (System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime()) { _tutorial._manager.sendTutorialMsg(player, " "); @@ -96,6 +128,11 @@ public class TutorialTask implements Listener public final boolean hasFinished(final Player player) { + if (_tutorial.get(player).QueuedFinish) + { + return true; + } + // CurrentTask will be null if player has finished tutorial return _tutorial.get(player).CurrentTask == null || _tutorial.get(player).CurrentTask.getID() < getID(); } @@ -120,6 +157,16 @@ public class TutorialTask implements Listener return _technicalName; } + public TutorialManager getManager() + { + return _tutorial._manager; + } + + public ClansManager getClans() + { + return _tutorial._clansManager; + } + public int getID() { return _id; 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 134eec3a8..26cb07f65 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 @@ -1,8 +1,10 @@ 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.UtilServer; import mineplex.game.clans.clans.event.ClanCreatedEvent; import mineplex.game.clans.tutorials.TutorialTask; @@ -15,7 +17,25 @@ 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! "; + _description = "Before beginning, use the {/c create } command to start up your own Clan! " + + "If you are already in a Clan, don't worry, you will automatically skip this part."; + } + + @Override + public void customStartFor(final Player player) + { + if (_tutorial.get(player).InClanOnStart) + { + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getManager().getPlugin(), new Runnable(){ + public void run() + { + if (isDoing(player)) + { + finishFor(player); + } + } + }, 6 * 20); + } } @EventHandler(priority = EventPriority.MONITOR) 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 802750575..23eaa66fc 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 @@ -26,12 +26,8 @@ public class TaskCustomizeClass extends TutorialTask _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 - public void customStartFor(Player player) - { - player.teleport(new Location(Spawn.getSpawnWorld(), 6, 66, -300, -180f, 0f)); + + _taskPos = new Location(Spawn.getSpawnWorld(), 6, 66, -300, -180f, 0f); } @EventHandler(priority = EventPriority.MONITOR) 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 index 0f21acf56..69ca5de33 100644 --- 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 @@ -1,7 +1,9 @@ package mineplex.game.clans.tutorials.gettingstarted; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import mineplex.core.common.util.UtilServer; import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.tutorials.TutorialTask; @@ -16,7 +18,25 @@ public class TaskDisbandClan extends TutorialTask _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!"; + + "This will delete your Clan, and you'll be able to create or join a new one! " + + "If you were already in a Clan before you originally begun the Tutorial, you will automatically skip this part."; + } + + @Override + public void customStartFor(final Player player) + { + if (_tutorial.get(player).InClanOnStart) + { + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getManager().getPlugin(), new Runnable(){ + public void run() + { + if (isDoing(player)) + { + finishFor(player); + } + } + }, 6 * 20); + } } @EventHandler 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 697ed3a9d..01584fd32 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 @@ -1,7 +1,6 @@ package mineplex.game.clans.tutorials.gettingstarted; -import java.util.HashMap; - +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -13,6 +12,7 @@ import mineplex.core.common.util.UtilItem; import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; +import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.tutorials.TutorialTask; import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent; @@ -27,7 +27,9 @@ public class TaskEquipClass extends TutorialTask _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 Champion’s Class."; + + "Then put on your armor to equip the Knight Class."; + + _taskPos = new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f); } private NautHashMap> _bought = new NautHashMap<>(); @@ -59,7 +61,7 @@ public class TaskEquipClass extends TutorialTask @EventHandler public void button(ClansShopAddButtonEvent event) { - if (isDoing(event.getPlayer())) + if (!isDoing(event.getPlayer())) { return; } 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 deleted file mode 100644 index e2b85aa1c..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskGoToWilderness.java +++ /dev/null @@ -1,37 +0,0 @@ -package mineplex.game.clans.tutorials.gettingstarted; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; -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 on our map by left and right clicking!"; - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onTerritory(final PlayerEnterTerritoryEvent event) - { - if (!isDoing(event.getPlayer())) - { - return; - } - - if (event.getNewTerritory().contains("Wilderness")) - { - finishFor(event.getPlayer()); - } - } -} 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 a1fbff948..3456ceb19 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 @@ -21,7 +21,8 @@ public class TaskLeaveSpawn extends TutorialTask _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!"; + + "Once you're down there, run out a couple of blocks to get to the Wilderness. " + + "When you finish the tutorial, you will be vulnerable to player attacks out there, so be careful!"; } @Override 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 index ebd16ede4..ca14eaf8c 100644 --- 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 @@ -17,7 +17,8 @@ public class TaskSetHome extends TutorialTask _technicalName = "SetClanHome"; _description = "You are now ready to set a Clan Home. " - + "To do this, use the {/c sethome} command."; + + "To do this, use the {/c sethome} command. " + + "After you set a Clan Home, you or any of your Clan mates will be able to teleport back to the Clan Home by typing {/c home} whenever they are at Spawn."; } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 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 95b989337..58c9bb58d 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 @@ -38,6 +38,8 @@ public class TaskUseAbility extends TutorialTask _description = "Now that you have equipped a class, you can start using abilities. " + "Purchase an Iron Axe from the PvP Shop. " + "Right-Click with your Iron Axe to use your Axe Ability!"; + + _taskPos = new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f); } private NautHashMap> _bought = new NautHashMap<>(); 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 1bbc4a23c..1972c2b0c 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 @@ -29,7 +29,6 @@ public class TutorialGettingStarted extends Tutorial 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)); From ba27d941587d9d71e5674d785d6772a7895987c3 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Tue, 1 Dec 2015 23:23:11 +0000 Subject: [PATCH 15/23] fixed skiptutorial message not displaying --- .../clans/scoreboard/elements/ScoreboardElementPlayer.java | 2 +- .../scoreboard/elements/ScoreboardElementPlayerCount.java | 2 +- .../src/mineplex/game/clans/tutorials/Tutorial.java | 4 +++- .../src/mineplex/game/clans/tutorials/TutorialTask.java | 2 +- .../tutorials/gettingstarted/TutorialGettingStarted.java | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index 71cff03d0..d96197fd2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -45,7 +45,7 @@ public class ScoreboardElementPlayer implements ScoreboardElement regionString += C.mBody + "(" + C.mElem + "Trusted" + C.mBody + ")"; } - output.add(C.cYellow + "Territory " + C.Reset + regionString); + output.add("Territory " + regionString); return output; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java index 81767e13e..288c4d757 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java @@ -29,7 +29,7 @@ public class ScoreboardElementPlayerCount implements ScoreboardElement List output = new ArrayList(); output.add(""); - output.add(C.cYellow + "Players Online " + C.cWhite + UtilServer.getPlayers().length + "/100"); + output.add("Players Online " + UtilServer.getPlayers().length + "/100"); return output; } 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 c6ced2b04..5203e5cd8 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 @@ -415,7 +415,9 @@ public abstract class Tutorial implements ScoreboardElement, Listener public void skip(final Player player) { new JsonMessage( - AllowedMessage + + AllowedMessage + ) + .extra( F.main( "Tutorial", "Are you sure you want to skip the tutorial? We " 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 90bd0cecf..909d303d6 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 @@ -118,7 +118,7 @@ public class TutorialTask implements Listener _tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); _tutorial._manager.sendTutorialMsg(player, " "); _tutorial._manager.sendTutorialMsg(player, C.cYellowB + "Part " + _id + ": " + _displayName); - _tutorial._manager.sendTutorialMsg(player, C.cWhite + _description.replace("{", C.cAqua).replace("}", C.cWhite)); + _tutorial._manager.sendTutorialMsg(player, C.cWhite + " " + _description.replace("{", C.cAqua).replace("}", C.cWhite)); _tutorial._manager.sendTutorialMsg(player, " "); _tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); 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 1972c2b0c..0fe1fc7fd 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 @@ -70,7 +70,7 @@ public class TutorialGettingStarted extends Tutorial _manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); _manager.sendTutorialMsg(player, " "); _manager.sendTutorialMsg(player, C.cYellowB + "Getting Started"); - _manager.sendTutorialMsg(player, C.cWhite + "Welcome to Clans! " + _manager.sendTutorialMsg(player, C.cWhite + " Welcome to Clans! " + "In this game mode you are able to create a clan, invite your friends to play with you, build a base, and wage war against others! " + "When you finish the tutorial, you will be awarded " + C.cAqua + "30,000 Gold"); _manager.sendTutorialMsg(player, " "); From b8e2086928a4051f0b5028addf4eb4c467c102d9 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 2 Dec 2015 00:19:48 +0000 Subject: [PATCH 16/23] changes to tutorial --- .../game/clans/clans/ClansUtility.java | 12 ++- .../event/PlayerPreClaimTerritoryEvent.java | 63 +++++++++++++ .../game/clans/tutorials/Tutorial.java | 94 ++++++++++--------- .../tutorials/gettingstarted/TaskClaim.java | 18 ++-- .../gettingstarted/TaskCustomizeClass.java | 5 +- .../gettingstarted/TaskLeaveSpawn.java | 2 +- .../gettingstarted/TaskViewClanDetails.java | 2 + 7 files changed, 137 insertions(+), 59 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerPreClaimTerritoryEvent.java 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 c39f1bbbe..c30741532 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 @@ -19,9 +19,9 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; -import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; +import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; import mineplex.game.clans.core.repository.ClanTerritory; @@ -689,6 +689,16 @@ public class ClansUtility { ClanInfo clan = getClanByPlayer(caller); + // Pre Event + PlayerPreClaimTerritoryEvent preEvent = new PlayerPreClaimTerritoryEvent(caller, caller.getLocation().getChunk(), clan); + + UtilServer.getServer().getPluginManager().callEvent(preEvent); + + if (preEvent.isCancelled()) + { + return false; + } + if (clan == null) { Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerPreClaimTerritoryEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerPreClaimTerritoryEvent.java new file mode 100644 index 000000000..e74cd8d96 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerPreClaimTerritoryEvent.java @@ -0,0 +1,63 @@ +package mineplex.game.clans.clans.event; + +import org.bukkit.Chunk; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.game.clans.clans.ClanInfo; + +public class PlayerPreClaimTerritoryEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _claimer; + private Chunk _claimedChunk; + + private boolean _cancelled; + + private ClanInfo _clan; + + public PlayerPreClaimTerritoryEvent(Player claimer, Chunk claimedChunk, ClanInfo clan) + { + _claimer = claimer; + _claimedChunk = claimedChunk; + _clan = clan; + } + + public Player getClaimer() + { + return _claimer; + } + + public ClanInfo getClan() + { + return _clan; + } + + public Chunk getClaimedChunk() + { + return _claimedChunk; + } + + 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 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 5203e5cd8..d5ce0818b 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 @@ -169,36 +169,43 @@ public abstract class Tutorial implements ScoreboardElement, Listener get(player).LastDescriptionSentTime = 0; get(player).CurrentTask.visibleFinish(player); - // Cycle to next task, or null if last task. - get(player).CurrentTask = task.equals(_tasks.get(_tasks.size())) ? null : _tasks.get(task.getID() + 1); - - if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName()))) + // 6 Seconds for player to read the finish message (sent by the line above) + _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() { - _taskManager.completedTask(new Callback() + public void run() { - public void run(final Boolean completed) + // Cycle to next task, or null if last task. + get(player).CurrentTask = task.equals(_tasks.get(_tasks.size())) ? null : _tasks.get(task.getID() + 1); + + if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName()))) { - // If last task, end tutorial. - if (task.equals(_tasks.get(_tasks.size()))) + _taskManager.completedTask(new Callback() { - finishFor(player); - } - else - { - // Start next task in 1.5 Seconds (just to give a more smooth feel to the tutorial) - _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() + public void run(final Boolean completed) { - public void run() + // If last task, end tutorial. + if (task.equals(_tasks.get(_tasks.size()))) { - get(player).CurrentTask.startFor(player); + finishFor(player); } - }, 10L); - } - - player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); + else + { + // Start next task in 1.5 Seconds (just to give a more smooth feel to the tutorial) + _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() + { + public void run() + { + get(player).CurrentTask.startFor(player); + } + }, 30L); + } + + player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); + } + }, player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())); } - }, player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())); - } + } + }, 6 * 20L); } public TutorialTask getTask(final String technicalName) @@ -303,35 +310,32 @@ public abstract class Tutorial implements ScoreboardElement, Listener public void run() { // Sets the tutorial as complete in the TaskManager and effects. - if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName))) + _taskManager.completedTask(new Callback() { - _taskManager.completedTask(new Callback() + public void run(final Boolean completed) { - public void run(final Boolean completed) + if (_ghostMode) { - if (_ghostMode) + for (Player other : UtilServer.getPlayers()) { - for (Player other : UtilServer.getPlayers()) - { - other.showPlayer(player); - player.showPlayer(other); - } - } - - for (int i = 0; i < 8; i++) - { - final int index = i; - _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() - { - public void run() - { - UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, (index % 2 == 0) ? Color.RED : Color.LIME, false, false, new Vector(0, 0, 0), 0); - } - }, i * 10); + other.showPlayer(player); + player.showPlayer(other); } } - }, player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); - } + + for (int i = 0; i < 8; i++) + { + final int index = i; + _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() + { + public void run() + { + UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, (index % 2 == 0) ? Color.RED : Color.LIME, false, false, new Vector(0, 0, 0), 0); + } + }, i * 10); + } + } + }, player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); } }, 20 * 2); } 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 1dee7b5c4..a3c936754 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 @@ -5,6 +5,7 @@ import org.bukkit.event.EventPriority; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent; import mineplex.game.clans.tutorials.TutorialTask; public class TaskClaim extends TutorialTask @@ -19,27 +20,24 @@ public class TaskClaim extends TutorialTask _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}!"; + + "You can only claim in the Wilderness, and not next to other Clan's Territory. " + + "To claim some territory, go into the Clans GUI by typing {/c} and {Left-Clicking}"; } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onClansCommand(ClansCommandExecutedEvent event) + public void onClansCommand(PlayerPreClaimTerritoryEvent event) { - if (!isDoing(event.getPlayer())) + if (!isDoing(event.getClaimer())) { return; } - if (!ClansManager.getInstance().isInClan(event.getPlayer())) + if (!ClansManager.getInstance().isInClan(event.getClaimer())) { return; } - if (event.getCommand().equals("claim")) - { - finishFor(event.getPlayer()); - event.setCancelled(true); - } + finishFor(event.getClaimer()); + event.setCancelled(true); } } 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 23eaa66fc..ea7d0c3a6 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 @@ -25,7 +25,8 @@ public class TaskCustomizeClass extends TutorialTask _technicalName = "CustomizeKlass"; _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."; + + "Click on the enchantment table, and click the edit build button. " + + "Make sure to select an axe ability to try out in the next task!"; _taskPos = new Location(Spawn.getSpawnWorld(), 6, 66, -300, -180f, 0f); } @@ -44,7 +45,7 @@ public class TaskCustomizeClass extends TutorialTask Player player = Bukkit.getPlayer(iterator.next()); final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(player); - if (clientclass != null && clientclass.GetSavingCustomBuild() != null) + if (clientclass != null && clientclass.GetSavingCustomBuild() != null && clientclass.GetSavingCustomBuild().AxeSkill != null) { 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 index 3456ceb19..71a8155da 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 @@ -47,7 +47,7 @@ public class TaskLeaveSpawn extends TutorialTask { Player player = Bukkit.getPlayer(iterator.next()); - if (player.getLocation().getY() < 100) + if (player.getLocation().getY() < 100 && getClans().getClanUtility().getClaim(player.getLocation()) == null) { finishFor(player); } 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 index 328400559..60e732340 100644 --- 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 @@ -28,6 +28,8 @@ public class TaskViewClanDetails extends TutorialTask return; } + System.out.println(event.getCommand()); + if (event.getCommand().equals("info")) { finishFor(event.getPlayer()); From bf92af647abceb78596f9fd1922d3522e61ff053 Mon Sep 17 00:00:00 2001 From: Virizion <9b717b9d4e5f09e89fa3@gmail.com> Date: Wed, 2 Dec 2015 00:00:32 -0500 Subject: [PATCH 17/23] Fixed the skull bug where it gave you the wrong skull type. Now gets the meta of the block as well. Also can return multiple items if the block is made up of multiple items (flower pots, ender portal frames). --- .../mineplex/core/common/util/UtilBlock.java | 177 +++++++++++++++++- 1 file changed, 173 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index 642f20998..da7bc464c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -6,18 +6,35 @@ import java.util.HashSet; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.SkullType; import org.bukkit.World; +import org.bukkit.block.Banner; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; +import org.bukkit.block.BrewingStand; +import org.bukkit.block.Chest; +import org.bukkit.block.Dispenser; +import org.bukkit.block.Dropper; +import org.bukkit.block.Furnace; +import org.bukkit.block.Hopper; +import org.bukkit.block.Jukebox; +import org.bukkit.block.Skull; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.material.Bed; import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.Blocks; import net.minecraft.server.v1_8_R3.EnumDirection; +import net.minecraft.server.v1_8_R3.Item; import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MinecraftKey; +import net.minecraft.server.v1_8_R3.NBTTagCompound; +import net.minecraft.server.v1_8_R3.TileEntityFlowerPot; import net.minecraft.server.v1_8_R3.WorldServer; public class UtilBlock @@ -844,9 +861,11 @@ public class UtilBlock return blocks; } - public static ItemStack blockToInventoryItemStack(Block block) + public static ArrayList blockToInventoryItemStacks(Block block) { ItemStack itemStack = new ItemStack(block.getType(), 1, block.getData()); + ArrayList itemStacks = new ArrayList(); + itemStacks.add(itemStack); switch (block.getType()) { @@ -877,6 +896,17 @@ public class UtilBlock break; case DISPENSER: itemStack.setDurability((short) 0); + + Dispenser dispenser = (Dispenser) block.getState(); + + for (ItemStack is : dispenser.getInventory().getContents()) + { + if (is == null) + continue; + + itemStacks.add(is); + } + break; case BED_BLOCK: itemStack.setType(Material.BED); @@ -921,6 +951,17 @@ public class UtilBlock break; case CHEST: itemStack.setDurability((short) 0); + + Chest chest = (Chest) block.getState(); + + for (ItemStack is : chest.getBlockInventory().getContents()) + { + if (is == null) + continue; + + itemStacks.add(is); + } + break; case REDSTONE_WIRE: itemStack.setType(Material.REDSTONE); @@ -936,10 +977,32 @@ public class UtilBlock break; case FURNACE: itemStack.setDurability((short) 0); + + Furnace furnace = (Furnace) block.getState(); + + for (ItemStack is : furnace.getInventory().getContents()) + { + if (is == null) + continue; + + itemStacks.add(is); + } + break; case BURNING_FURNACE: itemStack.setType(Material.FURNACE); itemStack.setDurability((short) 0); + + Furnace burningFurnace = (Furnace) block.getState(); + + for (ItemStack is : burningFurnace.getInventory().getContents()) + { + if (is == null) + continue; + + itemStacks.add(is); + } + break; case SIGN_POST: itemStack.setType(Material.SIGN); @@ -1001,6 +1064,12 @@ public class UtilBlock break; case JUKEBOX: itemStack.setDurability((short) 0); + + Jukebox jukebox = (Jukebox) block.getState(); + + if (jukebox.getPlaying() != Material.AIR) + itemStacks.add(new ItemStack(jukebox.getPlaying())); + break; case PORTAL: itemStack.setType(Material.AIR); @@ -1057,10 +1126,25 @@ public class UtilBlock case BREWING_STAND: itemStack.setType(Material.BREWING_STAND_ITEM); itemStack.setDurability((short) 0); + + BrewingStand brewingStand = (BrewingStand) block.getState(); + + for (ItemStack is : brewingStand.getInventory().getContents()) + { + if (is == null) + continue; + + itemStacks.add(is); + } + break; case CAULDRON: itemStack.setType(Material.CAULDRON_ITEM); itemStack.setDurability((short) 0); + + if (block.getData() != 0) + itemStacks.add(new ItemStack(Material.WATER_BUCKET)); + break; case ENDER_PORTAL: itemStack.setType(Material.AIR); @@ -1068,6 +1152,10 @@ public class UtilBlock break; case ENDER_PORTAL_FRAME: itemStack.setDurability((short) 0); + + if ((block.getData() & 0x4) != 0) + itemStacks.add(new ItemStack(Material.EYE_OF_ENDER)); + break; case REDSTONE_LAMP_ON: itemStack.setType(Material.REDSTONE_LAMP_OFF); @@ -1111,6 +1199,27 @@ public class UtilBlock case FLOWER_POT: itemStack.setType(Material.FLOWER_POT_ITEM); itemStack.setDurability((short) 0); + + //The FlowerPot class is outdated and doesn't work so we do some NBT checking + TileEntityFlowerPot tefp = (TileEntityFlowerPot) ((CraftWorld) block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ())); + + NBTTagCompound c = new NBTTagCompound(); + tefp.b(c); + + ItemStack blockInPot = new ItemStack(Material.AIR); + + if (c.hasKey("Item")) + { + MinecraftKey mk = new MinecraftKey(c.getString("Item")); + blockInPot = CraftItemStack.asNewCraftStack(Item.REGISTRY.get(mk)); + } + + if (c.hasKey("Data")) + blockInPot.setDurability(c.getShort("Data")); + + if (blockInPot.getType() != Material.AIR) + itemStacks.add(blockInPot); + break; case CARROT: itemStack.setType(Material.CARROT_ITEM); @@ -1125,9 +1234,31 @@ public class UtilBlock break; case SKULL: itemStack.setType(Material.SKULL_ITEM); + + Skull skull = (Skull) block.getState(); + itemStack.setDurability((short) skull.getSkullType().ordinal()); + + if (skull.getSkullType() == SkullType.PLAYER && skull.hasOwner()) + { + SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta(); + skullMeta.setOwner(skull.getOwner()); + itemStack.setItemMeta(skullMeta); + } + break; case TRAPPED_CHEST: itemStack.setDurability((short) 0); + + Chest trappedChest = (Chest) block.getState(); + + for (ItemStack is : trappedChest.getBlockInventory().getContents()) + { + if (is == null) + continue; + + itemStacks.add(is); + } + break; case GOLD_PLATE: itemStack.setDurability((short) 0); @@ -1148,6 +1279,17 @@ public class UtilBlock break; case HOPPER: itemStack.setDurability((short) 0); + + Hopper hopper = (Hopper) block.getState(); + + for (ItemStack is : hopper.getInventory().getContents()) + { + if (is == null) + continue; + + itemStacks.add(is); + } + break; case QUARTZ_STAIRS: itemStack.setDurability((short) 0); @@ -1157,6 +1299,17 @@ public class UtilBlock break; case DROPPER: itemStack.setDurability((short) 0); + + Dropper dropper = (Dropper) block.getState(); + + for (ItemStack is : dropper.getInventory().getContents()) + { + if (is == null) + continue; + + itemStacks.add(is); + } + break; case LEAVES_2: itemStack.setDurability((short) (itemStack.getDurability() % 4)); @@ -1178,11 +1331,27 @@ public class UtilBlock break; case STANDING_BANNER: itemStack.setType(Material.BANNER); - itemStack.setDurability((short) 0); + + Banner banner = (Banner) block.getState(); + itemStack.setDurability(banner.getBaseColor().getDyeData()); + + BannerMeta bannerMeta = (BannerMeta) itemStack.getItemMeta(); + bannerMeta.setBaseColor(bannerMeta.getBaseColor()); + bannerMeta.setPatterns(banner.getPatterns()); + itemStack.setItemMeta(bannerMeta); + break; case WALL_BANNER: itemStack.setType(Material.BANNER); - itemStack.setDurability((short) 0); + + Banner wallBanner = (Banner) block.getState(); + itemStack.setDurability(wallBanner.getBaseColor().getDyeData()); + + BannerMeta wallBannerMeta = (BannerMeta) itemStack.getItemMeta(); + wallBannerMeta.setBaseColor(wallBannerMeta.getBaseColor()); + wallBannerMeta.setPatterns(wallBanner.getPatterns()); + itemStack.setItemMeta(wallBannerMeta); + break; case DAYLIGHT_DETECTOR_INVERTED: itemStack.setType(Material.DAYLIGHT_DETECTOR); @@ -1235,6 +1404,6 @@ public class UtilBlock break; } - return itemStack; + return itemStacks; } } From d6ca52e4a42f11a8da58b7e609b7b8598d64a803 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 2 Dec 2015 05:11:09 +0000 Subject: [PATCH 18/23] modifications --- .../mineplex/core/common/util/UtilItem.java | 53 +++++++++++++++++++ .../core/scoreboard/PlayerScoreboard.java | 2 +- .../elements/ScoreboardElementPlayer.java | 2 +- .../ScoreboardElementPlayerCount.java | 2 +- 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index 4a0745708..c82d37f9f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -196,8 +196,56 @@ public class UtilItem _materials.put(Material.PACKED_ICE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.MOVEMENT_MODIFYING)); _materials.put(Material.DOUBLE_PLANT, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS)); + _materials.put(Material.SLIME_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); + _materials.put(Material.BARRIER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); + _materials.put(Material.IRON_TRAPDOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); + _materials.put(Material.PRISMARINE, EnumSet.of(ItemCategory.BLOCK)); + _materials.put(Material.SEA_LANTERN, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LIGHT_EMITTING)); + _materials.put(Material.STANDING_BANNER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); + _materials.put(Material.WALL_BANNER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); + _materials.put(Material.DAYLIGHT_DETECTOR_INVERTED, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); + _materials.put(Material.RED_SANDSTONE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.STONE)); + _materials.put(Material.RED_SANDSTONE_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.STONE, ItemCategory.TRANSLUCENT)); + _materials.put(Material.DOUBLE_STONE_SLAB2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.STONE)); + _materials.put(Material.STONE_SLAB2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.STONE, ItemCategory.TRANSLUCENT)); + _materials.put(Material.SPRUCE_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.BIRCH_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.JUNGLE_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.DARK_OAK_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.ACACIA_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.SPRUCE_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.BIRCH_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.JUNGLE_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.SPRUCE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.BIRCH_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.JUNGLE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.ACACIA_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.DARK_OAK_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + + + _materials.put(Material.DARK_OAK_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.ACACIA_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.DARK_OAK_DOOR_ITEM, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + // Items + _materials.put(Material.PRISMARINE_SHARD, EnumSet.of(ItemCategory.ITEM)); + _materials.put(Material.PRISMARINE_CRYSTALS, EnumSet.of(ItemCategory.ITEM)); + _materials.put(Material.RABBIT, EnumSet.of(ItemCategory.ITEM, ItemCategory.RAW_FOOD, ItemCategory.EDIBLE)); + _materials.put(Material.COOKED_RABBIT, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE)); + _materials.put(Material.RABBIT_STEW, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE)); + _materials.put(Material.RABBIT_FOOT, EnumSet.of(ItemCategory.ITEM)); + _materials.put(Material.RABBIT_HIDE, EnumSet.of(ItemCategory.ITEM)); + _materials.put(Material.ARMOR_STAND, EnumSet.of(ItemCategory.ITEM)); + _materials.put(Material.MUTTON, EnumSet.of(ItemCategory.ITEM, ItemCategory.RAW_FOOD, ItemCategory.EDIBLE)); + _materials.put(Material.COOKED_MUTTON, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE)); + _materials.put(Material.BANNER, EnumSet.of(ItemCategory.ITEM)); + _materials.put(Material.SPRUCE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD)); + _materials.put(Material.BIRCH_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD)); + _materials.put(Material.JUNGLE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD)); + _materials.put(Material.ACACIA_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD)); + + _materials.put(Material.IRON_SPADE, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.TOOL, ItemCategory.SHOVEL)); _materials.put(Material.IRON_PICKAXE, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.TOOL, ItemCategory.PICKAXE)); _materials.put(Material.IRON_AXE, EnumSet.of(ItemCategory.AXE, ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.WEAPON, ItemCategory.TOOL)); @@ -1063,4 +1111,9 @@ public class UtilItem } } } + + public static boolean isIndexed(Material material) + { + return _materials.containsKey(material); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java index 0fa2179d8..ef8e05796 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java @@ -113,7 +113,7 @@ public class PlayerScoreboard System.out.println("Scoreboard Error: Line Team Not Found!"); return; } - + //Set Line Prefix/Suffix team.setPrefix(newLine.substring(0, Math.min(newLine.length(), 16))); team.setSuffix(ChatColor.getLastColors(team.getPrefix()) + newLine.substring(team.getPrefix().length(), Math.min(newLine.length(), 32))); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index d96197fd2..36d4ac271 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -45,7 +45,7 @@ public class ScoreboardElementPlayer implements ScoreboardElement regionString += C.mBody + "(" + C.mElem + "Trusted" + C.mBody + ")"; } - output.add("Territory " + regionString); + output.add(regionString); return output; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java index 288c4d757..be56178a3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java @@ -29,7 +29,7 @@ public class ScoreboardElementPlayerCount implements ScoreboardElement List output = new ArrayList(); output.add(""); - output.add("Players Online " + UtilServer.getPlayers().length + "/100"); + output.add(C.cYellow + "Players Online " + UtilServer.getPlayers().length + "/100"); return output; } From 3a4e453ac322161dcdd325e01316cf0a21121afd Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 2 Dec 2015 05:18:04 +0000 Subject: [PATCH 19/23] made it so that you can only use /reset in safe zones --- .../clans/commands/RestartTutCommand.java | 31 ++++++++++++------- .../game/clans/tutorials/TutorialTask.java | 3 ++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java index 2b599831f..be19befc8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.task.TaskManager; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.tutorials.Tutorial; import mineplex.game.clans.tutorials.TutorialManager; import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted; @@ -21,20 +22,28 @@ public class RestartTutCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - String ignoreString = String.format(Tutorial.TUTORIAL_REWARD_TASK, "GettingStartedTutorial"); - Integer ignoreInt = TaskManager.Instance.getTaskId(ignoreString); - - Iterator it = TaskManager.Instance.Get(caller).TasksCompleted.iterator(); - while (it.hasNext()) + if (ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null + && ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).isSafe(caller.getLocation())) { - Integer i = it.next(); - if (i != null && (ignoreInt == null || i.intValue() != ignoreInt.intValue())) + String ignoreString = String.format(Tutorial.TUTORIAL_REWARD_TASK, "GettingStartedTutorial"); + Integer ignoreInt = TaskManager.Instance.getTaskId(ignoreString); + + Iterator it = TaskManager.Instance.Get(caller).TasksCompleted.iterator(); + while (it.hasNext()) { - it.remove(); + Integer i = it.next(); + if (i != null && (ignoreInt == null || i.intValue() != ignoreInt.intValue())) + { + it.remove(); + } } + + TutorialManager.Instance.cancelTutorial(caller); + TutorialManager.Instance.startTutorial(TutorialGettingStarted.class, caller); + } + else + { + TutorialManager.Instance.sendTutorialMsg(caller, "You must be in a safezone to restart the tutorial."); } - - TutorialManager.Instance.cancelTutorial(caller); - TutorialManager.Instance.startTutorial(TutorialGettingStarted.class, caller); } } 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 909d303d6..0934fff08 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 @@ -7,6 +7,7 @@ import org.bukkit.event.Listener; import mineplex.core.common.util.C; import mineplex.core.common.util.NautArrayList; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.game.clans.clans.ClansManager; public class TutorialTask implements Listener @@ -122,6 +123,8 @@ public class TutorialTask implements Listener _tutorial._manager.sendTutorialMsg(player, " "); _tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + UtilTextMiddle.display("", getDisplayName()); + client.LastDescriptionSentTime = System.currentTimeMillis(); } } From 8db5ffe5c755def1186034a6aafb2d9d4ffd4533 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 2 Dec 2015 05:54:00 +0000 Subject: [PATCH 20/23] forcejoin command for ADMIN+ and fixed auto tree replanting. --- .../clans/clans/commands/ClansCommand.java | 32 ++++++++++++++++++- .../game/clans/gameplay/Gameplay.java | 22 +++++-------- .../gettingstarted/TaskExploreShops.java | 2 ++ 3 files changed, 41 insertions(+), 15 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 7555950bb..b956eedfe 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 @@ -66,7 +66,8 @@ public class ClansCommand extends CommandBase else if (args[0].equalsIgnoreCase("promote") || args[0].equalsIgnoreCase("+")) promote(caller, args); - + else if (args[0].equalsIgnoreCase("forcejoin") || args[0].equalsIgnoreCase("fj")) + forceJoin(caller, args); else if (args[0].equalsIgnoreCase("demote") || args[0].equalsIgnoreCase("-")) demote(caller, args); @@ -122,6 +123,35 @@ public class ClansCommand extends CommandBase infoClan(caller, args[0]); } + private void forceJoin(Player caller, String[] args) + { + if (!Plugin.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.getName().equals("NewGarbo")) + { + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This requires ADMIN+ permission.")); + return; + } + + if (args.length > 1) + { + ClanInfo clan = Plugin.getClan(args[1]); + + if (clan != null) + { + _manager.getClanUtility().join(caller, clan); + _manager.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.LEADER); + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You have successfully joined " + F.elem(clan.getName()) + " and are now Leader Role.")); + } + else + { + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan provided does not exist.")); + } + } + else + { + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "No clan provided.")); + } + } + public void commandChat(Player caller, String[] args) { if (args.length == 0) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index 17a850bf8..6cb5196a7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -55,6 +55,7 @@ import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; @@ -433,7 +434,7 @@ public class Gameplay extends MiniPlugin @EventHandler(priority = EventPriority.LOWEST) public void replantTree(BlockBreakEvent event) { - Block block = event.getBlock(); + final Block block = event.getBlock(); if (!UtilItem.isLog(block.getType())) { @@ -455,22 +456,15 @@ public class Gameplay extends MiniPlugin return; } - Location saplingArea = null; + final byte data = block.getData(); - for (Block otherBlock : UtilBlock.getInRadius(event.getBlock().getLocation(), 4.5).keySet()) - { - if (!otherBlock.equals(UtilBlock.getHighest(otherBlock.getLocation().getWorld(), otherBlock.getX(), otherBlock.getZ()))) + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { + public void run() { - saplingArea = otherBlock.getLocation(); - if (Math.random() > .75) - { - break; - } + block.setType(Material.SAPLING); + block.setData(data); } - } - - saplingArea.add(0, 1, 0).getBlock().setType(Material.SAPLING); - saplingArea.getBlock().setData(block.getData()); + }, 20 * 5); } @EventHandler 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 ee10b2da4..a41c5f0ef 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 @@ -25,6 +25,8 @@ public class TaskExploreShops extends TutorialTask _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. " + + "To be able to claim territory for your clan, your clan must have energy. " + + "Clan energy is required to make keep territory claimed as yours. " + "Go to the Energy Shop and buy {Max Energy}. (FREE)"; } From 92c1abf221f82baa3da66efaf831c61f1c885b77 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 2 Dec 2015 06:04:53 +0000 Subject: [PATCH 21/23] a few last touches --- .../src/mineplex/game/clans/tutorials/Tutorial.java | 3 ++- .../clans/tutorials/gettingstarted/TaskExploreShops.java | 7 +++++-- .../clans/tutorials/gettingstarted/TaskMakingMoney.java | 4 ++++ 3 files changed, 11 insertions(+), 3 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 d5ce0818b..166dbc6e8 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 @@ -170,6 +170,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener get(player).CurrentTask.visibleFinish(player); // 6 Seconds for player to read the finish message (sent by the line above) + // (will be instant if get(player).CurrentTask.getFinishMessage() is null). _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() { public void run() @@ -205,7 +206,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener }, player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())); } } - }, 6 * 20L); + }, get(player).CurrentTask._finishMessage == null ? 1L : 6 * 20L); } public TutorialTask getTask(final String technicalName) 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 a41c5f0ef..39ddfd126 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 @@ -25,9 +25,12 @@ public class TaskExploreShops extends TutorialTask _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. " - + "To be able to claim territory for your clan, your clan must have energy. " - + "Clan energy is required to make keep territory claimed as yours. " + + "Clan Energy is required to maintain the clan, without it, you will lose all claimed Territory! " + "Go to the Energy Shop and buy {Max Energy}. (FREE)"; + + _finishMessage = "Great! " + + "Clans use energy to control Territory. " + + "More territory will cause your energy to drain faster, so make sure you remember to refill it regularly!"; } @Override 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 85964ae89..3aefb2ab7 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 @@ -24,6 +24,10 @@ public class TaskMakingMoney extends TutorialTask _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."; + _finishMessage = "Good job! " + + "Farming and selling foods like carrots and potatoes are great ways to make money. " + + "You can also sell blocks, ores, and many other items that a Shop may be interested in buying."; + _taskPos = new Location(Spawn.getSpawnWorld(), 25.536, 66, -316.844, -100f, 0f); } From 8fea5afdce91ed3273396ebc5980acdc1b20dac0 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 2 Dec 2015 06:56:58 +0000 Subject: [PATCH 22/23] fixed message on tick (might be cause of laggg) --- .../mineplex/game/clans/clans/worldevent/kinghill/KingHill.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java index dfe1d6d27..6d08c9e19 100755 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java @@ -114,7 +114,6 @@ public class KingHill extends WorldEvent for (Player player : UtilServer.getPlayers()) { - System.out.println(getCenterLocation()); if (_hill.isOnHill(player.getLocation(), getCenterLocation())) { ClanInfo playerClan = _clansManager.getClan(player); From e9fd661311910c81c287ca146d5f22ccbe80dfcc Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 2 Dec 2015 18:25:53 +0000 Subject: [PATCH 23/23] disabled koth --- .../mineplex/game/clans/clans/worldevent/WorldEventType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index fd000e344..3852f4451 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -12,7 +12,7 @@ import mineplex.minecraft.game.core.boss.WorldEvent; public enum WorldEventType { // SLIME_KING("Slime King", SlimeBoss.class, 30), - KING_HILL("King of The Hill", KingHill.class, 30), +// KING_HILL("King of The Hill", KingHill.class, 30), UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30);// , // Golem("Iron Wizard", GolemBoss.class, 30);