mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-28 13:36:06 +01:00
Updated to new package name
This commit is contained in:
parent
2d25850b3a
commit
353a9c3309
@ -4,8 +4,8 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
import bskyblock.addon.challenges.commands.ChallengesCommand;
|
import bskyblock.addon.challenges.commands.ChallengesCommand;
|
||||||
import bskyblock.addon.challenges.commands.admin.ChallengesAdminImportCommand;
|
import bskyblock.addon.challenges.commands.admin.ChallengesAdminImportCommand;
|
||||||
import world.bentobox.bbox.api.addons.Addon;
|
import world.bentobox.bentobox.api.addons.Addon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add-on to BSkyBlock that enables challenges
|
* Add-on to BSkyBlock that enables challenges
|
||||||
|
@ -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.Challenges.ChallengeType;
|
||||||
import bskyblock.addon.challenges.database.object.PlayerData;
|
import bskyblock.addon.challenges.database.object.PlayerData;
|
||||||
import bskyblock.addon.challenges.panel.ChallengesPanels;
|
import bskyblock.addon.challenges.panel.ChallengesPanels;
|
||||||
import world.bentobox.bbox.api.configuration.BSBConfig;
|
import world.bentobox.bentobox.api.configuration.BSBConfig;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bbox.database.BSBDatabase;
|
import world.bentobox.bentobox.database.BSBDatabase;
|
||||||
import world.bentobox.bbox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
public class ChallengesManager {
|
public class ChallengesManager {
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import bskyblock.addon.challenges.database.object.ChallengeLevels;
|
import bskyblock.addon.challenges.database.object.ChallengeLevels;
|
||||||
import bskyblock.addon.challenges.database.object.Challenges;
|
import bskyblock.addon.challenges.database.object.Challenges;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bbox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Imports challenges
|
* Imports challenges
|
||||||
@ -42,7 +42,7 @@ public class FreshSqueezedChallenges {
|
|||||||
addon.saveResource("challenges.yml",false);
|
addon.saveResource("challenges.yml",false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import challenges
|
* Import challenges
|
||||||
* @param user - user
|
* @param user - user
|
||||||
@ -101,8 +101,8 @@ public class FreshSqueezedChallenges {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Imports challenges
|
* Imports challenges
|
||||||
* @param overwrite
|
* @param overwrite
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
private void makeChallenges(User user, World world, boolean overwrite) {
|
private void makeChallenges(User user, World world, boolean overwrite) {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
@ -114,7 +114,7 @@ public class FreshSqueezedChallenges {
|
|||||||
newChallenge.setDeployed(true);
|
newChallenge.setDeployed(true);
|
||||||
ConfigurationSection details = chals.getConfigurationSection(challenge);
|
ConfigurationSection details = chals.getConfigurationSection(challenge);
|
||||||
newChallenge.setFriendlyName(details.getString("friendlyname", 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.setDescription(addon.getChallengesManager().stringSplit(details.getString("description", "")));
|
||||||
newChallenge.setIcon(new ParseItem(addon, details.getString("icon") + ":1").getItem());
|
newChallenge.setIcon(new ParseItem(addon, details.getString("icon") + ":1").getItem());
|
||||||
newChallenge.setLevel(details.getString("level", ChallengesManager.FREE));
|
newChallenge.setLevel(details.getString("level", ChallengesManager.FREE));
|
||||||
|
@ -4,8 +4,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import bskyblock.addon.challenges.panel.ChallengesPanels;
|
import bskyblock.addon.challenges.panel.ChallengesPanels;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
public class ChallengesCommand extends CompositeCommand {
|
public class ChallengesCommand extends CompositeCommand {
|
||||||
public static final String CHALLENGE_COMMAND = "challenges";
|
public static final String CHALLENGE_COMMAND = "challenges";
|
||||||
|
@ -5,9 +5,9 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bbox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
public class ChallengesAdminImportCommand extends CompositeCommand {
|
public class ChallengesAdminImportCommand extends CompositeCommand {
|
||||||
|
|
||||||
|
@ -4,9 +4,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import bskyblock.addon.challenges.panel.CreateChallengeListener;
|
import bskyblock.addon.challenges.panel.CreateChallengeListener;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.panels.builders.PanelBuilder;
|
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
public class CreateChallenge extends CompositeCommand {
|
public class CreateChallenge extends CompositeCommand {
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bbox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command to create a surrounding type challenge
|
* Command to create a surrounding type challenge
|
||||||
|
@ -6,8 +6,8 @@ package bskyblock.addon.challenges.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
|
@ -6,8 +6,8 @@ package bskyblock.addon.challenges.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
|
@ -6,8 +6,8 @@ package bskyblock.addon.challenges.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
|
@ -6,8 +6,8 @@ package bskyblock.addon.challenges.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
|
@ -6,8 +6,8 @@ package bskyblock.addon.challenges.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
|
@ -9,8 +9,8 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import bskyblock.addon.challenges.database.object.Challenges;
|
import bskyblock.addon.challenges.database.object.Challenges;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
|
@ -6,8 +6,8 @@ package bskyblock.addon.challenges.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
|
@ -6,8 +6,8 @@ package bskyblock.addon.challenges.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
|
@ -6,8 +6,8 @@ package bskyblock.addon.challenges.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
|
@ -6,8 +6,8 @@ package bskyblock.addon.challenges.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
|
@ -6,8 +6,8 @@ package bskyblock.addon.challenges.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
|
@ -6,8 +6,8 @@ package bskyblock.addon.challenges.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
|
@ -7,7 +7,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables the state of a Surrounding Challenge to be stored as it is built
|
* Enables the state of a Surrounding Challenge to be stored as it is built
|
||||||
|
@ -6,8 +6,8 @@ package bskyblock.addon.challenges.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
|
@ -6,8 +6,8 @@ import java.util.List;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesManager;
|
import bskyblock.addon.challenges.ChallengesManager;
|
||||||
import world.bentobox.bbox.api.configuration.ConfigComment;
|
import world.bentobox.bentobox.api.configuration.ConfigComment;
|
||||||
import world.bentobox.bbox.database.objects.DataObject;
|
import world.bentobox.bentobox.database.objects.DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represent a challenge level
|
* Represent a challenge level
|
||||||
|
@ -13,8 +13,8 @@ import org.bukkit.entity.EntityType;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesManager;
|
import bskyblock.addon.challenges.ChallengesManager;
|
||||||
import world.bentobox.bbox.api.configuration.ConfigComment;
|
import world.bentobox.bentobox.api.configuration.ConfigComment;
|
||||||
import world.bentobox.bbox.database.objects.DataObject;
|
import world.bentobox.bentobox.database.objects.DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data object for challenges
|
* Data object for challenges
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package bskyblock.addon.challenges.database.object;
|
package bskyblock.addon.challenges.database.object;
|
||||||
|
|
||||||
@ -12,8 +12,8 @@ import org.bukkit.World;
|
|||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
|
|
||||||
import world.bentobox.bbox.database.objects.DataObject;
|
import world.bentobox.bentobox.database.objects.DataObject;
|
||||||
import world.bentobox.bbox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the player's challenge situation
|
* Stores the player's challenge situation
|
||||||
@ -36,7 +36,7 @@ public class PlayerData implements DataObject {
|
|||||||
|
|
||||||
// Required for bean instantiation
|
// Required for bean instantiation
|
||||||
public PlayerData() {}
|
public PlayerData() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark a challenge as having been completed. Will increment the number of times and timestamp
|
* Mark a challenge as having been completed. Will increment the number of times and timestamp
|
||||||
* @param challengeName - unique challenge name
|
* @param challengeName - unique challenge name
|
||||||
@ -47,7 +47,7 @@ public class PlayerData implements DataObject {
|
|||||||
challengeStatus.put(name, times);
|
challengeStatus.put(name, times);
|
||||||
challengesTimestamp.put(name, System.currentTimeMillis());
|
challengesTimestamp.put(name, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a challenge has been done
|
* Check if a challenge has been done
|
||||||
* @param challengeName - unique challenge name
|
* @param challengeName - unique challenge name
|
||||||
@ -56,7 +56,7 @@ public class PlayerData implements DataObject {
|
|||||||
public boolean isChallengeDone(World world, String challengeName) {
|
public boolean isChallengeDone(World world, String challengeName) {
|
||||||
return getTimes(world, challengeName) > 0;
|
return getTimes(world, challengeName) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check how many times a challenge has been done
|
* Check how many times a challenge has been done
|
||||||
* @param challengeName - unique challenge name
|
* @param challengeName - unique challenge name
|
||||||
@ -65,7 +65,7 @@ public class PlayerData implements DataObject {
|
|||||||
public int getTimes(World world, String challengeName) {
|
public int getTimes(World world, String challengeName) {
|
||||||
return challengeStatus.getOrDefault(Util.getWorld(world).getName() + challengeName, 0);
|
return challengeStatus.getOrDefault(Util.getWorld(world).getName() + challengeName, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a player data entry
|
* Creates a player data entry
|
||||||
* @param uniqueId - the player's UUID in string format
|
* @param uniqueId - the player's UUID in string format
|
||||||
|
@ -15,11 +15,11 @@ import bskyblock.addon.challenges.LevelStatus;
|
|||||||
import bskyblock.addon.challenges.commands.ChallengesCommand;
|
import bskyblock.addon.challenges.commands.ChallengesCommand;
|
||||||
import bskyblock.addon.challenges.database.object.Challenges;
|
import bskyblock.addon.challenges.database.object.Challenges;
|
||||||
import bskyblock.addon.challenges.database.object.Challenges.ChallengeType;
|
import bskyblock.addon.challenges.database.object.Challenges.ChallengeType;
|
||||||
import world.bentobox.bbox.api.panels.Panel;
|
import world.bentobox.bentobox.api.panels.Panel;
|
||||||
import world.bentobox.bbox.api.panels.PanelItem;
|
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||||
import world.bentobox.bbox.api.panels.builders.PanelBuilder;
|
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||||
import world.bentobox.bbox.api.panels.builders.PanelItemBuilder;
|
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
|
|
||||||
public class ChallengesPanels {
|
public class ChallengesPanels {
|
||||||
|
@ -4,8 +4,8 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.panels.PanelListener;
|
import world.bentobox.bentobox.api.panels.PanelListener;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
public class CreateChallengeListener implements PanelListener {
|
public class CreateChallengeListener implements PanelListener {
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package bskyblock.addon.challenges.panel;
|
package bskyblock.addon.challenges.panel;
|
||||||
|
|
||||||
import bskyblock.addon.challenges.ChallengesAddon;
|
import bskyblock.addon.challenges.ChallengesAddon;
|
||||||
import world.bentobox.bbox.api.panels.builders.PanelBuilder;
|
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
public class CreateChallengePanel {
|
public class CreateChallengePanel {
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package bskyblock.addon.challenges.panel;
|
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;
|
||||||
import bskyblock.addon.challenges.database.object.Challenges.ChallengeType;
|
import bskyblock.addon.challenges.database.object.Challenges.ChallengeType;
|
||||||
import bskyblock.addon.level.Level;
|
import bskyblock.addon.level.Level;
|
||||||
import world.bentobox.bbox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bbox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run when a user tries to complete a challenge
|
* Run when a user tries to complete a challenge
|
||||||
@ -52,7 +52,7 @@ public class TryToComplete {
|
|||||||
this.user = user;
|
this.user = user;
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.challenge = challenge;
|
this.challenge = challenge;
|
||||||
|
|
||||||
// Check if can complete challenge
|
// Check if can complete challenge
|
||||||
ChallengeResult result = checkIfCanCompleteChallenge();
|
ChallengeResult result = checkIfCanCompleteChallenge();
|
||||||
if (!result.meetsRequirements) {
|
if (!result.meetsRequirements) {
|
||||||
@ -93,7 +93,7 @@ public class TryToComplete {
|
|||||||
* Checks if a challenge can be completed or not
|
* Checks if a challenge can be completed or not
|
||||||
*/
|
*/
|
||||||
private ChallengeResult checkIfCanCompleteChallenge() {
|
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)) {
|
if (!challenge.getLevel().equals(ChallengesManager.FREE) && !manager.isLevelUnlocked(user, challenge.getLevel(), world)) {
|
||||||
user.sendMessage("challenges.errors.challenge-level-not-available");
|
user.sendMessage("challenges.errors.challenge-level-not-available");
|
||||||
return new ChallengeResult();
|
return new ChallengeResult();
|
||||||
@ -104,7 +104,7 @@ public class TryToComplete {
|
|||||||
return new ChallengeResult();
|
return new ChallengeResult();
|
||||||
}
|
}
|
||||||
// Check repeatability
|
// Check repeatability
|
||||||
if (manager.isChallengeComplete(user, challenge.getUniqueId(), world)
|
if (manager.isChallengeComplete(user, challenge.getUniqueId(), world)
|
||||||
&& (!challenge.isRepeatable() || challenge.getChallengeType().equals(ChallengeType.LEVEL)
|
&& (!challenge.isRepeatable() || challenge.getChallengeType().equals(ChallengeType.LEVEL)
|
||||||
|| challenge.getChallengeType().equals(ChallengeType.ISLAND))) {
|
|| challenge.getChallengeType().equals(ChallengeType.ISLAND))) {
|
||||||
user.sendMessage("challenges.not-repeatable");
|
user.sendMessage("challenges.not-repeatable");
|
||||||
@ -170,7 +170,7 @@ public class TryToComplete {
|
|||||||
for (int z = -searchRadius; z <= searchRadius; z++) {
|
for (int z = -searchRadius; z <= searchRadius; z++) {
|
||||||
Material mat = user.getWorld().getBlockAt(user.getLocation().add(new Vector(x,y,z))).getType();
|
Material mat = user.getWorld().getBlockAt(user.getLocation().add(new Vector(x,y,z))).getType();
|
||||||
// Remove one
|
// Remove one
|
||||||
blocks.computeIfPresent(mat, (b, amount) -> amount - 1);
|
blocks.computeIfPresent(mat, (b, amount) -> amount - 1);
|
||||||
// Remove any that have an amount of 0
|
// Remove any that have an amount of 0
|
||||||
blocks.entrySet().removeIf(en -> en.getValue() <= 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();
|
cmd = cmd.substring(6,cmd.length()).replace("[player]", user.getName()).trim();
|
||||||
try {
|
try {
|
||||||
if (!user.performCommand(cmd)) {
|
if (!user.performCommand(cmd)) {
|
||||||
showError(cmd);
|
showError(cmd);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
showError(cmd);
|
showError(cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user