Do some visual adjustments, add back button to quest stats menu, remove quest from buy bar after completion

This commit is contained in:
Sarah 2017-06-01 00:34:21 +02:00
parent c355015041
commit d7731d330c
7 changed files with 54 additions and 22 deletions

View File

@ -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<QuestClientData>
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<QuestClientData>
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);
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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<QuestManager, QuestShop>
ArrayList<Quest> 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<QuestManager, QuestShop>
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;

View File

@ -33,7 +33,7 @@ public class QuestStatsPage extends ShopPageBase<QuestManager, QuestStatShop>
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<QuestManager, QuestStatShop>
@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<QuestManager, QuestStatShop>
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);
}
});
}

View File

@ -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())

View File

@ -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<String, Entity> getDeadBodies()