Rename Challenges and ChallengeLevels classes.

This commit is contained in:
BONNe1704 2019-01-23 16:09:38 +02:00
parent 59c0f6bfea
commit dba5a44461
18 changed files with 144 additions and 144 deletions

View File

@ -16,8 +16,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import world.bentobox.challenges.database.object.ChallengeLevels;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.ChallengeLevel;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.Util;
@ -78,7 +78,7 @@ public class ChallengesImportManager
String[] lvs = levels.split(" ");
int order = 0;
for (String level : lvs) {
ChallengeLevels challengeLevel = new ChallengeLevels();
ChallengeLevel challengeLevel = new ChallengeLevel();
challengeLevel.setFriendlyName(level);
challengeLevel.setUniqueId(level);
challengeLevel.setOrder(order++);
@ -110,7 +110,7 @@ public class ChallengesImportManager
// Parse the challenge file
ConfigurationSection chals = chal.getConfigurationSection("challenges.challengeList");
for (String challenge : chals.getKeys(false)) {
Challenges newChallenge = new Challenges();
Challenge newChallenge = new Challenge();
newChallenge.setUniqueId(Util.getWorld(world).getName() + "_" + challenge);
newChallenge.setDeployed(true);
ConfigurationSection details = chals.getConfigurationSection(challenge);
@ -119,7 +119,7 @@ public class ChallengesImportManager
newChallenge.setDescription(addon.getChallengesManager().stringSplit(details.getString("description", "")));
newChallenge.setIcon(new ParseItem(addon, details.getString("icon") + ":1").getItem());
newChallenge.setLevel(details.getString("level", ChallengesManager.FREE));
newChallenge.setChallengeType(Challenges.ChallengeType.valueOf(details.getString("type","INVENTORY").toUpperCase()));
newChallenge.setChallengeType(Challenge.ChallengeType.valueOf(details.getString("type","INVENTORY").toUpperCase()));
newChallenge.setTakeItems(details.getBoolean("takeItems",true));
newChallenge.setRewardText(details.getString("rewardText", ""));
newChallenge.setRewardCommands(details.getStringList("rewardcommands"));
@ -135,11 +135,11 @@ public class ChallengesImportManager
newChallenge.setReqMoney(details.getInt("requiredMoney"));
newChallenge.setReqExp(details.getInt("requiredExp"));
String reqItems = details.getString("requiredItems","");
if (newChallenge.getChallengeType().equals(Challenges.ChallengeType.INVENTORY)) {
if (newChallenge.getChallengeType().equals(Challenge.ChallengeType.INVENTORY)) {
newChallenge.setRequiredItems(parseItems(reqItems));
} else if (newChallenge.getChallengeType().equals(Challenges.ChallengeType.LEVEL)) {
} else if (newChallenge.getChallengeType().equals(Challenge.ChallengeType.LEVEL)) {
newChallenge.setReqIslandlevel(Long.parseLong(reqItems));
} else if (newChallenge.getChallengeType().equals(Challenges.ChallengeType.ISLAND)) {
} else if (newChallenge.getChallengeType().equals(Challenge.ChallengeType.ISLAND)) {
parseEntities(newChallenge, reqItems);
}
newChallenge.setRewardItems(parseItems(details.getString("itemReward")));
@ -158,7 +158,7 @@ public class ChallengesImportManager
* @param challenge - challenge to be adjusted
* @param string - string from YAML file
*/
private void parseEntities(Challenges challenge, String string) {
private void parseEntities(Challenge challenge, String string) {
Map<EntityType, Integer> req = new EnumMap<>(EntityType.class);
Map<Material, Integer> blocks = new EnumMap<>(Material.class);
if (!string.isEmpty()) {

View File

@ -17,18 +17,18 @@ import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.Database;
import world.bentobox.bentobox.util.Util;
import world.bentobox.challenges.commands.admin.SurroundChallengeBuilder;
import world.bentobox.challenges.database.object.ChallengeLevels;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.Challenges.ChallengeType;
import world.bentobox.challenges.database.object.ChallengeLevel;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.database.object.Challenge.ChallengeType;
import world.bentobox.challenges.database.object.ChallengesPlayerData;
import world.bentobox.challenges.panel.ChallengesPanels;
public class ChallengesManager {
public static final String FREE = "Free";
private Map<ChallengeLevels, Set<Challenges>> challengeMap;
private Config<Challenges> chConfig;
private Config<ChallengeLevels> lvConfig;
private Map<ChallengeLevel, Set<Challenge>> challengeMap;
private Config<Challenge> chConfig;
private Config<ChallengeLevel> lvConfig;
private Database<ChallengesPlayerData> players;
private ChallengesPanels challengesPanels;
private Map<UUID,ChallengesPlayerData> playerData;
@ -37,8 +37,8 @@ public class ChallengesManager {
public ChallengesManager(ChallengesAddon addon) {
this.addon = addon;
// Set up the configs
chConfig = new Config<>(addon, Challenges.class);
lvConfig = new Config<>(addon, ChallengeLevels.class);
chConfig = new Config<>(addon, Challenge.class);
lvConfig = new Config<>(addon, ChallengeLevel.class);
// Players is where all the player history will be stored
players = new Database<>(addon, ChallengesPlayerData.class);
// Cache of challenges
@ -78,7 +78,7 @@ public class ChallengesManager {
* @param challenge - challenge
* @return - number of times
*/
public long checkChallengeTimes(User user, Challenges challenge, World world) {
public long checkChallengeTimes(User user, Challenge challenge, World world) {
addPlayer(user);
return playerData.get(user.getUniqueId()).getTimes(world, challenge.getUniqueId());
}
@ -109,7 +109,7 @@ public class ChallengesManager {
if (inventory.getContents().length == 0) {
return false;
}
Challenges newChallenge = new Challenges();
Challenge newChallenge = new Challenge();
newChallenge.setChallengeType(ChallengeType.INVENTORY);
newChallenge.setFriendlyName(inventory.getTitle());
newChallenge.setDeployed(false);
@ -154,7 +154,7 @@ public class ChallengesManager {
challengeInfo.getOwner().sendMessage("challenges.error.no-items-clicked");
return false;
}
Challenges newChallenge = new Challenges();
Challenge newChallenge = new Challenge();
newChallenge.setChallengeType(ChallengeType.ISLAND);
newChallenge.setFriendlyName(challengeInfo.getName());
newChallenge.setDeployed(true);
@ -199,10 +199,10 @@ public class ChallengesManager {
* @param world - world to check
* @return - challenge or null if it does not exist
*/
public Challenges getChallenge(String name, World world) {
public Challenge getChallenge(String name, World world) {
String worldName = Util.getWorld(world).getName();
for (Set<Challenges> ch : challengeMap.values()) {
Optional<Challenges> challenge = ch.stream().filter(c -> c.getUniqueId().equalsIgnoreCase(worldName + name)).findFirst();
for (Set<Challenge> ch : challengeMap.values()) {
Optional<Challenge> challenge = ch.stream().filter(c -> c.getUniqueId().equalsIgnoreCase(worldName + name)).findFirst();
if (challenge.isPresent()) {
return challenge.get();
}
@ -223,11 +223,11 @@ public class ChallengesManager {
List<LevelStatus> result = new ArrayList<>();
// The first level is always unlocked
ChallengeLevels previousLevel = null;
ChallengeLevel previousLevel = null;
int doneChallengeCount = Integer.MAX_VALUE;
// For each challenge level, check how many the user has done
for (Entry<ChallengeLevels, Set<Challenges>> entry : this.challengeMap.entrySet())
for (Entry<ChallengeLevel, Set<Challenge>> entry : this.challengeMap.entrySet())
{
// Check how much challenges must be done in previous level.
int challengesToDo = Math.max(0, entry.getKey().getWaiveramount() - doneChallengeCount);
@ -254,7 +254,7 @@ public class ChallengesManager {
* Get the challenge list
* @return the challengeList
*/
public Map<ChallengeLevels, Set<Challenges>> getChallengeList() {
public Map<ChallengeLevel, Set<Challenge>> getChallengeList() {
// TODO return the challenges for world
return challengeMap;
}
@ -265,9 +265,9 @@ public class ChallengesManager {
* @param world
* @return the set of challenges for this level, or the first set of challenges if level is blank, or a blank list if there are no challenges
*/
public Set<Challenges> getChallenges(String level, World world) {
public Set<Challenge> getChallenges(String level, World world) {
String worldName = Util.getWorld(world).getName();
Optional<ChallengeLevels> lv = challengeMap.keySet().stream().filter(l -> l.getUniqueId().equalsIgnoreCase(level)).findFirst();
Optional<ChallengeLevel> lv = challengeMap.keySet().stream().filter(l -> l.getUniqueId().equalsIgnoreCase(level)).findFirst();
// Get the challenges applicable to this world
return lv.isPresent() ? challengeMap.get(lv.get()).stream()
.filter(c -> c.getWorld().equalsIgnoreCase(worldName) || c.getWorld().isEmpty()).collect(Collectors.toSet())
@ -286,9 +286,9 @@ public class ChallengesManager {
* @param currentLevel - the current level
* @return the previous level, or null if there is none
*/
public ChallengeLevels getPreviousLevel(ChallengeLevels currentLevel) {
ChallengeLevels result = null;
for (ChallengeLevels level : challengeMap.keySet()) {
public ChallengeLevel getPreviousLevel(ChallengeLevel currentLevel) {
ChallengeLevel result = null;
for (ChallengeLevel level : challengeMap.keySet()) {
if (level.equals(currentLevel)) {
return result;
}
@ -303,7 +303,7 @@ public class ChallengesManager {
* @return true if it exists, otherwise false
*/
public boolean isChallenge(String name) {
for (Set<Challenges> ch : challengeMap.values()) {
for (Set<Challenge> ch : challengeMap.values()) {
if (ch.stream().anyMatch(c -> c.getUniqueId().equalsIgnoreCase(name))) {
return true;
}
@ -318,7 +318,7 @@ public class ChallengesManager {
* @return true if it exists, otherwise false
*/
public boolean isChallenge(World world, String name) {
for (Set<Challenges> ch : challengeMap.values()) {
for (Set<Challenge> ch : challengeMap.values()) {
if (ch.stream().filter(c -> c.getWorld().equals(Util.getWorld(world).getName())).anyMatch(c -> c.getUniqueId().equalsIgnoreCase(name))) {
return true;
}
@ -417,7 +417,7 @@ public class ChallengesManager {
/**
* @param challengeList the challengeList to set
*/
public void setChallengeList(Map<ChallengeLevels, Set<Challenges>> challengeList) {
public void setChallengeList(Map<ChallengeLevel, Set<Challenge>> challengeList) {
this.challengeMap = challengeList;
}
@ -435,7 +435,7 @@ public class ChallengesManager {
* @param challenge
* @return true if successful
*/
private boolean storeChallenge(Challenges challenge) {
private boolean storeChallenge(Challenge challenge) {
return storeChallenge(challenge, true, null, true);
}
@ -447,15 +447,15 @@ public class ChallengesManager {
* @param silent - if true, no messages are sent to user
* @return - true if imported
*/
public boolean storeChallenge(Challenges challenge, boolean overwrite, User user, boolean silent) {
public boolean storeChallenge(Challenge challenge, boolean overwrite, User user, boolean silent) {
// See if we have this level already
ChallengeLevels level;
ChallengeLevel level;
if (lvConfig.configObjectExists(challenge.getLevel())) {
// Get it from the database
level = lvConfig.loadConfigObject(challenge.getLevel());
} else {
// Make it
level = new ChallengeLevels();
level = new ChallengeLevel();
level.setUniqueId(challenge.getLevel());
lvConfig.saveConfigObject(level);
}
@ -485,7 +485,7 @@ public class ChallengesManager {
* Store a challenge level
* @param level the challenge level
*/
public void storeLevel(ChallengeLevels level) {
public void storeLevel(ChallengeLevel level) {
lvConfig.saveConfigObject(level);
}
@ -517,37 +517,37 @@ public class ChallengesManager {
}
public Challenges createChallenge()
public Challenge createChallenge()
{
return new Challenges();
return new Challenge();
}
public List<Challenges> getChallenges(ChallengeLevels challengeLevel)
public List<Challenge> getChallenges(ChallengeLevel challengeLevel)
{
return new ArrayList<>(this.challengeMap.get(challengeLevel));
}
public List<ChallengeLevels> getChallengeLevelList()
public List<ChallengeLevel> getChallengeLevelList()
{
return new ArrayList<>(this.challengeMap.keySet());
}
public List<Challenges> getChallengesList()
public List<Challenge> getChallengesList()
{
return new ArrayList<>();
}
public void deleteChallenge(Challenges selectedChallenge)
public void deleteChallenge(Challenge selectedChallenge)
{
}
public void deleteChallengeLevel(ChallengeLevels valueObject)
public void deleteChallengeLevel(ChallengeLevel valueObject)
{
}
@ -558,9 +558,9 @@ public class ChallengesManager {
}
public Challenges createChallenge(String reply)
public Challenge createChallenge(String reply)
{
return new Challenges();
return new Challenge();
}
@ -576,55 +576,55 @@ public class ChallengesManager {
}
public ChallengeLevels createLevel(String reply)
public ChallengeLevel createLevel(String reply)
{
return new ChallengeLevels();
return new ChallengeLevel();
}
public void unlinkChallenge(ChallengeLevels challengeLevel, Challenges value)
public void unlinkChallenge(ChallengeLevel challengeLevel, Challenge value)
{
}
public void linkChallenge(ChallengeLevels challengeLevel, Challenges value)
public void linkChallenge(ChallengeLevel challengeLevel, Challenge value)
{
}
public void resetChallenge(UUID uniqueId, Challenges value)
public void resetChallenge(UUID uniqueId, Challenge value)
{
}
public void completeChallenge(UUID uniqueId, Challenges value)
public void completeChallenge(UUID uniqueId, Challenge value)
{
}
public List<Challenges> getFreeChallenges(User user, World world)
public List<Challenge> getFreeChallenges(User user, World world)
{
return Collections.emptyList();
}
public String getChallengesLevel(Challenges challenge)
public String getChallengesLevel(Challenge challenge)
{
return "HERE NEED LEVEL NAME";
}
public boolean isChallengeComplete(User user, Challenges challenge)
public boolean isChallengeComplete(User user, Challenge challenge)
{
return this.isChallengeComplete(user, challenge.getUniqueId(), user.getWorld());
}
public long checkChallengeTimes(User user, Challenges challenge)
public long checkChallengeTimes(User user, Challenge challenge)
{
return this.checkChallengeTimes(user, challenge, user.getWorld());
}

View File

@ -1,6 +1,6 @@
package world.bentobox.challenges;
import world.bentobox.challenges.database.object.ChallengeLevels;
import world.bentobox.challenges.database.object.ChallengeLevel;
/**
* Level status class
@ -8,8 +8,8 @@ import world.bentobox.challenges.database.object.ChallengeLevels;
*
*/
public class LevelStatus {
private final ChallengeLevels level;
private final ChallengeLevels previousLevel;
private final ChallengeLevel level;
private final ChallengeLevel previousLevel;
private final int numberOfChallengesStillToDo;
private final boolean complete;
private final boolean isUnlocked;
@ -21,7 +21,7 @@ public class LevelStatus {
* @param complete - whether complete or not
* @param isUnlocked
*/
public LevelStatus(ChallengeLevels level, ChallengeLevels previousLevel, int numberOfChallengesStillToDo, boolean complete, boolean isUnlocked) {
public LevelStatus(ChallengeLevel level, ChallengeLevel previousLevel, int numberOfChallengesStillToDo, boolean complete, boolean isUnlocked) {
super();
this.level = level;
this.previousLevel = previousLevel;
@ -32,7 +32,7 @@ public class LevelStatus {
/**
* @return the level
*/
public ChallengeLevels getLevel() {
public ChallengeLevel getLevel() {
return level;
}
/**
@ -44,7 +44,7 @@ public class LevelStatus {
/**
* @return the previousLevel
*/
public ChallengeLevels getPreviousLevel() {
public ChallengeLevel getPreviousLevel() {
return previousLevel;
}
/**

View File

@ -16,9 +16,9 @@ import world.bentobox.challenges.ChallengesManager;
* @author tastybento
*
*/
public class Challenges implements DataObject {
public class Challenge implements DataObject {
public Challenges() {}
public Challenge() {}
public boolean isRemoveEntities()
@ -649,10 +649,10 @@ public class Challenges implements DataObject {
if (obj == null) {
return false;
}
if (!(obj instanceof Challenges)) {
if (!(obj instanceof Challenge)) {
return false;
}
Challenges other = (Challenges) obj;
Challenge other = (Challenge) obj;
if (uniqueId == null) {
if (other.uniqueId != null) {
return false;

View File

@ -14,9 +14,9 @@ import world.bentobox.challenges.ChallengesManager;
* @author tastybento
*
*/
public class ChallengeLevels implements DataObject, Comparable<ChallengeLevels> {
public class ChallengeLevel implements DataObject, Comparable<ChallengeLevel> {
public ChallengeLevels() {}
public ChallengeLevel() {}
@ConfigComment("A friendly name for the level. If blank, level name is used.")
private String friendlyName = "";
@ -98,7 +98,7 @@ public class ChallengeLevels implements DataObject, Comparable<ChallengeLevels>
}
@Override
public int compareTo(ChallengeLevels o) {
public int compareTo(ChallengeLevel o) {
return Integer.compare(this.order, o.order);
}
@ -208,10 +208,10 @@ public class ChallengeLevels implements DataObject, Comparable<ChallengeLevels>
if (obj == null) {
return false;
}
if (!(obj instanceof ChallengeLevels)) {
if (!(obj instanceof ChallengeLevel)) {
return false;
}
ChallengeLevels other = (ChallengeLevels) obj;
ChallengeLevel other = (ChallengeLevel) obj;
if (uniqueId == null) {
if (other.uniqueId != null) {
return false;

View File

@ -6,7 +6,7 @@ import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.bentobox.api.panels.Panel;
import world.bentobox.bentobox.api.panels.PanelItem.ClickHandler;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
@ -22,7 +22,7 @@ public class AdminEditGUI implements ClickHandler {
private ChallengesAddon addon;
private User requester;
private Challenges challenge;
private Challenge challenge;
private World world;
private String permPrefix;
private String label;
@ -38,7 +38,7 @@ public class AdminEditGUI implements ClickHandler {
* @param permPrefix permission prefix for world
* @param label command label
*/
public AdminEditGUI(ChallengesAddon addon, User requester, User target, Challenges challenge, World world,
public AdminEditGUI(ChallengesAddon addon, User requester, User target, Challenge challenge, World world,
String permPrefix, String label) {
super();
this.addon = addon;

View File

@ -6,7 +6,7 @@ import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.bentobox.api.panels.Panel;
import world.bentobox.bentobox.api.panels.PanelItem.ClickHandler;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
@ -22,7 +22,7 @@ public class AdminGUI implements ClickHandler {
private ChallengesAddon addon;
private User player;
private Challenges challenge;
private Challenge challenge;
private World world;
private String permPrefix;
private String label;
@ -36,7 +36,7 @@ public class AdminGUI implements ClickHandler {
* @param permPrefix
* @param label
*/
public AdminGUI(ChallengesAddon addon, User player, Challenges challenge, World world,
public AdminGUI(ChallengesAddon addon, User player, Challenge challenge, World world,
String permPrefix, String label) {
super();
this.addon = addon;

View File

@ -13,8 +13,8 @@ import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.ChallengesManager;
import world.bentobox.challenges.LevelStatus;
import world.bentobox.challenges.commands.ChallengesCommand;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.Challenges.ChallengeType;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.database.object.Challenge.ChallengeType;
import world.bentobox.bentobox.api.panels.Panel;
import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
@ -69,9 +69,9 @@ public class ChallengesPanels {
}
private void addChallengeItems(PanelBuilder panelBuilder) {
Set<Challenges> levelChallenges = manager.getChallenges(level, world);
Set<Challenge> levelChallenges = manager.getChallenges(level, world);
// Only show a control panel for the level requested.
for (Challenges challenge : levelChallenges) {
for (Challenge challenge : levelChallenges) {
createItem(panelBuilder, challenge);
}
}
@ -87,7 +87,7 @@ public class ChallengesPanels {
* @param challenge
* @param user
*/
private void createItem(PanelBuilder panelBuilder, Challenges challenge) {
private void createItem(PanelBuilder panelBuilder, Challenge challenge) {
// Check completion
boolean completed = manager.isChallengeComplete(user, challenge.getUniqueId(), world);
// If challenge is removed after completion, remove it
@ -164,7 +164,7 @@ public class ChallengesPanels {
* @param player
* @return List of strings splitting challenge string into 25 chars long
*/
private List<String> challengeDescription(Challenges challenge) {
private List<String> challengeDescription(Challenge challenge) {
List<String> result = new ArrayList<String>();
String level = challenge.getLevel();
if (!level.isEmpty()) {

View File

@ -12,8 +12,8 @@ import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.ChallengesManager;
import world.bentobox.challenges.LevelStatus;
import world.bentobox.challenges.commands.ChallengesCommand;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.Challenges.ChallengeType;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.database.object.Challenge.ChallengeType;
import world.bentobox.bentobox.api.panels.Panel;
import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
@ -93,7 +93,7 @@ public class ChallengesPanels2 {
private void addChallengeItems(PanelBuilder panelBuilder) {
// Only show a control panel for the level requested.
for (Challenges challenge : manager.getChallenges(level, world)) {
for (Challenge challenge : manager.getChallenges(level, world)) {
createItem(panelBuilder, challenge);
}
}
@ -109,7 +109,7 @@ public class ChallengesPanels2 {
* @param challenge
* @param requester
*/
private void createItem(PanelBuilder panelBuilder, Challenges challenge) {
private void createItem(PanelBuilder panelBuilder, Challenge challenge) {
// For admin, glow means activated. For user, glow means done
boolean glow = false;
switch (mode) {
@ -219,7 +219,7 @@ public class ChallengesPanels2 {
* @param player
* @return List of strings splitting challenge string into 25 chars long
*/
private List<String> challengeDescription(Challenges challenge) {
private List<String> challengeDescription(Challenge challenge) {
List<String> result = new ArrayList<String>();
String level = challenge.getLevel();
if (!level.isEmpty()) {
@ -278,7 +278,7 @@ public class ChallengesPanels2 {
return result;
}
private List<String> addRewards(Challenges challenge, boolean complete, boolean admin) {
private List<String> addRewards(Challenge challenge, boolean complete, boolean admin) {
List<String> result = new ArrayList<>();
double moneyReward = 0;
int expReward = 0;

View File

@ -12,7 +12,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.ItemStack;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.bentobox.api.panels.Panel;
import world.bentobox.bentobox.api.panels.PanelItem.ClickHandler;
import world.bentobox.bentobox.api.panels.PanelListener;
@ -30,7 +30,7 @@ import world.bentobox.bentobox.util.Util;
@Deprecated
public class RequiredPanel implements ClickHandler, PanelListener {
private static final int CONTROL_NUMBER = 4;
private Challenges challenge;
private Challenge challenge;
private User user;
private Panel panel;
private Panel referringPanel;
@ -39,7 +39,7 @@ public class RequiredPanel implements ClickHandler, PanelListener {
* @param challenge
* @param user
*/
public RequiredPanel(Challenges challenge, User user, Panel referringPanel) {
public RequiredPanel(Challenge challenge, User user, Panel referringPanel) {
this.challenge = challenge;
this.user = user;
this.panel = openPanel();

View File

@ -23,8 +23,8 @@ import org.bukkit.util.Vector;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.ChallengesManager;
import world.bentobox.challenges.commands.ChallengesCommand;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.Challenges.ChallengeType;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.database.object.Challenge.ChallengeType;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.hooks.VaultHook;
@ -43,7 +43,7 @@ public class TryToComplete {
private String permPrefix;
private User user;
private ChallengesManager manager;
private Challenges challenge;
private Challenge challenge;
private String label;
public TryToComplete label(String label) {
@ -61,7 +61,7 @@ public class TryToComplete {
return this;
}
public TryToComplete challenge(Challenges challenge) {
public TryToComplete challenge(Challenge challenge) {
this.challenge = challenge;
return this;
}
@ -138,7 +138,7 @@ public class TryToComplete {
* @param world
* @param permPrefix
*/
public TryToComplete(ChallengesAddon addon, User user, ChallengesManager manager, Challenges challenge, World world, String permPrefix, String label) {
public TryToComplete(ChallengesAddon addon, User user, ChallengesManager manager, Challenge challenge, World world, String permPrefix, String label) {
this.addon = addon;
this.world = world;
this.permPrefix = permPrefix;

View File

@ -13,7 +13,7 @@ import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.ItemParser;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.panel.CommonGUI;
import world.bentobox.challenges.panel.util.ItemSwitchGUI;
import world.bentobox.challenges.panel.util.NumberGUI;
@ -40,7 +40,7 @@ public class EditChallengeGUI extends CommonGUI
public EditChallengeGUI(ChallengesAddon addon,
World world,
User user,
Challenges challenge,
Challenge challenge,
String topLabel,
String permissionPrefix)
{
@ -55,7 +55,7 @@ public class EditChallengeGUI extends CommonGUI
public EditChallengeGUI(ChallengesAddon addon,
World world,
User user,
Challenges challenge,
Challenge challenge,
String topLabel,
String permissionPrefix,
CommonGUI parentGUI)
@ -301,9 +301,9 @@ public class EditChallengeGUI extends CommonGUI
{
case TYPE:
{
List<String> values = new ArrayList<>(Challenges.ChallengeType.values().length);
List<String> values = new ArrayList<>(Challenge.ChallengeType.values().length);
for (Challenges.ChallengeType type : Challenges.ChallengeType.values())
for (Challenge.ChallengeType type : Challenge.ChallengeType.values())
{
values.add((this.challenge.getChallengeType().equals(type) ? "§2" : "§c") +
this.user.getTranslation("challenges.gui.admin.descriptions." + type.name().toLowerCase()));
@ -312,15 +312,15 @@ public class EditChallengeGUI extends CommonGUI
name = this.user.getTranslation("challenges.gui.admin.buttons.type");
description = values;
if (this.challenge.getChallengeType().equals(Challenges.ChallengeType.ISLAND))
if (this.challenge.getChallengeType().equals(Challenge.ChallengeType.ISLAND))
{
icon = new ItemStack(Material.GRASS_BLOCK);
}
else if (this.challenge.getChallengeType().equals(Challenges.ChallengeType.INVENTORY))
else if (this.challenge.getChallengeType().equals(Challenge.ChallengeType.INVENTORY))
{
icon = new ItemStack(Material.CHEST);
}
else if (this.challenge.getChallengeType().equals(Challenges.ChallengeType.LEVEL))
else if (this.challenge.getChallengeType().equals(Challenge.ChallengeType.LEVEL))
{
icon = new ItemStack(Material.EXPERIENCE_BOTTLE);
}
@ -1108,9 +1108,9 @@ public class EditChallengeGUI extends CommonGUI
* @param type Given challenge type.
* @return Next Challenge Type.
*/
private Challenges.ChallengeType getNextType(Challenges.ChallengeType type)
private Challenge.ChallengeType getNextType(Challenge.ChallengeType type)
{
Challenges.ChallengeType[] values = Challenges.ChallengeType.values();
Challenge.ChallengeType[] values = Challenge.ChallengeType.values();
for (int i = 0; i < values.length; i++)
{
@ -1136,9 +1136,9 @@ public class EditChallengeGUI extends CommonGUI
* @param type Given challenge type.
* @return Previous Challenge Type.
*/
private Challenges.ChallengeType getPreviousType(Challenges.ChallengeType type)
private Challenge.ChallengeType getPreviousType(Challenge.ChallengeType type)
{
Challenges.ChallengeType[] values = Challenges.ChallengeType.values();
Challenge.ChallengeType[] values = Challenge.ChallengeType.values();
for (int i = 0; i < values.length; i++)
{
@ -1228,7 +1228,7 @@ public class EditChallengeGUI extends CommonGUI
/**
* Variable holds challenge thats needs editing.
*/
private Challenges challenge;
private Challenge challenge;
/**
* Variable holds current active menu.

View File

@ -16,8 +16,8 @@ import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.ItemParser;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.ChallengesManager;
import world.bentobox.challenges.database.object.ChallengeLevels;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.ChallengeLevel;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.panel.CommonGUI;
import world.bentobox.challenges.panel.util.ItemSwitchGUI;
import world.bentobox.challenges.panel.util.NumberGUI;
@ -43,7 +43,7 @@ public class EditLevelGUI extends CommonGUI
public EditLevelGUI(ChallengesAddon addon,
World world,
User user,
ChallengeLevels challengeLevel,
ChallengeLevel challengeLevel,
String topLabel,
String permissionPrefix)
{
@ -58,7 +58,7 @@ public class EditLevelGUI extends CommonGUI
public EditLevelGUI(ChallengesAddon addon,
World world,
User user,
ChallengeLevels challengeLevel,
ChallengeLevel challengeLevel,
String topLabel,
String permissionPrefix,
CommonGUI parentGUI)
@ -145,7 +145,7 @@ public class EditLevelGUI extends CommonGUI
*/
private void buildChallengesPanel(PanelBuilder panelBuilder)
{
List<Challenges> challengeList = this.addon.getChallengesManager().getChallenges(this.challengeLevel);
List<Challenge> challengeList = this.addon.getChallengesManager().getChallenges(this.challengeLevel);
final int MAX_ELEMENTS = 21;
@ -262,7 +262,7 @@ public class EditLevelGUI extends CommonGUI
* @param challenge Challenge which icon must be created.
* @return PanelItem that represents given challenge.
*/
private PanelItem createChallengeIcon(Challenges challenge)
private PanelItem createChallengeIcon(Challenge challenge)
{
return new PanelItemBuilder().
name(challenge.getFriendlyName()).
@ -538,7 +538,7 @@ public class EditLevelGUI extends CommonGUI
ChallengesManager manager = this.addon.getChallengesManager();
// Get all challenge that is not in current challenge.
List<Challenges> challengeList = manager.getChallengesList();
List<Challenge> challengeList = manager.getChallengesList();
challengeList.removeAll(manager.getChallenges(this.challengeLevel));
new SelectChallengeGUI(this.user, challengeList, (status, value) -> {
@ -630,7 +630,7 @@ public class EditLevelGUI extends CommonGUI
/**
* This variable holds current challenge level that is in editing GUI.
*/
private ChallengeLevels challengeLevel;
private ChallengeLevel challengeLevel;
/**
* Variable holds current active menu.

View File

@ -10,7 +10,7 @@ import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.panel.CommonGUI;
import world.bentobox.challenges.panel.util.ConfirmationGUI;
import world.bentobox.challenges.utils.GuiUtils;
@ -82,7 +82,7 @@ public class ListChallengesGUI extends CommonGUI
GuiUtils.fillBorder(panelBuilder);
}
List<Challenges> challengeList = this.addon.getChallengesManager().getChallengesList();
List<Challenge> challengeList = this.addon.getChallengesManager().getChallengesList();
final int MAX_ELEMENTS = 21;
@ -130,7 +130,7 @@ public class ListChallengesGUI extends CommonGUI
* @param challenge Challenge which button must be created.
* @return Challenge button.
*/
private PanelItem createChallengeIcon(Challenges challenge)
private PanelItem createChallengeIcon(Challenge challenge)
{
PanelItemBuilder itemBuilder = new PanelItemBuilder().
name(challenge.getFriendlyName()).

View File

@ -10,7 +10,7 @@ import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.database.object.ChallengeLevels;
import world.bentobox.challenges.database.object.ChallengeLevel;
import world.bentobox.challenges.panel.CommonGUI;
import world.bentobox.challenges.panel.util.ConfirmationGUI;
import world.bentobox.challenges.utils.GuiUtils;
@ -82,7 +82,7 @@ public class ListLevelsGUI extends CommonGUI
GuiUtils.fillBorder(panelBuilder);
}
List<ChallengeLevels> levelList = this.addon.getChallengesManager().getChallengeLevelList();
List<ChallengeLevel> levelList = this.addon.getChallengesManager().getChallengeLevelList();
final int MAX_ELEMENTS = 21;
@ -130,7 +130,7 @@ public class ListLevelsGUI extends CommonGUI
* @param challengeLevel Level which button must be created.
* @return Level button.
*/
private PanelItem createLevelIcon(ChallengeLevels challengeLevel)
private PanelItem createLevelIcon(ChallengeLevel challengeLevel)
{
PanelItemBuilder itemBuilder = new PanelItemBuilder().
name(challengeLevel.getFriendlyName()).

View File

@ -15,7 +15,7 @@ import world.bentobox.bentobox.api.user.User;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.ChallengesManager;
import world.bentobox.challenges.LevelStatus;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.panel.CommonGUI;
import world.bentobox.challenges.panel.TryToComplete;
@ -123,7 +123,7 @@ public class ChallengesGUI extends CommonGUI
*/
private void addFreeChallenges(PanelBuilder panelBuilder)
{
List<Challenges> freeChallenges = this.challengesManager.getFreeChallenges(this.user, this.world);
List<Challenge> freeChallenges = this.challengesManager.getFreeChallenges(this.user, this.world);
final int freeChallengesCount = freeChallenges.size();
if (freeChallengesCount > 18)
@ -168,7 +168,7 @@ public class ChallengesGUI extends CommonGUI
}
else
{
for (Challenges challenge : freeChallenges)
for (Challenge challenge : freeChallenges)
{
// there are no limitations. Just bunch insert.
panelBuilder.item(this.getChallengeButton(challenge));
@ -185,7 +185,7 @@ public class ChallengesGUI extends CommonGUI
{
if (this.lastSelectedLevel != null)
{
List<Challenges> challenges = this.challengesManager.getChallenges(this.lastSelectedLevel.getLevel());
List<Challenge> challenges = this.challengesManager.getChallenges(this.lastSelectedLevel.getLevel());
final int challengesCount = challenges.size();
if (challengesCount > 18)
@ -230,7 +230,7 @@ public class ChallengesGUI extends CommonGUI
}
else
{
for (Challenges challenge : challenges)
for (Challenge challenge : challenges)
{
// there are no limitations. Just bunch insert.
panelBuilder.item(this.getChallengeButton(challenge));
@ -315,7 +315,7 @@ public class ChallengesGUI extends CommonGUI
* @param challenge which icon must be constructed.
* @return PanelItem icon for challenge.
*/
private PanelItem getChallengeButton(Challenges challenge)
private PanelItem getChallengeButton(Challenge challenge)
{
return new PanelItemBuilder().
icon(challenge.getIcon()).
@ -341,7 +341,7 @@ public class ChallengesGUI extends CommonGUI
* @param challenge Which information must be retrieved.
* @return List with strings that contains information about given challenge.
*/
private List<String> createChallengeDescription(Challenges challenge)
private List<String> createChallengeDescription(Challenge challenge)
{
List<String> result = new ArrayList<>();
@ -392,14 +392,14 @@ public class ChallengesGUI extends CommonGUI
{
result.addAll(challenge.getDescription());
if (challenge.getChallengeType().equals(Challenges.ChallengeType.INVENTORY))
if (challenge.getChallengeType().equals(Challenge.ChallengeType.INVENTORY))
{
if (challenge.isTakeItems())
{
result.add(this.user.getTranslation("challenges.item-take-warning"));
}
}
else if (challenge.getChallengeType().equals(Challenges.ChallengeType.ISLAND))
else if (challenge.getChallengeType().equals(Challenge.ChallengeType.ISLAND))
{
result.add(this.user.getTranslation("challenges.items-closeby"));
@ -433,7 +433,7 @@ public class ChallengesGUI extends CommonGUI
* @param challenge which reward message must be created.
* @return list of strings that contains rewards message.
*/
private List<String> challengeRewards(Challenges challenge)
private List<String> challengeRewards(Challenge challenge)
{
String rewardText;
double rewardMoney;

View File

@ -9,7 +9,7 @@ import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.utils.GuiUtils;
@ -18,7 +18,7 @@ import world.bentobox.challenges.utils.GuiUtils;
*/
public class SelectChallengeGUI
{
public SelectChallengeGUI(User user, List<Challenges> challengesList, BiConsumer<Boolean, Challenges> consumer)
public SelectChallengeGUI(User user, List<Challenge> challengesList, BiConsumer<Boolean, Challenge> consumer)
{
this.consumer = consumer;
this.user = user;
@ -123,7 +123,7 @@ public class SelectChallengeGUI
* @param challenge Challenge which PanelItem must be created.
* @return new PanelItem for given Challenge.
*/
private PanelItem createChallengeButton(Challenges challenge)
private PanelItem createChallengeButton(Challenge challenge)
{
return new PanelItemBuilder().
name(challenge.getFriendlyName()).
@ -144,7 +144,7 @@ public class SelectChallengeGUI
/**
* This variable stores consumer.
*/
private BiConsumer<Boolean, Challenges> consumer;
private BiConsumer<Boolean, Challenge> consumer;
/**
* User who runs GUI.
@ -154,5 +154,5 @@ public class SelectChallengeGUI
/**
* Current value.
*/
private List<Challenges> challengesList;
private List<Challenge> challengesList;
}

View File

@ -35,8 +35,8 @@ import org.powermock.modules.junit4.PowerMockRunner;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.database.object.Challenges.ChallengeType;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.database.object.Challenge.ChallengeType;
/**
* @author tastybento
@ -81,7 +81,7 @@ public class ChallengesAddonTest {
public void test() {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
Challenges challenges = new Challenges();
Challenge challenges = new Challenge();
challenges.setChallengeType(ChallengeType.ISLAND);
Map<Material, Integer> map = new HashMap<>();
map.put(Material.DIRT, 5);