Merge pull request #63 from BONNe/backward

Import Older Challenges
This commit is contained in:
tastybento 2019-01-28 09:39:40 -08:00 committed by GitHub
commit c304dba5e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1054 additions and 6 deletions

View File

@ -2,11 +2,7 @@ package world.bentobox.challenges;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
@ -16,9 +12,12 @@ 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.bentobox.api.configuration.Config;
import world.bentobox.bentobox.util.ItemParser; import world.bentobox.bentobox.util.ItemParser;
import world.bentobox.challenges.database.object.ChallengeLevel; import world.bentobox.challenges.database.object.ChallengeLevel;
import world.bentobox.challenges.database.object.ChallengeLevels;
import world.bentobox.challenges.database.object.Challenge; import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.database.object.Challenges;
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;
import world.bentobox.challenges.utils.GuiUtils; import world.bentobox.challenges.utils.GuiUtils;
@ -202,4 +201,173 @@ public class ChallengesImportManager
} }
return result; return result;
} }
// ---------------------------------------------------------------------
// Section: Backward compatibility
// ---------------------------------------------------------------------
/**
* This method imports challenges form 0.3 and below version.
* @param user - user
* @param world - world to import into
* @param overwrite - true if previous ones should be overwritten
* @return true if successful
*/
public boolean importPreviousChallenges(User user, World world, boolean overwrite)
{
ChallengesManager manager = this.addon.getChallengesManager();
List<Challenges> challenges =
new Config<>(this.addon, Challenges.class).loadConfigObjects();
if (!challenges.isEmpty())
{
List<ChallengeLevels> levels =
new Config<>(this.addon, ChallengeLevels.class).loadConfigObjects();
for (ChallengeLevels level : levels)
{
ChallengeLevel newlevel = this.createLevel(level, world);
if (newlevel != null)
{
manager.loadLevel(newlevel, overwrite, user, false);
}
}
for (Challenges challenge : challenges)
{
Challenge newChallenge = this.createChallenge(challenge, world);
if (newChallenge == null)
{
continue;
}
manager.loadChallenge(newChallenge, overwrite, user, false);
if (challenge.getLevel().isEmpty() || challenge.getLevel().equals("FREE"))
{
newChallenge.setLevel(ChallengesManager.FREE);
}
else
{
String levelName = Util.getWorld(world).getName() + "_" + challenge.getLevel();
if (this.addon.getChallengesManager().containsLevel(levelName))
{
manager.addChallengeToLevel(newChallenge,
this.addon.getChallengesManager().getLevel(levelName));
}
}
}
}
return true;
}
/**
* This method creates new ChallengeLevel based on old level settings.
* @param level Old level object.
* @param world World where new challenge will operate.
* @return New level or null, if old level does not operate in this world.
*/
private ChallengeLevel createLevel(ChallengeLevels level, World world)
{
if (!level.getWorlds().isEmpty() &&
!level.getWorlds().contains(Util.getWorld(world).getName()))
{
return null;
}
ChallengeLevel newLevel = new ChallengeLevel();
newLevel.setUniqueId(Util.getWorld(world).getName() + "_" + level.getUniqueId());
newLevel.setFriendlyName(level.getFriendlyName());
newLevel.setOrder(level.getOrder());
newLevel.setWorld(Util.getWorld(world).getName());
newLevel.setUnlockMessage(level.getUnlockMessage());
newLevel.setWaiverAmount(level.getWaiveramount());
newLevel.setRewardText(level.getRewardDescription());
newLevel.setRewardMoney(level.getMoneyReward());
newLevel.setRewardExperience(level.getExpReward());
newLevel.setRewardItems(level.getRewardItems());
newLevel.setRewardCommands(level.getRewardCommands());
return newLevel;
}
/**
* This method creates new Challenge based on old challenges settings.
* @param challenge Old challenges object.
* @param world World where new challenge will operate.
* @return New Challenge or null, if old challenge does not operate in this world.
*/
private Challenge createChallenge(Challenges challenge, World world)
{
if (!challenge.getWorld().equals(Util.getWorld(world).getName()))
{
// Does not operate in given world.
return null;
}
Challenge newChallenge = new Challenge();
newChallenge.setUniqueId(challenge.getUniqueId());
newChallenge.setFriendlyName(challenge.getFriendlyName());
newChallenge.setRemoveWhenCompleted(challenge.isRemoveWhenCompleted());
newChallenge.setDeployed(challenge.isDeployed());
newChallenge.setIcon(challenge.getIcon());
newChallenge.setEnvironment(new HashSet<>(challenge.getEnvironment()));
switch (challenge.getChallengeType())
{
case INVENTORY:
newChallenge.setChallengeType(Challenge.ChallengeType.INVENTORY);
break;
case ISLAND:
newChallenge.setChallengeType(Challenge.ChallengeType.ISLAND);
break;
default:
newChallenge.setChallengeType(Challenge.ChallengeType.OTHER);
break;
}
newChallenge.setOrder(challenge.getSlot());
newChallenge.setDescription(challenge.getDescription());
newChallenge.setRequiredEntities(challenge.getRequiredEntities());
newChallenge.setRequiredItems(challenge.getRequiredItems());
newChallenge.setRequiredBlocks(challenge.getRequiredBlocks());
newChallenge.setRequiredMoney(challenge.getReqMoney());
newChallenge.setRequiredExperience(challenge.getReqExp());
newChallenge.setRequiredIslandLevel(challenge.getReqIslandlevel());
newChallenge.setRequiredPermissions(challenge.getReqPerms());
newChallenge.setTakeMoney(challenge.isTakeMoney());
newChallenge.setTakeItems(challenge.isTakeItems());
newChallenge.setSearchRadius(challenge.getSearchRadius());
newChallenge.setRewardText(challenge.getRewardText());
newChallenge.setRewardItems(challenge.getRewardItems());
newChallenge.setRewardMoney(challenge.getRewardMoney());
newChallenge.setRewardExperience(challenge.getRewardExp());
newChallenge.setRewardCommands(challenge.getRewardCommands());
newChallenge.setRepeatable(challenge.isRepeatable());
newChallenge.setMaxTimes(challenge.getMaxTimes());
newChallenge.setRepeatRewardText(challenge.getRepeatRewardText());
newChallenge.setRepeatItemReward(challenge.getRepeatItemReward());
newChallenge.setRepeatMoneyReward(challenge.getRepeatMoneyReward());
newChallenge.setRepeatExperienceReward(challenge.getRepeatExpReward());
newChallenge.setRepeatRewardCommands(challenge.getRepeatRewardCommands());
return newChallenge;
}
} }

