Added auto hiding bossbar
This commit is contained in:
parent
2b9d6c0160
commit
b8114ba0d3
|
|
@ -1,10 +1,10 @@
|
||||||
package com.alttd.altitudequests.config;
|
package com.alttd.altitudequests.config;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class Config extends AbstractConfig {
|
public final class Config extends AbstractConfig {
|
||||||
|
|
||||||
static Config config;
|
static Config config;
|
||||||
static int version;
|
static int version;
|
||||||
public Config() {
|
public Config() {
|
||||||
|
|
@ -58,9 +58,11 @@ public final class Config extends AbstractConfig {
|
||||||
|
|
||||||
public static String NPC_NAME = "<light_purple>Scruff</light_purple>";
|
public static String NPC_NAME = "<light_purple>Scruff</light_purple>";
|
||||||
public static boolean DEBUG = false;
|
public static boolean DEBUG = false;
|
||||||
|
public static Duration BOSS_BAR_AUTO_HIDE;
|
||||||
private static void loadSettings() {
|
private static void loadSettings() {
|
||||||
NPC_NAME = config.getString("settings.npc-name", NPC_NAME);
|
NPC_NAME = config.getString("settings.npc-name", NPC_NAME);
|
||||||
DEBUG = config.getBoolean("settings.debug", DEBUG);
|
DEBUG = config.getBoolean("settings.debug", DEBUG);
|
||||||
|
BOSS_BAR_AUTO_HIDE = Duration.ofSeconds(config.getInt("settings.boss-bar-auto-hide-seconds", 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int MINE_QUEST_FREQ = 1;
|
public static int MINE_QUEST_FREQ = 1;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.alttd.altitudequests.config.Config;
|
||||||
import com.alttd.altitudequests.config.MessagesConfig;
|
import com.alttd.altitudequests.config.MessagesConfig;
|
||||||
import com.alttd.altitudequests.database.Database;
|
import com.alttd.altitudequests.database.Database;
|
||||||
import com.alttd.altitudequests.objects.quests.*;
|
import com.alttd.altitudequests.objects.quests.*;
|
||||||
|
import com.alttd.altitudequests.util.AutoHideBossBar;
|
||||||
import com.alttd.altitudequests.util.Logger;
|
import com.alttd.altitudequests.util.Logger;
|
||||||
import com.alttd.altitudequests.util.Utilities;
|
import com.alttd.altitudequests.util.Utilities;
|
||||||
import com.alttd.datalock.DataLockAPI;
|
import com.alttd.datalock.DataLockAPI;
|
||||||
|
|
@ -26,7 +27,7 @@ import java.util.stream.Collectors;
|
||||||
public abstract class Quest {
|
public abstract class Quest {
|
||||||
|
|
||||||
private static final HashMap<UUID, Quest> dailyQuests = new HashMap<>();
|
private static final HashMap<UUID, Quest> dailyQuests = new HashMap<>();
|
||||||
// private static Quest weeklyQuest = null;
|
// private static Quest weeklyQuest = null;
|
||||||
private static final List<Class<? extends Quest>> possibleQuests = new ArrayList<>();
|
private static final List<Class<? extends Quest>> possibleQuests = new ArrayList<>();
|
||||||
|
|
||||||
static { // maybe make this make more sense idk
|
static { // maybe make this make more sense idk
|
||||||
|
|
@ -49,6 +50,10 @@ public abstract class Quest {
|
||||||
private boolean isDone;
|
private boolean isDone;
|
||||||
private boolean rewardReceived;
|
private boolean rewardReceived;
|
||||||
private final int amount;
|
private final int amount;
|
||||||
|
// private final BossBar barProgressOne;
|
||||||
|
// private final BossBar barProgressTwo;
|
||||||
|
private final AutoHideBossBar barProgressOne;
|
||||||
|
private final AutoHideBossBar barProgressTwo;
|
||||||
|
|
||||||
public static synchronized void putDailyQuest(UUID uuid, Quest quest) {
|
public static synchronized void putDailyQuest(UUID uuid, Quest quest) {
|
||||||
dailyQuests.put(uuid, quest);
|
dailyQuests.put(uuid, quest);
|
||||||
|
|
@ -74,8 +79,8 @@ public abstract class Quest {
|
||||||
dailyQuests.clear();
|
dailyQuests.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Quest(UUID uuid, int step1, int step2, Variant variant, int amount, boolean rewardReceived) {
|
public Quest(Player player, int step1, int step2, Variant variant, int amount, boolean rewardReceived) throws Exception {
|
||||||
this.uuid = uuid;
|
this.uuid = player.getUniqueId();
|
||||||
this.step1 = step1;
|
this.step1 = step1;
|
||||||
this.step2 = step2;
|
this.step2 = step2;
|
||||||
this.variant = variant;
|
this.variant = variant;
|
||||||
|
|
@ -83,11 +88,14 @@ public abstract class Quest {
|
||||||
this.rewardReceived = rewardReceived;
|
this.rewardReceived = rewardReceived;
|
||||||
if (variant == null) {
|
if (variant == null) {
|
||||||
Logger.warning("Created % quest without a variant for %", this.getClass().getName(), uuid.toString());
|
Logger.warning("Created % quest without a variant for %", this.getClass().getName(), uuid.toString());
|
||||||
|
throw new Exception("Invalid variant");
|
||||||
}
|
}
|
||||||
if (variant != null && amount == -1)
|
if (amount == -1)
|
||||||
this.amount = variant.calculateAmount(loadQuestsDoneThisMonth(uuid));
|
this.amount = variant.calculateAmount(loadQuestsDoneThisMonth(uuid));
|
||||||
else
|
else
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
|
this.barProgressOne = new AutoHideBossBar(player, variant, "1");
|
||||||
|
this.barProgressTwo = new AutoHideBossBar(player, variant, "2");
|
||||||
}
|
}
|
||||||
|
|
||||||
private int loadQuestsDoneThisMonth(UUID uuid) {
|
private int loadQuestsDoneThisMonth(UUID uuid) {
|
||||||
|
|
@ -116,12 +124,17 @@ public abstract class Quest {
|
||||||
|
|
||||||
Class<? extends Quest> questClass = possibleQuests.get(Utilities.randomOr0(possibleQuests.size() - 1));
|
Class<? extends Quest> questClass = possibleQuests.get(Utilities.randomOr0(possibleQuests.size() - 1));
|
||||||
try {
|
try {
|
||||||
Constructor<? extends Quest> constructor = questClass.getDeclaredConstructor(UUID.class);
|
Constructor<? extends Quest> constructor = questClass.getDeclaredConstructor(Player.class);
|
||||||
putDailyQuest(player.getUniqueId(), constructor.newInstance(player.getUniqueId()));
|
putDailyQuest(player.getUniqueId(), constructor.newInstance(player));
|
||||||
} catch (InvocationTargetException | IllegalAccessException | InstantiationException | NoSuchMethodException e) {
|
} catch (InvocationTargetException | IllegalAccessException | InstantiationException |
|
||||||
|
NoSuchMethodException e) {
|
||||||
player.sendMiniMessage("<red>Unable to create quest, contact an admin</red>", null);
|
player.sendMiniMessage("<red>Unable to create quest, contact an admin</red>", null);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Logger.severe("% does not have a constructor with a UUID input or has improper access.", questClass.getName());
|
Logger.severe("% does not have a constructor with a Player input or has improper access.", questClass.getName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
player.sendMiniMessage("<red>Unable to create quest, contact an admin</red>", null);
|
||||||
|
e.printStackTrace();
|
||||||
|
Logger.severe("% could not be created due to invalid namespace key or variant.", questClass.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,7 +142,7 @@ public abstract class Quest {
|
||||||
// Quest.weeklyQuest = newQuest;
|
// Quest.weeklyQuest = newQuest;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// private static final HashSet<UUID> queriedUsers = new HashSet<>();
|
// private static final HashSet<UUID> queriedUsers = new HashSet<>();
|
||||||
public static void tryLoadDailyQuest(UUID uuid) {
|
public static void tryLoadDailyQuest(UUID uuid) {
|
||||||
// if (queriedUsers.contains(uuid))
|
// if (queriedUsers.contains(uuid))
|
||||||
// return;
|
// return;
|
||||||
|
|
@ -184,7 +197,8 @@ public abstract class Quest {
|
||||||
constructor = aClass.getConstructor(UUID.class, int.class, int.class, String.class, int.class, boolean.class);
|
constructor = aClass.getConstructor(UUID.class, int.class, int.class, String.class, int.class, boolean.class);
|
||||||
Quest quest1 = constructor.newInstance(uuid, step_1_progress, step_2_progress, quest_variant, amount, turnedIn);
|
Quest quest1 = constructor.newInstance(uuid, step_1_progress, step_2_progress, quest_variant, amount, turnedIn);
|
||||||
putDailyQuest(uuid, quest1);
|
putDailyQuest(uuid, quest1);
|
||||||
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
|
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException |
|
||||||
|
InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -289,6 +303,7 @@ public abstract class Quest {
|
||||||
|
|
||||||
public void addStep1(int step1) {
|
public void addStep1(int step1) {
|
||||||
this.step1 += step1;
|
this.step1 += step1;
|
||||||
|
barProgressOne.show(((double) getAmount()) / getStep1());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStep2() {
|
public int getStep2() {
|
||||||
|
|
@ -297,6 +312,7 @@ public abstract class Quest {
|
||||||
|
|
||||||
public void addStep2(int step2) {
|
public void addStep2(int step2) {
|
||||||
this.step2 += step2;
|
this.step2 += step2;
|
||||||
|
barProgressTwo.show(((double) getAmount()) / getStep2());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDone(boolean done) {
|
public void setDone(boolean done) {
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,14 @@ import org.bukkit.entity.Player;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class BreedMobsQuest extends Quest {
|
public class BreedMobsQuest extends Quest {
|
||||||
|
|
||||||
private final BreedMobsQuestObject breedMobsQuestObject;
|
private final BreedMobsQuestObject breedMobsQuestObject;
|
||||||
|
|
||||||
public BreedMobsQuest(UUID uuid) {
|
public BreedMobsQuest(Player player) throws Exception {
|
||||||
super(uuid, 0, 0,
|
super(player, 0, 0,
|
||||||
QuestsConfig.BREED_MOB_QUEST.get(Utilities.randomOr0(QuestsConfig.BREED_MOB_QUEST.size() - 1)), -1, false);
|
QuestsConfig.BREED_MOB_QUEST.get(Utilities.randomOr0(QuestsConfig.BREED_MOB_QUEST.size() - 1)), -1, false);
|
||||||
if (getVariant() instanceof BreedMobsQuestObject breedMobsQuestObject)
|
if (getVariant() instanceof BreedMobsQuestObject breedMobsQuestObject)
|
||||||
this.breedMobsQuestObject = breedMobsQuestObject;
|
this.breedMobsQuestObject = breedMobsQuestObject;
|
||||||
|
|
@ -38,8 +37,8 @@ public class BreedMobsQuest extends Quest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BreedMobsQuest(UUID uuid, int step1, int step2, String variant, int amount, boolean rewardReceived) {
|
public BreedMobsQuest(Player player, int step1, int step2, String variant, int amount, boolean rewardReceived) throws Exception {
|
||||||
super(uuid, step1, step2, QuestsConfig.BREED_MOB_QUEST.stream()
|
super(player, step1, step2, QuestsConfig.BREED_MOB_QUEST.stream()
|
||||||
.filter(object -> variant.equals(object.getInternalName()))
|
.filter(object -> variant.equals(object.getInternalName()))
|
||||||
.findAny().orElse(null), amount, rewardReceived);
|
.findAny().orElse(null), amount, rewardReceived);
|
||||||
if (getVariant() instanceof BreedMobsQuestObject breedMobsQuestObject)
|
if (getVariant() instanceof BreedMobsQuestObject breedMobsQuestObject)
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ public class CollectDropsQuest extends Quest {
|
||||||
|
|
||||||
private final CollectDropsQuestObject collectDropsQuestObject;
|
private final CollectDropsQuestObject collectDropsQuestObject;
|
||||||
|
|
||||||
public CollectDropsQuest(UUID uuid) {
|
public CollectDropsQuest(Player player) throws Exception {
|
||||||
super(uuid, 0, 0,
|
super(player, 0, 0,
|
||||||
QuestsConfig.COLLECT_DROPS_QUEST.get(Utilities.randomOr0(QuestsConfig.COLLECT_DROPS_QUEST.size() - 1)), -1, false);
|
QuestsConfig.COLLECT_DROPS_QUEST.get(Utilities.randomOr0(QuestsConfig.COLLECT_DROPS_QUEST.size() - 1)), -1, false);
|
||||||
if (getVariant() instanceof CollectDropsQuestObject collectDropsQuestObject)
|
if (getVariant() instanceof CollectDropsQuestObject collectDropsQuestObject)
|
||||||
this.collectDropsQuestObject = collectDropsQuestObject;
|
this.collectDropsQuestObject = collectDropsQuestObject;
|
||||||
|
|
@ -41,8 +41,8 @@ public class CollectDropsQuest extends Quest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CollectDropsQuest(UUID uuid, int step1, int step2, String variant, int amount, boolean rewardReceived) {
|
public CollectDropsQuest(Player player, int step1, int step2, String variant, int amount, boolean rewardReceived) throws Exception {
|
||||||
super(uuid, step1, step2, QuestsConfig.COLLECT_DROPS_QUEST.stream()
|
super(player, step1, step2, QuestsConfig.COLLECT_DROPS_QUEST.stream()
|
||||||
.filter(object -> variant.equals(object.getInternalName()))
|
.filter(object -> variant.equals(object.getInternalName()))
|
||||||
.findAny().orElse(null), amount, rewardReceived);
|
.findAny().orElse(null), amount, rewardReceived);
|
||||||
if (getVariant() instanceof CollectDropsQuestObject collectDropsQuestObject)
|
if (getVariant() instanceof CollectDropsQuestObject collectDropsQuestObject)
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ public class KillMobsQuest extends Quest {
|
||||||
|
|
||||||
private final KillMobsQuestObject killMobsQuestObject;
|
private final KillMobsQuestObject killMobsQuestObject;
|
||||||
|
|
||||||
public KillMobsQuest(UUID uuid) {
|
public KillMobsQuest(Player player) throws Exception {
|
||||||
super(uuid, 0, 0,
|
super(player, 0, 0,
|
||||||
QuestsConfig.KILL_MOB_QUEST.get(Utilities.randomOr0(QuestsConfig.KILL_MOB_QUEST.size() - 1)), -1, false);
|
QuestsConfig.KILL_MOB_QUEST.get(Utilities.randomOr0(QuestsConfig.KILL_MOB_QUEST.size() - 1)), -1, false);
|
||||||
if (getVariant() instanceof KillMobsQuestObject killMobsQuestObject)
|
if (getVariant() instanceof KillMobsQuestObject killMobsQuestObject)
|
||||||
this.killMobsQuestObject = killMobsQuestObject;
|
this.killMobsQuestObject = killMobsQuestObject;
|
||||||
|
|
@ -38,8 +38,8 @@ public class KillMobsQuest extends Quest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public KillMobsQuest(UUID uuid, int step1, int step2, String variant, int amount, boolean rewardReceived) {
|
public KillMobsQuest(Player player, int step1, int step2, String variant, int amount, boolean rewardReceived) throws Exception {
|
||||||
super(uuid, step1, step2, QuestsConfig.KILL_MOB_QUEST.stream()
|
super(player, step1, step2, QuestsConfig.KILL_MOB_QUEST.stream()
|
||||||
.filter(object -> variant.equals(object.getInternalName()))
|
.filter(object -> variant.equals(object.getInternalName()))
|
||||||
.findAny().orElse(null), amount, rewardReceived);
|
.findAny().orElse(null), amount, rewardReceived);
|
||||||
if (getVariant() instanceof KillMobsQuestObject killMobsQuestObject)
|
if (getVariant() instanceof KillMobsQuestObject killMobsQuestObject)
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ public class MineQuest extends Quest {
|
||||||
|
|
||||||
private final MineQuestObject mineQuestObject;
|
private final MineQuestObject mineQuestObject;
|
||||||
|
|
||||||
public MineQuest(UUID uuid) {
|
public MineQuest(Player player) throws Exception {
|
||||||
super(uuid, 0, 0,
|
super(player, 0, 0,
|
||||||
QuestsConfig.MINE_QUESTS.get(Utilities.randomOr0(QuestsConfig.MINE_QUESTS.size() - 1)), -1, false);
|
QuestsConfig.MINE_QUESTS.get(Utilities.randomOr0(QuestsConfig.MINE_QUESTS.size() - 1)), -1, false);
|
||||||
if (getVariant() instanceof MineQuestObject mineQuestObject)
|
if (getVariant() instanceof MineQuestObject mineQuestObject)
|
||||||
this.mineQuestObject = mineQuestObject;
|
this.mineQuestObject = mineQuestObject;
|
||||||
|
|
@ -40,8 +40,8 @@ public class MineQuest extends Quest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MineQuest(UUID uuid, int mined, int turnedIn, String variant, int amount, boolean rewardReceived) {
|
public MineQuest(Player player, int mined, int turnedIn, String variant, int amount, boolean rewardReceived) throws Exception {
|
||||||
super(uuid, mined, turnedIn, QuestsConfig.MINE_QUESTS.stream()
|
super(player, mined, turnedIn, QuestsConfig.MINE_QUESTS.stream()
|
||||||
.filter(object -> variant.equals(object.getInternalName()))
|
.filter(object -> variant.equals(object.getInternalName()))
|
||||||
.findAny().orElse(null), amount,
|
.findAny().orElse(null), amount,
|
||||||
rewardReceived);
|
rewardReceived);
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,14 @@ import java.sql.SQLException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class OtherQuest extends Quest {
|
public class OtherQuest extends Quest {
|
||||||
|
|
||||||
private final OtherQuestObject otherQuestObject;
|
private final OtherQuestObject otherQuestObject;
|
||||||
|
|
||||||
public OtherQuest(UUID uuid) {
|
public OtherQuest(Player player) throws Exception {
|
||||||
super(uuid, 0, 0,
|
super(player, 0, 0,
|
||||||
QuestsConfig.OTHER_QUEST.get(Utilities.randomOr0(QuestsConfig.OTHER_QUEST.size() - 1)), -1, false);
|
QuestsConfig.OTHER_QUEST.get(Utilities.randomOr0(QuestsConfig.OTHER_QUEST.size() - 1)), -1, false);
|
||||||
if (getVariant() instanceof OtherQuestObject otherQuestObject)
|
if (getVariant() instanceof OtherQuestObject otherQuestObject)
|
||||||
this.otherQuestObject = otherQuestObject;
|
this.otherQuestObject = otherQuestObject;
|
||||||
|
|
@ -41,12 +40,11 @@ public class OtherQuest extends Quest {
|
||||||
this.otherQuestObject = null;
|
this.otherQuestObject = null;
|
||||||
if (otherQuestObject == null) {
|
if (otherQuestObject == null) {
|
||||||
Logger.warning("Tried to create OtherQuest but unable to find variant: %.", "unknown");
|
Logger.warning("Tried to create OtherQuest but unable to find variant: %.", "unknown");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public OtherQuest(UUID uuid, int step1, int step2, String variant, int amount, boolean rewardReceived) {
|
public OtherQuest(Player player, int step1, int step2, String variant, int amount, boolean rewardReceived) throws Exception {
|
||||||
super(uuid, step1, step2, QuestsConfig.OTHER_QUEST.stream()
|
super(player, step1, step2, QuestsConfig.OTHER_QUEST.stream()
|
||||||
.filter(object -> variant.equals(object.getInternalName()))
|
.filter(object -> variant.equals(object.getInternalName()))
|
||||||
.findAny().orElse(null), amount, rewardReceived);
|
.findAny().orElse(null), amount, rewardReceived);
|
||||||
if (getVariant() instanceof OtherQuestObject otherQuestObject)
|
if (getVariant() instanceof OtherQuestObject otherQuestObject)
|
||||||
|
|
@ -148,7 +146,7 @@ public class OtherQuest extends Quest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return MiniMessage.miniMessage().deserialize("<green>%s</green>".formatted( otherQuestObject.getCategory()));
|
return MiniMessage.miniMessage().deserialize("<green>%s</green>".formatted(otherQuestObject.getCategory()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -156,7 +154,7 @@ public class OtherQuest extends Quest {
|
||||||
return QuestsConfig.COLLECT_DROPS_COMMANDS;
|
return QuestsConfig.COLLECT_DROPS_COMMANDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fish(ItemStack caughtItem){
|
public void fish(ItemStack caughtItem) {
|
||||||
if (isDone() || !caughtItem.getType().equals(otherQuestObject.getMaterial()) || getAmount() == getStep1()) {
|
if (isDone() || !caughtItem.getType().equals(otherQuestObject.getMaterial()) || getAmount() == getStep1()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -169,8 +167,7 @@ public class OtherQuest extends Quest {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DyeColor color = getDyeColorFromItemStack(otherQuestObject.getMaterial());
|
DyeColor color = getDyeColorFromItemStack(otherQuestObject.getMaterial());
|
||||||
if (entity instanceof Sheep) {
|
if (entity instanceof Sheep sheep) {
|
||||||
Sheep sheep = (Sheep) entity;
|
|
||||||
if (sheep.getColor() != color) {
|
if (sheep.getColor() != color) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -187,7 +184,7 @@ public class OtherQuest extends Quest {
|
||||||
checkDone();
|
checkDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void raid(){
|
public void raid() {
|
||||||
if (isDone() || getAmount() == getStep1() || !Objects.equals(otherQuestObject.getCategory(), "Raid")) { //without checking the category, other players who have otherQuests active will also have a step added
|
if (isDone() || getAmount() == getStep1() || !Objects.equals(otherQuestObject.getCategory(), "Raid")) { //without checking the category, other players who have otherQuests active will also have a step added
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.alttd.altitudequests.util;
|
||||||
|
|
||||||
|
import com.alttd.altitudequests.AQuest;
|
||||||
|
import com.alttd.altitudequests.config.Config;
|
||||||
|
import com.alttd.altitudequests.objects.Variant;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.boss.BarColor;
|
||||||
|
import org.bukkit.boss.BarStyle;
|
||||||
|
import org.bukkit.boss.BossBar;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
|
||||||
|
public class AutoHideBossBar extends BukkitRunnable {
|
||||||
|
|
||||||
|
private final BossBar bossBar;
|
||||||
|
|
||||||
|
public AutoHideBossBar(Player player, Variant variant, String suffix) throws Exception {
|
||||||
|
NamespacedKey namespacedKeyOne = NamespacedKey.fromString(player.getUniqueId() + variant.getInternalName() + suffix, AQuest.getInstance());
|
||||||
|
if (namespacedKeyOne == null) {
|
||||||
|
Logger.warning("Unable to create nameSpacedKey with suffix % for quest for %", suffix, player.getName());
|
||||||
|
throw new Exception("Failed to create namespace key");
|
||||||
|
}
|
||||||
|
this.bossBar = Bukkit.createBossBar(
|
||||||
|
namespacedKeyOne,
|
||||||
|
"Step One Progress",
|
||||||
|
BarColor.GREEN,
|
||||||
|
BarStyle.SOLID);
|
||||||
|
bossBar.setVisible(false);
|
||||||
|
bossBar.addPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show(double progress) {
|
||||||
|
BukkitScheduler scheduler = Bukkit.getScheduler();
|
||||||
|
if (scheduler.isQueued(this.getTaskId()))
|
||||||
|
scheduler.cancelTask(this.getTaskId());
|
||||||
|
bossBar.setVisible(true);
|
||||||
|
bossBar.setProgress(progress);
|
||||||
|
this.runTaskLater(AQuest.getInstance(), Config.BOSS_BAR_AUTO_HIDE.getSeconds() * 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
bossBar.setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user