From d7731d330c0d41a4b8f651304c259201fb1891f7 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 1 Jun 2017 00:34:21 +0200 Subject: [PATCH] Do some visual adjustments, add back button to quest stats menu, remove quest from buy bar after completion --- .../mineplex/core/quests/QuestManager.java | 8 ++++- ...tBuyEvent.java => QuestInteractEvent.java} | 4 +-- .../core/quests/shop/BuyQuestButton.java | 6 ++-- .../mineplex/core/quests/shop/QuestPage.java | 14 +++++++-- .../core/quests/shop/QuestStatsPage.java | 30 ++++++++++++------- .../quests/shop/RedeemDeclineQuestButton.java | 8 +++++ .../src/nautilus/game/arcade/game/Game.java | 6 ++-- 7 files changed, 54 insertions(+), 22 deletions(-) rename Plugins/Mineplex.Core/src/mineplex/core/quests/event/{QuestBuyEvent.java => QuestInteractEvent.java} (90%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index 6ec36cbb9..edcf26733 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -25,6 +25,8 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.Pair; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; import mineplex.core.google.GoogleSheetsManager; import mineplex.core.hologram.Hologram; @@ -90,7 +92,7 @@ public class QuestManager extends MiniClientPlugin else { Location loc = _questNPC.getEntity().getLocation(); - _hologram = new Hologram(hologramManager, loc.clone().add(0, 2.5, 0), ChatColor.GREEN + "" + ChatColor.BOLD + "(QUESTS)"); + _hologram = new Hologram(hologramManager, loc.clone().add(0, 2.8, 0), ChatColor.AQUA + "Quests"); _hologram.start(); _enableNPC = true; } @@ -252,6 +254,10 @@ public class QuestManager extends MiniClientPlugin public void incrementQuest(Player player, Quest quest, int value) { quest.increment(value); + if (quest.isCompleted()) + { + UtilPlayer.message(player, F.main("Quest", "You have completed the Quest: " + ChatColor.YELLOW + quest.getName())); + } _repository.incrementQuest(_clients.Get(player), quest, value); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestBuyEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestInteractEvent.java similarity index 90% rename from Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestBuyEvent.java rename to Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestInteractEvent.java index a1cfba344..2ebc13f8d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestBuyEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestInteractEvent.java @@ -11,7 +11,7 @@ import mineplex.core.quests.Quest; * * @author xXVevzZXx */ -public class QuestBuyEvent extends Event +public class QuestInteractEvent extends Event { private static final HandlerList handlers = new HandlerList(); @@ -21,7 +21,7 @@ public class QuestBuyEvent extends Event private String _cancelReason; - public QuestBuyEvent(Quest quest) + public QuestInteractEvent(Quest quest) { _quest = quest; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java index ac0ad615f..2d7364a8c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java @@ -13,7 +13,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.quests.Quest; import mineplex.core.quests.QuestManager; -import mineplex.core.quests.event.QuestBuyEvent; +import mineplex.core.quests.event.QuestInteractEvent; import mineplex.core.recharge.Recharge; import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; @@ -69,14 +69,14 @@ public class BuyQuestButton implements IButton } } - QuestBuyEvent event = UtilServer.CallEvent(new QuestBuyEvent(_quest)); + QuestInteractEvent event = UtilServer.CallEvent(new QuestInteractEvent(_quest)); if (event.isCancelled()) { UtilPlayer.message(player, F.main("Quest", event.getCancelMessage())); return; } - SalesPackageBase salesPackage = new QuestSale(_quest.getName(), Material.PAPER, _quest.getCost()); + SalesPackageBase salesPackage = new QuestSale(ChatColor.YELLOW + "" + ChatColor.BOLD + _quest.getName(), Material.PAPER, _quest.getCost()); _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, _page.getDonationManager(), () -> { _questManager.addNewQuest(player, _quest); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java index adcac183e..44d18dcb3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java @@ -15,6 +15,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; @@ -52,7 +55,7 @@ public class QuestPage extends ShopPageBase ArrayList playerQuests = _shop.getQuestManager().Get(_player).getQuests(); int i = 0; - setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.RESET + "" + ChatColor.BOLD + "Quests to buy")); + setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.RESET + "" + ChatColor.BOLD + "Available Quests")); { int currentSlot = 4; int diff = 0; @@ -74,9 +77,14 @@ public class QuestPage extends ShopPageBase for (Quest playerQuest : playerQuests) { - if (playerQuest.isActive()) + if (playerQuest.getID() == questID) { - if (playerQuest.getID() == questID) + if (!UtilTime.elapsed(playerQuest.getLastCompleted(), 1000*60*60*24)) + { + cont = true; + break; + } + if (playerQuest.isActive()) { cont = true; break; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java index 60b26f201..7fcdce5bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java @@ -33,7 +33,7 @@ public class QuestStatsPage extends ShopPageBase public QuestStatsPage(QuestManager plugin, QuestStatShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, int site) { - super(plugin, shop, clientManager, donationManager, "Quest Stats", player, 4*9); + super(plugin, shop, clientManager, donationManager, "Quest Stats", player, 6*9); _siteIndex = site; @@ -46,8 +46,8 @@ public class QuestStatsPage extends ShopPageBase @Override protected void buildPage() { - int questID = (_siteIndex * 3 * 9); - for (int i = 0; i < 9*3; i++) + int questID = (_siteIndex * 5 * 9); + for (int i = 0; i < 9*5; i++) { Quest quest = _manager.getQuestByID(questID); @@ -76,30 +76,40 @@ public class QuestStatsPage extends ShopPageBase if (_siteIndex != 0) { - addButton(3*9, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Previous Page"), new IButton() + addButton(5*9, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Previous Page"), new IButton() { @Override public void onClick(Player player, ClickType clickType) { - player.closeInventory(); - getQuestStatsShop().openPageForPlayer(player, new QuestStatsPage(_manager, getQuestStatsShop(), _manager.getClients(), _manager.getDonations(), player, _siteIndex - 1)); + _siteIndex--; + buildPage(); } }); } - if (((_siteIndex + 1) * 3 * 9) < _manager.getAvailableQuests().size()) + if (((_siteIndex + 1) * 5 * 9) < _manager.getAvailableQuests().size()) { - addButton((4*9) - 1, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Next Page"), new IButton() + addButton((6*9) - 1, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Next Page"), new IButton() { @Override public void onClick(Player player, ClickType clickType) { - player.closeInventory(); - getQuestStatsShop().openPageForPlayer(player, new QuestStatsPage(_manager, getQuestStatsShop(), _manager.getClients(), _manager.getDonations(), player, _siteIndex + 1)); + _siteIndex++; + buildPage(); } }); } + addButton(5*9 + 4, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Back to Quests"), new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + player.closeInventory(); + new QuestShop(_manager, getClientManager(), getDonationManager()).attemptShopOpen(player); + } + }); + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java index 2a254ed94..42949355b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java @@ -18,6 +18,7 @@ import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.quests.Quest; import mineplex.core.quests.QuestManager; +import mineplex.core.quests.event.QuestInteractEvent; import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; @@ -59,6 +60,13 @@ public class RedeemDeclineQuestButton implements IButton return; } + QuestInteractEvent event = UtilServer.CallEvent(new QuestInteractEvent(_quest)); + if (event.isCancelled()) + { + UtilPlayer.message(player, F.main("Quest", event.getCancelMessage())); + return; + } + if (clickType == ClickType.SHIFT_RIGHT) { if (_quest.isCompleted()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index efa797e1f..5e8c129c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -75,7 +75,7 @@ import mineplex.core.lifetimes.ListenerComponent; import mineplex.core.lifetimes.PhasedLifetime; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; -import mineplex.core.quests.event.QuestBuyEvent; +import mineplex.core.quests.event.QuestInteractEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilGameProfile; @@ -2083,10 +2083,10 @@ public abstract class Game extends ListenerComponent implements Lifetimed } @EventHandler - public void onQuestBuy(QuestBuyEvent event) + public void onQuestBuy(QuestInteractEvent event) { if (GetState() == GameState.Live || GetState() == GameState.Prepare || GetState() == GameState.End) - event.setCancelled("You cant buy Quests while you are ingame!"); + event.setCancelled("You cant interact with Quests while you are ingame!"); } public NautHashMap getDeadBodies()