Add basic Quest system

This commit is contained in:
Sarah 2017-05-02 18:57:20 +02:00
parent 87b829b411
commit 8d32c35f88
8 changed files with 571 additions and 0 deletions

View File

@ -0,0 +1,112 @@
package mineplex.core.quests;
import mineplex.core.game.GameDisplay;
/**
* Quest
*
* @author xXVevzZXx
*/
public class Quest
{
private int _questID;
private String _questName;
private String _questTask;
private int _questCost;
private int _questReward;
private QuestRarity _rarity;
private GameDisplay _game;
private TriggerType _trigger;
private String _item;
private int _statToComplete;
private int _current;
public Quest(int questID, String name, String task, int cost, int reward, QuestRarity rarity, GameDisplay game, TriggerType trigger, String item, int statToComplete)
{
_questID = questID;
_questName = name;
_questTask = task;
_questCost = cost;
_questReward = reward;
_rarity = rarity;
_game = game;
_trigger = trigger;
_item = item;
_statToComplete = statToComplete;
}
public int getID()
{
return _questID;
}
public String getName()
{
return _questName;
}
public String getTask()
{
return _questTask;
}
public int getCost()
{
return _questCost;
}
public int getReward()
{
return _questReward;
}
public QuestRarity getRarity()
{
return _rarity;
}
public GameDisplay getGame()
{
return _game;
}
public TriggerType getTrigger()
{
return _trigger;
}
public String getItem()
{
return _item;
}
public int getStatToComplete()
{
return _statToComplete;
}
public void setProgress(int progress)
{
_current = progress;
}
public void increment()
{
_current++;
}
public void decrement()
{
_current--;
}
public boolean isCompleted()
{
return _current == _statToComplete;
}
}

View File

@ -0,0 +1,18 @@
package mineplex.core.quests;
import org.bukkit.entity.Player;
/**
* QuestClientData
*
* @author xXVevzZXx
*/
public class QuestClientData
{
public QuestClientData(Player player)
{
}
}

View File

@ -0,0 +1,26 @@
package mineplex.core.quests;
import java.util.UUID;
import mineplex.core.MiniClientPlugin;
/**
* QuestManager
*
* @author xXVevzZXx
*/
public class QuestManager extends MiniClientPlugin<QuestClientData>
{
public QuestManager()
{
super("Quest Manager");
}
@Override
protected QuestClientData addPlayer(UUID uuid)
{
return null;
}
}

View File

@ -0,0 +1,44 @@
package mineplex.core.quests;
import org.bukkit.ChatColor;
/**
* QuestRarity
*
* @author xXVevzZXx
*/
public enum QuestRarity
{
COMMON("Common", ChatColor.YELLOW), RARE("Rare", ChatColor.LIGHT_PURPLE), LEGENDARY("Legendary", ChatColor.GREEN);
private String _name;
private ChatColor _color;
private QuestRarity(String name, ChatColor color)
{
_name = name;
_color = color;
}
@Override
public String toString()
{
return _name;
}
public ChatColor getColor()
{
return _color;
}
public static QuestRarity getByName(String name)
{
for (QuestRarity rarity : values())
{
if (rarity.toString().equalsIgnoreCase(name))
return rarity;
}
return null;
}
}

View File

@ -0,0 +1,36 @@
package mineplex.core.quests;
/**
* TriggerType
*
* @author xXVevzZXx
*/
public enum TriggerType
{
KILL("Kill"), DIE("Die"), WIN("Win"), LOSE("Lose"), COLLECT("Collect");
private String _name;
private TriggerType(String name)
{
_name = name;
}
@Override
public String toString()
{
return _name;
}
public static TriggerType getByName(String name)
{
for (TriggerType type : values())
{
if (type.toString().equalsIgnoreCase(name))
return type;
}
return null;
}
}

View File

@ -0,0 +1,19 @@
package mineplex.core.quests.repository;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
/**
* QuestRepository
*
* @author xXVevzZXx
*/
public class QuestRepository extends RepositoryBase
{
public QuestRepository()
{
super(DBPool.getAccount());
}
}

View File

