This commit is contained in:
Tastybento 2018-03-24 10:55:48 -07:00
parent fd3e7a928f
commit fcd8078249
3 changed files with 22 additions and 0 deletions

View File

@ -52,6 +52,8 @@ challenges:
parameters: ""
description: "admin command to create challenges"
create:
description: "&6Collect:"
description-item-color: "&B"
inventory:
parameters: "[challenge name]"
description: "create an inventory challenge"

View File

@ -56,6 +56,7 @@ public class ChallengesAddon extends Addon {
new ChallengesCommand(this);
new ChallengesAdminCommand(this);
// Done
/*
Gson gson = new Gson();
Challenges challenges = new Challenges();
challenges.setChallengeType(ChallengeType.SURROUNDING);
@ -120,6 +121,7 @@ public class ChallengesAddon extends Addon {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
}
@Override

View File

@ -21,6 +21,7 @@ import bskyblock.addon.challenges.panel.ChallengesPanels;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.configuration.BSBConfig;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.util.Util;
public class ChallengesManager {
@ -70,6 +71,7 @@ public class ChallengesManager {
newChallenge.setIcon(new ItemStack(Material.EMPTY_MAP));
newChallenge.setFreeChallenge(true);
newChallenge.setLevel(FREE);
newChallenge.setDescription(createDescription(user, requiredItems));
// Move all the items back to the player's inventory
inventory.forEach(item -> {
@ -91,6 +93,21 @@ public class ChallengesManager {
return true;
}
/**
* Creates a simple example description of the requirements
* @param user - user of this command
* @param requiredItems - list of items
* @return Description list
*/
private List<String> createDescription(User user, List<ItemStack> requiredItems) {
List<String> result = new ArrayList<>();
result.add(user.getTranslation("challenges.admin.create.description"));
for (ItemStack item : requiredItems) {
result.add(user.getTranslation("challenges.admin.create.description-item-color") + item.getAmount() + " x " + Util.prettifyText(item.getType().toString()));
}
return result;
}
/**
* Create a surrounding challenge
* @param challengeInfo - info on the challenge from the builder
@ -195,6 +212,7 @@ public class ChallengesManager {
public void load() {
// Load the challenges
challengeList.clear();
Bukkit.getLogger().info("Loading challenges...");
for (Challenges challenge : chConfig.loadConfigObjects()) {
Bukkit.getLogger().info("Loading challenge " + challenge.getFriendlyName() + " level " + challenge.getLevel());
// See if we have this level already