Updaed to 1.13 API

This commit is contained in:
tastybento 2018-07-28 17:15:30 -07:00
parent 14f1d04ba1
commit 457a32a65d
7 changed files with 86 additions and 118 deletions

View File

@ -188,18 +188,18 @@ challenges:
dyemaker:
friendlyname: 'Dye Maker'
description: 'Craft 32 cactus green dyes'
icon: INK_SACK:2
icon: CACTUS_GREEN
level: 'Novice'
type: inventory
requiredItems: 'INK_SACK:2:32'
requiredItems: 'CACTUS_GREEN:32'
takeItems: true
itemReward: 'SAPLING:0:2 SAPLING:1:2 SAPLING:2:2 SAPLING:3:2'
itemReward: 'OAK_SAPLING:2 BIRCH_SAPLING:2 JUNGLE_SAPLING:2 SPRUCE_SAPLING:2'
rewardText: '2 oak, 2 birch, 2 jungle and 2 spruce saplings'
moneyReward: 10
expReward: 30
permissionReward: ''
repeatable: true
repeatItemReward: 'SAPLING:0:1 SAPLING:1:1 SAPLING:2:1 SAPLING:3:1 SAPLING:4:1 SAPLING:5:1'
repeatItemReward: 'ACACIA_SAPLING:1 DARK_OAK_SAPLING:1 OAK_SAPLING:1 BIRCH_SAPLING:1 JUNGLE_SAPLING:1 SPRUCE_SAPLING:1'
repeatRewardText: '1 of each kind of sapling'
repeatMoneyReward: 5
repeatExpReward: 10
@ -247,11 +247,11 @@ challenges:
maxtimes: 100
seedbank:
friendlyname: 'Seedbank'
description: 'Collect 64 melon seeds, 64 pumpkin seeds and 64 wheat seeds'
description: 'Collect 32 melon seeds, 32 pumpkin seeds, 32 beetroot seeds and 32 wheat seeds'
icon: PUMPKIN_SEEDS
level: 'Novice'
type: inventory
requiredItems: 'MELON_SEEDS:64 PUMPKIN_SEEDS:64 SEEDS:64'
requiredItems: 'MELON_SEEDS:32 PUMPKIN_SEEDS:32 WHEAT_SEEDS:32 BEETROOT_SEEDS:32'
takeItems: true
itemReward: 'DIRT:5 VINE:20'
rewardText: '5 dirt blocks and 20 vines'
@ -268,18 +268,18 @@ challenges:
stewmaker:
friendlyname: 'Stew Maker'
description: 'Cook up 18 bowls of mushroom stew'
icon: MUSHROOM_SOUP
icon: MUSHROOM_STEW
level: 'Novice'
type: inventory
requiredItems: 'MUSHROOM_SOUP:18'
requiredItems: 'MUSHROOM_STEW:18'
takeItems: true
itemReward: 'MYCEL:2'
itemReward: 'MYCELIUM:2'
rewardText: '2 mycelium blocks'
moneyReward: 15
expReward: 30
permissionReward: ''
repeatable: true
repeatItemReward: 'MYCEL:1'
repeatItemReward: 'MYCELIUM:1'
repeatRewardText: '1 mycelium block'
repeatMoneyReward: 5
repeatExpReward: 10
@ -288,7 +288,7 @@ challenges:
builder:
friendlyname: 'Builder'
description: 'Reach island level 10 (/[label] level).'
icon: WOOD
icon: OAK_WOOD
level: 'Novice'
type: level
requiredItems: 10
@ -308,7 +308,7 @@ challenges:
icon: BONE
level: 'Competent'
type: inventory
requiredItems: 'ROTTEN_FLESH:64 STRING:32 SULPHUR:16 ARROW:32 BONE:32 SPIDER_EYE:5'
requiredItems: 'ROTTEN_FLESH:64 STRING:32 GUNPOWDER:16 ARROW:32 BONE:32 SPIDER_EYE:5'
takeItems: true
itemReward: 'REDSTONE:16 IRON_ORE:5 FLINT:1 POTION:WATER_BREATHING:1 POTION:NIGHT_VISION:1'
rewardText: '16 redstone dust, 1 flint, 1 water breathing potion, 1 night vision potion and 5 iron(ore)'
@ -327,35 +327,35 @@ challenges:
icon: WHEAT
level: 'Competent'
type: inventory
requiredItems: 'WHEAT:64 SUGAR:64 MELON:64 CARROT_ITEM:64 POTATO_ITEM:64 PUMPKIN:64'
requiredItems: 'WHEAT:64 SUGAR:64 MELON:64 CARROTS:64 POTATOES:64 PUMPKIN:64'
takeItems: true
itemReward: 'REDSTONE:16 INK_SACK:3:1 MONSTER_EGG:PIG:1 MONSTER_EGG:COW:1 MONSTER_EGG:CHICKEN:1'
rewardText: '16 redstone dust, 1 cocoa bean, 1 spawn egg(chicken,cow,pig)'
itemReward: 'REDSTONE:16 COCOA_BEANS:1 PIG_SPAWN_EGG:1 COW_SPAWN_EGG:1 CHICKEN_SPAWN_EGG:1'
rewardText: '16 redstone dust, 1 cocoa bean, 1 spawn egg (chicken,cow,pig)'
moneyReward: 75
expReward: 75
permissionReward: ''
repeatable: true
repeatItemReward: 'INK_SACK:3:1 MONSTER_EGG:PIG:1 MONSTER_EGG:COW:1 MONSTER_EGG:CHICKEN:1'
repeatRewardText: '1 cocoa bean, 1 spawn egg(chicken,cow,pig)'
repeatItemReward: 'COCOA_BEANS:1 PIG_SPAWN_EGG:1 COW_SPAWN_EGG:1 CHICKEN_SPAWN_EGG:1'
repeatRewardText: '1 cocoa bean, 1 spawn egg (chicken,cow,pig)'
repeatMoneyReward: 20
repeatExpReward: 20
# Max times limits how many times a challenge can be done. Comment out to make unlimited
maxtimes: 100
angler:
friendlyname: 'Angler'
description: 'Catch and cook 10 standard fish (no salmon)'
icon: COOKED_FISH
description: 'Catch and cook 10 salmon fish'
icon: COOKED_SALMON
level: 'Competent'
type: inventory
requiredItems: 'COOKED_FISH:10'
requiredItems: 'COOKED_SALMON:10'
takeItems: true
itemReward: 'REDSTONE:16 IRON_ORE:5 INK_SACK:5'
itemReward: 'REDSTONE:16 IRON_ORE:5 INK_SAC:5'
rewardText: '16 redstone dust, 5 inksacs, 5 iron (ore)'
moneyReward: 75
expReward: 75
permissionReward: ''
repeatable: true
repeatItemReward: 'REDSTONE:2 IRON_ORE:1 INK_SACK:1'
repeatItemReward: 'REDSTONE:2 IRON_ORE:1 INK_SAC:1'
repeatRewardText: '2 redstone dust, 1 inksac, 1 iron (ore)'
repeatMoneyReward: 15
repeatExpReward: 15
@ -363,13 +363,13 @@ challenges:
maxtimes: 100
treecutter:
friendlyname: 'Treecutter'
description: 'Create a tree farm and collect 16 oak, birch, jungle, and spruce logs'
icon: LOG
description: 'Create a tree farm and collect 16 oak, birch, jungle, acacia, dark oak and spruce logs'
icon: OAK_LOG
level: 'Competent'
type: inventory
requiredItems: 'LOG:0:16 LOG:1:16 LOG:2:16 LOG:3:16'
requiredItems: 'OAK_LOG:16 BIRCH_LOG:16 JUNGLE_LOG:16 SPRUCE_LOG:16 ACACIA_LOG:16 DARK_OAK_LOG:16'
takeItems: true
itemReward: 'REDSTONE:16 IRON_ORE:5 MONSTER_EGG:WOLF:1'
itemReward: 'REDSTONE:16 IRON_ORE:5 WOLF_SPAWN_EGG:1'
rewardText: '16 redstone dust, 5 iron (ore), 1 wolf spawn egg'
moneyReward: 75
expReward: 75
@ -421,17 +421,17 @@ challenges:
repeatExpReward: 0
homestead:
friendlyname: 'Homestead'
description: 'Build a house that contains at least 1 wooden door, bed, bookshelf, crafting table, furnace, glass-block window, and torch.'
icon: BED
description: 'Build a house that contains at least 1 oak door, white bed, bookshelf, crafting table, furnace, glass-block window, and wall torch.'
icon: WHITE_BED
level: 'Competent'
type: island
requiredItems: 'BED_BLOCK:1 WORKBENCH:1 GLASS:1 WOODEN_DOOR:1 FURNACE:1 BOOKSHELF:1 TORCH:1'
requiredItems: 'WHITE_BED:1 CRAFTING_TABLE:1 GLASS:1 OAK_DOOR:1 FURNACE:1 BOOKSHELF:1 WALL_TORCH:1'
# Search radius - the number of blocks that will be searched around the player
# Minimum 10, which searches from -10 to +10 blocks around the player in x,y,z
# Max is 50 because big searches cause lag
searchRadius: 10
takeItems: false
itemReward: 'JUKEBOX:1 RECORD_12:1 LAPIS_BLOCK:10'
itemReward: 'JUKEBOX:1 MUSIC_DISC_CHIRP:1 LAPIS_BLOCK:10'
rewardText: '1 jukebox, 1 music disk, 10 lapis lazuli blocks'
moneyReward: 100
expReward: 100
@ -447,7 +447,7 @@ challenges:
icon: NETHERRACK
level: 'Expert'
type: island
requiredItems: 'OBSIDIAN:10 PORTAL:1'
requiredItems: 'OBSIDIAN:10 NETHER_PORTAL:1'
takeItems: false
itemReward: 'DIAMOND_SWORD:1'
rewardText: '1 diamond sword'
@ -525,9 +525,9 @@ challenges:
icon: MAP
level: 'Expert'
type: inventory
requiredItems: 'NETHERRACK:64 SOUL_SAND:16 GHAST_TEAR:1 MAP:1 COMPASS:1 WATCH:1'
requiredItems: 'NETHERRACK:64 SOUL_SAND:16 GHAST_TEAR:1 MAP:1 COMPASS:1 CLOCK:1'
takeItems: true
itemReward: 'POWERED_RAIL:32 RAILS:256 DIAMOND:1 MONSTER_EGG:OCELOT:1'
itemReward: 'POWERED_RAIL:32 RAIL:256 DIAMOND:1 OCELOT_SPAWN_EGG:1'
rewardText: '256 rails, 32 powered rails, 1 ocelot spawn egg, 1 diamond'
moneyReward: 100
expReward: 100
@ -560,18 +560,18 @@ challenges:
shepherd:
friendlyname: 'Shepherd'
description: 'Collect 5 of every color of wool'
icon: WOOL:2
icon: BLUE_WOOL
level: 'Advanced'
type: inventory
requiredItems: 'WOOL:0:5 WOOL:1:5 WOOL:2:5 WOOL:3:5 WOOL:4:5 WOOL:5:5 WOOL:6:5 WOOL:7:5 WOOL:8:5 WOOL:9:5 WOOL:10:5 WOOL:11:5 WOOL:12:5 WOOL:13:5 WOOL:14:5 WOOL:15:5'
requiredItems: 'BLACK_WOOL:5 BLUE_WOOL:5 BROWN_WOOL:5 CYAN_WOOL:5 GRAY_WOOL:5 GREEN_WOOL:5 LIGHT_BLUE_WOOL:5 LIGHT_GRAY_WOOL:5 LIME_WOOL:5 MAGENTA_WOOL:5 ORANGE_WOOL:5 PINK_WOOL:5 PURPLE_WOOL:5 RED_WOOL:5 WHITE_WOOL:5 YELLOW_WOOL:5 '
takeItems: true
itemReward: 'DIAMOND:2 RECORD_7:1 RECORD_8:1 RECORD_6:1 MONSTER_EGG:SHEEP:1 EMERALD:5'
itemReward: 'DIAMOND:2 MUSIC_DISC_CAT:1 MUSIC_DISC_BLOCKS:1 MUSIC_DISC_STAL:1 SHEEP_SPAWN_EGG:1 EMERALD:5'
rewardText: '2 diamonds, 5 emeralds, 3 music disks, 1 sheep spawn egg'
moneyReward: 200
expReward: 200
permissionReward: ''
repeatable: true
repeatItemReward: 'EMERALD:1 MONSTER_EGG:SHEEP:1'
repeatItemReward: 'EMERALD:1 SHEEP_SPAWN_EGG:1'
repeatRewardText: '1 emerald, 1 sheep spawn egg'
repeatMoneyReward: 20
repeatExpReward: 20
@ -580,13 +580,13 @@ challenges:
alchemist:
friendlyname: 'Alchemist'
description: 'Brew 1 potion of Fire Resistance, Slowness, Swiftness, Healing, Harming, Invisibility, Strength and Regeneration'
icon: BREWING_STAND_ITEM
icon: BREWING_STAND
level: 'Advanced'
type: inventory
requiredItems: 'POTION:FIRE_RESISTANCE::::1 POTION:SLOWNESS::::1 POTION:SPEED::::1 POTION:INSTANT_HEAL::::1 POTION:INSTANT_DAMAGE::::1 POTION:INVISIBILITY::::1 POTION:STRENGTH::::1 POTION:REGEN::::1'
takeItems: true
itemReward: 'ENCHANTMENT_TABLE:1'
rewardText: 'Enchantment Table'
itemReward: 'ENCHANTING_TABLE:1'
rewardText: 'Enchanting Table'
moneyReward: 200
expReward: 200
permissionReward: ''
@ -598,10 +598,10 @@ challenges:
dj:
friendlyname: 'DJ'
description: 'Craft a jukebox and collect all music discs'
icon: RECORD_5
icon: MUSIC_DISC_CHIRP
level: 'Advanced'
type: inventory
requiredItems: 'GOLD_RECORD:1 GREEN_RECORD:1 RECORD_3:1 RECORD_4:1 RECORD_5:1 RECORD_6:1 RECORD_7:1 RECORD_8:1 RECORD_9:1 RECORD_10:1 RECORD_11:1 RECORD_12:1 JUKEBOX:1'
requiredItems: 'MUSIC_DISC_11:1 MUSIC_DISC_13:1 MUSIC_DISC_BLOCKS:1 MUSIC_DISC_CAT:1 MUSIC_DISC_CHIRP:1 MUSIC_DISC_FAR:1 MUSIC_DISC_MALL:1 MUSIC_DISC_MELLOHI:1 MUSIC_DISC_STAL:1 MUSIC_DISC_STRAD:1 MUSIC_DISC_WAIT:1 MUSIC_DISC_WARD:1 JUKEBOX:1'
takeItems: true
itemReward: 'DIAMOND:3 EMERALD:10 GOLD_INGOT:5'
rewardText: '3 diamonds, 10 emeralds and 5 gold ingots'
@ -641,17 +641,15 @@ challenges:
icon: GOLDEN_APPLE
level: 'Advanced'
type: inventory
requiredItems: 'BAKED_POTATO:1 BREAD:1 CAKE:1 COOKED_CHICKEN:1 COOKED_FISH:1 GRILLED_PORK:1 COOKIE:1 GOLDEN_APPLE:0:1 GOLDEN_CARROT:1 MUSHROOM_SOUP:1 PUMPKIN_PIE:1 COOKED_BEEF:1'
# If you are running 1.8 change to this:
# requiredItems: 'BAKED_POTATO:1 BREAD:1 CAKE:1 COOKED_CHICKEN:1 COOKED_FISH:1 GRILLED_PORK:1 COOKIE:1 GOLDEN_APPLE:0:1 GOLDEN_CARROT:1 MUSHROOM_SOUP:1 PUMPKIN_PIE:1 COOKED_BEEF:1 COOKED_RABBIT:1 RABBIT_STEW:1 COOKED_MUTTON:1'
requiredItems: 'BAKED_POTATO:1 BREAD:1 CAKE:1 COOKED_CHICKEN:1 COOKED_COD:1 COOKED_SALMON:1 COOKED_PORKCHOP:1 COOKED_RABBIT:1 COOKIE:1 GOLDEN_APPLE:0:1 GOLDEN_CARROT:1 MUSHROOM_STEW:1 PUMPKIN_PIE:1 COOKED_BEEF:1'
takeItems: true
itemReward: 'GOLD_BLOCK:2 GREEN_RECORD:1 RECORD_3:1 RECORD_5:1 MONSTER_EGG:MUSHROOM_COW:1 EMERALD:5'
itemReward: 'GOLD_BLOCK:2 MUSIC_DISC_MALL:1 MUSIC_DISC_WAIT:1 MUSIC_DISC_13:1 MOOSHROOM_SPAWN_EGG:1 EMERALD:5'
rewardText: '2 gold blocks, 3 music discs, 1 mooshroom spawn egg, and 5 emeralds'
moneyReward: 200
expReward: 200
permissionReward: ''
repeatable: true
repeatItemReward: 'GOLD_INGOT:10 MONSTER_EGG:MUSHROOM_COW:1 EMERALD:1'
repeatItemReward: 'GOLD_INGOT:10 MOOSHROOM_SPAWN_EGG:1 EMERALD:1'
repeatRewardText: '10 gold ingots, 1 mooshroom spawn egg, 1 emerald'
repeatMoneyReward: 20
repeatExpReward: 20
@ -665,7 +663,7 @@ challenges:
type: island
requiredItems: 'BEACON:1'
takeItems: false
itemReward: 'SMOOTH_BRICK:20 SMOOTH_BRICK:1:20 SMOOTH_BRICK:2:20 SMOOTH_BRICK:3:20'
itemReward: 'STONE_BRICKS:20 CHISELED_STONE_BRICKS:20 CRACKED_STONE_BRICKS:20 MOSSY_STONE_BRICKS:20'
rewardText: '20 blocks of every kind of stone brick'
moneyReward: 300
expReward: 300
@ -701,7 +699,7 @@ challenges:
type: island
requiredItems: 'IRON_GOLEM:1'
takeItems: false
itemReward: 'NAME_TAG:1 ANVIL:1 CAULDRON_ITEM:1 IRON_BLOCK:2'
itemReward: 'NAME_TAG:1 ANVIL:1 CAULDRON:1 IRON_BLOCK:2'
rewardText: 'A name tag, an anvil, a cauldron and 2 iron blocks'
moneyReward: 300
expReward: 300
@ -714,12 +712,12 @@ challenges:
snowplay:
friendlyname: 'Snow Play!'
description: 'Build a snow golem'
icon: SNOW_BALL
icon: SNOWBALL
level: 'Advanced'
type: island
requiredItems: 'SNOWMAN:1'
takeItems: false
itemReward: 'DIAMOND_SPADE:1'
itemReward: 'DIAMOND_SHOVEL:1'
rewardText: 'A diamond spade - get shoveling!'
moneyReward: 300
expReward: 300
@ -750,12 +748,12 @@ challenges:
itsamonsterparty:
friendlyname: "It's a Monster Party"
description: 'Have a party - all monsters invited! Get close to a Skeleton, Zombie, Spider, Creeper and Enderman all at the same time.'
icon: SKULL_ITEM
icon: SKELETON_SKULL
level: 'Advanced'
type: island
requiredItems: 'SKELETON:1 ZOMBIE:1 SPIDER:1 CREEPER:1 ENDERMAN:1'
takeItems: false
itemReward: 'SKULL_ITEM:0:2 SKULL_ITEM:2:2 SKULL_ITEM:3:2'
itemReward: 'SKELETON_SKULL:1 ZOMBIE_HEAD:1 CREEPER_HEAD:1'
rewardText: 'Skulls!'
moneyReward: 200
expReward: 400