@ -0,0 +1,114 @@
package mineplex.database.tables;
import org.jooq.impl.TableImpl;
/**
* This class is generated by jOOQ.
*/
@javax.annotation.Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.5.2"
},
comments = "This class is generated by jOOQ"
)
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class AccountQuest extends TableImpl<mineplex.database.tables.records.AccountQuestRecord> implements java.io.Serializable, java.lang.Cloneable
{
/**
*
*/
private static final long serialVersionUID = -8158716179851336044L;
/**
* The reference instance of <code>Account.accountStat</code>
*/
public static final mineplex.database.tables.AccountStat accountStat = new mineplex.database.tables.AccountStat();
/**
* The class holding records for this type
*/
@Override
public java.lang.Class<mineplex.database.tables.records.AccountQuestRecord> getRecordType() {
return mineplex.database.tables.records.AccountQuestRecord.class;
}
/**
* 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, "");
/**
* 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, "");
/**
* 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, "");
/**
* Create a <code>Account.accountStat</code> table reference
*/
public AccountQuest()
{
super("accountquest", null);
}
/**
* Create an aliased <code>Account.accountStat</code> table reference
*/
public AccountQuest(java.lang.String alias) {
this(alias, mineplex.database.tables.AccountQuest.accountStat);
}
private AccountQuest(java.lang.String alias, org.jooq.Table<mineplex.database.tables.records.AccountQuestRecord> aliased) {
this(alias, aliased, null);
}
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, "");
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.UniqueKey<mineplex.database.tables.records.AccountStatRecord> getPrimaryKey() {
return mineplex.database.Keys.KEY_accountStat_PRIMARY;
}
/**
* {@inheritDoc}
*/
@Override
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);
}
/**
* {@inheritDoc}
*/
@Override
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);
}
/**
* {@inheritDoc}
*/
@Override
public mineplex.database.tables.AccountStat as(java.lang.String alias) {
return new mineplex.database.tables.AccountStat(alias, this);
}
/**
* Rename this table
*/
public mineplex.database.tables.AccountStat rename(java.lang.String name) {
return new mineplex.database.tables.AccountStat(name, null);
}
}

View File

@ -0,0 +1,202 @@
package mineplex.database.tables.records;
import org.jooq.Table;
/**
* AccountQuest
*
* @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>
{
/**
*
*/
private static final long serialVersionUID = 5171965369180094201L;
public AccountQuestRecord(Table<AccountQuestRecord> table)
{
super(table);
}
/**
* Setter for <code>Account.accountStat.accountId</code>.
*/
public void setAccountId(java.lang.Integer value) {
setValue(0, value);
}
/**
* Getter for <code>Account.accountStat.accountId</code>.
*/
public java.lang.Integer getAccountId() {
return (java.lang.Integer) getValue(0);
}
/**
* Setter for <code>Account.accountStat.statId</code>.
*/
public void setStatId(java.lang.Integer value) {
setValue(1, value);
}
/**
* Getter for <code>Account.accountStat.statId</code>.
*/
public java.lang.Integer getStatId() {
return (java.lang.Integer) getValue(1);
}
/**
* Setter for <code>Account.accountStat.value</code>.
*/
public void setValue(org.jooq.types.ULong value) {
setValue(2, value);
}
/**
* Getter for <code>Account.accountStat.value</code>.
*/
public org.jooq.types.ULong getValue() {
return (org.jooq.types.ULong) getValue(2);
}
// -------------------------------------------------------------------------
// Primary key information
// -------------------------------------------------------------------------
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Record2<java.lang.Integer, java.lang.Integer> key() {
return (org.jooq.Record2) super.key();
}
// -------------------------------------------------------------------------
// Record3 type implementation
// -------------------------------------------------------------------------
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Row3<java.lang.Integer, java.lang.Integer, org.jooq.types.ULong> fieldsRow() {
return (org.jooq.Row3) super.fieldsRow();
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Row3<java.lang.Integer, java.lang.Integer, org.jooq.types.ULong> valuesRow() {
return (org.jooq.Row3) super.valuesRow();
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.Integer> field1() {
return mineplex.database.tables.AccountStat.accountStat.accountId;
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Field<java.lang.Integer> field2() {
return mineplex.database.tables.AccountStat.accountStat.statId;
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Field<org.jooq.types.ULong> field3() {
return mineplex.database.tables.AccountStat.accountStat.value;
}
/**
* {@inheritDoc}
*/
@Override
public java.lang.Integer value1() {
return getAccountId();
}
/**
* {@inheritDoc}
*/
@Override
public java.lang.Integer value2() {
return getStatId();
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.types.ULong value3() {
return getValue();
}
/**
* {@inheritDoc}
*/
@Override
public AccountStatRecord value1(java.lang.Integer value) {
setAccountId(value);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public AccountStatRecord value2(java.lang.Integer value) {
setStatId(value);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public AccountStatRecord value3(org.jooq.types.ULong value) {
setValue(value);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public AccountStatRecord values(java.lang.Integer value1, java.lang.Integer value2, org.jooq.types.ULong value3) {
return this;
}
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
/**
* Create a detached AccountStatRecord
*/
public AccountStatRecord() {
super(mineplex.database.tables.AccountStat.accountStat);
}
/**
* Create a detached, initialised AccountStatRecord
*/
public AccountStatRecord(java.lang.Integer accountId, java.lang.Integer statId, org.jooq.types.ULong value) {
super(mineplex.database.tables.AccountStat.accountStat);
setValue(0, accountId);
setValue(1, statId);
setValue(2, value);
}
}