View File

@ -0,0 +1,226 @@
package world.bentobox.challenges.database.object;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.inventory.ItemStack;
import world.bentobox.challenges.ChallengesManager;
import world.bentobox.bentobox.api.configuration.ConfigComment;
import world.bentobox.bentobox.database.objects.DataObject;
/**
* Represent a challenge level
* @author tastybento
*
*/
@Deprecated
public class ChallengeLevels implements DataObject, Comparable<ChallengeLevels> {
public ChallengeLevels() {}
@ConfigComment("A friendly name for the level. If blank, level name is used.")
private String friendlyName = "";
@ConfigComment("Worlds that this level applies in. String list.")
private List<String> worlds = new ArrayList<>();
@ConfigComment("Commands to run when this level is completed")
private List<String> rewardCommands = new ArrayList<>();
@ConfigComment("Level name")
private String uniqueId = ChallengesManager.FREE;
@ConfigComment("The number of undone challenges that can be left on this level before unlocking next level")
private int waiveramount = 1;
@ConfigComment("The ordering of the levels, lowest to highest")
private int order = 0;
@ConfigComment("The message shown when unlocking this level")
private String unlockMessage = "";
@ConfigComment("Unlock reward description")
private String rewardDescription = "";
@ConfigComment("List of reward itemstacks")
private List<ItemStack> rewardItems;
@ConfigComment("Unlock experience reward")
private int expReward;
@ConfigComment("Unlock money reward")
private int moneyReward;
public String getFriendlyName() {
return friendlyName;
}
public List<String> getRewardCommands() {
return rewardCommands = new ArrayList<>();
}
@Override
public String getUniqueId() {
return uniqueId;
}
/**
* Get the number of undone tasks that can be left on a level before unlocking next level
* @return
*/
public int getWaiveramount() {
return waiveramount;
}
public void setFriendlyName(String friendlyName) {
this.friendlyName = friendlyName;
}
public void setRewardCommands(List<String> rewardCommands) {
this.rewardCommands = rewardCommands;
}
@Override
public void setUniqueId(String uniqueId) {
this.uniqueId = uniqueId;
}
public void setWaiveramount(int waiveramount) {
this.waiveramount = waiveramount;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
@Override
public int compareTo(ChallengeLevels o) {
return Integer.compare(this.order, o.order);
}
/**
* @return the rewardDescription
*/
public String getRewardDescription() {
return rewardDescription;
}
/**
* @param rewardDescription the rewardDescription to set
*/
public void setRewardDescription(String rewardDescription) {
this.rewardDescription = rewardDescription;
}
/**
* @return the rewardItems
*/
public List<ItemStack> getRewardItems() {
return rewardItems;
}
/**
* @param rewardItems the rewardItems to set
*/
public void setRewardItems(List<ItemStack> rewardItems) {
this.rewardItems = rewardItems;
}
/**
* @return the expReward
*/
public int getExpReward() {
return expReward;
}
/**
* @param expReward the expReward to set
*/
public void setExpReward(int expReward) {
this.expReward = expReward;
}
/**
* @return the moneyReward
*/
public int getMoneyReward() {
return moneyReward;
}
/**
* @param moneyReward the moneyReward to set
*/
public void setMoneyReward(int moneyReward) {
this.moneyReward = moneyReward;
}
/**
* @return the unlockMessage
*/
public String getUnlockMessage() {
return unlockMessage;
}
/**
* @param unlockMessage the unlockMessage to set
*/
public void setUnlockMessage(String unlockMessage) {
this.unlockMessage = unlockMessage;
}
/**
* @return the worlds
*/
public List<String> getWorlds() {
return worlds;
}
/**
* @param worlds the worlds to set
*/
public void setWorlds(List<String> worlds) {
this.worlds = worlds;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
return result;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ChallengeLevels)) {
return false;
}
ChallengeLevels other = (ChallengeLevels) obj;
if (uniqueId == null) {
if (other.uniqueId != null) {
return false;
}
} else if (!uniqueId.equals(other.uniqueId)) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,634 @@
package world.bentobox.challenges.database.object;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import world.bentobox.challenges.ChallengesManager;
import world.bentobox.bentobox.api.configuration.ConfigComment;
import world.bentobox.bentobox.database.objects.DataObject;
/**
* Data object for challenges
* @author tastybento
*
*/
@Deprecated
public class Challenges implements DataObject {
public Challenges() {}
public enum ChallengeType {
/**
* This challenge only shows and icon in the GUI and doesn't do anything.
*/
ICON,
/**
* The player must have the items on them.
*/
INVENTORY,
/**
* The island level has to be equal or over this amount. Only works if there's an island level plugin installed.
*/
LEVEL,
/**
* Items or required entities have to be within x blocks of the player.
*/
ISLAND
}
// The order of the fields is the order shown in the YML files
@ConfigComment("Whether this challenge is deployed or not")
private boolean deployed;
// Description
@ConfigComment("Name of the icon and challenge. May include color codes. Single line.")
private String friendlyName = "";
@ConfigComment("Description of the challenge. Will become the lore on the icon. Can include & color codes. String List.")
private List<String> description = new ArrayList<>();
@ConfigComment("The icon in the GUI for this challenge. ItemStack.")
private ItemStack icon = new ItemStack(Material.PAPER);
@ConfigComment("Icon slot where this challenge should be placed. 0 to 49. A negative value means any slot")
private int slot = -1;
// Definition
@ConfigComment("Challenge level. Default is Free")
private String level = ChallengesManager.FREE;
@ConfigComment("Challenge type can be ICON, INVENTORY, LEVEL or ISLAND.")
private ChallengeType challengeType = ChallengeType.INVENTORY;
@ConfigComment("World where this challenge operates. List only overworld. Nether and end are automatically covered.")
private String world = "";
@ConfigComment("List of environments where this challenge will occur: NETHER, NORMAL, THE_END. Leave blank for all.")
private List<World.Environment> environment = new ArrayList<>();
@ConfigComment("The required permissions to see this challenge. String list.")
private Set<String> reqPerms = new HashSet<>();
@ConfigComment("The number of blocks around the player to search for items on an island")
private int searchRadius = 10;
@ConfigComment("If true, the challenge will disappear from the GUI when completed")
private boolean removeWhenCompleted;
@ConfigComment("Take the required items from the player")
private boolean takeItems = true;
@ConfigComment("Take the money from the player")
private boolean takeMoney = false;
// Requirements
@ConfigComment("This is a map of the blocks required in a ISLAND challenge. Material, Integer")
private Map<Material, Integer> requiredBlocks = new EnumMap<>(Material.class);
@ConfigComment("The items that must be in the inventory to complete the challenge. ItemStack List.")
private List<ItemStack> requiredItems = new ArrayList<>();
@ConfigComment("Any entities that must be in the area for ISLAND type challenges. Map EntityType, Number")
private Map<EntityType, Integer> requiredEntities = new EnumMap<>(EntityType.class);
@ConfigComment("Required experience")
private int reqExp;
@ConfigComment("Required island level for this challenge. Only works if Level Addon is being used.")
private long reqIslandlevel;
@ConfigComment("Required money")
private int reqMoney;
// Rewards
@ConfigComment("List of items the player will receive first time. ItemStack List.")
private List<ItemStack> rewardItems = new ArrayList<>();
@ConfigComment("If this is blank, the reward text will be auto-generated, otherwise this will be used.")
private String rewardText = "";
@ConfigComment("Experience point reward")
private int rewardExp;
@ConfigComment("Money reward")
private int rewardMoney;
@ConfigComment("Commands to run when the player completes the challenge for the first time. String List")
private List<String> rewardCommands = new ArrayList<>();
// Repeatable
@ConfigComment("True if the challenge is repeatable")
private boolean repeatable;
@ConfigComment("Maximum number of times the challenge can be repeated")
private int maxTimes = 1;
@ConfigComment("Repeat exp award")
private int repeatExpReward;
@ConfigComment("Reward items for repeating the challenge. List of ItemStacks.")
private List<ItemStack> repeatItemReward = new ArrayList<>();
@ConfigComment("Repeat money award")
private int repeatMoneyReward;
@ConfigComment("Commands to run when challenge is repeated. String List.")
private List<String> repeatRewardCommands = new ArrayList<>();
@ConfigComment("Description of the repeat rewards. If blank, it will be autogenerated.")
private String repeatRewardText = "";
@ConfigComment("Unique name of the challenge")
private String uniqueId = "";
/*
* END OF SETTINGS
*/
/**
* @return the challengeType
*/
public ChallengeType getChallengeType() {
return challengeType;
}
/**
* @param challengeType the challengeType to set
*/
public void setChallengeType(ChallengeType challengeType) {
this.challengeType = challengeType;
}
/**
* @return the deployed
*/
public boolean isDeployed() {
return deployed;
}
/**
* @param deployed the deployed to set
*/
public void setDeployed(boolean deployed) {
this.deployed = deployed;
}
/**
* @return the description
*/
public List<String> getDescription() {
return description;
}
/**
* @param description the description to set
*/
public void setDescription(List<String> description) {
this.description = description;
}
/**
* @return the expReward
*/
public int getRewardExp() {
return rewardExp;
}
/**
* @param expReward the expReward to set
*/
public void setRewardExp(int expReward) {
this.rewardExp = expReward;
}
/**
* @return the friendlyName
*/
public String getFriendlyName() {
return friendlyName;
}
/**
* @param friendlyName the friendlyName to set
*/
public void setFriendlyName(String friendlyName) {
this.friendlyName = friendlyName;
}
/**
* @return the icon
*/
public ItemStack getIcon() {
return icon != null ? icon.clone() : new ItemStack(Material.MAP);
}
/**
* @param icon the icon to set
*/
public void setIcon(ItemStack icon) {
this.icon = icon;
}
/**
* @return the level
*/
public String getLevel() {
return level;
}
/**
* @param level the level to set
*/
public void setLevel(String level) {
if (level.isEmpty()) {
level = ChallengesManager.FREE;
}
this.level = level;
}
/**
* @return the maxTimes
*/
public int getMaxTimes() {
return maxTimes;
}
/**
* @param maxTimes the maxTimes to set
*/
public void setMaxTimes(int maxTimes) {
this.maxTimes = maxTimes;
}
/**
* @return the moneyReward
*/
public int getRewardMoney() {
return rewardMoney;
}
/**
* @param moneyReward the moneyReward to set
*/
public void setRewardMoney(int moneyReward) {
this.rewardMoney = moneyReward;
}
/**
* @return the removeWhenCompleted
*/
public boolean isRemoveWhenCompleted() {
return removeWhenCompleted;
}
/**
* @param removeWhenCompleted the removeWhenCompleted to set
*/
public void setRemoveWhenCompleted(boolean removeWhenCompleted) {
this.removeWhenCompleted = removeWhenCompleted;
}
/**
* @return the repeatable
*/
public boolean isRepeatable() {
return repeatable;
}
/**
* @param repeatable the repeatable to set
*/
public void setRepeatable(boolean repeatable) {
this.repeatable = repeatable;
}
/**
* @return the repeatExpReward
*/
public int getRepeatExpReward() {
return repeatExpReward;
}
/**
* @param repeatExpReward the repeatExpReward to set
*/
public void setRepeatExpReward(int repeatExpReward) {
this.repeatExpReward = repeatExpReward;
}
/**
* @return the repeatItemReward
*/
public List<ItemStack> getRepeatItemReward() {
return repeatItemReward;
}
/**
* @param repeatItemReward the repeatItemReward to set
*/
public void setRepeatItemReward(List<ItemStack> repeatItemReward) {
this.repeatItemReward = repeatItemReward;
}
/**
* @return the repeatMoneyReward
*/
public int getRepeatMoneyReward() {
return repeatMoneyReward;
}
/**
* @param repeatMoneyReward the repeatMoneyReward to set
*/
public void setRepeatMoneyReward(int repeatMoneyReward) {
this.repeatMoneyReward = repeatMoneyReward;
}
/**
* @return the repeatRewardCommands
*/
public List<String> getRepeatRewardCommands() {
return repeatRewardCommands;
}
/**
* @param repeatRewardCommands the repeatRewardCommands to set
*/
public void setRepeatRewardCommands(List<String> repeatRewardCommands) {
this.repeatRewardCommands = repeatRewardCommands;
}
/**
* @return the repeatRewardText
*/
public String getRepeatRewardText() {
return repeatRewardText;
}
/**
* @param repeatRewardText the repeatRewardText to set
*/
public void setRepeatRewardText(String repeatRewardText) {
this.repeatRewardText = repeatRewardText;
}
/**
* @return the reqExp
*/
public int getReqExp() {
return reqExp;
}
/**
* @param reqExp the reqExp to set
*/
public void setReqExp(int reqExp) {
this.reqExp = reqExp;
}
/**
* @return the reqIslandlevel
*/
public long getReqIslandlevel() {
return reqIslandlevel;
}
/**
* @param reqIslandlevel the reqIslandlevel to set
*/
public void setReqIslandlevel(long reqIslandlevel) {
this.reqIslandlevel = reqIslandlevel;
}
/**
* @return the reqMoney
*/
public int getReqMoney() {
return reqMoney;
}
/**
* @param reqMoney the reqMoney to set
*/
public void setReqMoney(int reqMoney) {
this.reqMoney = reqMoney;
}
/**
* @return the reqPerms
*/
public Set<String> getReqPerms() {
return reqPerms;
}
/**
* @param reqPerms the reqPerms to set
*/
public void setReqPerms(Set<String> reqPerms) {
this.reqPerms = reqPerms;
}
/**
* @return the requiredItems
*/
public List<ItemStack> getRequiredItems() {
return requiredItems;
}
/**
* @param requiredItems the requiredItems to set
*/
public void setRequiredItems(List<ItemStack> requiredItems) {
this.requiredItems = requiredItems;
}
/**
* @return requiredEntities
*/
public Map<EntityType, Integer> getRequiredEntities() {
return requiredEntities;
}
/**
* @param requiredEntities the requiredEntities to set
*/
public void setRequiredEntities(Map<EntityType, Integer> requiredEntities) {
this.requiredEntities = requiredEntities;
}
/**
* @return the requiredBlocks
*/
public Map<Material, Integer> getRequiredBlocks() {
return requiredBlocks;
}
/**
* @param map the requiredBlocks to set
*/
public void setRequiredBlocks(Map<Material, Integer> map) {
this.requiredBlocks = map;
}
/**
* @return the rewardCommands
*/
public List<String> getRewardCommands() {
return rewardCommands;
}
/**
* @param rewardCommands the rewardCommands to set
*/
public void setRewardCommands(List<String> rewardCommands) {
this.rewardCommands = rewardCommands;
}
/**
* @return the itemReward
*/
public List<ItemStack> getRewardItems() {
return rewardItems;
}
/**
* @param itemReward the itemReward to set
*/
public void setRewardItems(List<ItemStack> itemReward) {
this.rewardItems = itemReward;
}
/**
* @return the rewardText
*/
public String getRewardText() {
return rewardText;
}
/**
* @param rewardText the rewardText to set
*/
public void setRewardText(String rewardText) {
this.rewardText = rewardText;
}
/**
* @return the searchRadius
*/
public int getSearchRadius() {
return searchRadius;
}
/**
* @param searchRadius the searchRadius to set
*/
public void setSearchRadius(int searchRadius) {
this.searchRadius = searchRadius;
}
/**
* @return the slot
*/
public int getSlot() {
return slot;
}
/**
* @param slot the slot to set
*/
public void setSlot(int slot) {
this.slot = slot;
}
/**
* @return the takeItems
*/
public boolean isTakeItems() {
return takeItems;
}
/**
* @param takeItems the takeItems to set
*/
public void setTakeItems(boolean takeItems) {
this.takeItems = takeItems;
}
/**
* @return the takeMoney
*/
public boolean isTakeMoney() {
return takeMoney;
}
/**
* @param takeMoney the takeMoney to set
*/
public void setTakeMoney(boolean takeMoney) {
this.takeMoney = takeMoney;
}
/**
* @return the environment
*/
public List<World.Environment> getEnvironment() {
return environment;
}
/**
* @param environment the environment to set
*/
public void setEnvironment(List<World.Environment> environment) {
this.environment = environment;
}
/**
* @return the worlds
*/
public String getWorld() {
return world;
}
/**
* @param worlds the worlds to set
*/
public void setWorld(String world) {
this.world = world;
}
/**
* @return the uniqueId
*/
@Override
public String getUniqueId() {
return uniqueId;
}
/**
* @param uniqueId the uniqueId to set
*/
@Override
public void setUniqueId(String uniqueId) {
this.uniqueId = uniqueId;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
return result;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof Challenges)) {
return false;
}
Challenges other = (Challenges) obj;
if (uniqueId == null) {
if (other.uniqueId != null) {
return false;
}
} else if (!uniqueId.equals(other.uniqueId)) {
return false;
}
return true;
}
}