View File

@ -44,7 +44,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<version>1.13-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -53,7 +53,7 @@ public class ChallengesManager {
challengeMap = new LinkedHashMap<>();
// Cache of player data
playerData = new HashMap<>();
load();
load();
}
/**
@ -130,7 +130,7 @@ public class ChallengesManager {
newChallenge.setRequiredItems(requiredItems);
newChallenge.setTakeItems(true);
newChallenge.setUniqueId(inventory.getTitle());
newChallenge.setIcon(new ItemStack(Material.EMPTY_MAP));
newChallenge.setIcon(new ItemStack(Material.MAP));
newChallenge.setLevel(FREE);
newChallenge.setDescription(createDescription(user, requiredItems));
@ -197,7 +197,7 @@ 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 Challenges 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();
@ -249,7 +249,7 @@ public class ChallengesManager {
/**
* Get the set of challenges for this level for this world
* @param level - the level required
* @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
*/
public Set<Challenges> getChallenges(String level, World world) {
@ -257,7 +257,7 @@ public class ChallengesManager {
Optional<ChallengeLevels> 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())
.filter(c -> c.getWorld().equalsIgnoreCase(worldName) || c.getWorld().isEmpty()).collect(Collectors.toSet())
: new HashSet<>();
}

View File

@ -1,11 +1,8 @@
package bskyblock.addon.challenges;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.inventory.meta.SpawnEggMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
@ -40,6 +37,7 @@ public class ParseItem {
} else if (part.length == 6 && (part[0].contains("POTION") || part[0].equalsIgnoreCase("TIPPED_ARROW"))) {
return potion(s, part);
}
showError(s);
return null;
}
@ -89,23 +87,16 @@ public class ParseItem {
String[] twoer = {part[0], part[2]};
ItemStack result = two(s, twoer);
if (result == null) {
showError(s);
return null;
}
if (StringUtils.isNumeric(part[1])) {
result.setDurability((short) Integer.parseInt(part[1]));
} else if (result.getType().equals(Material.MONSTER_EGG)) {
// Check if this is a string
EntityType entityType = EntityType.valueOf(part[1]);
SpawnEggMeta meta = ((SpawnEggMeta)result.getItemMeta());
meta.setSpawnedType(entityType);
result.setItemMeta(meta);
}
return result;
}
private void showError(String s) {
addon.getLogger().severe(() -> "Problem with " + s + " in challenges.yml!");
addon.getLogger().severe(() -> "Problem with " + s + " in config.yml!");
}
private ItemStack two(String s, String[] part) {
@ -113,10 +104,9 @@ public class ParseItem {
try {
reqAmount = Integer.parseInt(part[1]);
} catch (Exception e) {
addon.getLogger().severe(() -> "Could not parse the quantity of the item " + s);
showError(s);
return null;
}
Material reqItem = Material.getMaterial(part[0].toUpperCase() + "_ITEM");
if (reqItem == null) {
// Try the item

View File

@ -41,20 +41,20 @@ public class Challenges implements DataObject {
*/
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<>();
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;
private int slot = -1;
// Definition
@ConfigComment("Challenge level. Default is Free")
@ -64,7 +64,7 @@ public class Challenges implements DataObject {
@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<>();
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")
@ -80,7 +80,7 @@ public class Challenges implements DataObject {
@ConfigComment("This is a map of the blocks required in a SURROUNDING 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<>();
private List<ItemStack> requiredItems = new ArrayList<>();
@ConfigComment("Any entities that must be in the area for SURROUNDING type challenges. Map EntityType, Number")
private Map<EntityType, Integer> requiredEntities = new EnumMap<>(EntityType.class);
@ConfigComment("Required experience")
@ -200,7 +200,7 @@ public class Challenges implements DataObject {
* @return the icon
*/
public ItemStack getIcon() {
return icon.clone();
return icon != null ? icon.clone() : new ItemStack(Material.MAP);
}
/**

View File

@ -38,14 +38,14 @@ public class ChallengesPanels {
this.world = world;
this.permPrefix = permPrefix;
this.label = label;
if (manager.getChallengeList().isEmpty()) {
addon.getLogger().severe("There are no challenges set up!");
user.sendMessage("general.errors.general");
return;
}
if (level.isEmpty()) {
level = manager.getChallengeList().keySet().iterator().next().getUniqueId();
level = manager.getChallengeList().keySet().iterator().next().getUniqueId();
}
this.level = level;
// Check if level is valid
@ -71,7 +71,7 @@ public class ChallengesPanels {
createItem(panelBuilder, challenge);
}
}
private void addFreeChallanges(PanelBuilder panelBuilder) {
manager.getChallenges(ChallengesManager.FREE, world).forEach(challenge -> createItem(panelBuilder, challenge));
}
@ -122,7 +122,7 @@ public class ChallengesPanels {
if (status.isUnlocked()) {
// Clicking on this icon will open up this level's challenges
PanelItem item = new PanelItemBuilder()
.icon(new ItemStack(Material.BOOK_AND_QUILL))
.icon(new ItemStack(Material.ENCHANTED_BOOK))
.name(name)
.description(manager.stringSplit(user.getTranslation("challenges.navigation","[level]",name)))
.clickHandler((p, u, c, s) -> {
@ -147,10 +147,10 @@ public class ChallengesPanels {
/**
* Creates the challenge description for the "item" in the inventory
*
*
* @param challenge
* @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) {
List<String> result = new ArrayList<String>();
@ -174,8 +174,8 @@ public class ChallengesPanels {
result.addAll(splitTrans(user, "challenges.completed-times","[donetimes]", String.valueOf(doneTimes),"[maxtimes]", String.valueOf(maxTimes)));
} else {
result.addAll(splitTrans(user, "challenges.maxed-reached","[donetimes]", String.valueOf(doneTimes),"[maxtimes]", String.valueOf(maxTimes)));
}
}
}
}
}
if (!complete || (complete && challenge.isRepeatable())) {
result.addAll(challenge.getDescription());

View File

@ -13,7 +13,6 @@ import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
@ -66,9 +65,9 @@ public class ParseItemTest {
assertNull(new ParseItem(addon, "anything:anything").getItem());
// Bad material
assertNull(new ParseItem(addon, "nosuchmaterial:2").getItem());
// Material
for (Material mat : Material.values()) {
for (Material mat : Material.values()) {
ItemStack test = new ParseItem(addon, mat.name() + ":5").getItem();
if (test.getType().toString().endsWith("_ITEM") && !mat.toString().endsWith("_ITEM")) {
assertEquals(mat.toString() + "_ITEM", test.getType().toString());
@ -76,54 +75,35 @@ public class ParseItemTest {
assertEquals(mat, test.getType());
}
}
// Nothing amount
ItemStack test = new ParseItem(addon, "STONE:").getItem();
assertNull(test);
// Test 3
// Bad material
assertNull(new ParseItem(addon, "nosuchmaterial:2:2").getItem());
// Bad amount
assertNull(new ParseItem(addon, "STONE:1:sdfgsd").getItem());
// Missing amount = 1
test = new ParseItem(addon, "STONE:1:").getItem();
assertNotNull(test); // This is okay, it's just a 2
// Material
for (Material mat : Material.values()) {
test = new ParseItem(addon, mat.name() + ":5:5").getItem();
if (test.getType().toString().endsWith("_ITEM") && !mat.toString().endsWith("_ITEM")) {
assertEquals(mat.toString() + "_ITEM", test.getType().toString());
assertEquals(5, test.getDurability());
} else {
assertEquals(mat, test.getType());
assertEquals(5, test.getDurability());
}
}
// Test spawn eggs
for (EntityType ent : EntityType.values()) {
if (ent.isSpawnable()) {
test = new ParseItem(addon, "MONSTER_EGG:" + ent.name() + ":3").getItem();
assertEquals(Material.MONSTER_EGG, test.getType());
assertEquals(3, test.getAmount());
}
}
// Test Potions
PotionMeta itemMeta = mock(PotionMeta.class);
when(itemFactory.getItemMeta(any())).thenReturn(itemMeta);
when(Bukkit.getItemFactory()).thenReturn(itemFactory);
// Bad material
assertNull(new ParseItem(addon, "nosuchmaterial:JUMP:2:NOTEXTENDED:NOSPLASH:2").getItem());
// Bad amount
assertNull(new ParseItem(addon, "POTION:JUMP:2:NOTEXTENDED:NOSPLASH:asfdas").getItem());
test = new ParseItem(addon, "POTION:JUMP:2:NOTEXTENDED:NOSPLASH:").getItem();
assertNull(test);
test = new ParseItem(addon, "POTION:JUMP:2:NOTEXTENDED:NOSPLASH:1").getItem();
assertEquals(Material.POTION, test.getType());
test = new ParseItem(addon, "POTION:STRENGTH:1:EXTENDED:SPLASH:1").getItem();