parent
94161d1df3
commit
a7cd204ec6
|
@ -428,4 +428,5 @@ public class ChallengesManager {
|
|||
Arrays.asList(string.split("\\|")).forEach(line -> result.addAll(Arrays.asList(WordUtils.wrap(line,25).split("\\n"))));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -148,6 +148,4 @@ public class FreshSqueezedChallenges {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -8,6 +8,7 @@ import bskyblock.addon.challenges.database.object.ChallengeLevels;
|
|||
*
|
||||
*/
|
||||
public class LevelStatus {
|
||||
|
||||
private final ChallengeLevels level;
|
||||
private final ChallengeLevels previousLevel;
|
||||
private final int numberOfChallengesStillToDo;
|
||||
|
@ -29,30 +30,35 @@ public class LevelStatus {
|
|||
this.complete = complete;
|
||||
this.isUnlocked = isUnlocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level
|
||||
*/
|
||||
public ChallengeLevels getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the numberOfChallengesStillToDo
|
||||
*/
|
||||
public int getNumberOfChallengesStillToDo() {
|
||||
return numberOfChallengesStillToDo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the previousLevel
|
||||
*/
|
||||
public ChallengeLevels getPreviousLevel() {
|
||||
return previousLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the complete
|
||||
*/
|
||||
public boolean isComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isUnlocked
|
||||
*/
|
||||
|
@ -60,5 +66,4 @@ public class LevelStatus {
|
|||
return isUnlocked;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -18,6 +18,7 @@ import org.bukkit.potion.PotionType;
|
|||
public class ParseItem {
|
||||
|
||||
private final ItemStack item;
|
||||
|
||||
private ChallengesAddon addon;
|
||||
|
||||
public ParseItem(ChallengesAddon addon, String s) {
|
||||
|
@ -137,4 +138,5 @@ public class ParseItem {
|
|||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,12 +3,13 @@ package bskyblock.addon.challenges.commands;
|
|||
import java.util.List;
|
||||
|
||||
import bskyblock.addon.challenges.ChallengesAddon;
|
||||
import us.tastybento.bskyblock.Constants;
|
||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
|
||||
public class ChallengesCommand extends CompositeCommand {
|
||||
|
||||
public static final String CHALLENGE_COMMAND = "challenges";
|
||||
|
||||
private ChallengesAddon addon;
|
||||
|
||||
public ChallengesCommand(ChallengesAddon addon) {
|
||||
|
@ -30,11 +31,10 @@ public class ChallengesCommand extends CompositeCommand {
|
|||
@Override
|
||||
public void setup() {
|
||||
this.setOnlyPlayer(true);
|
||||
this.setPermission(Constants.PERMPREFIX + CHALLENGE_COMMAND);
|
||||
this.setPermission("bskyblock." + CHALLENGE_COMMAND);
|
||||
this.setParameters(CHALLENGE_COMMAND + ".parameters");
|
||||
this.setDescription(CHALLENGE_COMMAND + ".description");
|
||||
this.setOnlyPlayer(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -3,12 +3,13 @@ package bskyblock.addon.challenges.commands.admin;
|
|||
import java.util.List;
|
||||
|
||||
import bskyblock.addon.challenges.ChallengesAddon;
|
||||
import us.tastybento.bskyblock.Constants;
|
||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
|
||||
public class ChallengesAdminCommand extends CompositeCommand {
|
||||
|
||||
private static final String CHALLENGE_ADMIN_COMMAND = "cadmin";
|
||||
|
||||
private ChallengesAddon addon;
|
||||
|
||||
public ChallengesAdminCommand(ChallengesAddon addon) {
|
||||
|
@ -32,8 +33,8 @@ public class ChallengesAdminCommand extends CompositeCommand {
|
|||
@Override
|
||||
public void setup() {
|
||||
this.setOnlyPlayer(true);
|
||||
this.setPermission(Constants.PERMPREFIX + "challenges.admin");
|
||||
this.setParameters("challaneges.admin.parameters");
|
||||
this.setPermission("bskyblock.challenges.admin");
|
||||
this.setParameters("challenges.admin.parameters");
|
||||
this.setDescription("challenges.admin.description");
|
||||
this.setOnlyPlayer(true);
|
||||
}
|
||||
|
|
|
@ -4,14 +4,12 @@ import java.util.List;
|
|||
|
||||
import bskyblock.addon.challenges.ChallengesAddon;
|
||||
import bskyblock.addon.challenges.panel.CreateChallengeListener;
|
||||
import us.tastybento.bskyblock.Constants;
|
||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||
import us.tastybento.bskyblock.api.panels.builders.PanelBuilder;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
|
||||
public class CreateChallenge extends CompositeCommand {
|
||||
|
||||
|
||||
private ChallengesAddon addon;
|
||||
|
||||
/**
|
||||
|
@ -22,14 +20,13 @@ public class CreateChallenge extends CompositeCommand {
|
|||
super(parent, "create");
|
||||
this.addon = addon;
|
||||
new CreateSurrounding(addon, this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
this.setOnlyPlayer(true);
|
||||
this.setPermission(Constants.PERMPREFIX + "admin.challenges");
|
||||
this.setParameters("challaneges.admin.create.parameters");
|
||||
this.setPermission("bskyblock.admin.challenges");
|
||||
this.setParameters("challenges.admin.create.parameters");
|
||||
this.setDescription("challenges.admin.create.description");
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import bskyblock.addon.challenges.ChallengesAddon;
|
||||
import us.tastybento.bskyblock.Constants;
|
||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.util.Util;
|
||||
|
@ -29,8 +28,8 @@ import us.tastybento.bskyblock.util.Util;
|
|||
*/
|
||||
public class CreateSurrounding extends CompositeCommand implements Listener {
|
||||
|
||||
|
||||
private ChallengesAddon addon;
|
||||
|
||||
HashMap<UUID,SurroundChallengeBuilder> inProgress = new HashMap<>();
|
||||
|
||||
/**
|
||||
|
@ -46,7 +45,7 @@ public class CreateSurrounding extends CompositeCommand implements Listener {
|
|||
@Override
|
||||
public void setup() {
|
||||
this.setOnlyPlayer(true);
|
||||
this.setPermission(Constants.PERMPREFIX + "admin.challenges");
|
||||
this.setPermission("bskyblock.admin.challenges");
|
||||
this.setParameters("challaneges.admin.create.surrounding.parameters");
|
||||
this.setDescription("challenges.admin.create.surrounding.description");
|
||||
}
|
||||
|
@ -123,5 +122,4 @@ public class CreateSurrounding extends CompositeCommand implements Listener {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -15,6 +15,7 @@ import us.tastybento.bskyblock.api.user.User;
|
|||
*
|
||||
*/
|
||||
public class SurroundChallengeBuilder {
|
||||
|
||||
private ChallengesAddon addon;
|
||||
private String name;
|
||||
private User owner;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -16,7 +16,6 @@ import us.tastybento.bskyblock.database.objects.DataObject;
|
|||
*/
|
||||
public class ChallengeLevels implements DataObject, Comparable<ChallengeLevels> {
|
||||
|
||||
|
||||
@ConfigComment("A friendly name for the level. If blank, level name is used.")
|
||||
private String friendlyName = "";
|
||||
|
||||
|
|
|
@ -610,4 +610,5 @@ public class Challenges implements DataObject {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package bskyblock.addon.challenges.database.object;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -94,24 +91,28 @@ public class PlayerData implements DataObject {
|
|||
public Map<String, Integer> getChallengeStatus() {
|
||||
return challengeStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param challengeStatus the challengeStatus to set
|
||||
*/
|
||||
public void setChallengeStatus(Map<String, Integer> challengeStatus) {
|
||||
this.challengeStatus = challengeStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the challengesTimestamp
|
||||
*/
|
||||
public Map<String, Long> getChallengesTimestamp() {
|
||||
return challengesTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param challengesTimestamp the challengesTimestamp to set
|
||||
*/
|
||||
public void setChallengesTimestamp(Map<String, Long> challengesTimestamp) {
|
||||
this.challengesTimestamp = challengesTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the levelsDone
|
||||
*/
|
||||
|
|
|
@ -14,16 +14,16 @@ 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.Constants;
|
||||
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;
|
||||
|
||||
|
||||
public class ChallengesPanels {
|
||||
|
||||
private ChallengesAddon addon;
|
||||
|
||||
private ChallengesManager manager;
|
||||
|
||||
public ChallengesPanels(ChallengesAddon plugin, ChallengesManager manager){
|
||||
|
@ -163,8 +163,8 @@ public class ChallengesPanels {
|
|||
if (!level.isEmpty()) {
|
||||
result.addAll(splitTrans(user, "challenges.level", "[level]", level));
|
||||
}
|
||||
// Check if completed or not
|
||||
|
||||
// Check if completed or not
|
||||
boolean complete = addon.getChallengesManager().isChallengeComplete(user, challenge.getUniqueId());
|
||||
int maxTimes = challenge.getMaxTimes();
|
||||
long doneTimes = addon.getChallengesManager().checkChallengeTimes(user, challenge);
|
||||
|
@ -215,7 +215,6 @@ public class ChallengesPanels {
|
|||
if (!rewardText.isEmpty()) {
|
||||
result.addAll(splitTrans(user, "challenges.repeat-rewards"));
|
||||
}
|
||||
|
||||
}
|
||||
if (!rewardText.isEmpty()) {
|
||||
result.addAll(splitTrans(user,rewardText));
|
||||
|
@ -227,11 +226,12 @@ public class ChallengesPanels {
|
|||
result.addAll(splitTrans(user,"challenges.money-reward", "[reward]", String.valueOf(moneyReward)));
|
||||
}
|
||||
// Final placeholder change for [label]
|
||||
result.replaceAll(x -> x.replace("[label]", Constants.ISLANDCOMMAND));
|
||||
result.replaceAll(x -> x.replace("[label]", "island"));
|
||||
return result;
|
||||
}
|
||||
|
||||
private Collection<? extends String> splitTrans(User user, String string, String...strings) {
|
||||
return addon.getChallengesManager().stringSplit(user.getTranslation(string, strings));
|
||||
}
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ import us.tastybento.bskyblock.api.user.User;
|
|||
public class CreateChallengeListener implements PanelListener {
|
||||
|
||||
private ChallengesAddon addon;
|
||||
|
||||
private User user;
|
||||
|
||||
public CreateChallengeListener(ChallengesAddon addon, User user) {
|
||||
|
@ -32,4 +33,5 @@ public class CreateChallengeListener implements PanelListener {
|
|||
// Allow drag and drop
|
||||
event.setCancelled(false);
|
||||
}
|
||||
|
||||
}
|
|
@ -19,7 +19,7 @@ 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.Constants;
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.util.Util;
|
||||
|
||||
|
@ -30,6 +30,8 @@ import us.tastybento.bskyblock.util.Util;
|
|||
*/
|
||||
public class TryToComplete {
|
||||
|
||||
private BSkyBlock bSkyBlock;
|
||||
|
||||
private ChallengesAddon addon;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +43,7 @@ public class TryToComplete {
|
|||
public TryToComplete(ChallengesAddon addon, User user, ChallengesManager manager, Challenges challenge) {
|
||||
this.addon = addon;
|
||||
// Check if user is in the worlds
|
||||
if (!Util.inWorld(user.getLocation())) {
|
||||
if (!Util.sameWorld(bSkyBlock.getIWM().getIslandWorld(), user.getLocation().getWorld())) {
|
||||
user.sendMessage("general.errors.wrong-world");
|
||||
return;
|
||||
}
|
||||
|
@ -136,12 +138,12 @@ public class TryToComplete {
|
|||
private ChallengeResult checkLevel(User user, Challenges challenge) {
|
||||
// Check if the level addon is installed or not
|
||||
return addon.getAddonByName("BSkyBlock-Level")
|
||||
.map(l -> ((Level)l).getIslandLevel(user.getUniqueId()) >= challenge.getReqIslandlevel() ? new ChallengeResult().setMeetsRequirements() : new ChallengeResult()
|
||||
.map(l -> ((Level)l).getIslandLevel(bSkyBlock.getIWM().getIslandWorld(), user.getUniqueId()) >= challenge.getReqIslandlevel() ? new ChallengeResult().setMeetsRequirements() : new ChallengeResult()
|
||||
).orElse(new ChallengeResult());
|
||||
}
|
||||
|
||||
private ChallengeResult checkSurrounding(User user, Challenges challenge) {
|
||||
if (!addon.getIslands().userIsOnIsland(user)) {
|
||||
if (!addon.getIslands().userIsOnIsland(bSkyBlock.getIWM().getIslandWorld(), user)) {
|
||||
// Player is not on island
|
||||
user.sendMessage("challenges.error.not-on-island");
|
||||
return new ChallengeResult();
|
||||
|
@ -223,7 +225,7 @@ public class TryToComplete {
|
|||
|
||||
private void runCommands(User player, List<String> commands) {
|
||||
// Ignore commands with this perm
|
||||
if (player.hasPermission(Constants.PERMPREFIX + "command.challengeexempt") && !player.isOp()) {
|
||||
if (player.hasPermission("bskyblock.command.challengeexempt") && !player.isOp()) {
|
||||
return;
|
||||
}
|
||||
for (String cmd : commands) {
|
||||
|
@ -255,6 +257,6 @@ public class TryToComplete {
|
|||
private void showError(final String cmd) {
|
||||
addon.getLogger().severe("Problem executing command executed by player - skipping!");
|
||||
addon.getLogger().severe(() -> "Command was : " + cmd);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue