Allow for empty objective lores

This commit is contained in:
Indyuce 2021-08-25 21:13:17 +02:00
parent ebf0d40fbf
commit 63c837be2c
2 changed files with 184 additions and 182 deletions

View File

@ -3,9 +3,9 @@ package net.Indyuce.mmocore.api.quest;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import io.lumine.mythic.lib.MythicLib;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import io.lumine.mythic.lib.MythicLib;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.boss.BarColor; import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle; import org.bukkit.boss.BarStyle;
@ -173,7 +173,7 @@ public class PlayerQuests {
} }
public void updateBossBar() { public void updateBossBar() {
if (!hasCurrent()) { if (!hasCurrent() || !current.getProgress().getObjective().hasLore()) {
bossbar.setVisible(false); bossbar.setVisible(false);
return; return;
} }

View File

@ -1,18 +1,17 @@
package net.Indyuce.mmocore.api.quest.objective; package net.Indyuce.mmocore.api.quest.objective;
import java.util.ArrayList; import io.lumine.mythic.lib.api.MMOLineConfig;
import java.util.List;
import java.util.logging.Level;
import org.apache.commons.lang.Validate;
import org.bukkit.boss.BarColor;
import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress; import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress; import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.Indyuce.mmocore.api.quest.trigger.Trigger; import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import io.lumine.mythic.lib.api.MMOLineConfig; import org.apache.commons.lang.Validate;
import org.bukkit.boss.BarColor;
import org.bukkit.configuration.ConfigurationSection;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
public abstract class Objective { public abstract class Objective {
private final String id, lore; private final String id, lore;
@ -24,7 +23,6 @@ public abstract class Objective {
this.id = config.getName(); this.id = config.getName();
this.lore = config.getString("lore"); this.lore = config.getString("lore");
Validate.notNull(lore, "Could not find objective lore");
Validate.notNull(config.getStringList("triggers"), "Could not load trigger list"); Validate.notNull(config.getStringList("triggers"), "Could not load trigger list");
String format = config.getString("bar-color", "PURPLE"); String format = config.getString("bar-color", "PURPLE");
@ -47,6 +45,10 @@ public abstract class Objective {
return barColor; return barColor;
} }
public boolean hasLore() {
return lore != null && !lore.isEmpty();
}
public String getDefaultLore() { public String getDefaultLore() {
return lore; return lore;
} }