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.entity.EntityType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import world.bentobox.challenges.database.object.ChallengeLevels; import world.bentobox.challenges.database.object.ChallengeLevel;
import world.bentobox.challenges.database.object.Challenges; import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.Util; import world.bentobox.bentobox.util.Util;
@ -78,7 +78,7 @@ public class ChallengesImportManager
String[] lvs = levels.split(" "); String[] lvs = levels.split(" ");
int order = 0; int order = 0;
for (String level : lvs) { for (String level : lvs) {
ChallengeLevels challengeLevel = new ChallengeLevels(); ChallengeLevel challengeLevel = new ChallengeLevel();
challengeLevel.setFriendlyName(level); challengeLevel.setFriendlyName(level);
challengeLevel.setUniqueId(level); challengeLevel.setUniqueId(level);
challengeLevel.setOrder(order++); challengeLevel.setOrder(order++);
@ -110,7 +110,7 @@ public class ChallengesImportManager
// Parse the challenge file // Parse the challenge file
ConfigurationSection chals = chal.getConfigurationSection("challenges.challengeList"); ConfigurationSection chals = chal.getConfigurationSection("challenges.challengeList");
for (String challenge : chals.getKeys(false)) { for (String challenge : chals.getKeys(false)) {
Challenges newChallenge = new Challenges(); Challenge newChallenge = new Challenge();
newChallenge.setUniqueId(Util.getWorld(world).getName() + "_" + challenge); newChallenge.setUniqueId(Util.getWorld(world).getName() + "_" + challenge);
newChallenge.setDeployed(true); newChallenge.setDeployed(true);
ConfigurationSection details = chals.getConfigurationSection(challenge); ConfigurationSection details = chals.getConfigurationSection(challenge);
@ -119,7 +119,7 @@ public class ChallengesImportManager
newChallenge.setDescription(addon.getChallengesManager().stringSplit(details.getString("description", ""))); newChallenge.setDescription(addon.getChallengesManager().stringSplit(details.getString("description", "")));
newChallenge.setIcon(new ParseItem(addon, details.getString("icon") + ":1").getItem()); newChallenge.setIcon(new ParseItem(addon, details.getString("icon") + ":1").getItem());
newChallenge.setLevel(details.getString("level", ChallengesManager.FREE)); 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.setTakeItems(details.getBoolean("takeItems",true));
newChallenge.setRewardText(details.getString("rewardText", "")); newChallenge.setRewardText(details.getString("rewardText", ""));
newChallenge.setRewardCommands(details.getStringList("rewardcommands")); newChallenge.setRewardCommands(details.getStringList("rewardcommands"));
@ -135,11 +135,11 @@ public class ChallengesImportManager
newChallenge.setReqMoney(details.getInt("requiredMoney")); newChallenge.setReqMoney(details.getInt("requiredMoney"));
newChallenge.setReqExp(details.getInt("requiredExp")); newChallenge.setReqExp(details.getInt("requiredExp"));
String reqItems = details.getString("requiredItems",""); String reqItems = details.getString("requiredItems","");
if (newChallenge.getChallengeType().equals(Challenges.ChallengeType.INVENTORY)) { if (newChallenge.getChallengeType().equals(Challenge.ChallengeType.INVENTORY)) {
newChallenge.setRequiredItems(parseItems(reqItems)); 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)); newChallenge.setReqIslandlevel(Long.parseLong(reqItems));
} else if (newChallenge.getChallengeType().equals(Challenges.ChallengeType.ISLAND)) { } else if (newChallenge.getChallengeType().equals(Challenge.ChallengeType.ISLAND)) {
parseEntities(newChallenge, reqItems); parseEntities(newChallenge, reqItems);
} }
newChallenge.setRewardItems(parseItems(details.getString("itemReward"))); newChallenge.setRewardItems(parseItems(details.getString("itemReward")));
@ -158,7 +158,7 @@ public class ChallengesImportManager
* @param challenge - challenge to be adjusted * @param challenge - challenge to be adjusted
* @param string - string from YAML file * @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<EntityType, Integer> req = new EnumMap<>(EntityType.class);
Map<Material, Integer> blocks = new EnumMap<>(Material.class); Map<Material, Integer> blocks = new EnumMap<>(Material.class);
if (!string.isEmpty()) { 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.database.Database;
import world.bentobox.bentobox.util.Util; import world.bentobox.bentobox.util.Util;
import world.bentobox.challenges.commands.admin.SurroundChallengeBuilder; import world.bentobox.challenges.commands.admin.SurroundChallengeBuilder;
import world.bentobox.challenges.database.object.ChallengeLevels; import world.bentobox.challenges.database.object.ChallengeLevel;
import world.bentobox.challenges.database.object.Challenges; import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.database.object.Challenges.ChallengeType; import world.bentobox.challenges.database.object.Challenge.ChallengeType;
import world.bentobox.challenges.database.object.ChallengesPlayerData; import world.bentobox.challenges.database.object.ChallengesPlayerData;
import world.bentobox.challenges.panel.ChallengesPanels; import world.bentobox.challenges.panel.ChallengesPanels;
public class ChallengesManager { public class ChallengesManager {
public static final String FREE = "Free"; public static final String FREE = "Free";
private Map<ChallengeLevels, Set<Challenges>> challengeMap; private Map<ChallengeLevel, Set<Challenge>> challengeMap;
private Config<Challenges> chConfig; private Config<Challenge> chConfig;
private Config<ChallengeLevels> lvConfig; private Config<ChallengeLevel> lvConfig;
private Database<ChallengesPlayerData> players; private Database<ChallengesPlayerData> players;
private ChallengesPanels challengesPanels; private ChallengesPanels challengesPanels;
private Map<UUID,ChallengesPlayerData> playerData; private Map<UUID,ChallengesPlayerData> playerData;
@ -37,8 +37,8 @@ public class ChallengesManager {
public ChallengesManager(ChallengesAddon addon) { public ChallengesManager(ChallengesAddon addon) {
this.addon = addon; this.addon = addon;
// Set up the configs // Set up the configs
chConfig = new Config<>(addon, Challenges.class); chConfig = new Config<>(addon, Challenge.class);
lvConfig = new Config<>(addon, ChallengeLevels.class); lvConfig = new Config<>(addon, ChallengeLevel.class);
// Players is where all the player history will be stored // Players is where all the player history will be stored
players = new Database<>(addon, ChallengesPlayerData.class); players = new Database<>(addon, ChallengesPlayerData.class);
// Cache of challenges // Cache of challenges
@ -78,7 +78,7 @@ public class ChallengesManager {
* @param challenge - challenge * @param challenge - challenge
* @return - number of times * @return - number of times
*/ */
public long checkChallengeTimes(User user, Challenges challenge, World world) { public long checkChallengeTimes(User user, Challenge challenge, World world) {
addPlayer(user); addPlayer(user);
return playerData.get(user.getUniqueId()).getTimes(world, challenge.getUniqueId()); return playerData.get(user.getUniqueId()).getTimes(world, challenge.getUniqueId());
} }
@ -109,7 +109,7 @@ public class ChallengesManager {
if (inventory.getContents().length == 0) { if (inventory.getContents().length == 0) {
return false; return false;
} }
Challenges newChallenge = new Challenges(); Challenge newChallenge = new Challenge();
newChallenge.setChallengeType(ChallengeType.INVENTORY); newChallenge.setChallengeType(ChallengeType.INVENTORY);
newChallenge.setFriendlyName(inventory.getTitle()); newChallenge.setFriendlyName(inventory.getTitle());
newChallenge.setDeployed(false); newChallenge.setDeployed(false);
@ -154,7 +154,7 @@ public class ChallengesManager {
challengeInfo.getOwner().sendMessage("challenges.error.no-items-clicked"); challengeInfo.getOwner().sendMessage("challenges.error.no-items-clicked");
return false; return false;
} }
Challenges newChallenge = new Challenges(); Challenge newChallenge = new Challenge();
newChallenge.setChallengeType(ChallengeType.ISLAND); newChallenge.setChallengeType(ChallengeType.ISLAND);
newChallenge.setFriendlyName(challengeInfo.getName()); newChallenge.setFriendlyName(challengeInfo.getName());
newChallenge.setDeployed(true); newChallenge.setDeployed(true);
@ -199,10 +199,10 @@ public class ChallengesManager {
* @param world - world to check * @param world - world to check
* @return - challenge or null if it does not exist * @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(); String worldName = Util.getWorld(world).getName();
for (Set<Challenges> ch : challengeMap.values()) { for (Set<Challenge> ch : challengeMap.values()) {
Optional<Challenges> challenge = ch.stream().filter(c -> c.getUniqueId().equalsIgnoreCase(worldName + name)).findFirst(); Optional<Challenge> challenge = ch.stream().filter(c -> c.getUniqueId().equalsIgnoreCase(worldName + name)).findFirst();
if (challenge.isPresent()) { if (challenge.isPresent()) {
return challenge.get(); return challenge.get();
} }
@ -223,11 +223,11 @@ public class ChallengesManager {
List<LevelStatus> result = new ArrayList<>(); List<LevelStatus> result = new ArrayList<>();
// The first level is always unlocked // The first level is always unlocked
ChallengeLevels previousLevel = null; ChallengeLevel previousLevel = null;
int doneChallengeCount = Integer.MAX_VALUE; int doneChallengeCount = Integer.MAX_VALUE;
// For each challenge level, check how many the user has done // 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. // Check how much challenges must be done in previous level.
int challengesToDo = Math.max(0, entry.getKey().getWaiveramount() - doneChallengeCount); int challengesToDo = Math.max(0, entry.getKey().getWaiveramount() - doneChallengeCount);
@ -254,7 +254,7 @@ public class ChallengesManager {
* Get the challenge list * Get the challenge list
* @return the challengeList * @return the challengeList
*/ */
public Map<ChallengeLevels, Set<Challenges>> getChallengeList() { public Map<ChallengeLevel, Set<Challenge>> getChallengeList() {
// TODO return the challenges for world // TODO return the challenges for world
return challengeMap; return challengeMap;
} }
@ -265,9 +265,9 @@ public class ChallengesManager {
* @param world * @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 * @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(); 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 // Get the challenges applicable to this world
return lv.isPresent() ? challengeMap.get(lv.get()).stream() return lv.isPresent() ? challengeMap.get(lv.get()).stream()
.filter(c -> c.getWorld().equalsIgnoreCase(worldName) || c.getWorld().isEmpty()).collect(Collectors.toSet()) .filter(c -> c.getWorld().equalsIgnoreCase(worldName) || c.getWorld().isEmpty()).collect(Collectors.toSet())
@ -286,9 +286,9 @@ public class ChallengesManager {
* @param currentLevel - the current level * @param currentLevel - the current level
* @return the previous level, or null if there is none * @return the previous level, or null if there is none
*/ */
public ChallengeLevels getPreviousLevel(ChallengeLevels currentLevel) { public ChallengeLevel getPreviousLevel(ChallengeLevel currentLevel) {
ChallengeLevels result = null; ChallengeLevel result = null;
for (ChallengeLevels level : challengeMap.keySet()) { for (ChallengeLevel level : challengeMap.keySet()) {
if (level.equals(currentLevel)) { if (level.equals(currentLevel)) {
return result; return result;
} }
@ -303,7 +303,7 @@ public class ChallengesManager {
* @return true if it exists, otherwise false * @return true if it exists, otherwise false
*/ */
public boolean isChallenge(String name) { 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))) { if (ch.stream().anyMatch(c -> c.getUniqueId().equalsIgnoreCase(name))) {
return true; return true;
} }
@ -318,7 +318,7 @@ public class ChallengesManager {
* @return true if it exists, otherwise false * @return true if it exists, otherwise false
*/ */
public boolean isChallenge(World world, String name) { 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))) { if (ch.stream().filter(c -> c.getWorld().equals(Util.getWorld(world).getName())).anyMatch(c -> c.getUniqueId().equalsIgnoreCase(name))) {
return true; return true;
} }
@ -417,7 +417,7 @@ public class ChallengesManager {
/** /**
* @param challengeList the challengeList to set * @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; this.challengeMap = challengeList;
} }
@ -435,7 +435,7 @@ public class ChallengesManager {
* @param challenge * @param challenge
* @return true if successful * @return true if successful
*/ */
private boolean storeChallenge(Challenges challenge) { private boolean storeChallenge(Challenge challenge) {
return storeChallenge(challenge, true, null, true); return storeChallenge(challenge, true, null, true);
} }
@ -447,15 +447,15 @@ public class ChallengesManager {
* @param silent - if true, no messages are sent to user * @param silent - if true, no messages are sent to user
* @return - true if imported * @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 // See if we have this level already
ChallengeLevels level; ChallengeLevel level;
if (lvConfig.configObjectExists(challenge.getLevel())) { if (lvConfig.configObjectExists(challenge.getLevel())) {
// Get it from the database // Get it from the database
level = lvConfig.loadConfigObject(challenge.getLevel()); level = lvConfig.loadConfigObject(challenge.getLevel());
} else { } else {
// Make it // Make it
level = new ChallengeLevels(); level = new ChallengeLevel();
level.setUniqueId(challenge.getLevel()); level.setUniqueId(challenge.getLevel());
lvConfig.saveConfigObject(level); lvConfig.saveConfigObject(level);
} }
@ -485,7 +485,7 @@ public class ChallengesManager {
* Store a challenge level * Store a challenge level
* @param level the challenge level * @param level the challenge level
*/ */
public void storeLevel(ChallengeLevels level) { public void storeLevel(ChallengeLevel level) {
lvConfig.saveConfigObject(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)); return new ArrayList<>(this.challengeMap.get(challengeLevel));
} }
public List<ChallengeLevels> getChallengeLevelList() public List<ChallengeLevel> getChallengeLevelList()
{ {
return new ArrayList<>(this.challengeMap.keySet()); return new ArrayList<>(this.challengeMap.keySet());
} }
public List<Challenges> getChallengesList() public List<Challenge> getChallengesList()
{ {
return new ArrayList<>(); 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(); return Collections.emptyList();
} }
public String getChallengesLevel(Challenges challenge) public String getChallengesLevel(Challenge challenge)
{ {
return "HERE NEED LEVEL NAME"; 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()); 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()); return this.checkChallengeTimes(user, challenge, user.getWorld());
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,8 +12,8 @@ import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.ChallengesManager; import world.bentobox.challenges.ChallengesManager;
import world.bentobox.challenges.LevelStatus; import world.bentobox.challenges.LevelStatus;
import world.bentobox.challenges.commands.ChallengesCommand; import world.bentobox.challenges.commands.ChallengesCommand;
import world.bentobox.challenges.database.object.Challenges; import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.database.object.Challenges.ChallengeType; import world.bentobox.challenges.database.object.Challenge.ChallengeType;
import world.bentobox.bentobox.api.panels.Panel; import world.bentobox.bentobox.api.panels.Panel;
import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
@ -93,7 +93,7 @@ public class ChallengesPanels2 {
private void addChallengeItems(PanelBuilder panelBuilder) { private void addChallengeItems(PanelBuilder panelBuilder) {
// Only show a control panel for the level requested. // 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); createItem(panelBuilder, challenge);
} }
} }
@ -109,7 +109,7 @@ public class ChallengesPanels2 {
* @param challenge * @param challenge
* @param requester * @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 // For admin, glow means activated. For user, glow means done
boolean glow = false; boolean glow = false;
switch (mode) { switch (mode) {
@ -219,7 +219,7 @@ public class ChallengesPanels2 {
* @param player * @param player
* @return List of strings splitting challenge string into 25 chars long * @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>(); List<String> result = new ArrayList<String>();
String level = challenge.getLevel(); String level = challenge.getLevel();
if (!level.isEmpty()) { if (!level.isEmpty()) {
@ -278,7 +278,7 @@ public class ChallengesPanels2 {
return result; 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<>(); List<String> result = new ArrayList<>();
double moneyReward = 0; double moneyReward = 0;
int expReward = 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.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.ItemStack; 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.Panel;
import world.bentobox.bentobox.api.panels.PanelItem.ClickHandler; import world.bentobox.bentobox.api.panels.PanelItem.ClickHandler;
import world.bentobox.bentobox.api.panels.PanelListener; import world.bentobox.bentobox.api.panels.PanelListener;
@ -30,7 +30,7 @@ import world.bentobox.bentobox.util.Util;
@Deprecated @Deprecated
public class RequiredPanel implements ClickHandler, PanelListener { public class RequiredPanel implements ClickHandler, PanelListener {
private static final int CONTROL_NUMBER = 4; private static final int CONTROL_NUMBER = 4;
private Challenges challenge; private Challenge challenge;
private User user; private User user;
private Panel panel; private Panel panel;
private Panel referringPanel; private Panel referringPanel;
@ -39,7 +39,7 @@ public class RequiredPanel implements ClickHandler, PanelListener {
* @param challenge * @param challenge
* @param user * @param user
*/ */
public RequiredPanel(Challenges challenge, User user, Panel referringPanel) { public RequiredPanel(Challenge challenge, User user, Panel referringPanel) {
this.challenge = challenge; this.challenge = challenge;
this.user = user; this.user = user;
this.panel = openPanel(); this.panel = openPanel();

View File

@ -23,8 +23,8 @@ import org.bukkit.util.Vector;
import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.ChallengesManager; import world.bentobox.challenges.ChallengesManager;
import world.bentobox.challenges.commands.ChallengesCommand; import world.bentobox.challenges.commands.ChallengesCommand;
import world.bentobox.challenges.database.object.Challenges; import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.database.object.Challenges.ChallengeType; import world.bentobox.challenges.database.object.Challenge.ChallengeType;
import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.hooks.VaultHook; import world.bentobox.bentobox.hooks.VaultHook;
@ -43,7 +43,7 @@ public class TryToComplete {
private String permPrefix; private String permPrefix;
private User user; private User user;
private ChallengesManager manager; private ChallengesManager manager;
private Challenges challenge; private Challenge challenge;
private String label; private String label;
public TryToComplete label(String label) { public TryToComplete label(String label) {
@ -61,7 +61,7 @@ public class TryToComplete {
return this; return this;
} }
public TryToComplete challenge(Challenges challenge) { public TryToComplete challenge(Challenge challenge) {
this.challenge = challenge; this.challenge = challenge;
return this; return this;
} }
@ -138,7 +138,7 @@ public class TryToComplete {
* @param world * @param world
* @param permPrefix * @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.addon = addon;
this.world = world; this.world = world;
this.permPrefix = permPrefix; 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.api.user.User;
import world.bentobox.bentobox.util.ItemParser; import world.bentobox.bentobox.util.ItemParser;
import world.bentobox.challenges.ChallengesAddon; 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.CommonGUI;
import world.bentobox.challenges.panel.util.ItemSwitchGUI; import world.bentobox.challenges.panel.util.ItemSwitchGUI;
import world.bentobox.challenges.panel.util.NumberGUI; import world.bentobox.challenges.panel.util.NumberGUI;
@ -40,7 +40,7 @@ public class EditChallengeGUI extends CommonGUI
public EditChallengeGUI(ChallengesAddon addon, public EditChallengeGUI(ChallengesAddon addon,
World world, World world,
User user, User user,
Challenges challenge, Challenge challenge,
String topLabel, String topLabel,
String permissionPrefix) String permissionPrefix)
{ {
@ -55,7 +55,7 @@ public class EditChallengeGUI extends CommonGUI
public EditChallengeGUI(ChallengesAddon addon, public EditChallengeGUI(ChallengesAddon addon,
World world, World world,
User user, User user,
Challenges challenge, Challenge challenge,
String topLabel, String topLabel,
String permissionPrefix, String permissionPrefix,
CommonGUI parentGUI) CommonGUI parentGUI)
@ -301,9 +301,9 @@ public class EditChallengeGUI extends CommonGUI
{ {
case TYPE: 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") + values.add((this.challenge.getChallengeType().equals(type) ? "§2" : "§c") +
this.user.getTranslation("challenges.gui.admin.descriptions." + type.name().toLowerCase())); 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"); name = this.user.getTranslation("challenges.gui.admin.buttons.type");
description = values; description = values;
if (this.challenge.getChallengeType().equals(Challenges.ChallengeType.ISLAND)) if (this.challenge.getChallengeType().equals(Challenge.ChallengeType.ISLAND))
{ {
icon = new ItemStack(Material.GRASS_BLOCK); 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); 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); icon = new ItemStack(Material.EXPERIENCE_BOTTLE);
} }
@ -1108,9 +1108,9 @@ public class EditChallengeGUI extends CommonGUI
* @param type Given challenge type. * @param type Given challenge type.
* @return Next 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++) for (int i = 0; i < values.length; i++)
{ {
@ -1136,9 +1136,9 @@ public class EditChallengeGUI extends CommonGUI
* @param type Given challenge type. * @param type Given challenge type.
* @return Previous 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++) for (int i = 0; i < values.length; i++)
{ {
@ -1228,7 +1228,7 @@ public class EditChallengeGUI extends CommonGUI
/** /**
* Variable holds challenge thats needs editing. * Variable holds challenge thats needs editing.
*/ */
private Challenges challenge; private Challenge challenge;
/** /**
* Variable holds current active menu. * 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.bentobox.util.ItemParser;
import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.ChallengesManager; import world.bentobox.challenges.ChallengesManager;
import world.bentobox.challenges.database.object.ChallengeLevels; import world.bentobox.challenges.database.object.ChallengeLevel;
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.CommonGUI;
import world.bentobox.challenges.panel.util.ItemSwitchGUI; import world.bentobox.challenges.panel.util.ItemSwitchGUI;
import world.bentobox.challenges.panel.util.NumberGUI; import world.bentobox.challenges.panel.util.NumberGUI;
@ -43,7 +43,7 @@ public class EditLevelGUI extends CommonGUI
public EditLevelGUI(ChallengesAddon addon, public EditLevelGUI(ChallengesAddon addon,
World world, World world,
User user, User user,
ChallengeLevels challengeLevel, ChallengeLevel challengeLevel,
String topLabel, String topLabel,
String permissionPrefix) String permissionPrefix)
{ {
@ -58,7 +58,7 @@ public class EditLevelGUI extends CommonGUI
public EditLevelGUI(ChallengesAddon addon, public EditLevelGUI(ChallengesAddon addon,
World world, World world,
User user, User user,
ChallengeLevels challengeLevel, ChallengeLevel challengeLevel,
String topLabel, String topLabel,
String permissionPrefix, String permissionPrefix,
CommonGUI parentGUI) CommonGUI parentGUI)
@ -145,7 +145,7 @@ public class EditLevelGUI extends CommonGUI
*/ */
private void buildChallengesPanel(PanelBuilder panelBuilder) 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; final int MAX_ELEMENTS = 21;
@ -262,7 +262,7 @@ public class EditLevelGUI extends CommonGUI
* @param challenge Challenge which icon must be created. * @param challenge Challenge which icon must be created.
* @return PanelItem that represents given challenge. * @return PanelItem that represents given challenge.
*/ */
private PanelItem createChallengeIcon(Challenges challenge) private PanelItem createChallengeIcon(Challenge challenge)
{ {
return new PanelItemBuilder(). return new PanelItemBuilder().
name(challenge.getFriendlyName()). name(challenge.getFriendlyName()).
@ -538,7 +538,7 @@ public class EditLevelGUI extends CommonGUI
ChallengesManager manager = this.addon.getChallengesManager(); ChallengesManager manager = this.addon.getChallengesManager();
// Get all challenge that is not in current challenge. // 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)); challengeList.removeAll(manager.getChallenges(this.challengeLevel));
new SelectChallengeGUI(this.user, challengeList, (status, value) -> { 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. * This variable holds current challenge level that is in editing GUI.
*/ */
private ChallengeLevels challengeLevel; private ChallengeLevel challengeLevel;
/** /**
* Variable holds current active menu. * 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.panels.builders.PanelItemBuilder;
import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.api.user.User;
import world.bentobox.challenges.ChallengesAddon; 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.CommonGUI;
import world.bentobox.challenges.panel.util.ConfirmationGUI; import world.bentobox.challenges.panel.util.ConfirmationGUI;
import world.bentobox.challenges.utils.GuiUtils; import world.bentobox.challenges.utils.GuiUtils;
@ -82,7 +82,7 @@ public class ListChallengesGUI extends CommonGUI
GuiUtils.fillBorder(panelBuilder); GuiUtils.fillBorder(panelBuilder);
} }
List<Challenges> challengeList = this.addon.getChallengesManager().getChallengesList(); List<Challenge> challengeList = this.addon.getChallengesManager().getChallengesList();
final int MAX_ELEMENTS = 21; final int MAX_ELEMENTS = 21;
@ -130,7 +130,7 @@ public class ListChallengesGUI extends CommonGUI
* @param challenge Challenge which button must be created. * @param challenge Challenge which button must be created.
* @return Challenge button. * @return Challenge button.
*/ */
private PanelItem createChallengeIcon(Challenges challenge) private PanelItem createChallengeIcon(Challenge challenge)
{ {
PanelItemBuilder itemBuilder = new PanelItemBuilder(). PanelItemBuilder itemBuilder = new PanelItemBuilder().
name(challenge.getFriendlyName()). 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.panels.builders.PanelItemBuilder;
import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.api.user.User;
import world.bentobox.challenges.ChallengesAddon; 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.CommonGUI;
import world.bentobox.challenges.panel.util.ConfirmationGUI; import world.bentobox.challenges.panel.util.ConfirmationGUI;
import world.bentobox.challenges.utils.GuiUtils; import world.bentobox.challenges.utils.GuiUtils;
@ -82,7 +82,7 @@ public class ListLevelsGUI extends CommonGUI
GuiUtils.fillBorder(panelBuilder); GuiUtils.fillBorder(panelBuilder);
} }
List<ChallengeLevels> levelList = this.addon.getChallengesManager().getChallengeLevelList(); List<ChallengeLevel> levelList = this.addon.getChallengesManager().getChallengeLevelList();
final int MAX_ELEMENTS = 21; final int MAX_ELEMENTS = 21;
@ -130,7 +130,7 @@ public class ListLevelsGUI extends CommonGUI
* @param challengeLevel Level which button must be created. * @param challengeLevel Level which button must be created.
* @return Level button. * @return Level button.
*/ */
private PanelItem createLevelIcon(ChallengeLevels challengeLevel) private PanelItem createLevelIcon(ChallengeLevel challengeLevel)
{ {
PanelItemBuilder itemBuilder = new PanelItemBuilder(). PanelItemBuilder itemBuilder = new PanelItemBuilder().
name(challengeLevel.getFriendlyName()). 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.ChallengesAddon;
import world.bentobox.challenges.ChallengesManager; import world.bentobox.challenges.ChallengesManager;
import world.bentobox.challenges.LevelStatus; 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.CommonGUI;
import world.bentobox.challenges.panel.TryToComplete; import world.bentobox.challenges.panel.TryToComplete;
@ -123,7 +123,7 @@ public class ChallengesGUI extends CommonGUI
*/ */
private void addFreeChallenges(PanelBuilder panelBuilder) 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(); final int freeChallengesCount = freeChallenges.size();
if (freeChallengesCount > 18) if (freeChallengesCount > 18)
@ -168,7 +168,7 @@ public class ChallengesGUI extends CommonGUI
} }
else else
{ {
for (Challenges challenge : freeChallenges) for (Challenge challenge : freeChallenges)
{ {
// there are no limitations. Just bunch insert. // there are no limitations. Just bunch insert.
panelBuilder.item(this.getChallengeButton(challenge)); panelBuilder.item(this.getChallengeButton(challenge));
@ -185,7 +185,7 @@ public class ChallengesGUI extends CommonGUI
{ {
if (this.lastSelectedLevel != null) 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(); final int challengesCount = challenges.size();
if (challengesCount > 18) if (challengesCount > 18)
@ -230,7 +230,7 @@ public class ChallengesGUI extends CommonGUI
} }
else else
{ {
for (Challenges challenge : challenges) for (Challenge challenge : challenges)
{ {
// there are no limitations. Just bunch insert. // there are no limitations. Just bunch insert.
panelBuilder.item(this.getChallengeButton(challenge)); panelBuilder.item(this.getChallengeButton(challenge));
@ -315,7 +315,7 @@ public class ChallengesGUI extends CommonGUI
* @param challenge which icon must be constructed. * @param challenge which icon must be constructed.
* @return PanelItem icon for challenge. * @return PanelItem icon for challenge.
*/ */
private PanelItem getChallengeButton(Challenges challenge) private PanelItem getChallengeButton(Challenge challenge)
{ {
return new PanelItemBuilder(). return new PanelItemBuilder().
icon(challenge.getIcon()). icon(challenge.getIcon()).
@ -341,7 +341,7 @@ public class ChallengesGUI extends CommonGUI
* @param challenge Which information must be retrieved. * @param challenge Which information must be retrieved.
* @return List with strings that contains information about given challenge. * @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<>(); List<String> result = new ArrayList<>();
@ -392,14 +392,14 @@ public class ChallengesGUI extends CommonGUI
{ {
result.addAll(challenge.getDescription()); result.addAll(challenge.getDescription());
if (challenge.getChallengeType().equals(Challenges.ChallengeType.INVENTORY)) if (challenge.getChallengeType().equals(Challenge.ChallengeType.INVENTORY))
{ {
if (challenge.isTakeItems()) if (challenge.isTakeItems())
{ {
result.add(this.user.getTranslation("challenges.item-take-warning")); 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")); 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. * @param challenge which reward message must be created.
* @return list of strings that contains rewards message. * @return list of strings that contains rewards message.
*/ */
private List<String> challengeRewards(Challenges challenge) private List<String> challengeRewards(Challenge challenge)
{ {
String rewardText; String rewardText;
double rewardMoney; 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.PanelBuilder;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
import world.bentobox.bentobox.api.user.User; 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; import world.bentobox.challenges.utils.GuiUtils;
@ -18,7 +18,7 @@ import world.bentobox.challenges.utils.GuiUtils;
*/ */
public class SelectChallengeGUI 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.consumer = consumer;
this.user = user; this.user = user;
@ -123,7 +123,7 @@ public class SelectChallengeGUI
* @param challenge Challenge which PanelItem must be created. * @param challenge Challenge which PanelItem must be created.
* @return new PanelItem for given Challenge. * @return new PanelItem for given Challenge.
*/ */
private PanelItem createChallengeButton(Challenges challenge) private PanelItem createChallengeButton(Challenge challenge)
{ {
return new PanelItemBuilder(). return new PanelItemBuilder().
name(challenge.getFriendlyName()). name(challenge.getFriendlyName()).
@ -144,7 +144,7 @@ public class SelectChallengeGUI
/** /**
* This variable stores consumer. * This variable stores consumer.
*/ */
private BiConsumer<Boolean, Challenges> consumer; private BiConsumer<Boolean, Challenge> consumer;
/** /**
* User who runs GUI. * User who runs GUI.
@ -154,5 +154,5 @@ public class SelectChallengeGUI
/** /**
* Current value. * 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.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import world.bentobox.challenges.database.object.Challenges; import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.database.object.Challenges.ChallengeType; import world.bentobox.challenges.database.object.Challenge.ChallengeType;
/** /**
* @author tastybento * @author tastybento
@ -81,7 +81,7 @@ public class ChallengesAddonTest {
public void test() { public void test() {
Gson gson = new GsonBuilder().setPrettyPrinting().create(); Gson gson = new GsonBuilder().setPrettyPrinting().create();
Challenges challenges = new Challenges(); Challenge challenges = new Challenge();
challenges.setChallengeType(ChallengeType.ISLAND); challenges.setChallengeType(ChallengeType.ISLAND);
Map<Material, Integer> map = new HashMap<>(); Map<Material, Integer> map = new HashMap<>();
map.put(Material.DIRT, 5); map.put(Material.DIRT, 5);