Add Quest triggers, add a Repository, add Spreadsheet parsing, and add menus.
This commit is contained in:
parent
8d32c35f88
commit
20281648c2
@ -9,6 +9,8 @@ import mineplex.core.game.GameDisplay;
|
|||||||
*/
|
*/
|
||||||
public class Quest
|
public class Quest
|
||||||
{
|
{
|
||||||
|
private static final Object _progressLock = new Object();
|
||||||
|
|
||||||
private int _questID;
|
private int _questID;
|
||||||
|
|
||||||
private String _questName;
|
private String _questName;
|
||||||
@ -89,24 +91,57 @@ public class Quest
|
|||||||
return _statToComplete;
|
return _statToComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getProgress()
|
||||||
|
{
|
||||||
|
return _current;
|
||||||
|
}
|
||||||
|
|
||||||
public void setProgress(int progress)
|
public void setProgress(int progress)
|
||||||
{
|
{
|
||||||
_current = progress;
|
_current = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void increment(int value)
|
||||||
|
{
|
||||||
|
synchronized (_progressLock)
|
||||||
|
{
|
||||||
|
_current += value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void increment()
|
public void increment()
|
||||||
{
|
{
|
||||||
_current++;
|
synchronized (_progressLock)
|
||||||
|
{
|
||||||
|
_current++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decrement(int value)
|
||||||
|
{
|
||||||
|
synchronized (_progressLock)
|
||||||
|
{
|
||||||
|
_current -= value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decrement()
|
public void decrement()
|
||||||
{
|
{
|
||||||
_current--;
|
synchronized (_progressLock)
|
||||||
|
{
|
||||||
|
_current--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompleted()
|
public boolean isCompleted()
|
||||||
{
|
{
|
||||||
return _current == _statToComplete;
|
return _current >= _statToComplete;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Quest clone()
|
||||||
|
{
|
||||||
|
return new Quest(_questID, _questName, _questTask, _questCost, _questReward, _rarity, _game, _trigger, _item, _statToComplete);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package mineplex.core.quests;
|
package mineplex.core.quests;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* QuestClientData
|
* QuestClientData
|
||||||
@ -9,10 +9,41 @@ import org.bukkit.entity.Player;
|
|||||||
*/
|
*/
|
||||||
public class QuestClientData
|
public class QuestClientData
|
||||||
{
|
{
|
||||||
|
private ArrayList<Quest> _quests = new ArrayList<>();
|
||||||
|
|
||||||
public QuestClientData(Player player)
|
public void addQuest(Quest quest)
|
||||||
{
|
{
|
||||||
|
_quests.add(quest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Quest> getQuests()
|
||||||
|
{
|
||||||
|
return _quests;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasQuest(Quest quest)
|
||||||
|
{
|
||||||
|
for (Quest other : _quests)
|
||||||
|
{
|
||||||
|
if (other.getID() == quest.getID())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quest getQuest(int id)
|
||||||
|
{
|
||||||
|
for (Quest quest : _quests)
|
||||||
|
{
|
||||||
|
if (quest.getID() == id)
|
||||||
|
return quest;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeQuest(int id)
|
||||||
|
{
|
||||||
|
Quest toRemove = getQuest(id);
|
||||||
|
_quests.remove(toRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,24 @@
|
|||||||
package mineplex.core.quests;
|
package mineplex.core.quests;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
|
import mineplex.core.account.CoreClient;
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.game.GameDisplay;
|
||||||
|
import mineplex.core.google.GoogleSheetsManager;
|
||||||
|
import mineplex.core.quests.command.OpenGuiCommand;
|
||||||
|
import mineplex.core.quests.repository.QuestRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* QuestManager
|
* QuestManager
|
||||||
@ -11,16 +27,154 @@ import mineplex.core.MiniClientPlugin;
|
|||||||
*/
|
*/
|
||||||
public class QuestManager extends MiniClientPlugin<QuestClientData>
|
public class QuestManager extends MiniClientPlugin<QuestClientData>
|
||||||
{
|
{
|
||||||
|
private static final String GOOGLE_SHEET = "QUESTS_SHEET";
|
||||||
|
private static final String GOOGLE_TABLE = "Quests";
|
||||||
|
|
||||||
|
private QuestRepository _repository;
|
||||||
|
private GoogleSheetsManager _sheetsManager;
|
||||||
|
private CoreClientManager _clients;
|
||||||
|
private DonationManager _donationManager;
|
||||||
|
|
||||||
|
public ArrayList<Quest> _availableQuests;
|
||||||
|
|
||||||
public QuestManager()
|
public QuestManager()
|
||||||
{
|
{
|
||||||
super("Quest Manager");
|
super("Quest Manager");
|
||||||
|
|
||||||
|
_repository = new QuestRepository();
|
||||||
|
_sheetsManager = require(GoogleSheetsManager.class);
|
||||||
|
_clients = require(CoreClientManager.class);
|
||||||
|
_availableQuests = new ArrayList<>();
|
||||||
|
|
||||||
|
setupQuests();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCommands()
|
||||||
|
{
|
||||||
|
addCommand(new OpenGuiCommand(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupQuests()
|
||||||
|
{
|
||||||
|
_availableQuests.clear();
|
||||||
|
Map<String, List<List<String>>> sheet = _sheetsManager.getSheetData(GOOGLE_SHEET);
|
||||||
|
List<List<String>> table = new ArrayList<>();
|
||||||
|
for (String key : sheet.keySet())
|
||||||
|
{
|
||||||
|
if (key.equalsIgnoreCase(GOOGLE_TABLE))
|
||||||
|
table = sheet.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
int size = table.size();
|
||||||
|
|
||||||
|
for (int i = 1; i < size; i++)
|
||||||
|
{
|
||||||
|
String name = table.get(i).get(0);
|
||||||
|
String task = table.get(i).get(1);
|
||||||
|
String game = table.get(i).get(2);
|
||||||
|
String cost = table.get(i).get(3);
|
||||||
|
String reward = table.get(i).get(4);
|
||||||
|
String trigger = table.get(i).get(5);
|
||||||
|
String statcompletion = table.get(i).get(6);
|
||||||
|
String item = table.get(i).get(7);
|
||||||
|
String rarity = table.get(i).get(8);
|
||||||
|
|
||||||
|
_availableQuests.add(new Quest(i, name, task,
|
||||||
|
Integer.parseInt(cost),
|
||||||
|
Integer.parseInt(reward),
|
||||||
|
QuestRarity.getByName(rarity),
|
||||||
|
GameDisplay.matchName(game),
|
||||||
|
TriggerType.getByName(trigger),
|
||||||
|
item,
|
||||||
|
Integer.parseInt(statcompletion)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void playerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
QuestClientData data = Get(event.getPlayer());
|
||||||
|
for (Triple<Integer, Integer, Long> triple : _repository.getQuests(_clients.Get(event.getPlayer())))
|
||||||
|
{
|
||||||
|
int id = triple.getLeft();
|
||||||
|
int value = triple.getMiddle();
|
||||||
|
long time = triple.getRight();
|
||||||
|
|
||||||
|
if (value == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!UtilTime.elapsed(time, 1000*60*60*24))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (Quest quest : _availableQuests)
|
||||||
|
{
|
||||||
|
if (quest.getID() == id)
|
||||||
|
{
|
||||||
|
Quest clone = quest.clone();
|
||||||
|
clone.setProgress(value);
|
||||||
|
data.addQuest(clone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quest getQuestByID(int id)
|
||||||
|
{
|
||||||
|
for (Quest quest : _availableQuests)
|
||||||
|
{
|
||||||
|
if (quest.getID() == id)
|
||||||
|
return quest;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNewQuest(Player player, Quest quest)
|
||||||
|
{
|
||||||
|
Quest clone = quest.clone();
|
||||||
|
clone.setProgress(0);
|
||||||
|
Get(player).addQuest(clone);
|
||||||
|
|
||||||
|
_repository.addNew(_clients.Get(player), quest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetQuest(Player player, Quest quest, boolean completed)
|
||||||
|
{
|
||||||
|
Get(player).removeQuest(quest.getID());
|
||||||
|
|
||||||
|
_repository.resetQuest(_clients.Get(player), quest, completed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementQuest(CoreClient client, Quest quest, int value)
|
||||||
|
{
|
||||||
|
quest.increment(value);
|
||||||
|
_repository.incrementQuest(client, quest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getCurrentQuests()
|
||||||
|
{
|
||||||
|
return new int[]{2, 4};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CoreClientManager getClients()
|
||||||
|
{
|
||||||
|
return _clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DonationManager getDonations()
|
||||||
|
{
|
||||||
|
return _donationManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected QuestClientData addPlayer(UUID uuid)
|
protected QuestClientData addPlayer(UUID uuid)
|
||||||
{
|
{
|
||||||
return null;
|
return new QuestClientData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Quest> getAvailableQuests()
|
||||||
|
{
|
||||||
|
return _availableQuests;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package mineplex.core.quests.command;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.command.CommandBase;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.quests.QuestManager;
|
||||||
|
import mineplex.core.quests.shop.QuestShop;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OpenGuiCommand
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class OpenGuiCommand extends CommandBase<QuestManager>
|
||||||
|
{
|
||||||
|
public OpenGuiCommand(QuestManager plugin)
|
||||||
|
{
|
||||||
|
super(plugin, Rank.ALL, "Quests");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Execute(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
new QuestShop(Plugin, Plugin.getClients(), Plugin.getDonations()).attemptShopOpen(caller);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,14 @@
|
|||||||
package mineplex.core.quests.repository;
|
package mineplex.core.quests.repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClient;
|
||||||
|
import mineplex.core.quests.Quest;
|
||||||
import mineplex.serverdata.database.DBPool;
|
import mineplex.serverdata.database.DBPool;
|
||||||
import mineplex.serverdata.database.RepositoryBase;
|
import mineplex.serverdata.database.RepositoryBase;
|
||||||
|
|
||||||
@ -10,10 +19,79 @@ import mineplex.serverdata.database.RepositoryBase;
|
|||||||
*/
|
*/
|
||||||
public class QuestRepository extends RepositoryBase
|
public class QuestRepository extends RepositoryBase
|
||||||
{
|
{
|
||||||
|
private HashMap<String, ArrayList<Triple<Integer, Integer, Long>>> _db;
|
||||||
|
|
||||||
public QuestRepository()
|
public QuestRepository()
|
||||||
{
|
{
|
||||||
super(DBPool.getAccount());
|
super(DBPool.getAccount());
|
||||||
|
|
||||||
|
_db = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void player(Player player)
|
||||||
|
{
|
||||||
|
for (String string : _db.keySet())
|
||||||
|
{
|
||||||
|
if (string.equalsIgnoreCase(player.getUniqueId().toString()))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_db.put(player.getUniqueId().toString(), new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Triple<Integer, Integer, Long>> getQuests(CoreClient client)
|
||||||
|
{
|
||||||
|
player(client.GetPlayer());
|
||||||
|
// ArrayList<Triple<Integer, Integer, Long>> list = new ArrayList<>();
|
||||||
|
// for (int i = 2; i <= 3; i++)
|
||||||
|
// {
|
||||||
|
// list.add(Triple.of(i, UtilMath.r(10) + 1, System.currentTimeMillis() - (1000*60*60*48)));
|
||||||
|
// }
|
||||||
|
// return list;
|
||||||
|
return _db.get(client.GetPlayer().getUniqueId().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetQuest(CoreClient client, Quest quest, boolean completed)
|
||||||
|
{
|
||||||
|
player(client.GetPlayer());
|
||||||
|
Triple<Integer, Integer, Long> toAdd = null;
|
||||||
|
ArrayList<Triple<Integer, Integer, Long>> liste = _db.get(client.GetPlayer().getUniqueId().toString());
|
||||||
|
Iterator<Triple<Integer, Integer, Long>> iterator = liste.iterator();
|
||||||
|
while (iterator.hasNext())
|
||||||
|
{
|
||||||
|
Triple<Integer, Integer, Long> triple = iterator.next();
|
||||||
|
if (triple.getLeft() == quest.getID())
|
||||||
|
{
|
||||||
|
toAdd = Triple.of(triple.getLeft(), -1, (completed ? System.currentTimeMillis() : (long) 0));
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (toAdd != null)
|
||||||
|
_db.get(client.GetPlayer().getUniqueId().toString()).add(toAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNew(CoreClient client, Quest quest)
|
||||||
|
{
|
||||||
|
player(client.GetPlayer());
|
||||||
|
_db.get(client.GetPlayer().getUniqueId().toString()).add(Triple.of(quest.getID(), 0, (long) 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementQuest(CoreClient client, Quest quest)
|
||||||
|
{
|
||||||
|
player(client.GetPlayer());
|
||||||
|
Triple<Integer, Integer, Long> toAdd = null;
|
||||||
|
ArrayList<Triple<Integer, Integer, Long>> liste = _db.get(client.GetPlayer().getUniqueId().toString());
|
||||||
|
Iterator<Triple<Integer, Integer, Long>> iterator = liste.iterator();
|
||||||
|
while (iterator.hasNext())
|
||||||
|
{
|
||||||
|
Triple<Integer, Integer, Long> triple = iterator.next();
|
||||||
|
if (triple.getLeft() == quest.getID())
|
||||||
|
{
|
||||||
|
toAdd = Triple.of(triple.getLeft(), triple.getMiddle() + 1, triple.getRight());
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (toAdd != null)
|
||||||
|
_db.get(client.GetPlayer().getUniqueId().toString()).add(toAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
package mineplex.core.quests.shop;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
|
import mineplex.core.quests.Quest;
|
||||||
|
import mineplex.core.quests.QuestManager;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||||
|
import mineplex.core.shop.item.IButton;
|
||||||
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
|
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BuyQuestButton
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class BuyQuestButton implements IButton
|
||||||
|
{
|
||||||
|
private QuestManager _questManager;
|
||||||
|
|
||||||
|
private QuestPage _page;
|
||||||
|
|
||||||
|
private Quest _quest;
|
||||||
|
|
||||||
|
public BuyQuestButton(QuestManager questManager, QuestPage page, Quest quest)
|
||||||
|
{
|
||||||
|
_questManager = questManager;
|
||||||
|
_quest = quest;
|
||||||
|
_page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(Player player, ClickType clickType)
|
||||||
|
{
|
||||||
|
if (!Recharge.Instance.use(player, "Buy Quest", 1000, false, false))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_questManager.Get(player).hasQuest(_quest))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Quest", "You already own that Quest!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SalesPackageBase salesPackage = new QuestSale(_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);
|
||||||
|
|
||||||
|
player.closeInventory();
|
||||||
|
|
||||||
|
QuestPage page = new QuestPage(_page.getPlugin(), _page.getQuestShop(), _page.getClientManager(), _page.getDonationManager(), player);
|
||||||
|
_page.getQuestShop().openPageForPlayer(player, page);
|
||||||
|
|
||||||
|
}), salesPackage.buildIcon()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,132 @@
|
|||||||
|
package mineplex.core.quests.shop;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.quests.Quest;
|
||||||
|
import mineplex.core.quests.QuestManager;
|
||||||
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* QuestPage
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class QuestPage extends ShopPageBase<QuestManager, QuestShop>
|
||||||
|
{
|
||||||
|
|
||||||
|
public QuestPage(QuestManager plugin, QuestShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
|
||||||
|
{
|
||||||
|
super(plugin, shop, clientManager, donationManager, "Quest Page", player);
|
||||||
|
|
||||||
|
buildPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void buildPage()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
while (i < 9)
|
||||||
|
{
|
||||||
|
setItem(i, ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.BLACK.getData()));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int currentSlot = 4;
|
||||||
|
int diff = 0;
|
||||||
|
boolean forward = true;
|
||||||
|
for (int questID : getQuestShop().getQuestManager().getCurrentQuests())
|
||||||
|
{
|
||||||
|
if (forward)
|
||||||
|
{
|
||||||
|
currentSlot += diff;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentSlot -= diff;
|
||||||
|
}
|
||||||
|
diff++;
|
||||||
|
forward = !forward;
|
||||||
|
|
||||||
|
Quest quest = _shop.getQuestManager().getQuestByID(questID);
|
||||||
|
|
||||||
|
ItemStack item = new ItemStack(Material.PAPER);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + quest.getName());
|
||||||
|
meta.setLore(Arrays.asList(
|
||||||
|
ChatColor.YELLOW + quest.getTask(),
|
||||||
|
"",
|
||||||
|
ChatColor.GREEN + "Cost: " + quest.getCost() + " Gems",
|
||||||
|
ChatColor.AQUA + "Reward: " + quest.getReward() + " Shards",
|
||||||
|
"",
|
||||||
|
quest.getRarity().getColor() + "" + ChatColor.BOLD + quest.getRarity().toString(),
|
||||||
|
"",
|
||||||
|
ChatColor.GREEN + "Click to buy Quest!"
|
||||||
|
));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
|
addButton(i + currentSlot, item, new BuyQuestButton(_plugin, this, quest));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i = 9*2;
|
||||||
|
while (i < (9*3))
|
||||||
|
{
|
||||||
|
setItem(i, ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.BLACK.getData()));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i = 9*4;
|
||||||
|
|
||||||
|
{
|
||||||
|
int currentSlot = 4;
|
||||||
|
int diff = 0;
|
||||||
|
boolean forward = true;
|
||||||
|
for (Quest quest : _shop.getQuestManager().Get(_player).getQuests())
|
||||||
|
{
|
||||||
|
if (forward)
|
||||||
|
{
|
||||||
|
currentSlot += diff;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentSlot -= diff;
|
||||||
|
}
|
||||||
|
diff++;
|
||||||
|
forward = !forward;
|
||||||
|
|
||||||
|
ItemStack item = new ItemStack(Material.PAPER);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + quest.getName());
|
||||||
|
meta.setLore(Arrays.asList(
|
||||||
|
ChatColor.YELLOW + quest.getTask(),
|
||||||
|
"",
|
||||||
|
ChatColor.AQUA + "Reward: " + quest.getReward() + " Shards",
|
||||||
|
"",
|
||||||
|
quest.getRarity().getColor() + "" + ChatColor.BOLD + quest.getRarity().toString(),
|
||||||
|
"",
|
||||||
|
ChatColor.YELLOW + "Progress: " + (quest.isCompleted() ? ChatColor.GREEN + "Completed!" : quest.getProgress() + "/" + quest.getStatToComplete()),
|
||||||
|
"",
|
||||||
|
(quest.isCompleted() ? ChatColor.GREEN + "Left Click to Complete" : ChatColor.RED + "Right Shift Click to cancell")
|
||||||
|
));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
|
addButton(i + currentSlot, item, new RedeemDeclineQuestButton(_donationManager, _plugin, this, quest));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public QuestShop getQuestShop()
|
||||||
|
{
|
||||||
|
return _shop;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package mineplex.core.quests.shop;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* QuestSale
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class QuestSale extends SalesPackageBase
|
||||||
|
{
|
||||||
|
|
||||||
|
public QuestSale(String name, Material mat, int cost)
|
||||||
|
{
|
||||||
|
super(name, mat, (byte) 0, new String[] {}, cost);
|
||||||
|
|
||||||
|
KnownPackage = false;
|
||||||
|
OneTimePurchaseOnly = false;
|
||||||
|
CurrencyCostMap.clear();
|
||||||
|
CurrencyCostMap.put(GlobalCurrency.GEM, cost);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package mineplex.core.quests.shop;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.quests.QuestManager;
|
||||||
|
import mineplex.core.shop.ShopBase;
|
||||||
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* QuestShop
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class QuestShop extends ShopBase<QuestManager>
|
||||||
|
{
|
||||||
|
public QuestShop(QuestManager plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||||
|
{
|
||||||
|
super(plugin, clientManager, donationManager, "Quest Shop");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ShopPageBase<QuestManager, ? extends ShopBase<QuestManager>> buildPagesFor(Player player)
|
||||||
|
{
|
||||||
|
return new QuestPage(getPlugin(), this, getClientManager(), getDonationManager(), player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public QuestManager getQuestManager()
|
||||||
|
{
|
||||||
|
return getPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
package mineplex.core.quests.shop;
|
||||||
|
|
||||||
|
import javax.jws.Oneway;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.quests.Quest;
|
||||||
|
import mineplex.core.quests.QuestManager;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.core.shop.item.IButton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RedeemDeclineQuest
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class RedeemDeclineQuestButton implements IButton
|
||||||
|
{
|
||||||
|
private QuestManager _questManager;
|
||||||
|
private DonationManager _donations;
|
||||||
|
|
||||||
|
private QuestPage _page;
|
||||||
|
|
||||||
|
private Quest _quest;
|
||||||
|
|
||||||
|
public RedeemDeclineQuestButton(DonationManager donations, QuestManager questManager, QuestPage page, Quest quest)
|
||||||
|
{
|
||||||
|
_questManager = questManager;
|
||||||
|
_donations = donations;
|
||||||
|
_quest = quest;
|
||||||
|
_page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(Player player, ClickType clickType)
|
||||||
|
{
|
||||||
|
if (!Recharge.Instance.use(player, "Decline Quest", 1000, false, false))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_questManager.Get(player).hasQuest(_quest))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Quest", "You dont own that Quest!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clickType == ClickType.SHIFT_RIGHT)
|
||||||
|
{
|
||||||
|
if (_quest.isCompleted())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Quest", "You can't cancell a completed Quest!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_questManager.resetQuest(player, _quest, false);
|
||||||
|
UtilPlayer.message(player, F.main("Quest", "You have cancelled that Quest!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clickType == ClickType.LEFT)
|
||||||
|
{
|
||||||
|
if (!_quest.isCompleted())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Quest", "You havent completed that Quest yet!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_questManager.resetQuest(player, _quest, true);
|
||||||
|
_donations.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completed Quest: " + _quest.getID(), _quest.getReward());
|
||||||
|
UtilPlayer.message(player, F.main("Quest", "You have recieved " + ChatColor.AQUA + _quest.getReward() + " Shards " + ChatColor.GRAY + "for completing a Quest!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clickType == ClickType.LEFT || clickType == ClickType.SHIFT_RIGHT)
|
||||||
|
{
|
||||||
|
QuestPage page = new QuestPage(_page.getPlugin(), _page.getQuestShop(), _page.getClientManager(), _page.getDonationManager(), player);
|
||||||
|
_page.getQuestShop().openPageForPlayer(player, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -13,102 +13,102 @@ import org.jooq.impl.TableImpl;
|
|||||||
comments = "This class is generated by jOOQ"
|
comments = "This class is generated by jOOQ"
|
||||||
)
|
)
|
||||||
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||||
public class AccountQuest extends TableImpl<mineplex.database.tables.records.AccountQuestRecord> implements java.io.Serializable, java.lang.Cloneable
|
public class AccountQuest //extends TableImpl<mineplex.database.tables.records.AccountQuestRecord> implements java.io.Serializable, java.lang.Cloneable
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
*
|
// *
|
||||||
*/
|
// */
|
||||||
private static final long serialVersionUID = -8158716179851336044L;
|
// private static final long serialVersionUID = -8158716179851336044L;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* The reference instance of <code>Account.accountStat</code>
|
// * The reference instance of <code>Account.accountStat</code>
|
||||||
*/
|
// */
|
||||||
public static final mineplex.database.tables.AccountStat accountStat = new mineplex.database.tables.AccountStat();
|
// public static final mineplex.database.tables.AccountStat accountStat = new mineplex.database.tables.AccountStat();
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* The class holding records for this type
|
// * The class holding records for this type
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public java.lang.Class<mineplex.database.tables.records.AccountQuestRecord> getRecordType() {
|
// public java.lang.Class<mineplex.database.tables.records.AccountQuestRecord> getRecordType() {
|
||||||
return mineplex.database.tables.records.AccountQuestRecord.class;
|
// return mineplex.database.tables.records.AccountQuestRecord.class;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* The column <code>Account.accountStat.accountId</code>.
|
// * The column <code>Account.accountStat.accountId</code>.
|
||||||
*/
|
// */
|
||||||
public final org.jooq.TableField<mineplex.database.tables.records.AccountQuestRecord, java.lang.Integer> accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "");
|
// public final org.jooq.TableField<mineplex.database.tables.records.AccountQuestRecord, java.lang.Integer> accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "");
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* The column <code>Account.accountStat.statId</code>.
|
// * The column <code>Account.accountStat.statId</code>.
|
||||||
*/
|
// */
|
||||||
public final org.jooq.TableField<mineplex.database.tables.records.AccountQuestRecord, java.lang.Integer> statId = createField("statId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "");
|
// public final org.jooq.TableField<mineplex.database.tables.records.AccountQuestRecord, java.lang.Integer> statId = createField("statId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "");
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* The column <code>Account.accountStat.value</code>.
|
// * The column <code>Account.accountStat.value</code>.
|
||||||
*/
|
// */
|
||||||
public final org.jooq.TableField<mineplex.database.tables.records.AccountQuestRecord, org.jooq.types.ULong> value = createField("value", org.jooq.impl.SQLDataType.BIGINTUNSIGNED.defaulted(true), this, "");
|
// public final org.jooq.TableField<mineplex.database.tables.records.AccountQuestRecord, org.jooq.types.ULong> value = createField("value", org.jooq.impl.SQLDataType.BIGINTUNSIGNED.defaulted(true), this, "");
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Create a <code>Account.accountStat</code> table reference
|
// * Create a <code>Account.accountStat</code> table reference
|
||||||
*/
|
// */
|
||||||
public AccountQuest()
|
// public AccountQuest()
|
||||||
{
|
// {
|
||||||
super("accountquest", null);
|
// super("accountquest", null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Create an aliased <code>Account.accountStat</code> table reference
|
// * Create an aliased <code>Account.accountStat</code> table reference
|
||||||
*/
|
// */
|
||||||
public AccountQuest(java.lang.String alias) {
|
// public AccountQuest(java.lang.String alias) {
|
||||||
this(alias, mineplex.database.tables.AccountQuest.accountStat);
|
// this(alias, mineplex.database.tables.AccountQuest.accountStat);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private AccountQuest(java.lang.String alias, org.jooq.Table<mineplex.database.tables.records.AccountQuestRecord> aliased) {
|
// private AccountQuest(java.lang.String alias, org.jooq.Table<mineplex.database.tables.records.AccountQuestRecord> aliased) {
|
||||||
this(alias, aliased, null);
|
// this(alias, aliased, null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private AccountQuest(java.lang.String alias, org.jooq.Table<mineplex.database.tables.records.AccountQuestRecord> aliased, org.jooq.Field<?>[] parameters) {
|
// private AccountQuest(java.lang.String alias, org.jooq.Table<mineplex.database.tables.records.AccountQuestRecord> aliased, org.jooq.Field<?>[] parameters) {
|
||||||
super(alias, mineplex.database.Account.Account, aliased, parameters, "");
|
// super(alias, mineplex.database.Account.Account, aliased, parameters, "");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public org.jooq.UniqueKey<mineplex.database.tables.records.AccountStatRecord> getPrimaryKey() {
|
// public org.jooq.UniqueKey<mineplex.database.tables.records.AccountStatRecord> getPrimaryKey() {
|
||||||
return mineplex.database.Keys.KEY_accountStat_PRIMARY;
|
// return mineplex.database.Keys.KEY_accountStat_PRIMARY;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public java.util.List<org.jooq.UniqueKey<mineplex.database.tables.records.AccountStatRecord>> getKeys() {
|
// public java.util.List<org.jooq.UniqueKey<mineplex.database.tables.records.AccountStatRecord>> getKeys() {
|
||||||
return java.util.Arrays.<org.jooq.UniqueKey<mineplex.database.tables.records.AccountStatRecord>>asList(mineplex.database.Keys.KEY_accountStat_PRIMARY);
|
// return java.util.Arrays.<org.jooq.UniqueKey<mineplex.database.tables.records.AccountStatRecord>>asList(mineplex.database.Keys.KEY_accountStat_PRIMARY);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public java.util.List<org.jooq.ForeignKey<mineplex.database.tables.records.AccountStatRecord, ?>> getReferences() {
|
// public java.util.List<org.jooq.ForeignKey<mineplex.database.tables.records.AccountStatRecord, ?>> getReferences() {
|
||||||
return java.util.Arrays.<org.jooq.ForeignKey<mineplex.database.tables.records.AccountStatRecord, ?>>asList(mineplex.database.Keys.accountStat_account, mineplex.database.Keys.accountStat_stat);
|
// return java.util.Arrays.<org.jooq.ForeignKey<mineplex.database.tables.records.AccountStatRecord, ?>>asList(mineplex.database.Keys.accountStat_account, mineplex.database.Keys.accountStat_stat);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public mineplex.database.tables.AccountStat as(java.lang.String alias) {
|
// public mineplex.database.tables.AccountStat as(java.lang.String alias) {
|
||||||
return new mineplex.database.tables.AccountStat(alias, this);
|
// return new mineplex.database.tables.AccountStat(alias, this);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Rename this table
|
// * Rename this table
|
||||||
*/
|
// */
|
||||||
public mineplex.database.tables.AccountStat rename(java.lang.String name) {
|
// public mineplex.database.tables.AccountStat rename(java.lang.String name) {
|
||||||
return new mineplex.database.tables.AccountStat(name, null);
|
// return new mineplex.database.tables.AccountStat(name, null);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,196 +7,196 @@ import org.jooq.Table;
|
|||||||
*
|
*
|
||||||
* @author xXVevzZXx
|
* @author xXVevzZXx
|
||||||
*/
|
*/
|
||||||
public class AccountQuestRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.database.tables.records.AccountQuestRecord> implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3<java.lang.Integer, java.lang.Integer, org.jooq.types.ULong>
|
public class AccountQuestRecord //extends org.jooq.impl.UpdatableRecordImpl<mineplex.database.tables.records.AccountQuestRecord> implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3<java.lang.Integer, java.lang.Integer, org.jooq.types.ULong>
|
||||||
{
|
{
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
*
|
// *
|
||||||
*/
|
// */
|
||||||
private static final long serialVersionUID = 5171965369180094201L;
|
// private static final long serialVersionUID = 5171965369180094201L;
|
||||||
|
//
|
||||||
public AccountQuestRecord(Table<AccountQuestRecord> table)
|
// public AccountQuestRecord(Table<AccountQuestRecord> table)
|
||||||
{
|
// {
|
||||||
super(table);
|
// super(table);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Setter for <code>Account.accountStat.accountId</code>.
|
// * Setter for <code>Account.accountStat.accountId</code>.
|
||||||
*/
|
// */
|
||||||
public void setAccountId(java.lang.Integer value) {
|
// public void setAccountId(java.lang.Integer value) {
|
||||||
setValue(0, value);
|
// setValue(0, value);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Getter for <code>Account.accountStat.accountId</code>.
|
// * Getter for <code>Account.accountStat.accountId</code>.
|
||||||
*/
|
// */
|
||||||
public java.lang.Integer getAccountId() {
|
// public java.lang.Integer getAccountId() {
|
||||||
return (java.lang.Integer) getValue(0);
|
// return (java.lang.Integer) getValue(0);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Setter for <code>Account.accountStat.statId</code>.
|
// * Setter for <code>Account.accountStat.statId</code>.
|
||||||
*/
|
// */
|
||||||
public void setStatId(java.lang.Integer value) {
|
// public void setStatId(java.lang.Integer value) {
|
||||||
setValue(1, value);
|
// setValue(1, value);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Getter for <code>Account.accountStat.statId</code>.
|
// * Getter for <code>Account.accountStat.statId</code>.
|
||||||
*/
|
// */
|
||||||
public java.lang.Integer getStatId() {
|
// public java.lang.Integer getStatId() {
|
||||||
return (java.lang.Integer) getValue(1);
|
// return (java.lang.Integer) getValue(1);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Setter for <code>Account.accountStat.value</code>.
|
// * Setter for <code>Account.accountStat.value</code>.
|
||||||
*/
|
// */
|
||||||
public void setValue(org.jooq.types.ULong value) {
|
// public void setValue(org.jooq.types.ULong value) {
|
||||||
setValue(2, value);
|
// setValue(2, value);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Getter for <code>Account.accountStat.value</code>.
|
// * Getter for <code>Account.accountStat.value</code>.
|
||||||
*/
|
// */
|
||||||
public org.jooq.types.ULong getValue() {
|
// public org.jooq.types.ULong getValue() {
|
||||||
return (org.jooq.types.ULong) getValue(2);
|
// return (org.jooq.types.ULong) getValue(2);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// -------------------------------------------------------------------------
|
// // -------------------------------------------------------------------------
|
||||||
// Primary key information
|
// // Primary key information
|
||||||
// -------------------------------------------------------------------------
|
// // -------------------------------------------------------------------------
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public org.jooq.Record2<java.lang.Integer, java.lang.Integer> key() {
|
// public org.jooq.Record2<java.lang.Integer, java.lang.Integer> key() {
|
||||||
return (org.jooq.Record2) super.key();
|
// return (org.jooq.Record2) super.key();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// -------------------------------------------------------------------------
|
// // -------------------------------------------------------------------------
|
||||||
// Record3 type implementation
|
// // Record3 type implementation
|
||||||
// -------------------------------------------------------------------------
|
// // -------------------------------------------------------------------------
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public org.jooq.Row3<java.lang.Integer, java.lang.Integer, org.jooq.types.ULong> fieldsRow() {
|
// public org.jooq.Row3<java.lang.Integer, java.lang.Integer, org.jooq.types.ULong> fieldsRow() {
|
||||||
return (org.jooq.Row3) super.fieldsRow();
|
// return (org.jooq.Row3) super.fieldsRow();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public org.jooq.Row3<java.lang.Integer, java.lang.Integer, org.jooq.types.ULong> valuesRow() {
|
// public org.jooq.Row3<java.lang.Integer, java.lang.Integer, org.jooq.types.ULong> valuesRow() {
|
||||||
return (org.jooq.Row3) super.valuesRow();
|
// return (org.jooq.Row3) super.valuesRow();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public org.jooq.Field<java.lang.Integer> field1() {
|
// public org.jooq.Field<java.lang.Integer> field1() {
|
||||||
return mineplex.database.tables.AccountStat.accountStat.accountId;
|
// return mineplex.database.tables.AccountStat.accountStat.accountId;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public org.jooq.Field<java.lang.Integer> field2() {
|
// public org.jooq.Field<java.lang.Integer> field2() {
|
||||||
return mineplex.database.tables.AccountStat.accountStat.statId;
|
// return mineplex.database.tables.AccountStat.accountStat.statId;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public org.jooq.Field<org.jooq.types.ULong> field3() {
|
// public org.jooq.Field<org.jooq.types.ULong> field3() {
|
||||||
return mineplex.database.tables.AccountStat.accountStat.value;
|
// return mineplex.database.tables.AccountStat.accountStat.value;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public java.lang.Integer value1() {
|
// public java.lang.Integer value1() {
|
||||||
return getAccountId();
|
// return getAccountId();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public java.lang.Integer value2() {
|
// public java.lang.Integer value2() {
|
||||||
return getStatId();
|
// return getStatId();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public org.jooq.types.ULong value3() {
|
// public org.jooq.types.ULong value3() {
|
||||||
return getValue();
|
// return getValue();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public AccountStatRecord value1(java.lang.Integer value) {
|
// public AccountStatRecord value1(java.lang.Integer value) {
|
||||||
setAccountId(value);
|
// setAccountId(value);
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public AccountStatRecord value2(java.lang.Integer value) {
|
// public AccountStatRecord value2(java.lang.Integer value) {
|
||||||
setStatId(value);
|
// setStatId(value);
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public AccountStatRecord value3(org.jooq.types.ULong value) {
|
// public AccountStatRecord value3(org.jooq.types.ULong value) {
|
||||||
setValue(value);
|
// setValue(value);
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* {@inheritDoc}
|
// * {@inheritDoc}
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public AccountStatRecord values(java.lang.Integer value1, java.lang.Integer value2, org.jooq.types.ULong value3) {
|
// public AccountStatRecord values(java.lang.Integer value1, java.lang.Integer value2, org.jooq.types.ULong value3) {
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// -------------------------------------------------------------------------
|
// // -------------------------------------------------------------------------
|
||||||
// Constructors
|
// // Constructors
|
||||||
// -------------------------------------------------------------------------
|
// // -------------------------------------------------------------------------
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Create a detached AccountStatRecord
|
// * Create a detached AccountStatRecord
|
||||||
*/
|
// */
|
||||||
public AccountStatRecord() {
|
// public AccountStatRecord() {
|
||||||
super(mineplex.database.tables.AccountStat.accountStat);
|
// super(mineplex.database.tables.AccountStat.accountStat);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Create a detached, initialised AccountStatRecord
|
// * Create a detached, initialised AccountStatRecord
|
||||||
*/
|
// */
|
||||||
public AccountStatRecord(java.lang.Integer accountId, java.lang.Integer statId, org.jooq.types.ULong value) {
|
// public AccountStatRecord(java.lang.Integer accountId, java.lang.Integer statId, org.jooq.types.ULong value) {
|
||||||
super(mineplex.database.tables.AccountStat.accountStat);
|
// super(mineplex.database.tables.AccountStat.accountStat);
|
||||||
|
//
|
||||||
setValue(0, accountId);
|
// setValue(0, accountId);
|
||||||
setValue(1, statId);
|
// setValue(1, statId);
|
||||||
setValue(2, value);
|
// setValue(2, value);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,13 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
|
import net.md_5.bungee.api.chat.HoverEvent.Action;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityInsentient;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -96,6 +103,7 @@ import mineplex.core.preferences.Preference;
|
|||||||
import mineplex.core.preferences.PreferencesManager;
|
import mineplex.core.preferences.PreferencesManager;
|
||||||
import mineplex.core.projectile.ProjectileManager;
|
import mineplex.core.projectile.ProjectileManager;
|
||||||
import mineplex.core.punish.Punish;
|
import mineplex.core.punish.Punish;
|
||||||
|
import mineplex.core.quests.QuestManager;
|
||||||
import mineplex.core.scoreboard.MineplexScoreboard;
|
import mineplex.core.scoreboard.MineplexScoreboard;
|
||||||
import mineplex.core.scoreboard.ScoreboardManager;
|
import mineplex.core.scoreboard.ScoreboardManager;
|
||||||
import mineplex.core.stats.StatsManager;
|
import mineplex.core.stats.StatsManager;
|
||||||
@ -131,12 +139,6 @@ import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent;
|
|||||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
|
||||||
import net.md_5.bungee.api.chat.HoverEvent.Action;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import net.minecraft.server.v1_8_R3.EntityInsentient;
|
|
||||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
|
||||||
|
|
||||||
public class HubManager extends MiniClientPlugin<HubClient> implements IChatMessageFormatter
|
public class HubManager extends MiniClientPlugin<HubClient> implements IChatMessageFormatter
|
||||||
{
|
{
|
||||||
@ -175,6 +177,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
|||||||
// private HalloweenSpookinessManager _halloweenManager;
|
// private HalloweenSpookinessManager _halloweenManager;
|
||||||
// private TrickOrTreatManager _trickOrTreatManager;
|
// private TrickOrTreatManager _trickOrTreatManager;
|
||||||
private MavericksManager _mavericksManager;
|
private MavericksManager _mavericksManager;
|
||||||
|
private QuestManager _questManager;
|
||||||
private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class);
|
private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class);
|
||||||
|
|
||||||
private HologramManager _hologramManager;
|
private HologramManager _hologramManager;
|
||||||
@ -288,6 +291,8 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
|||||||
_hologramManager = hologramManager;
|
_hologramManager = hologramManager;
|
||||||
|
|
||||||
new EasterEggHunt(plugin, _clientManager);
|
new EasterEggHunt(plugin, _clientManager);
|
||||||
|
|
||||||
|
_questManager = new QuestManager();
|
||||||
|
|
||||||
ScoreboardManager scoreboardManager = new ScoreboardManager(plugin)
|
ScoreboardManager scoreboardManager = new ScoreboardManager(plugin)
|
||||||
{
|
{
|
||||||
@ -1024,4 +1029,9 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
|||||||
{
|
{
|
||||||
return _jumpManager;
|
return _jumpManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QuestManager getQuestManager()
|
||||||
|
{
|
||||||
|
return _questManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ import mineplex.core.preferences.PreferencesManager;
|
|||||||
import mineplex.core.progression.KitProgressionManager;
|
import mineplex.core.progression.KitProgressionManager;
|
||||||
import mineplex.core.projectile.ProjectileManager;
|
import mineplex.core.projectile.ProjectileManager;
|
||||||
import mineplex.core.punish.Punish;
|
import mineplex.core.punish.Punish;
|
||||||
|
import mineplex.core.quests.QuestManager;
|
||||||
import mineplex.core.rankGiveaway.eternal.EternalGiveawayManager;
|
import mineplex.core.rankGiveaway.eternal.EternalGiveawayManager;
|
||||||
import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager;
|
import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager;
|
||||||
import mineplex.core.resourcepack.ResourcePackManager;
|
import mineplex.core.resourcepack.ResourcePackManager;
|
||||||
@ -233,7 +234,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
private ScoreboardManager _scoreboardManager;
|
private ScoreboardManager _scoreboardManager;
|
||||||
private NextBestGameManager _nextBestGameManager;
|
private NextBestGameManager _nextBestGameManager;
|
||||||
private TrackManager _trackManager;
|
private TrackManager _trackManager;
|
||||||
|
private QuestManager _questManager;
|
||||||
|
|
||||||
private IncognitoManager _incognitoManager;
|
private IncognitoManager _incognitoManager;
|
||||||
|
|
||||||
private TaskManager _taskManager;
|
private TaskManager _taskManager;
|
||||||
@ -389,6 +391,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
_kitProgressionManager = new KitProgressionManager(getPlugin(), donationManager, clientManager);
|
_kitProgressionManager = new KitProgressionManager(getPlugin(), donationManager, clientManager);
|
||||||
_progressionKitManager = new ProgressingKitManager(this);
|
_progressionKitManager = new ProgressingKitManager(this);
|
||||||
_serverUptimeManager = new ServerUptimeManager(this);
|
_serverUptimeManager = new ServerUptimeManager(this);
|
||||||
|
_questManager = new QuestManager();
|
||||||
|
|
||||||
if (GetHost() != null && !GetHost().isEmpty() && !GetHost().startsWith("COM-"))
|
if (GetHost() != null && !GetHost().isEmpty() && !GetHost().startsWith("COM-"))
|
||||||
{
|
{
|
||||||
@ -2063,4 +2066,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
{
|
{
|
||||||
return this._titles;
|
return this._titles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QuestManager getQuestManager()
|
||||||
|
{
|
||||||
|
return _questManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,10 @@ import nautilus.game.arcade.kit.Perk;
|
|||||||
import nautilus.game.arcade.kit.ProgressingKit;
|
import nautilus.game.arcade.kit.ProgressingKit;
|
||||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||||
import nautilus.game.arcade.managers.lobby.LobbyManager;
|
import nautilus.game.arcade.managers.lobby.LobbyManager;
|
||||||
|
import nautilus.game.arcade.quest.CollectQuestTracker;
|
||||||
|
import nautilus.game.arcade.quest.KillQuestTracker;
|
||||||
|
import nautilus.game.arcade.quest.QuestTracker;
|
||||||
|
import nautilus.game.arcade.quest.WinQuestTracker;
|
||||||
import nautilus.game.arcade.scoreboard.GameScoreboard;
|
import nautilus.game.arcade.scoreboard.GameScoreboard;
|
||||||
import nautilus.game.arcade.stats.AssistsStatTracker;
|
import nautilus.game.arcade.stats.AssistsStatTracker;
|
||||||
import nautilus.game.arcade.stats.DamageDealtStatTracker;
|
import nautilus.game.arcade.stats.DamageDealtStatTracker;
|
||||||
@ -343,6 +347,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
public int EloStart = 1000;
|
public int EloStart = 1000;
|
||||||
|
|
||||||
public boolean CanAddStats = true;
|
public boolean CanAddStats = true;
|
||||||
|
public boolean CanProgressQuests = true;
|
||||||
public boolean CanGiveLoot = true;
|
public boolean CanGiveLoot = true;
|
||||||
|
|
||||||
public boolean HideTeamSheep = false;
|
public boolean HideTeamSheep = false;
|
||||||
@ -378,6 +383,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
private NautHashMap<String, Long> _deadBodiesExpire = new NautHashMap<String, Long>();
|
private NautHashMap<String, Long> _deadBodiesExpire = new NautHashMap<String, Long>();
|
||||||
|
|
||||||
private final Set<StatTracker<? extends Game>> _statTrackers = new HashSet<>();
|
private final Set<StatTracker<? extends Game>> _statTrackers = new HashSet<>();
|
||||||
|
private final Set<QuestTracker> _questTrackers = new HashSet<>();
|
||||||
|
|
||||||
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
|
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
|
||||||
public WinEffectManager WinEffectManager = new WinEffectManager();
|
public WinEffectManager WinEffectManager = new WinEffectManager();
|
||||||
@ -450,6 +456,9 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
registerStatTrackers(new KillsStatTracker(this), new DeathsStatTracker(this), new AssistsStatTracker(this),
|
registerStatTrackers(new KillsStatTracker(this), new DeathsStatTracker(this), new AssistsStatTracker(this),
|
||||||
new ExperienceStatTracker(this), new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker(
|
new ExperienceStatTracker(this), new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker(
|
||||||
this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this));
|
this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this));
|
||||||
|
|
||||||
|
// Quest Trackers
|
||||||
|
registerQuestTrackers(new WinQuestTracker(this), new KillQuestTracker(this), new CollectQuestTracker(this));
|
||||||
|
|
||||||
Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(this), gameType.isEnforceResourcePack(this));
|
Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(this), gameType.isEnforceResourcePack(this));
|
||||||
|
|
||||||
@ -1773,6 +1782,20 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
{
|
{
|
||||||
return _statTrackers;
|
return _statTrackers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registerQuestTrackers(QuestTracker... questTrackers)
|
||||||
|
{
|
||||||
|
for (QuestTracker tracker : questTrackers)
|
||||||
|
{
|
||||||
|
if (_questTrackers.add(tracker))
|
||||||
|
Bukkit.getPluginManager().registerEvents(tracker, Manager.getPlugin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<QuestTracker> getQuestTrackers()
|
||||||
|
{
|
||||||
|
return _questTrackers;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onHangingBreak(HangingBreakEvent event)
|
public void onHangingBreak(HangingBreakEvent event)
|
||||||
@ -2360,6 +2383,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
Managers.get(AntiHack.class).resetIgnoredChecks();
|
Managers.get(AntiHack.class).resetIgnoredChecks();
|
||||||
getLifetime().end();
|
getLifetime().end();
|
||||||
getStatTrackers().forEach(HandlerList::unregisterAll);
|
getStatTrackers().forEach(HandlerList::unregisterAll);
|
||||||
|
getQuestTrackers().forEach(HandlerList::unregisterAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
package nautilus.game.arcade.quest;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
|
import mineplex.core.quests.TriggerType;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.Game;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CollectQuestTracker
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class CollectQuestTracker extends QuestTracker
|
||||||
|
{
|
||||||
|
private ArrayList<ItemStack> _alreadyCounted;
|
||||||
|
|
||||||
|
public CollectQuestTracker(Game game)
|
||||||
|
{
|
||||||
|
super(game, TriggerType.COLLECT);
|
||||||
|
|
||||||
|
_alreadyCounted = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void collectItem(InventoryClickEvent event)
|
||||||
|
{
|
||||||
|
if (event.getClickedInventory() instanceof PlayerInventory)
|
||||||
|
return;
|
||||||
|
|
||||||
|
System.out.println(event.getCurrentItem().getType().toString());
|
||||||
|
_alreadyCounted.add(event.getCurrentItem());
|
||||||
|
|
||||||
|
incrementQuests((Player) event.getWhoClicked(), event.getCurrentItem().getType().toString(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package nautilus.game.arcade.quest;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
|
import mineplex.core.quests.TriggerType;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.Game;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WInQuestTracker
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class KillQuestTracker extends QuestTracker
|
||||||
|
{
|
||||||
|
|
||||||
|
public KillQuestTracker(Game game)
|
||||||
|
{
|
||||||
|
super(game, TriggerType.WIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onKil(EntityDamageByEntityEvent event)
|
||||||
|
{
|
||||||
|
if (!(event.getDamager() instanceof Player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(event.getEntity() instanceof Player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (((Player) event.getEntity()).getHealth() > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
incrementQuests((Player) event.getDamager(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package nautilus.game.arcade.quest;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
import mineplex.core.game.GameDisplay;
|
||||||
|
import mineplex.core.quests.Quest;
|
||||||
|
import mineplex.core.quests.QuestClientData;
|
||||||
|
import mineplex.core.quests.TriggerType;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.Game;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* QuestTracker
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class QuestTracker implements Listener
|
||||||
|
{
|
||||||
|
private Game _game;
|
||||||
|
private TriggerType _trigger;
|
||||||
|
|
||||||
|
public QuestTracker(Game game, TriggerType type)
|
||||||
|
{
|
||||||
|
_game = game;
|
||||||
|
_trigger = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Game getGame()
|
||||||
|
{
|
||||||
|
return _game;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canProgressQuests()
|
||||||
|
{
|
||||||
|
return getGame().CanProgressQuests;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementQuests(Player player, int value)
|
||||||
|
{
|
||||||
|
incrementQuests(player, "", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementQuests(Player player, String item, int value)
|
||||||
|
{
|
||||||
|
if (canProgressQuests())
|
||||||
|
{
|
||||||
|
for (Quest quest : getGame().getArcadeManager().getQuestManager().getAvailableQuests())
|
||||||
|
{
|
||||||
|
if (getGame().GetType().getDisplay() != quest.getGame())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (quest.getTrigger() != _trigger)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!quest.getItem().equalsIgnoreCase(item))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QuestClientData data = _game.getArcadeManager().getQuestManager().Get(player);
|
||||||
|
if (!data.hasQuest(quest))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Quest toProgress = data.getQuest(quest.getID());
|
||||||
|
|
||||||
|
_game.getArcadeManager().getQuestManager().incrementQuest(_game.getArcadeManager().GetClients().Get(player), toProgress, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TriggerType getTrigger()
|
||||||
|
{
|
||||||
|
return _trigger;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package nautilus.game.arcade.quest;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import mineplex.core.quests.TriggerType;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
|
import nautilus.game.arcade.game.Game;
|
||||||
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WinQuestTracker
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class WinQuestTracker extends QuestTracker
|
||||||
|
{
|
||||||
|
|
||||||
|
public WinQuestTracker(Game game)
|
||||||
|
{
|
||||||
|
super(game, TriggerType.WIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onWin(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() != GameState.End)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Player player : getGame().getWinners())
|
||||||
|
{
|
||||||
|
incrementQuests(player, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -8,6 +8,8 @@ public enum SpreadsheetType
|
|||||||
|
|
||||||
GEM_HUNTERS_CHESTS("11Noztgbpu_gUKkc5F4evKKfyxS-Jv1coE0IrBToX_gg"),
|
GEM_HUNTERS_CHESTS("11Noztgbpu_gUKkc5F4evKKfyxS-Jv1coE0IrBToX_gg"),
|
||||||
GEM_HUNTERS_SHOP("1OcYktxVZaW6Fm29Zh6w4Lb-UVyuN8r1x-TFb_3USYYI"),
|
GEM_HUNTERS_SHOP("1OcYktxVZaW6Fm29Zh6w4Lb-UVyuN8r1x-TFb_3USYYI"),
|
||||||
|
|
||||||
|
QUESTS_SHEET("1Gy1a7GCVopmOLwYE3Sk1DNVCAIwT8ReaLu4wRe0sfDE")
|
||||||
;
|
;
|
||||||
|
|
||||||
private String _id;
|
private String _id;
|
||||||
|
Loading…
Reference in New Issue
Block a user