Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
tastybento 2018-08-01 09:53:43 -07:00
commit 303d9a95dc
33 changed files with 283 additions and 302 deletions

View File

@ -11,3 +11,9 @@ permissions:
bskyblock.admin.challenges:
description: Access challenge admin commands
default: op
acidisland.challenges:
description: Let the player use the /challenges command
default: true
acidisland.admin.challenges:
description: Access challenge admin commands
default: op

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,12 +44,12 @@
<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>
<groupId>us.tastybento</groupId>
<artifactId>bskyblock</artifactId>
<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>

View File

@ -4,8 +4,8 @@ import org.bukkit.Bukkit;
import bskyblock.addon.challenges.commands.ChallengesCommand;
import bskyblock.addon.challenges.commands.admin.ChallengesAdminImportCommand;
import us.tastybento.bskyblock.api.addons.Addon;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
/**
* Add-on to BSkyBlock that enables challenges
@ -21,7 +21,7 @@ public class ChallengesAddon extends Addon {
@Override
public void onEnable() {
// Check if it is enabled - it might be loaded, but not enabled.
if (getBSkyBlock() == null || !getBSkyBlock().isEnabled()) {
if (getPlugin() == null || !getPlugin().isEnabled()) {
Bukkit.getLogger().severe("BSkyBlock is not available or disabled!");
this.setEnabled(false);
return;
@ -34,19 +34,26 @@ public class ChallengesAddon extends Addon {
// Register commands - run one tick later to allow all addons to load
// AcidIsland hook in
getServer().getScheduler().runTask(getBSkyBlock(), () -> {
this.getBSkyBlock().getAddonsManager().getAddonByName("AcidIsland").ifPresent(a -> {
CompositeCommand acidIslandCmd = getBSkyBlock().getCommandsManager().getCommand("ai");
new ChallengesCommand(this, acidIslandCmd);
CompositeCommand acidCmd = getBSkyBlock().getCommandsManager().getCommand("acid");
new ChallengesAdminImportCommand(this, acidCmd);
getServer().getScheduler().runTask(getPlugin(), () -> {
this.getPlugin().getAddonsManager().getAddonByName("AcidIsland").ifPresent(a -> {
CompositeCommand acidIslandCmd = getPlugin().getCommandsManager().getCommand("ai");
if (acidIslandCmd != null) {
new ChallengesCommand(this, acidIslandCmd);
CompositeCommand acidCmd = getPlugin().getCommandsManager().getCommand("acid");
new ChallengesAdminImportCommand(this, acidCmd);
}
});
this.getPlugin().getAddonsManager().getAddonByName("BSkyBlock").ifPresent(a -> {
// BSkyBlock hook in
CompositeCommand bsbIslandCmd = getPlugin().getCommandsManager().getCommand("island");
if (bsbIslandCmd != null) {
new ChallengesCommand(this, bsbIslandCmd);
CompositeCommand bsbAdminCmd = getPlugin().getCommandsManager().getCommand("bsbadmin");
new ChallengesAdminImportCommand(this, bsbAdminCmd);
}
});
});
// BSkyBlock hook in
CompositeCommand bsbIslandCmd = getBSkyBlock().getCommandsManager().getCommand("island");
new ChallengesCommand(this, bsbIslandCmd);
CompositeCommand bsbAdminCmd = getBSkyBlock().getCommandsManager().getCommand("bsbadmin");
new ChallengesAdminImportCommand(this, bsbAdminCmd);
// Done
}

View File

@ -26,10 +26,10 @@ import bskyblock.addon.challenges.database.object.Challenges;
import bskyblock.addon.challenges.database.object.Challenges.ChallengeType;
import bskyblock.addon.challenges.database.object.PlayerData;
import bskyblock.addon.challenges.panel.ChallengesPanels;
import us.tastybento.bskyblock.api.configuration.BSBConfig;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.BSBDatabase;
import us.tastybento.bskyblock.util.Util;
import world.bentobox.bentobox.api.configuration.BSBConfig;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.BSBDatabase;
import world.bentobox.bentobox.util.Util;
public class ChallengesManager {
@ -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<>();
}
@ -356,7 +356,7 @@ public class ChallengesManager {
*/
public void save(boolean async) {
if (async) {
addon.getServer().getScheduler().runTaskAsynchronously(addon.getBSkyBlock(), this::save);
addon.getServer().getScheduler().runTaskAsynchronously(addon.getPlugin(), this::save);
} else {
save();
}

View File

@ -18,8 +18,8 @@ import org.bukkit.inventory.ItemStack;
import bskyblock.addon.challenges.database.object.ChallengeLevels;
import bskyblock.addon.challenges.database.object.Challenges;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.util.Util;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.Util;
/**
* Imports challenges
@ -42,7 +42,7 @@ public class FreshSqueezedChallenges {
addon.saveResource("challenges.yml",false);
}
}
/**
* Import challenges
* @param user - user
@ -101,8 +101,8 @@ public class FreshSqueezedChallenges {
/**
* Imports challenges
* @param overwrite
* @param args
* @param overwrite
* @param args
*/
private void makeChallenges(User user, World world, boolean overwrite) {
int size = 0;
@ -114,7 +114,7 @@ public class FreshSqueezedChallenges {
newChallenge.setDeployed(true);
ConfigurationSection details = chals.getConfigurationSection(challenge);
newChallenge.setFriendlyName(details.getString("friendlyname", challenge));
newChallenge.setWorld(Util.getWorld(world).getName());
newChallenge.setWorld(Util.getWorld(world).getName());
newChallenge.setDescription(addon.getChallengesManager().stringSplit(details.getString("description", "")));
newChallenge.setIcon(new ParseItem(addon, details.getString("icon") + ":1").getItem());
newChallenge.setLevel(details.getString("level", ChallengesManager.FREE));

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

@ -4,35 +4,35 @@ import java.util.List;
import bskyblock.addon.challenges.ChallengesAddon;
import bskyblock.addon.challenges.panel.ChallengesPanels;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
public class ChallengesCommand extends CompositeCommand {
public static final String CHALLENGE_COMMAND = "challenges";
private ChallengesAddon addon;
public ChallengesCommand(ChallengesAddon addon, CompositeCommand cmd) {
super(cmd, CHALLENGE_COMMAND, "c", "challenge");
super(cmd, CHALLENGE_COMMAND);
this.addon = addon;
}
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
// Open up the challenges GUI
if (user.isPlayer()) {
new ChallengesPanels(addon, user, args.isEmpty() ? "" : args.get(0), getWorld(), getPermissionPrefix(), getTopLabel());
return true;
}
}
return false;
}
@Override
public void setup() {
this.setOnlyPlayer(true);
this.setPermission(getPermissionPrefix() + CHALLENGE_COMMAND);
this.setPermission(CHALLENGE_COMMAND);
this.setParameters(CHALLENGE_COMMAND + ".parameters");
this.setDescription(CHALLENGE_COMMAND + ".description");
this.setOnlyPlayer(true);
this.setOnlyPlayer(true);
}

View File

@ -5,9 +5,9 @@ import java.util.List;
import java.util.Optional;
import bskyblock.addon.challenges.ChallengesAddon;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.util.Util;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.Util;
public class ChallengesAdminImportCommand extends CompositeCommand {
@ -24,13 +24,13 @@ public class ChallengesAdminImportCommand extends CompositeCommand {
}
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
return addon.getImportManager().importChallenges(user, getWorld(), !args.isEmpty() && args.get(0).equalsIgnoreCase("overwrite"));
}
@Override
public void setup() {
this.setPermission(getPermissionPrefix() + "challenges.admin");
this.setPermission("challenges.admin");
this.setParameters("challenges.admin.import.parameters");
this.setDescription("challenges.admin.import.description");
}

View File

@ -4,9 +4,9 @@ import java.util.List;
import bskyblock.addon.challenges.ChallengesAddon;
import bskyblock.addon.challenges.panel.CreateChallengeListener;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.panels.builders.PanelBuilder;
import us.tastybento.bskyblock.api.user.User;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
import world.bentobox.bentobox.api.user.User;
public class CreateChallenge extends CompositeCommand {
@ -27,14 +27,14 @@ public class CreateChallenge extends CompositeCommand {
@Override
public void setup() {
this.setOnlyPlayer(true);
this.setPermission(getPermissionPrefix() + "admin.challenges");
this.setPermission("admin.challenges");
this.setParameters("challaneges.admin.create.parameters");
this.setDescription("challenges.admin.create.description");
}
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
if (args.isEmpty()) {
user.sendRawMessage("not enough args");
return false;

View File

@ -17,9 +17,9 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import bskyblock.addon.challenges.ChallengesAddon;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.util.Util;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.Util;
/**
* Command to create a surrounding type challenge
@ -39,19 +39,19 @@ public class CreateSurrounding extends CompositeCommand implements Listener {
public CreateSurrounding(ChallengesAddon addon, CompositeCommand parent) {
super(parent, "surrounding");
this.addon = addon;
addon.getServer().getPluginManager().registerEvents(this, addon.getBSkyBlock());
addon.getServer().getPluginManager().registerEvents(this, addon.getPlugin());
}
@Override
public void setup() {
this.setOnlyPlayer(true);
this.setPermission(getPermissionPrefix() + "admin.challenges");
this.setPermission("admin.challenges");
this.setParameters("challaneges.admin.create.surrounding.parameters");
this.setDescription("challenges.admin.create.surrounding.description");
}
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
if (args.isEmpty()) {
user.sendMessage("challenges.admin.error.no-name");
return false;

View File

@ -1,13 +1,13 @@
/**
*
*
*/
package bskyblock.addon.challenges.commands.admin;
import java.util.List;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import bskyblock.addon.challenges.ChallengesAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @author tastybento
@ -20,7 +20,7 @@ public class MakeLevel extends CompositeCommand {
* @param label
* @param string
*/
public MakeLevel(BSkyBlock plugin, String label, String... string) {
public MakeLevel(ChallengesAddon plugin, String label, String... string) {
super(plugin, label, string);
// TODO Auto-generated constructor stub
}
@ -45,7 +45,7 @@ public class MakeLevel extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
* @see world.bentobox.bbox.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
@ -54,10 +54,10 @@ public class MakeLevel extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
* @see world.bentobox.bbox.api.commands.BSBCommand#execute(world.bentobox.bbox.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
// TODO Auto-generated method stub
return false;
}

View File

@ -1,13 +1,13 @@
/**
*
*
*/
package bskyblock.addon.challenges.commands.admin;
import java.util.List;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import bskyblock.addon.challenges.ChallengesAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @author tastybento
@ -20,7 +20,7 @@ public class SetDeployed extends CompositeCommand {
* @param label
* @param string
*/
public SetDeployed(BSkyBlock plugin, String label, String... string) {
public SetDeployed(ChallengesAddon plugin, String label, String... string) {
super(plugin, label, string);
// TODO Auto-generated constructor stub
}
@ -45,7 +45,7 @@ public class SetDeployed extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
* @see world.bentobox.bbox.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
@ -54,10 +54,10 @@ public class SetDeployed extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
* @see world.bentobox.bbox.api.commands.BSBCommand#execute(world.bentobox.bbox.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
// TODO Auto-generated method stub
return false;
}

View File

@ -1,13 +1,13 @@
/**
*
*
*/
package bskyblock.addon.challenges.commands.admin;
import java.util.List;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import bskyblock.addon.challenges.ChallengesAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @author tastybento
@ -20,7 +20,7 @@ public class SetDescription extends CompositeCommand {
* @param label
* @param string
*/
public SetDescription(BSkyBlock plugin, String label, String... string) {
public SetDescription(ChallengesAddon plugin, String label, String... string) {
super(plugin, label, string);
// TODO Auto-generated constructor stub
}
@ -45,7 +45,7 @@ public class SetDescription extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
* @see world.bentobox.bbox.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
@ -54,10 +54,10 @@ public class SetDescription extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
* @see world.bentobox.bbox.api.commands.BSBCommand#execute(world.bentobox.bbox.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
// TODO Auto-generated method stub
return false;
}

View File

@ -1,13 +1,13 @@
/**
*
*
*/
package bskyblock.addon.challenges.commands.admin;
import java.util.List;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import bskyblock.addon.challenges.ChallengesAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @author tastybento
@ -20,7 +20,7 @@ public class SetExp extends CompositeCommand {
* @param label
* @param string
*/
public SetExp(BSkyBlock plugin, String label, String... string) {
public SetExp(ChallengesAddon plugin, String label, String... string) {
super(plugin, label, string);
// TODO Auto-generated constructor stub
}
@ -45,7 +45,7 @@ public class SetExp extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
* @see world.bentobox.bbox.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
@ -54,10 +54,10 @@ public class SetExp extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
* @see world.bentobox.bbox.api.commands.BSBCommand#execute(world.bentobox.bbox.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
// TODO Auto-generated method stub
return false;
}

View File

@ -1,13 +1,13 @@
/**
*
*
*/
package bskyblock.addon.challenges.commands.admin;
import java.util.List;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import bskyblock.addon.challenges.ChallengesAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @author tastybento
@ -20,7 +20,7 @@ public class SetFriendlyName extends CompositeCommand {
* @param label
* @param string
*/
public SetFriendlyName(BSkyBlock plugin, String label, String... string) {
public SetFriendlyName(ChallengesAddon plugin, String label, String... string) {
super(plugin, label, string);
// TODO Auto-generated constructor stub
}
@ -45,7 +45,7 @@ public class SetFriendlyName extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
* @see world.bentobox.bbox.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
@ -54,10 +54,10 @@ public class SetFriendlyName extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
* @see world.bentobox.bbox.api.commands.BSBCommand#execute(world.bentobox.bbox.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
// TODO Auto-generated method stub
return false;
}

View File

@ -1,5 +1,5 @@
/**
*
*
*/
package bskyblock.addon.challenges.commands.admin;
@ -9,8 +9,8 @@ import org.bukkit.inventory.ItemStack;
import bskyblock.addon.challenges.ChallengesAddon;
import bskyblock.addon.challenges.database.object.Challenges;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @author tastybento
@ -31,7 +31,7 @@ public class SetIcon extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
* @see world.bentobox.bbox.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
@ -40,10 +40,10 @@ public class SetIcon extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
* @see world.bentobox.bbox.api.commands.BSBCommand#execute(world.bentobox.bbox.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
ItemStack icon = user.getInventory().getItemInMainHand();
if (args.isEmpty() || icon == null) {
user.sendMessage("challenges.admin.seticon.description");

View File

@ -1,13 +1,13 @@
/**
*
*
*/
package bskyblock.addon.challenges.commands.admin;
import java.util.List;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import bskyblock.addon.challenges.ChallengesAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @author tastybento
@ -20,7 +20,7 @@ public class SetLevel extends CompositeCommand {
* @param label
* @param string
*/
public SetLevel(BSkyBlock plugin, String label, String... string) {
public SetLevel(ChallengesAddon plugin, String label, String... string) {
super(plugin, label, string);
// TODO Auto-generated constructor stub
}
@ -45,7 +45,7 @@ public class SetLevel extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
* @see world.bentobox.bbox.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
@ -54,10 +54,10 @@ public class SetLevel extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
* @see world.bentobox.bbox.api.commands.BSBCommand#execute(world.bentobox.bbox.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
// TODO Auto-generated method stub
return false;
}

View File

@ -1,13 +1,13 @@
/**
*
*
*/
package bskyblock.addon.challenges.commands.admin;
import java.util.List;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import bskyblock.addon.challenges.ChallengesAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @author tastybento
@ -20,7 +20,7 @@ public class SetMaxTimes extends CompositeCommand {
* @param label
* @param string
*/
public SetMaxTimes(BSkyBlock plugin, String label, String... string) {
public SetMaxTimes(ChallengesAddon plugin, String label, String... string) {
super(plugin, label, string);
// TODO Auto-generated constructor stub
}
@ -45,7 +45,7 @@ public class SetMaxTimes extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
* @see world.bentobox.bbox.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
@ -54,10 +54,10 @@ public class SetMaxTimes extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
* @see world.bentobox.bbox.api.commands.BSBCommand#execute(world.bentobox.bbox.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
// TODO Auto-generated method stub
return false;
}

View File

@ -1,13 +1,13 @@
/**
*
*
*/
package bskyblock.addon.challenges.commands.admin;
import java.util.List;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import bskyblock.addon.challenges.ChallengesAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @author tastybento
@ -20,7 +20,7 @@ public class SetPerm extends CompositeCommand {
* @param label
* @param string
*/
public SetPerm(BSkyBlock plugin, String label, String... string) {
public SetPerm(ChallengesAddon plugin, String label, String... string) {
super(plugin, label, string);
// TODO Auto-generated constructor stub
}
@ -45,7 +45,7 @@ public class SetPerm extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
* @see world.bentobox.bbox.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
@ -54,10 +54,10 @@ public class SetPerm extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
* @see world.bentobox.bbox.api.commands.BSBCommand#execute(world.bentobox.bbox.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
// TODO Auto-generated method stub
return false;
}

View File

@ -1,13 +1,13 @@
/**
*
*
*/
package bskyblock.addon.challenges.commands.admin;
import java.util.List;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import bskyblock.addon.challenges.ChallengesAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @author tastybento
@ -20,7 +20,7 @@ public class SetRepeatable extends CompositeCommand {
* @param label
* @param string
*/
public SetRepeatable(BSkyBlock plugin, String label, String... string) {
public SetRepeatable(ChallengesAddon plugin, String label, String... string) {
super(plugin, label, string);
// TODO Auto-generated constructor stub
}
@ -45,7 +45,7 @@ public class SetRepeatable extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
* @see world.bentobox.bbox.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
@ -54,10 +54,10 @@ public class SetRepeatable extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
* @see world.bentobox.bbox.api.commands.BSBCommand#execute(world.bentobox.bbox.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
// TODO Auto-generated method stub
return false;
}

View File

@ -1,13 +1,13 @@
/**
*
*
*/
package bskyblock.addon.challenges.commands.admin;
import java.util.List;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import bskyblock.addon.challenges.ChallengesAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @author tastybento
@ -20,7 +20,7 @@ public class SetReward extends CompositeCommand {
* @param label
* @param string
*/
public SetReward(BSkyBlock plugin, String label, String... string) {
public SetReward(ChallengesAddon plugin, String label, String... string) {
super(plugin, label, string);
// TODO Auto-generated constructor stub
}
@ -45,7 +45,7 @@ public class SetReward extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
* @see world.bentobox.bbox.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
@ -54,10 +54,10 @@ public class SetReward extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
* @see world.bentobox.bbox.api.commands.BSBCommand#execute(world.bentobox.bbox.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
// TODO Auto-generated method stub
return false;
}

View File

@ -1,13 +1,13 @@
/**
*
*
*/
package bskyblock.addon.challenges.commands.admin;
import java.util.List;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import bskyblock.addon.challenges.ChallengesAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @author tastybento
@ -20,7 +20,7 @@ public class SetType extends CompositeCommand {
* @param label
* @param string
*/
public SetType(BSkyBlock plugin, String label, String... string) {
public SetType(ChallengesAddon plugin, String label, String... string) {
super(plugin, label, string);
// TODO Auto-generated constructor stub
}
@ -45,7 +45,7 @@ public class SetType extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
* @see world.bentobox.bbox.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
@ -54,10 +54,10 @@ public class SetType extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
* @see world.bentobox.bbox.api.commands.BSBCommand#execute(world.bentobox.bbox.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
// TODO Auto-generated method stub
return false;
}

View File

@ -7,7 +7,7 @@ import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import bskyblock.addon.challenges.ChallengesAddon;
import us.tastybento.bskyblock.api.user.User;
import world.bentobox.bentobox.api.user.User;
/**
* Enables the state of a Surrounding Challenge to be stored as it is built

View File

@ -1,13 +1,13 @@
/**
*
*
*/
package bskyblock.addon.challenges.commands.admin;
import java.util.List;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import bskyblock.addon.challenges.ChallengesAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @author tastybento
@ -20,7 +20,7 @@ public class TakeItems extends CompositeCommand {
* @param label
* @param string
*/
public TakeItems(BSkyBlock plugin, String label, String... string) {
public TakeItems(ChallengesAddon plugin, String label, String... string) {
super(plugin, label, string);
// TODO Auto-generated constructor stub
}
@ -45,7 +45,7 @@ public class TakeItems extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
* @see world.bentobox.bbox.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
@ -54,10 +54,10 @@ public class TakeItems extends CompositeCommand {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
* @see world.bentobox.bbox.api.commands.BSBCommand#execute(world.bentobox.bbox.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, List<String> args) {
public boolean execute(User user, String label, List<String> args) {
// TODO Auto-generated method stub
return false;
}

View File

@ -6,8 +6,8 @@ import java.util.List;
import org.bukkit.inventory.ItemStack;
import bskyblock.addon.challenges.ChallengesManager;
import us.tastybento.bskyblock.api.configuration.ConfigComment;
import us.tastybento.bskyblock.database.objects.DataObject;
import world.bentobox.bentobox.api.configuration.ConfigComment;
import world.bentobox.bentobox.database.objects.DataObject;
/**
* Represent a challenge level

View File

@ -13,8 +13,8 @@ import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import bskyblock.addon.challenges.ChallengesManager;
import us.tastybento.bskyblock.api.configuration.ConfigComment;
import us.tastybento.bskyblock.database.objects.DataObject;
import world.bentobox.bentobox.api.configuration.ConfigComment;
import world.bentobox.bentobox.database.objects.DataObject;
/**
* Data object for challenges
@ -43,20 +43,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")
@ -66,7 +66,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")
@ -82,7 +82,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")
@ -202,7 +202,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

@ -1,5 +1,5 @@
/**
*
*
*/
package bskyblock.addon.challenges.database.object;
@ -12,8 +12,8 @@ import org.bukkit.World;
import com.google.gson.annotations.Expose;
import us.tastybento.bskyblock.database.objects.DataObject;
import us.tastybento.bskyblock.util.Util;
import world.bentobox.bentobox.database.objects.DataObject;
import world.bentobox.bentobox.util.Util;
/**
* Stores the player's challenge situation
@ -36,7 +36,7 @@ public class PlayerData implements DataObject {
// Required for bean instantiation
public PlayerData() {}
/**
* Mark a challenge as having been completed. Will increment the number of times and timestamp
* @param challengeName - unique challenge name
@ -47,7 +47,7 @@ public class PlayerData implements DataObject {
challengeStatus.put(name, times);
challengesTimestamp.put(name, System.currentTimeMillis());
}
/**
* Check if a challenge has been done
* @param challengeName - unique challenge name
@ -56,7 +56,7 @@ public class PlayerData implements DataObject {
public boolean isChallengeDone(World world, String challengeName) {
return getTimes(world, challengeName) > 0;
}
/**
* Check how many times a challenge has been done
* @param challengeName - unique challenge name
@ -65,7 +65,7 @@ public class PlayerData implements DataObject {
public int getTimes(World world, String challengeName) {
return challengeStatus.getOrDefault(Util.getWorld(world).getName() + challengeName, 0);
}
/**
* Creates a player data entry
* @param uniqueId - the player's UUID in string format
@ -75,7 +75,7 @@ public class PlayerData implements DataObject {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.database.objects.DataObject#getUniqueId()
* @see world.bentobox.bbox.database.objects.DataObject#getUniqueId()
*/
@Override
public String getUniqueId() {
@ -83,7 +83,7 @@ public class PlayerData implements DataObject {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.database.objects.DataObject#setUniqueId(java.lang.String)
* @see world.bentobox.bbox.database.objects.DataObject#setUniqueId(java.lang.String)
*/
@Override
public void setUniqueId(String uniqueId) {

View File

@ -15,11 +15,11 @@ import bskyblock.addon.challenges.LevelStatus;
import bskyblock.addon.challenges.commands.ChallengesCommand;
import bskyblock.addon.challenges.database.object.Challenges;
import bskyblock.addon.challenges.database.object.Challenges.ChallengeType;
import us.tastybento.bskyblock.api.panels.Panel;
import us.tastybento.bskyblock.api.panels.PanelItem;
import us.tastybento.bskyblock.api.panels.builders.PanelBuilder;
import us.tastybento.bskyblock.api.panels.builders.PanelItemBuilder;
import us.tastybento.bskyblock.api.user.User;
import world.bentobox.bentobox.api.panels.Panel;
import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
import world.bentobox.bentobox.api.user.User;
public class ChallengesPanels {
@ -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());
@ -218,7 +218,7 @@ public class ChallengesPanels {
if (expReward > 0) {
result.addAll(splitTrans(user,"challenges.exp-reward", "[reward]", String.valueOf(expReward)));
}
if (addon.getBSkyBlock().getSettings().isUseEconomy() && moneyReward > 0) {
if (addon.getPlugin().getSettings().isUseEconomy() && moneyReward > 0) {
result.addAll(splitTrans(user,"challenges.money-reward", "[reward]", String.valueOf(moneyReward)));
}
// Final placeholder change for [label]

View File

@ -4,8 +4,8 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import bskyblock.addon.challenges.ChallengesAddon;
import us.tastybento.bskyblock.api.panels.PanelListener;
import us.tastybento.bskyblock.api.user.User;
import world.bentobox.bentobox.api.panels.PanelListener;
import world.bentobox.bentobox.api.user.User;
public class CreateChallengeListener implements PanelListener {

View File

@ -1,8 +1,8 @@
package bskyblock.addon.challenges.panel;
import bskyblock.addon.challenges.ChallengesAddon;
import us.tastybento.bskyblock.api.panels.builders.PanelBuilder;
import us.tastybento.bskyblock.api.user.User;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
import world.bentobox.bentobox.api.user.User;
public class CreateChallengePanel {

View File

@ -1,5 +1,5 @@
/**
*
*
*/
package bskyblock.addon.challenges.panel;
@ -20,8 +20,8 @@ import bskyblock.addon.challenges.commands.ChallengesCommand;
import bskyblock.addon.challenges.database.object.Challenges;
import bskyblock.addon.challenges.database.object.Challenges.ChallengeType;
import bskyblock.addon.level.Level;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.util.Util;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.Util;
/**
* Run when a user tries to complete a challenge
@ -52,7 +52,7 @@ public class TryToComplete {
this.user = user;
this.manager = manager;
this.challenge = challenge;
// Check if can complete challenge
ChallengeResult result = checkIfCanCompleteChallenge();
if (!result.meetsRequirements) {
@ -93,7 +93,7 @@ public class TryToComplete {
* Checks if a challenge can be completed or not
*/
private ChallengeResult checkIfCanCompleteChallenge() {
// Check if user has the
// Check if user has the
if (!challenge.getLevel().equals(ChallengesManager.FREE) && !manager.isLevelUnlocked(user, challenge.getLevel(), world)) {
user.sendMessage("challenges.errors.challenge-level-not-available");
return new ChallengeResult();
@ -104,7 +104,7 @@ public class TryToComplete {
return new ChallengeResult();
}
// Check repeatability
if (manager.isChallengeComplete(user, challenge.getUniqueId(), world)
if (manager.isChallengeComplete(user, challenge.getUniqueId(), world)
&& (!challenge.isRepeatable() || challenge.getChallengeType().equals(ChallengeType.LEVEL)
|| challenge.getChallengeType().equals(ChallengeType.ISLAND))) {
user.sendMessage("challenges.not-repeatable");
@ -170,7 +170,7 @@ public class TryToComplete {
for (int z = -searchRadius; z <= searchRadius; z++) {
Material mat = user.getWorld().getBlockAt(user.getLocation().add(new Vector(x,y,z))).getType();
// Remove one
blocks.computeIfPresent(mat, (b, amount) -> amount - 1);
blocks.computeIfPresent(mat, (b, amount) -> amount - 1);
// Remove any that have an amount of 0
blocks.entrySet().removeIf(en -> en.getValue() <= 0);
}
@ -241,7 +241,7 @@ public class TryToComplete {
cmd = cmd.substring(6,cmd.length()).replace("[player]", user.getName()).trim();
try {
if (!user.performCommand(cmd)) {
showError(cmd);
showError(cmd);
}
} catch (Exception e) {
showError(cmd);

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();