View File

@ -56,6 +56,7 @@ public class AdminGUI extends CommonGUI
DELETE_CHALLENGE, DELETE_CHALLENGE,
DELETE_LEVEL, DELETE_LEVEL,
IMPORT_CHALLENGES, IMPORT_CHALLENGES,
BACKWARD_CHALLENGES,
EDIT_SETTINGS EDIT_SETTINGS
} }
@ -111,6 +112,7 @@ public class AdminGUI extends CommonGUI
// Import Challenges // Import Challenges
panelBuilder.item(15, this.createButton(Button.IMPORT_CHALLENGES)); panelBuilder.item(15, this.createButton(Button.IMPORT_CHALLENGES));
panelBuilder.item(24, this.createButton(Button.BACKWARD_CHALLENGES));
// Edit Addon Settings // Edit Addon Settings
panelBuilder.item(16, this.createButton(Button.EDIT_SETTINGS)); panelBuilder.item(16, this.createButton(Button.EDIT_SETTINGS));
@ -371,6 +373,23 @@ public class AdminGUI extends CommonGUI
break; break;
} }
case BACKWARD_CHALLENGES:
{
permissionSuffix = IMPORT;
name = this.user.getTranslation("challenges.gui.admin.buttons.backward");
description = Collections.emptyList();
icon = new ItemStack(Material.HOPPER);
clickHandler = (panel, user, clickType, slot) -> {
this.addon.getImportManager().
importPreviousChallenges(this.user, this.world, false);
return true;
};
glow = false;
break;
}
case EDIT_SETTINGS: case EDIT_SETTINGS:
{ {
permissionSuffix = SETTINGS; permissionSuffix = SETTINGS;

View File

@ -136,7 +136,8 @@ challenges:
toggle-users: Choose players toggle-users: Choose players
type: 'Challenge Type: [value]' type: 'Challenge Type: [value]'
waiver-amount: Waiver Amount waiver-amount: Waiver Amount
import: Import import: Import from ASkyBlock Challenges
backward: Import from Older ChallengesAddon
choose-challenge-title: Challenges List choose-challenge-title: Challenges List
choose-level-title: Levels List choose-level-title: Levels List
choose-user-title: Users List choose-user-title: Users List