-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Statistic Requirement for Challenges addon.
Statistic requirement is a new type of challenge that is based on Statistic page for clients.
- Loading branch information
Showing
10 changed files
with
1,091 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
223 changes: 223 additions & 0 deletions
223
...in/java/world/bentobox/challenges/database/object/requirements/StatisticRequirements.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
// | ||
// Created by BONNe | ||
// Copyright - 2021 | ||
// | ||
|
||
|
||
package world.bentobox.challenges.database.object.requirements; | ||
|
||
|
||
import com.google.gson.annotations.Expose; | ||
import org.bukkit.Material; | ||
import org.bukkit.Statistic; | ||
import org.bukkit.entity.EntityType; | ||
|
||
|
||
public class StatisticRequirements extends Requirements | ||
{ | ||
/** | ||
* Constructor Requirements creates a new Requirements instance. | ||
*/ | ||
public StatisticRequirements() | ||
{ | ||
// Empty constructor | ||
} | ||
|
||
|
||
/** | ||
* This method clones given statistic object. | ||
* @return Clone of this object. | ||
*/ | ||
@Override | ||
public Requirements clone() | ||
{ | ||
StatisticRequirements requirements = new StatisticRequirements(); | ||
requirements.setStatistic(this.statistic); | ||
requirements.setEntity(this.entity); | ||
requirements.setMaterial(this.material); | ||
requirements.setAmount(this.amount); | ||
requirements.setReduceStatistic(this.reduceStatistic); | ||
|
||
return requirements; | ||
} | ||
|
||
|
||
@Override | ||
public boolean isValid() | ||
{ | ||
if (!super.isValid()) | ||
{ | ||
return false; | ||
} | ||
|
||
if (this.statistic == null) | ||
{ | ||
return false; | ||
} | ||
|
||
switch (this.statistic.getType()) | ||
{ | ||
case ITEM -> { | ||
return this.material != null && this.material.isItem(); | ||
} | ||
case BLOCK -> { | ||
return this.material != null && this.material.isBlock(); | ||
} | ||
case ENTITY -> { | ||
return this.entity != null; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
|
||
// --------------------------------------------------------------------- | ||
// Section: Getters and setters | ||
// --------------------------------------------------------------------- | ||
|
||
|
||
/** | ||
* Gets statistic. | ||
* | ||
* @return the statistic | ||
*/ | ||
public Statistic getStatistic() | ||
{ | ||
return statistic; | ||
} | ||
|
||
|
||
/** | ||
* Sets statistic. | ||
* | ||
* @param statistic the statistic | ||
*/ | ||
public void setStatistic(Statistic statistic) | ||
{ | ||
this.statistic = statistic; | ||
} | ||
|
||
|
||
/** | ||
* Gets entity. | ||
* | ||
* @return the entity | ||
*/ | ||
public EntityType getEntity() | ||
{ | ||
return entity; | ||
} | ||
|
||
|
||
/** | ||
* Sets entity. | ||
* | ||
* @param entity the entity | ||
*/ | ||
public void setEntity(EntityType entity) | ||
{ | ||
this.entity = entity; | ||
} | ||
|
||
|
||
/** | ||
* Gets material. | ||
* | ||
* @return the material | ||
*/ | ||
public Material getMaterial() | ||
{ | ||
return material; | ||
} | ||
|
||
|
||
/** | ||
* Sets material. | ||
* | ||
* @param material the material | ||
*/ | ||
public void setMaterial(Material material) | ||
{ | ||
this.material = material; | ||
} | ||
|
||
|
||
/** | ||
* Gets amount. | ||
* | ||
* @return the amount | ||
*/ | ||
public int getAmount() | ||
{ | ||
return amount; | ||
} | ||
|
||
|
||
/** | ||
* Sets amount. | ||
* | ||
* @param amount the amount | ||
*/ | ||
public void setAmount(int amount) | ||
{ | ||
this.amount = amount; | ||
} | ||
|
||
|
||
/** | ||
* Is reduce statistic boolean. | ||
* | ||
* @return the boolean | ||
*/ | ||
public boolean isReduceStatistic() | ||
{ | ||
return reduceStatistic; | ||
} | ||
|
||
|
||
/** | ||
* Sets reduce statistic. | ||
* | ||
* @param reduceStatistic the reduce statistic | ||
*/ | ||
public void setReduceStatistic(boolean reduceStatistic) | ||
{ | ||
this.reduceStatistic = reduceStatistic; | ||
} | ||
|
||
|
||
// --------------------------------------------------------------------- | ||
// Section: Variables | ||
// --------------------------------------------------------------------- | ||
|
||
/** | ||
* Type of the statistic field. | ||
*/ | ||
@Expose | ||
private Statistic statistic; | ||
|
||
/** | ||
* Type of entity for entity related statistics. | ||
*/ | ||
@Expose | ||
private EntityType entity; | ||
|
||
/** | ||
* Type of material for block and item related statistics. | ||
*/ | ||
@Expose | ||
private Material material; | ||
|
||
/** | ||
* Amount of the stats. | ||
*/ | ||
@Expose | ||
private int amount; | ||
|
||
/** | ||
* Indicate that player statistic fields must be adjusted after completing challenges. | ||
*/ | ||
@Expose | ||
private boolean reduceStatistic; | ||
} |
Oops, something went wrong.