mirror of https://github.com/PikaMug/Quests.git
Refactoring intensifies
This commit is contained in:
parent
9a14601dd3
commit
6b9a8e01bb
|
@ -14,9 +14,10 @@ package me.pikamug.quests;
|
|||
|
||||
import me.pikamug.quests.actions.Action;
|
||||
import me.pikamug.quests.actions.ActionFactory;
|
||||
import me.pikamug.quests.conditions.ConditionFactory;
|
||||
import me.pikamug.quests.conditions.Condition;
|
||||
import me.pikamug.quests.config.Settings;
|
||||
import me.pikamug.quests.conditions.ConditionFactory;
|
||||
import me.pikamug.quests.conditions.ConditionSettings;
|
||||
import me.pikamug.quests.config.ConfigSettings;
|
||||
import me.pikamug.quests.dependencies.Dependencies;
|
||||
import me.pikamug.quests.module.CustomObjective;
|
||||
import me.pikamug.quests.module.CustomRequirement;
|
||||
|
@ -46,7 +47,9 @@ public interface Quests {
|
|||
|
||||
Dependencies getDependencies();
|
||||
|
||||
Settings getSettings();
|
||||
ConfigSettings getConfigSettings();
|
||||
|
||||
ConditionSettings getConditionSettings();
|
||||
|
||||
List<CustomObjective> getCustomObjectives();
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package me.pikamug.quests.actions;
|
||||
|
||||
public interface ActionSettings {
|
||||
void init();
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package me.pikamug.quests.conditions;
|
||||
|
||||
public interface ConditionSettings {
|
||||
void init();
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
package me.pikamug.quests.config;
|
||||
|
||||
public interface Settings {
|
||||
public interface ConfigSettings {
|
||||
int getAcceptTimeout();
|
||||
void setAcceptTimeout(final int acceptTimeout);
|
||||
boolean canAllowCommands();
|
|
@ -66,7 +66,7 @@ public abstract class QuestsNumericPrompt extends NumericPrompt {
|
|||
if (context.getPlugin() == null) {
|
||||
return Language.get("itemCreateCriticalError");
|
||||
}
|
||||
if (!(context.getForWhom() instanceof Player) || !((Quests)context.getPlugin()).getSettings().canClickablePrompts()) {
|
||||
if (!(context.getForWhom() instanceof Player) || !((Quests)context.getPlugin()).getConfigSettings().canClickablePrompts()) {
|
||||
return input;
|
||||
}
|
||||
final String[] basicText = input.split("\n");
|
||||
|
|
|
@ -59,7 +59,7 @@ public abstract class QuestsStringPrompt extends StringPrompt {
|
|||
if (context.getPlugin() == null) {
|
||||
return Language.get("itemCreateCriticalError");
|
||||
}
|
||||
if (!(context.getForWhom() instanceof Player) || !((Quests)context.getPlugin()).getSettings().canClickablePrompts()) {
|
||||
if (!(context.getForWhom() instanceof Player) || !((Quests)context.getPlugin()).getConfigSettings().canClickablePrompts()) {
|
||||
return ChatColor.GOLD + header + "\n" + ChatColor.AQUA + String.join(ChatColor.GRAY + ", " + ChatColor.AQUA, list) + "\n" + ChatColor.YELLOW + footer;
|
||||
}
|
||||
final TextComponent component = new TextComponent(header + "\n");
|
||||
|
|
|
@ -29,12 +29,6 @@ public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public QuestsEditorNumericPrompt(final ConversationContext context, final QuestFactory factory) {
|
||||
this.context = context;
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
|
|
|
@ -28,12 +28,6 @@ public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public QuestsEditorStringPrompt(final ConversationContext context, final QuestFactory factory) {
|
||||
this.context = context;
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
|
|
|
@ -26,6 +26,4 @@ public interface QuestMob {
|
|||
void setDropChances(final Float[] dropChances);
|
||||
|
||||
void spawn();
|
||||
|
||||
String serialize();
|
||||
}
|
||||
|
|
|
@ -82,10 +82,7 @@ public interface Quester extends Comparable<Quester> {
|
|||
|
||||
void setCurrentQuests(final ConcurrentHashMap<Quest, Integer> currentQuests);
|
||||
|
||||
/**
|
||||
* @deprecated Do not use
|
||||
*/
|
||||
ConcurrentSkipListSet<Quest> getCompletedQuestsTemp();
|
||||
ConcurrentSkipListSet<Quest> getCompletedQuests();
|
||||
|
||||
void setCompletedQuests(final ConcurrentSkipListSet<Quest> completedQuests);
|
||||
|
||||
|
@ -139,10 +136,6 @@ public interface Quester extends Comparable<Quester> {
|
|||
|
||||
void showCurrentObjectives(final Quest quest, final Quester quester, final boolean ignoreOverrides);
|
||||
|
||||
LinkedList<String> getObjectives(final Quest quest, final boolean ignoreOverrides);
|
||||
|
||||
boolean containsObjective(final Quest quest, final String name);
|
||||
|
||||
boolean hasObjective(final Quest quest, final ObjectiveType type);
|
||||
|
||||
boolean hasCustomObjective(final Quest quest, final String name);
|
||||
|
@ -256,4 +249,10 @@ public interface Quester extends Comparable<Quester> {
|
|||
boolean isSelectingBlock();
|
||||
|
||||
boolean isInRegion(final String regionID);
|
||||
|
||||
boolean canAcceptQuest(final UUID npc);
|
||||
|
||||
boolean canAcceptCompletedQuest(final UUID npc);
|
||||
|
||||
boolean canAcceptCompletedRedoableQuest(final UUID npc);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,5 @@ public interface Quest extends Comparable<Quest> {
|
|||
|
||||
void failQuest(final Quester quester, final boolean ignoreFailAction);
|
||||
|
||||
boolean isInRegion(final Quester quester);
|
||||
|
||||
boolean isInRegionStart(final Quester quester);
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ public class Key {
|
|||
public static final String A_WORLD_STORM_DURATION = "actStormDuration";
|
||||
public static final String A_WORLD_THUNDER = "actThunderWorld";
|
||||
public static final String A_WORLD_THUNDER_DURATION = "actThunderDuration";
|
||||
public static final String A_MOB_TYPES = "actMobTypes";
|
||||
public static final String A_MOBS = "actMobs";
|
||||
public static final String A_LIGHTNING = "actLightningStrikes";
|
||||
public static final String A_POTION_TYPES = "actPotionTypes";
|
||||
public static final String A_POTION_DURATIONS = "actPotionDurations";
|
||||
|
|
|
@ -76,7 +76,7 @@ public class Language {
|
|||
final String language = locale.substring(0, separator);
|
||||
final String country = locale.substring(separator + 1).toUpperCase();
|
||||
locale = language + "-" + country;
|
||||
if (plugin.getSettings().canLanguageOverrideClient() || locale.equals(plugin.getSettings().getLanguage())) {
|
||||
if (plugin.getConfigSettings().canLanguageOverrideClient() || locale.equals(plugin.getConfigSettings().getLanguage())) {
|
||||
return defaultLang.containsKey(key) ? LangToken.convertString(player, defaultLang.get(key)) : "NULL";
|
||||
}
|
||||
if (!otherLang.containsKey(locale)) {
|
||||
|
@ -197,8 +197,8 @@ public class Language {
|
|||
.info("If the plugin has not generated language files, ensure Quests has write permissions");
|
||||
plugin.getPluginLogger()
|
||||
.info("For help, visit https://pikamug.gitbook.io/quests/casual/translations");
|
||||
plugin.getSettings().setLanguage("en-US");
|
||||
if (plugin.getSettings().getConsoleLogging() > 3) {
|
||||
plugin.getConfigSettings().setLanguage("en-US");
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 3) {
|
||||
plugin.getPluginLogger().info("CodeSource: " + plugin.getClass().getProtectionDomain().getCodeSource()
|
||||
.toString());
|
||||
plugin.getPluginLogger().info("LocationPath: " + plugin.getClass().getProtectionDomain().getCodeSource()
|
||||
|
@ -289,7 +289,7 @@ public class Language {
|
|||
allStrings.put(entry.getKey(), entry.getValue().replace("<semicolon>", strSemicolon));
|
||||
}
|
||||
}
|
||||
if (iso.equals(plugin.getSettings().getLanguage())) {
|
||||
if (iso.equals(plugin.getConfigSettings().getLanguage())) {
|
||||
defaultLang.clear();
|
||||
defaultLang.putAll(allStrings);
|
||||
} else {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,18 +12,17 @@
|
|||
|
||||
package me.pikamug.quests.actions;
|
||||
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.convo.actions.main.ActionMainPrompt;
|
||||
import me.pikamug.quests.convo.actions.menu.ActionMenuPrompt;
|
||||
import me.pikamug.quests.entity.BukkitQuestMob;
|
||||
import me.pikamug.quests.entity.QuestMob;
|
||||
import me.pikamug.quests.interfaces.ReloadCallback;
|
||||
import me.pikamug.quests.util.Key;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.util.BukkitConfigUtil;
|
||||
import me.pikamug.quests.util.BukkitFakeConversable;
|
||||
import me.pikamug.quests.util.BukkitItemUtil;
|
||||
import me.pikamug.quests.util.Key;
|
||||
import me.pikamug.quests.util.Language;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
|
@ -195,11 +194,7 @@ public class BukkitActionFactory implements ActionFactory, ConversationAbandoned
|
|||
context.setSessionData(Key.A_WORLD_THUNDER_DURATION, bukkitAction.getThunderDuration());
|
||||
}
|
||||
if (bukkitAction.getMobSpawns() != null && !bukkitAction.getMobSpawns().isEmpty()) {
|
||||
final LinkedList<String> questMobs = new LinkedList<>();
|
||||
for (final QuestMob questMob : bukkitAction.getMobSpawns()) {
|
||||
questMobs.add(questMob.serialize());
|
||||
}
|
||||
context.setSessionData(Key.A_MOB_TYPES, questMobs);
|
||||
context.setSessionData(Key.A_MOBS, bukkitAction.getMobSpawns());
|
||||
}
|
||||
if (bukkitAction.getLightningStrikes() != null && !bukkitAction.getLightningStrikes().isEmpty()) {
|
||||
final LinkedList<String> locs = new LinkedList<>();
|
||||
|
@ -259,7 +254,7 @@ public class BukkitActionFactory implements ActionFactory, ConversationAbandoned
|
|||
context.setSessionData(Key.A_WORLD_STORM_DURATION, null);
|
||||
context.setSessionData(Key.A_WORLD_THUNDER, null);
|
||||
context.setSessionData(Key.A_WORLD_THUNDER_DURATION, null);
|
||||
context.setSessionData(Key.A_MOB_TYPES, null);
|
||||
context.setSessionData(Key.A_MOBS, null);
|
||||
context.setSessionData(Key.A_LIGHTNING, null);
|
||||
context.setSessionData(Key.A_POTION_TYPES, null);
|
||||
context.setSessionData(Key.A_POTION_DURATIONS, null);
|
||||
|
@ -307,7 +302,7 @@ public class BukkitActionFactory implements ActionFactory, ConversationAbandoned
|
|||
};
|
||||
plugin.reload(callback);
|
||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Language.get("eventEditorDeleted"));
|
||||
if (plugin.getSettings().getConsoleLogging() > 0) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 0) {
|
||||
final String identifier = context.getForWhom() instanceof Player ?
|
||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||
plugin.getLogger().info(identifier + " deleted action " + action);
|
||||
|
@ -379,30 +374,31 @@ public class BukkitActionFactory implements ActionFactory, ConversationAbandoned
|
|||
section.set("thunder-duration", context.getSessionData(Key.A_WORLD_THUNDER_DURATION));
|
||||
}
|
||||
try {
|
||||
if (context.getSessionData(Key.A_MOB_TYPES) != null) {
|
||||
if (context.getSessionData(Key.A_MOBS) != null) {
|
||||
int count = 0;
|
||||
for (final String s : (LinkedList<String>) Objects.requireNonNull(context
|
||||
.getSessionData(Key.A_MOB_TYPES))) {
|
||||
for (final QuestMob mob : (LinkedList<QuestMob>) Objects.requireNonNull(context
|
||||
.getSessionData(Key.A_MOBS))) {
|
||||
ConfigurationSection ss = section.getConfigurationSection("mob-spawns." + count);
|
||||
if (ss == null) {
|
||||
ss = section.createSection("mob-spawns." + count);
|
||||
}
|
||||
final BukkitQuestMob questMob = BukkitQuestMob.fromString(s);
|
||||
final BukkitQuestMob questMob = (BukkitQuestMob) mob;
|
||||
if (questMob.getName() != null) {
|
||||
ss.set("name", questMob.getName());
|
||||
}
|
||||
// TODO - save ItemStack better way
|
||||
ss.set("spawn-location", BukkitConfigUtil.getLocationInfo(questMob.getSpawnLocation()));
|
||||
ss.set("mob-type", questMob.getType().name());
|
||||
ss.set("spawn-amounts", questMob.getSpawnAmounts());
|
||||
ss.set("held-item", BukkitItemUtil.serializeItemStack(questMob.getInventory()[0]));
|
||||
ss.set("held-item", questMob.getInventory()[0]);
|
||||
ss.set("held-item-drop-chance", questMob.getDropChances()[0]);
|
||||
ss.set("boots", BukkitItemUtil.serializeItemStack(questMob.getInventory()[1]));
|
||||
ss.set("boots", questMob.getInventory()[1]);
|
||||
ss.set("boots-drop-chance", questMob.getDropChances()[1]);
|
||||
ss.set("leggings", BukkitItemUtil.serializeItemStack(questMob.getInventory()[2]));
|
||||
ss.set("leggings", questMob.getInventory()[2]);
|
||||
ss.set("leggings-drop-chance", questMob.getDropChances()[2]);
|
||||
ss.set("chest-plate", BukkitItemUtil.serializeItemStack(questMob.getInventory()[3]));
|
||||
ss.set("chest-plate", questMob.getInventory()[3]);
|
||||
ss.set("chest-plate-drop-chance", questMob.getDropChances()[3]);
|
||||
ss.set("helmet", BukkitItemUtil.serializeItemStack(questMob.getInventory()[4]));
|
||||
ss.set("helmet", questMob.getInventory()[4]);
|
||||
ss.set("helmet-drop-chance", questMob.getDropChances()[4]);
|
||||
count++;
|
||||
}
|
||||
|
@ -464,7 +460,7 @@ public class BukkitActionFactory implements ActionFactory, ConversationAbandoned
|
|||
};
|
||||
plugin.reload(callback);
|
||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Language.get("eventEditorSaved"));
|
||||
if (plugin.getSettings().getConsoleLogging() > 0) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 0) {
|
||||
final String identifier = context.getForWhom() instanceof Player ?
|
||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||
plugin.getLogger().info(identifier + " saved action " + context.getSessionData(Key.A_NAME));
|
||||
|
|
|
@ -0,0 +1,436 @@
|
|||
package me.pikamug.quests.actions;
|
||||
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.entity.BukkitQuestMob;
|
||||
import me.pikamug.quests.entity.QuestMob;
|
||||
import me.pikamug.quests.exceptions.ActionFormatException;
|
||||
import me.pikamug.quests.util.BukkitConfigUtil;
|
||||
import me.pikamug.quests.util.BukkitItemUtil;
|
||||
import me.pikamug.quests.util.BukkitMiscUtil;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class BukkitActionSettings implements ActionSettings {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitActionSettings(final BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load actions from file
|
||||
*/
|
||||
public void init() {
|
||||
final YamlConfiguration config = new YamlConfiguration();
|
||||
final File legacyFile = new File(plugin.getDataFolder(), "events.yml");
|
||||
final File actionsFile = new File(plugin.getDataFolder(), "actions.yml");
|
||||
// Using #isFile because #exists and #renameTo can return false positives
|
||||
if (legacyFile.isFile()) {
|
||||
try {
|
||||
if (legacyFile.renameTo(actionsFile)) {
|
||||
plugin.getLogger().log(Level.INFO, "Renamed legacy events.yml to actions.yml");
|
||||
}
|
||||
if (actionsFile.isFile()) {
|
||||
plugin.getLogger().log(Level.INFO, "Successfully deleted legacy events.yml");
|
||||
if (legacyFile.delete()) {
|
||||
plugin.getLogger().log(Level.INFO, "Done!");
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
plugin.getLogger().log(Level.WARNING, "Unable to convert events.yml to actions.yml");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (actionsFile.length() != 0) {
|
||||
try {
|
||||
if (actionsFile.isFile()) {
|
||||
config.load(actionsFile);
|
||||
} else {
|
||||
config.load(legacyFile);
|
||||
}
|
||||
} catch (final IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ConfigurationSection sec = config.getConfigurationSection("actions");
|
||||
if (sec == null) {
|
||||
plugin.getLogger().log(Level.INFO,
|
||||
"Could not find section \"actions\" from actions.yml. Trying legacy \"events\"...");
|
||||
sec = config.getConfigurationSection("events");
|
||||
}
|
||||
if (sec != null) {
|
||||
for (final String s : sec.getKeys(false)) {
|
||||
BukkitAction action = null;
|
||||
try {
|
||||
action = loadAction(s);
|
||||
} catch (final ActionFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (action != null) {
|
||||
final Collection<Action> actions = plugin.getLoadedActions();
|
||||
actions.add(action);
|
||||
plugin.setLoadedActions(actions);
|
||||
} else {
|
||||
plugin.getLogger().log(Level.SEVERE, "Failed to load Action \"" + s + "\". Skipping.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().log(Level.SEVERE, "Could not find beginning section from actions.yml. Skipping.");
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().log(Level.WARNING, "Empty file actions.yml was not loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked"})
|
||||
private BukkitAction loadAction(final String name) throws ActionFormatException {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
final File legacy = new File(plugin.getDataFolder(), "events.yml");
|
||||
final File actions = new File(plugin.getDataFolder(), "actions.yml");
|
||||
final FileConfiguration data = new YamlConfiguration();
|
||||
try {
|
||||
if (actions.isFile()) {
|
||||
data.load(actions);
|
||||
} else {
|
||||
data.load(legacy);
|
||||
}
|
||||
} catch (final IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
final String legacyName = "events." + name;
|
||||
String actionKey = "actions." + name + ".";
|
||||
if (data.contains(legacyName)) {
|
||||
actionKey = legacyName + ".";
|
||||
}
|
||||
final BukkitAction action = new BukkitAction(plugin);
|
||||
action.setName(name);
|
||||
if (data.contains(actionKey + "message")) {
|
||||
action.setMessage(BukkitConfigUtil.parseString(data.getString(actionKey + "message")));
|
||||
}
|
||||
if (data.contains(actionKey + "open-book")) {
|
||||
action.setBook(data.getString(actionKey + "open-book"));
|
||||
}
|
||||
if (data.contains(actionKey + "clear-inventory")) {
|
||||
if (data.isBoolean(actionKey + "clear-inventory")) {
|
||||
action.setClearInv(data.getBoolean(actionKey + "clear-inventory"));
|
||||
} else {
|
||||
throw new ActionFormatException("'clear-inventory' is not a true/false value", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "fail-quest")) {
|
||||
if (data.isBoolean(actionKey + "fail-quest")) {
|
||||
action.setFailQuest(data.getBoolean(actionKey + "fail-quest"));
|
||||
} else {
|
||||
throw new ActionFormatException("'fail-quest' is not a true/false value", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "explosions")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(actionKey + "explosions"), String.class)) {
|
||||
final LinkedList<Location> explosions = new LinkedList<>();
|
||||
for (final String s : data.getStringList(actionKey + "explosions")) {
|
||||
final Location loc = BukkitConfigUtil.getLocation(s);
|
||||
if (loc == null) {
|
||||
throw new ActionFormatException("'explosions' is not in proper \"WorldName x y z\" format",
|
||||
actionKey);
|
||||
}
|
||||
explosions.add(loc);
|
||||
}
|
||||
action.setExplosions(explosions);
|
||||
} else {
|
||||
throw new ActionFormatException("'explosions' is not a list of locations", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "effects")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(actionKey + "effects"), String.class)) {
|
||||
if (data.contains(actionKey + "effect-locations")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(actionKey + "effect-locations"), String.class)) {
|
||||
final List<String> effectList = data.getStringList(actionKey + "effects");
|
||||
final List<String> effectLocs = data.getStringList(actionKey + "effect-locations");
|
||||
final Map<Location, Effect> effects = new HashMap<>();
|
||||
for (final String s : effectList) {
|
||||
final Effect effect;
|
||||
try {
|
||||
effect = Effect.valueOf(s.toUpperCase());
|
||||
} catch (final IllegalArgumentException e) {
|
||||
throw new ActionFormatException(s + " is not a valid effect name",
|
||||
actionKey);
|
||||
}
|
||||
final Location l = BukkitConfigUtil.getLocation(effectLocs.get(effectList.indexOf(s)));
|
||||
if (l == null) {
|
||||
throw new ActionFormatException("'effect-locations' is not in proper \"WorldName x y z\""
|
||||
+ "format", actionKey);
|
||||
}
|
||||
effects.put(l, effect);
|
||||
}
|
||||
action.setEffects(effects);
|
||||
} else {
|
||||
throw new ActionFormatException("'effect-locations' is not a list of locations", actionKey);
|
||||
}
|
||||
} else {
|
||||
throw new ActionFormatException("'effect-locations' is missing", actionKey);
|
||||
}
|
||||
} else {
|
||||
throw new ActionFormatException("'effects' is not a list of effects", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "items")) {
|
||||
final LinkedList<ItemStack> temp = new LinkedList<>();
|
||||
final List<ItemStack> stackList = (List<ItemStack>) data.get(actionKey + "items");
|
||||
if (BukkitConfigUtil.checkList(stackList, ItemStack.class)) {
|
||||
for (final ItemStack stack : stackList) {
|
||||
if (stack != null) {
|
||||
temp.add(stack);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ActionFormatException("'items' is not a list of items", actionKey);
|
||||
}
|
||||
action.setItems(temp);
|
||||
}
|
||||
if (data.contains(actionKey + "storm-world")) {
|
||||
final String world = data.getString(actionKey + "storm-world");
|
||||
if (world != null) {
|
||||
final World stormWorld = plugin.getServer().getWorld(world);
|
||||
if (stormWorld == null) {
|
||||
throw new ActionFormatException("'storm-world' is not a valid world name", actionKey);
|
||||
}
|
||||
if (data.contains(actionKey + "storm-duration")) {
|
||||
if (data.getInt(actionKey + "storm-duration", -999) != -999) {
|
||||
action.setStormDuration(data.getInt(actionKey + "storm-duration") * 1000);
|
||||
} else {
|
||||
throw new ActionFormatException("'storm-duration' is not a number", actionKey);
|
||||
}
|
||||
action.setStormWorld(stormWorld);
|
||||
} else {
|
||||
throw new ActionFormatException("'storm-duration' is missing", actionKey);
|
||||
}
|
||||
} else {
|
||||
throw new ActionFormatException("'storm-world' is not a valid world", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "thunder-world")) {
|
||||
final String world = data.getString(actionKey + "thunder-world");
|
||||
if (world != null) {
|
||||
final World thunderWorld = plugin.getServer().getWorld(world);
|
||||
if (thunderWorld == null) {
|
||||
throw new ActionFormatException("'thunder-world' is not a valid world name", actionKey);
|
||||
}
|
||||
if (data.contains(actionKey + "thunder-duration")) {
|
||||
if (data.getInt(actionKey + "thunder-duration", -999) != -999) {
|
||||
action.setThunderDuration(data.getInt(actionKey + "thunder-duration"));
|
||||
} else {
|
||||
throw new ActionFormatException("'thunder-duration' is not a number", actionKey);
|
||||
}
|
||||
action.setThunderWorld(thunderWorld);
|
||||
} else {
|
||||
throw new ActionFormatException("'thunder-duration' is missing", actionKey);
|
||||
}
|
||||
} else {
|
||||
throw new ActionFormatException("'thunder-world' is not a valid world", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "mob-spawns")) {
|
||||
final ConfigurationSection section = data.getConfigurationSection(actionKey + "mob-spawns");
|
||||
if (section != null) {
|
||||
final LinkedList<QuestMob> mobSpawns = new LinkedList<>();
|
||||
for (final String s : section.getKeys(false)) {
|
||||
final String mobName = section.getString(s + ".name");
|
||||
final String location = section.getString(s + ".spawn-location");
|
||||
if (location != null) {
|
||||
final Location spawnLocation = BukkitConfigUtil.getLocation(location);
|
||||
final EntityType type = BukkitMiscUtil.getProperMobType(section.getString(s + ".mob-type"));
|
||||
final int mobAmount = section.getInt(s + ".spawn-amounts");
|
||||
if (spawnLocation == null) {
|
||||
throw new ActionFormatException("'mob-spawn-locations' is not in proper \"WorldName x y z\" format",
|
||||
actionKey);
|
||||
}
|
||||
if (type == null) {
|
||||
throw new ActionFormatException("'mob-spawn-types' is not a list of mob types", actionKey);
|
||||
}
|
||||
final ItemStack[] inventory = new ItemStack[5];
|
||||
final Float[] dropChances = new Float[5];
|
||||
inventory[0] = loadMobItem(section, s + ".held-item");
|
||||
dropChances[0] = (float) section.getDouble(s + ".held-item-drop-chance");
|
||||
inventory[1] = loadMobItem(section, s + ".boots");
|
||||
dropChances[1] = (float) section.getDouble(s + ".boots-drop-chance");
|
||||
inventory[2] = loadMobItem(section, s + ".leggings");
|
||||
dropChances[2] = (float) section.getDouble(s + ".leggings-drop-chance");
|
||||
inventory[3] = loadMobItem(section, s + ".chest-plate");
|
||||
dropChances[3] = (float) section.getDouble(s + ".chest-plate-drop-chance");
|
||||
inventory[4] = loadMobItem(section, s + ".helmet");
|
||||
dropChances[4] = (float) section.getDouble(s + ".helmet-drop-chance");
|
||||
final BukkitQuestMob questMob = new BukkitQuestMob(type, spawnLocation, mobAmount);
|
||||
questMob.setInventory(inventory);
|
||||
questMob.setDropChances(dropChances);
|
||||
questMob.setName(mobName);
|
||||
mobSpawns.add(questMob);
|
||||
} else {
|
||||
throw new ActionFormatException("'mob-spawn-locations' contains an invalid location", actionKey);
|
||||
}
|
||||
}
|
||||
action.setMobSpawns(mobSpawns);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "lightning-strikes")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(actionKey + "lightning-strikes"), String.class)) {
|
||||
final LinkedList<Location> lightningStrikes = new LinkedList<>();
|
||||
for (final String s : data.getStringList(actionKey + "lightning-strikes")) {
|
||||
final Location loc = BukkitConfigUtil.getLocation(s);
|
||||
if (loc == null) {
|
||||
throw new ActionFormatException("'lightning-strikes' is not in proper \"WorldName x y z\" format",
|
||||
actionKey);
|
||||
}
|
||||
lightningStrikes.add(loc);
|
||||
}
|
||||
action.setLightningStrikes(lightningStrikes);
|
||||
} else {
|
||||
throw new ActionFormatException("'lightning-strikes' is not a list of locations", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "commands")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(actionKey + "commands"), String.class)) {
|
||||
final LinkedList<String> commands = new LinkedList<>();
|
||||
for (String s : data.getStringList(actionKey + "commands")) {
|
||||
if (s.startsWith("/")) {
|
||||
s = s.replaceFirst("/", "");
|
||||
}
|
||||
commands.add(s);
|
||||
}
|
||||
action.setCommands(commands);
|
||||
} else {
|
||||
throw new ActionFormatException("'commands' is not a list of commands", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "potion-effect-types")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(actionKey + "potion-effect-types"), String.class)) {
|
||||
if (data.contains(actionKey + "potion-effect-durations")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(actionKey + "potion-effect-durations"), Integer.class)) {
|
||||
if (data.contains(actionKey + "potion-effect-amplifiers")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(actionKey + "potion-effect-amplifiers"),
|
||||
Integer.class)) {
|
||||
final List<String> types = data.getStringList(actionKey + "potion-effect-types");
|
||||
final List<Integer> durations = data.getIntegerList(actionKey + "potion-effect-durations");
|
||||
final List<Integer> amplifiers = data.getIntegerList(actionKey + "potion-effect-amplifiers");
|
||||
final LinkedList<PotionEffect> potionEffects = new LinkedList<>();
|
||||
for (final String s : types) {
|
||||
final PotionEffectType type = PotionEffectType.getByName(s);
|
||||
if (type == null) {
|
||||
throw new ActionFormatException("potion-effect-types is not a list of potion "
|
||||
+ "effect types", actionKey);
|
||||
}
|
||||
final PotionEffect effect = new PotionEffect(type, durations
|
||||
.get(types.indexOf(s)), amplifiers.get(types.indexOf(s)));
|
||||
potionEffects.add(effect);
|
||||
}
|
||||
action.setPotionEffects(potionEffects);
|
||||
} else {
|
||||
throw new ActionFormatException("'potion-effect-amplifiers' is not a list of numbers",
|
||||
actionKey);
|
||||
}
|
||||
} else {
|
||||
throw new ActionFormatException("'potion-effect-amplifiers' is missing", actionKey);
|
||||
}
|
||||
} else {
|
||||
throw new ActionFormatException("'potion-effect-durations' is not a list of numbers", actionKey);
|
||||
}
|
||||
} else {
|
||||
throw new ActionFormatException("'potion-effect-durations' is missing", actionKey);
|
||||
}
|
||||
} else {
|
||||
throw new ActionFormatException("'potion-effect-types' is not a list of potion effects", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "hunger")) {
|
||||
if (data.getInt(actionKey + "hunger", -999) != -999) {
|
||||
action.setHunger(data.getInt(actionKey + "hunger"));
|
||||
} else {
|
||||
throw new ActionFormatException("'hunger' is not a number", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "saturation")) {
|
||||
if (data.getInt(actionKey + "saturation", -999) != -999) {
|
||||
action.setSaturation(data.getInt(actionKey + "saturation"));
|
||||
} else {
|
||||
throw new ActionFormatException("'saturation' is not a number", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "health")) {
|
||||
if (data.getInt(actionKey + "health", -999) != -999) {
|
||||
action.setHealth(data.getInt(actionKey + "health"));
|
||||
} else {
|
||||
throw new ActionFormatException("'health' is not a number", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "teleport-location")) {
|
||||
if (data.isString(actionKey + "teleport-location")) {
|
||||
final String location = data.getString(actionKey + "teleport-location");
|
||||
if (location != null) {
|
||||
final Location teleport = BukkitConfigUtil.getLocation(location);
|
||||
if (teleport == null) {
|
||||
throw new ActionFormatException("'teleport-location' is not in proper \"WorldName x y z\" format",
|
||||
actionKey);
|
||||
}
|
||||
action.setTeleport(teleport);
|
||||
} else {
|
||||
throw new ActionFormatException("'teleport-location' has invalid location", actionKey);
|
||||
}
|
||||
} else {
|
||||
throw new ActionFormatException("'teleport-location' is not a location", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "timer")) {
|
||||
if (data.isInt(actionKey + "timer")) {
|
||||
action.setTimer(data.getInt(actionKey + "timer"));
|
||||
} else {
|
||||
throw new ActionFormatException("'timer' is not a number", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "cancel-timer")) {
|
||||
if (data.isBoolean(actionKey + "cancel-timer")) {
|
||||
action.setCancelTimer(data.getBoolean(actionKey + "cancel-timer"));
|
||||
} else {
|
||||
throw new ActionFormatException("'cancel-timer' is not a true/false value", actionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "denizen-script")) {
|
||||
action.setDenizenScript(data.getString(actionKey + "denizen-script"));
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load mob inventory item whether legacy or not
|
||||
*
|
||||
* @deprecated Will be removed at some point
|
||||
* @param section section
|
||||
* @param node node
|
||||
* @return ItemStack
|
||||
*/
|
||||
private ItemStack loadMobItem(ConfigurationSection section, String node) {
|
||||
try {
|
||||
return (ItemStack) section.get(node);
|
||||
} catch (Exception e) {
|
||||
return BukkitItemUtil.readItemStack(section.getString(node));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -110,7 +110,7 @@ public class QuestCommandHandler {
|
|||
index++;
|
||||
}
|
||||
}
|
||||
final Quest q = plugin.getQuestTemp(name.toString());
|
||||
final Quest q = plugin.getQuest(name.toString());
|
||||
if (q != null) {
|
||||
final Player player = (Player) cs;
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
|
@ -124,7 +124,7 @@ public class QuestCommandHandler {
|
|||
cs.sendMessage(ChatColor.YELLOW + q.getDescription());
|
||||
}
|
||||
cs.sendMessage(" ");
|
||||
if (plugin.getSettings().canShowQuestReqs()) {
|
||||
if (plugin.getConfigSettings().canShowQuestReqs()) {
|
||||
final BukkitRequirements reqs = (BukkitRequirements) q.getRequirements();
|
||||
if (reqs.hasRequirement()) {
|
||||
cs.sendMessage(ChatColor.GOLD + Language.get("requirements"));
|
||||
|
@ -198,7 +198,7 @@ public class QuestCommandHandler {
|
|||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + BukkitItemUtil.getString(is));
|
||||
}
|
||||
}
|
||||
for (Quest quest : quester.getCompletedQuestsTemp()) {
|
||||
for (Quest quest : quester.getCompletedQuests()) {
|
||||
if (reqs.getNeededQuestIds().contains(quest.getId())) {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + Language.get("complete") + " "
|
||||
+ ChatColor.ITALIC + quest.getName());
|
||||
|
@ -207,7 +207,7 @@ public class QuestCommandHandler {
|
|||
+ ChatColor.ITALIC + quest.getName());
|
||||
}
|
||||
}
|
||||
final Map<String, String> completed = quester.getCompletedQuestsTemp().stream()
|
||||
final Map<String, String> completed = quester.getCompletedQuests().stream()
|
||||
.collect(Collectors.toMap(Quest::getId, Quest::getName));
|
||||
for (final String questId : reqs.getBlockQuestIds()) {
|
||||
if (completed.containsKey(questId)) {
|
||||
|
|
|
@ -105,7 +105,7 @@ public class QuestadminCommandHandler {
|
|||
}
|
||||
cs.sendMessage(ChatColor.GOLD + Language.get("questAdminHelpTitle"));
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin" + ChatColor.RED + " " + Language.get("COMMAND_QUESTADMIN_HELP"));
|
||||
final boolean translateSubCommands = plugin.getSettings().canTranslateSubCommands();
|
||||
final boolean translateSubCommands = plugin.getConfigSettings().canTranslateSubCommands();
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.stats")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED + Language.get("COMMAND_QUESTADMIN_STATS_HELP")
|
||||
.replace("<command>", ChatColor.GOLD + (translateSubCommands ? Language.get("COMMAND_QUESTADMIN_STATS")
|
||||
|
|
|
@ -89,7 +89,7 @@ public class QuestadminFinishCommand extends QuestsSubCommand {
|
|||
msg = msg.replace("<player>", target.getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
final Quest quest = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 1, ' '));
|
||||
final Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
|
||||
if (quest == null) {
|
||||
cs.sendMessage(ChatColor.RED + Language.get("questNotFound"));
|
||||
return;
|
||||
|
|
|
@ -96,7 +96,7 @@ public class QuestadminGiveCommand extends QuestsSubCommand {
|
|||
}
|
||||
}
|
||||
}
|
||||
questToGive = plugin.getQuestTemp(name.toString());
|
||||
questToGive = plugin.getQuest(name.toString());
|
||||
if (questToGive == null) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Language.get("questNotFound"));
|
||||
} else {
|
||||
|
|
|
@ -89,7 +89,7 @@ public class QuestadminNextstageCommand extends QuestsSubCommand {
|
|||
msg = msg.replace("<player>", target.getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
final Quest quest = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 1, ' '));
|
||||
final Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
|
||||
if (quest == null) {
|
||||
cs.sendMessage(ChatColor.RED + Language.get("questNotFound"));
|
||||
return;
|
||||
|
|
|
@ -89,7 +89,7 @@ public class QuestadminQuitCommand extends QuestsSubCommand {
|
|||
msg = msg.replace("<player>", target.getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
final Quest quest = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 1, ' '));
|
||||
final Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
|
||||
if (quest == null) {
|
||||
cs.sendMessage(ChatColor.RED + Language.get("questNotFound"));
|
||||
return;
|
||||
|
|
|
@ -83,7 +83,7 @@ public class QuestadminRemoveCommand extends QuestsSubCommand {
|
|||
return;
|
||||
}
|
||||
}
|
||||
final Quest toRemove = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 1, ' '));
|
||||
final Quest toRemove = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
|
||||
if (toRemove == null) {
|
||||
cs.sendMessage(ChatColor.RED + Language.get("questNotFound"));
|
||||
return;
|
||||
|
|
|
@ -12,10 +12,9 @@
|
|||
|
||||
package me.pikamug.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.pikamug.quests.quests.BukkitQuest;
|
||||
import me.pikamug.quests.player.BukkitQuester;
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.commands.QuestsSubCommand;
|
||||
import me.pikamug.quests.player.BukkitQuester;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.util.Language;
|
||||
|
@ -97,7 +96,7 @@ public class QuestadminSetstageCommand extends QuestsSubCommand {
|
|||
msg = msg.replace("<player>", target.getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
final Quest quest = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 2, ' '));
|
||||
final Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 2, ' '));
|
||||
if (quest == null) {
|
||||
cs.sendMessage(ChatColor.RED + Language.get("questNotFound"));
|
||||
return;
|
||||
|
@ -155,7 +154,7 @@ public class QuestadminSetstageCommand extends QuestsSubCommand {
|
|||
}
|
||||
return results;
|
||||
} else if (args.length > 3) {
|
||||
final BukkitQuest quest = plugin.getQuest(args[2]);
|
||||
final Quest quest = plugin.getQuest(args[2]);
|
||||
if (quest != null) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
for (int i = 1; i <= quest.getStages().size(); i++) {
|
||||
|
|
|
@ -98,18 +98,18 @@ public class QuestadminStatsCommand extends QuestsSubCommand {
|
|||
}
|
||||
cs.sendMessage(ChatColor.YELLOW + Language.get("completedQuest"));
|
||||
|
||||
if (quester.getCompletedQuestsTemp().isEmpty()) {
|
||||
if (quester.getCompletedQuests().isEmpty()) {
|
||||
cs.sendMessage(ChatColor.DARK_PURPLE + Language.get("none"));
|
||||
} else {
|
||||
final StringBuilder completed = new StringBuilder(" ");
|
||||
int index = 1;
|
||||
for (final Quest q : quester.getCompletedQuestsTemp()) {
|
||||
for (final Quest q : quester.getCompletedQuests()) {
|
||||
completed.append(ChatColor.DARK_PURPLE).append(q.getName());
|
||||
if (quester.getAmountsCompleted().containsKey(q) && quester.getAmountsCompleted().get(q) > 1) {
|
||||
completed.append(ChatColor.LIGHT_PURPLE).append(" (x").append(quester.getAmountsCompleted()
|
||||
.get(q)).append(")");
|
||||
}
|
||||
if (index < (quester.getCompletedQuestsTemp().size())) {
|
||||
if (index < (quester.getCompletedQuests().size())) {
|
||||
completed.append(", ");
|
||||
}
|
||||
index++;
|
||||
|
|
|
@ -107,7 +107,7 @@ public class QuestsCommandHandler {
|
|||
continue;
|
||||
}
|
||||
cs.sendMessage(ChatColor.YELLOW + "/quests " + cmd.getDescription().replace("<command>", ChatColor.GOLD
|
||||
+ (plugin.getSettings().canTranslateSubCommands() ? cmd.getNameI18N() : cmd.getName())
|
||||
+ (plugin.getConfigSettings().canTranslateSubCommands() ? cmd.getNameI18N() : cmd.getName())
|
||||
+ ChatColor.YELLOW));
|
||||
}
|
||||
if (cs instanceof Player) {
|
||||
|
|
|
@ -79,7 +79,7 @@ public class QuestsJournalCommand extends QuestsSubCommand {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getSettings().canGiveJournalItem()) {
|
||||
if (!plugin.getConfigSettings().canGiveJournalItem()) {
|
||||
final BukkitQuestJournal journal = new BukkitQuestJournal(plugin, quester);
|
||||
BookUtil.openPlayer(player, journal.toItemStack());
|
||||
} else {
|
||||
|
|
|
@ -81,7 +81,7 @@ public class QuestsListCommand extends QuestsSubCommand {
|
|||
return;
|
||||
}
|
||||
|
||||
plugin.listQuests(quester, 1);
|
||||
quester.listQuests(quester, 1);
|
||||
} else if (args.length == 2) {
|
||||
final int page;
|
||||
try {
|
||||
|
@ -97,7 +97,7 @@ public class QuestsListCommand extends QuestsSubCommand {
|
|||
return;
|
||||
}
|
||||
|
||||
plugin.listQuests(quester, page);
|
||||
quester.listQuests(quester, page);
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Language.get(player, "pageSelectionNum"));
|
||||
|
|
|
@ -77,7 +77,7 @@ public class QuestsQuitCommand extends QuestsSubCommand {
|
|||
if (player.hasPermission(getPermission())) {
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (!quester.getCurrentQuests().isEmpty()) {
|
||||
final Quest quest = plugin.getQuestTemp(concatArgArray(args, 1, args.length - 1, ' '));
|
||||
final Quest quest = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' '));
|
||||
if (quest != null) {
|
||||
if (quest.getOptions().canAllowQuitting()) {
|
||||
final String msg = ChatColor.YELLOW + Language.get(player, "questQuit").replace("<quest>",
|
||||
|
|
|
@ -87,18 +87,18 @@ public class QuestsStatsCommand extends QuestsSubCommand {
|
|||
}
|
||||
cs.sendMessage(ChatColor.YELLOW + Language.get(player, "completedQuest"));
|
||||
|
||||
if (quester.getCompletedQuestsTemp().isEmpty()) {
|
||||
if (quester.getCompletedQuests().isEmpty()) {
|
||||
cs.sendMessage(ChatColor.DARK_PURPLE + Language.get("none"));
|
||||
} else {
|
||||
final StringBuilder completed = new StringBuilder(" ");
|
||||
int index = 1;
|
||||
for (final Quest q : quester.getCompletedQuestsTemp()) {
|
||||
for (final Quest q : quester.getCompletedQuests()) {
|
||||
completed.append(ChatColor.DARK_PURPLE).append(q.getName());
|
||||
if (quester.getAmountsCompleted().containsKey(q) && quester.getAmountsCompleted().get(q) > 1) {
|
||||
completed.append(ChatColor.LIGHT_PURPLE).append(" (x").append(quester.getAmountsCompleted()
|
||||
.get(q)).append(")");
|
||||
}
|
||||
if (index < (quester.getCompletedQuestsTemp().size())) {
|
||||
if (index < (quester.getCompletedQuests().size())) {
|
||||
completed.append(", ");
|
||||
}
|
||||
index++;
|
||||
|
|
|
@ -73,9 +73,9 @@ public class QuestsTakeCommand extends QuestsSubCommand {
|
|||
return;
|
||||
}
|
||||
final Player player = (Player) cs;
|
||||
if (plugin.getSettings().canAllowCommands()) {
|
||||
if (plugin.getConfigSettings().canAllowCommands()) {
|
||||
if (player.hasPermission(getPermission())) {
|
||||
final Quest questToFind = plugin.getQuestTemp(concatArgArray(args, 1, args.length - 1, ' '));
|
||||
final Quest questToFind = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' '));
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (questToFind != null) {
|
||||
for (final Quest q : quester.getCurrentQuests().keySet()) {
|
||||
|
|
|
@ -80,9 +80,9 @@ public class QuestsTopCommand extends QuestsSubCommand {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (topNumber < 1 || topNumber > plugin.getSettings().getTopLimit()) {
|
||||
if (topNumber < 1 || topNumber > plugin.getConfigSettings().getTopLimit()) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Language.get(cs, "invalidRange").replace("<least>", "1")
|
||||
.replace("<greatest>", String.valueOf(plugin.getSettings().getTopLimit())));
|
||||
.replace("<greatest>", String.valueOf(plugin.getConfigSettings().getTopLimit())));
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
|
|
|
@ -241,7 +241,7 @@ public class BukkitCondition implements Condition {
|
|||
}
|
||||
if (!plugin.getDependencies().getVaultPermission().has(player, p)) {
|
||||
failed = true;
|
||||
if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info("DEBUG: Condition permission mismatch for " + player.getName() + ": "
|
||||
+ p);
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ public class BukkitCondition implements Condition {
|
|||
for (final String r : regionsWhileStayingWithin) {
|
||||
if (!quester.isInRegion(r)) {
|
||||
failed = true;
|
||||
if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info("DEBUG: Condition region mismatch for " + player.getName() + ": " + r);
|
||||
}
|
||||
break;
|
||||
|
@ -330,7 +330,7 @@ public class BukkitCondition implements Condition {
|
|||
}
|
||||
if (!placeholdersCheckValue.get(index).equals(PlaceholderAPI.setPlaceholders(player, i))) {
|
||||
failed = true;
|
||||
if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info("DEBUG: Condition placeholder mismatch for " + player.getName() + ": "
|
||||
+ i);
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ public class BukkitConditionFactory implements ConditionFactory, ConversationAba
|
|||
};
|
||||
plugin.reload(callback);
|
||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Language.get("conditionEditorDeleted"));
|
||||
if (plugin.getSettings().getConsoleLogging() > 0) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 0) {
|
||||
final String identifier = context.getForWhom() instanceof Player ?
|
||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||
plugin.getLogger().info(identifier + " deleted condition " + condition);
|
||||
|
@ -279,7 +279,7 @@ public class BukkitConditionFactory implements ConditionFactory, ConversationAba
|
|||
};
|
||||
plugin.reload(callback);
|
||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Language.get("conditionEditorSaved"));
|
||||
if (plugin.getSettings().getConsoleLogging() > 0) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 0) {
|
||||
final String identifier = context.getForWhom() instanceof Player ?
|
||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||
plugin.getLogger().info(identifier + " saved condition " + context.getSessionData(Key.C_NAME));
|
||||
|
|
|
@ -0,0 +1,270 @@
|
|||
package me.pikamug.quests.conditions;
|
||||
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.exceptions.ConditionFormatException;
|
||||
import me.pikamug.quests.util.BukkitConfigUtil;
|
||||
import me.pikamug.quests.util.BukkitMiscUtil;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class BukkitConditionSettings implements ConditionSettings {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitConditionSettings(final BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load conditions from file
|
||||
*/
|
||||
public void init() {
|
||||
final YamlConfiguration config = new YamlConfiguration();
|
||||
final File conditionsFile = new File(plugin.getDataFolder(), "conditions.yml");
|
||||
// Using #isFile because #exists and #renameTo can return false positives
|
||||
if (conditionsFile.length() != 0) {
|
||||
try {
|
||||
if (conditionsFile.isFile()) {
|
||||
config.load(conditionsFile);
|
||||
}
|
||||
} catch (final IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
final ConfigurationSection sec = config.getConfigurationSection("conditions");
|
||||
if (sec != null) {
|
||||
for (final String s : sec.getKeys(false)) {
|
||||
BukkitCondition condition = null;
|
||||
try {
|
||||
condition = loadCondition(s);
|
||||
} catch (final ConditionFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (condition != null) {
|
||||
final Collection<Condition> conditions = plugin.getLoadedConditions();
|
||||
conditions.add(condition);
|
||||
plugin.setLoadedConditions(conditions);
|
||||
} else {
|
||||
plugin.getLogger().log(Level.SEVERE, "Failed to load Condition \"" + s + "\". Skipping.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().log(Level.SEVERE, "Could not find beginning section from conditions.yml. Skipping.");
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().log(Level.WARNING, "Empty file conditions.yml was not loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
private BukkitCondition loadCondition(final String name) throws ConditionFormatException {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
final File conditions = new File(plugin.getDataFolder(), "conditions.yml");
|
||||
final FileConfiguration data = new YamlConfiguration();
|
||||
try {
|
||||
if (conditions.isFile()) {
|
||||
data.load(conditions);
|
||||
}
|
||||
} catch (final IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
final String conditionKey = "conditions." + name + ".";
|
||||
final BukkitCondition condition = new BukkitCondition(plugin);
|
||||
condition.setName(name);
|
||||
if (data.contains(conditionKey + "fail-quest")) {
|
||||
if (data.isBoolean(conditionKey + "fail-quest")) {
|
||||
condition.setFailQuest(data.getBoolean(conditionKey + "fail-quest"));
|
||||
} else {
|
||||
throw new ConditionFormatException("'fail-quest' is not a true/false value", conditionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(conditionKey + "ride-entity")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(conditionKey + "ride-entity"), String.class)) {
|
||||
final LinkedList<String> entities = new LinkedList<>();
|
||||
for (final String s : data.getStringList(conditionKey + "ride-entity")) {
|
||||
final EntityType e = BukkitMiscUtil.getProperMobType(s);
|
||||
if (e == null) {
|
||||
throw new ConditionFormatException("'ride-entity' is not a valid entity type",
|
||||
conditionKey);
|
||||
}
|
||||
entities.add(s);
|
||||
}
|
||||
condition.setEntitiesWhileRiding(entities);
|
||||
} else {
|
||||
throw new ConditionFormatException("'ride-entity' is not a list of entity types", conditionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(conditionKey + "ride-npc-uuid")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(conditionKey + "ride-npc-uuid"), String.class)) {
|
||||
final LinkedList<UUID> npcList = new LinkedList<>();
|
||||
for (final String s : data.getStringList(conditionKey + "ride-npc-uuid")) {
|
||||
final UUID u = UUID.fromString(s);
|
||||
npcList.add(u);
|
||||
}
|
||||
condition.setNpcsWhileRiding(npcList);
|
||||
}
|
||||
} else if (data.contains(conditionKey + "ride-npc")) {
|
||||
// Legacy
|
||||
if (BukkitConfigUtil.checkList(data.getList(conditionKey + "ride-npc"), Integer.class)) {
|
||||
final LinkedList<UUID> npcList = new LinkedList<>();
|
||||
if (plugin.getDependencies().getCitizens() != null) {
|
||||
for (final int i : data.getIntegerList(conditionKey + "ride-npc")) {
|
||||
final NPC npc = CitizensAPI.getNPCRegistry().getById(i);
|
||||
if (npc != null) {
|
||||
npcList.add(npc.getUniqueId());
|
||||
} else {
|
||||
throw new ConditionFormatException("'ride-npc' is not a valid NPC ID",
|
||||
conditionKey);
|
||||
}
|
||||
}
|
||||
condition.setNpcsWhileRiding(npcList);
|
||||
} else {
|
||||
throw new ConditionFormatException("Citizens not found for 'ride-npc'", conditionKey);
|
||||
}
|
||||
} else {
|
||||
throw new ConditionFormatException("'ride-npc' is not a list of NPC IDs", conditionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(conditionKey + "permission")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(conditionKey + "permission"), String.class)) {
|
||||
final LinkedList<String> permissions
|
||||
= new LinkedList<>(data.getStringList(conditionKey + "permission"));
|
||||
condition.setPermissions(permissions);
|
||||
} else {
|
||||
throw new ConditionFormatException("'permission' is not a list of permissions", conditionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(conditionKey + "hold-main-hand")) {
|
||||
final LinkedList<ItemStack> temp = new LinkedList<>();
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<ItemStack> stackList = (List<ItemStack>) data.get(conditionKey + "hold-main-hand");
|
||||
if (BukkitConfigUtil.checkList(stackList, ItemStack.class)) {
|
||||
for (final ItemStack stack : stackList) {
|
||||
if (stack != null) {
|
||||
temp.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
condition.setItemsWhileHoldingMainHand(temp);
|
||||
}
|
||||
if (data.contains(conditionKey + "wear")) {
|
||||
final LinkedList<ItemStack> temp = new LinkedList<>();
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<ItemStack> stackList = (List<ItemStack>) data.get(conditionKey + "wear");
|
||||
if (BukkitConfigUtil.checkList(stackList, ItemStack.class)) {
|
||||
for (final ItemStack stack : stackList) {
|
||||
if (stack != null) {
|
||||
temp.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
condition.setItemsWhileWearing(temp);
|
||||
}
|
||||
if (data.contains(conditionKey + "stay-within-world")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(conditionKey + "stay-within-world"), String.class)) {
|
||||
final LinkedList<String> worlds = new LinkedList<>();
|
||||
for (final String s : data.getStringList(conditionKey + "stay-within-world")) {
|
||||
final World w = plugin.getServer().getWorld(s);
|
||||
if (w == null) {
|
||||
throw new ConditionFormatException("'stay-within-world' is not a valid world",
|
||||
conditionKey);
|
||||
}
|
||||
worlds.add(s);
|
||||
}
|
||||
condition.setWorldsWhileStayingWithin(worlds);
|
||||
} else {
|
||||
throw new ConditionFormatException("'stay-within-world' is not a list of worlds", conditionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(conditionKey + "stay-within-ticks")) {
|
||||
if (data.isInt(conditionKey + "stay-within-ticks.start")) {
|
||||
condition.setTickStartWhileStayingWithin(data.getInt(conditionKey + "stay-within-ticks.start"));
|
||||
} else {
|
||||
throw new ConditionFormatException("'start' tick is not a number", conditionKey);
|
||||
}
|
||||
if (data.isInt(conditionKey + "stay-within-ticks.end")) {
|
||||
condition.setTickEndWhileStayingWithin(data.getInt(conditionKey + "stay-within-ticks.end"));
|
||||
} else {
|
||||
throw new ConditionFormatException("'end' tick is not a number", conditionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(conditionKey + "stay-within-biome")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(conditionKey + "stay-within-biome"), String.class)) {
|
||||
final LinkedList<String> biomes = new LinkedList<>();
|
||||
for (final String s : data.getStringList(conditionKey + "stay-within-biome")) {
|
||||
final Biome b = BukkitMiscUtil.getProperBiome(s);
|
||||
if (b == null) {
|
||||
throw new ConditionFormatException("'stay-within-biome' is not a valid biome",
|
||||
conditionKey);
|
||||
}
|
||||
biomes.add(s);
|
||||
}
|
||||
condition.setBiomesWhileStayingWithin(biomes);
|
||||
} else {
|
||||
throw new ConditionFormatException("'stay-within-biome' is not a list of biomes", conditionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(conditionKey + "stay-within-region")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(conditionKey + "stay-within-region"), String.class)) {
|
||||
final LinkedList<String> regions = new LinkedList<>();
|
||||
for (final String region : data.getStringList(conditionKey + "stay-within-region")) {
|
||||
if (region != null) {
|
||||
boolean exists = false;
|
||||
for (final World world : plugin.getServer().getWorlds()) {
|
||||
if (world != null && plugin.getDependencies().getWorldGuardApi().getRegionManager(world) != null) {
|
||||
if (Objects.requireNonNull(plugin.getDependencies().getWorldGuardApi().getRegionManager(world))
|
||||
.hasRegion(region)) {
|
||||
regions.add(region);
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!exists) {
|
||||
throw new ConditionFormatException("'region' has invalid WorldGuard region name", conditionKey);
|
||||
}
|
||||
} else {
|
||||
throw new ConditionFormatException("'region' has invalid WorldGuard region", conditionKey);
|
||||
}
|
||||
}
|
||||
condition.setRegionsWhileStayingWithin(regions);
|
||||
} else {
|
||||
throw new ConditionFormatException("'stay-within-region' is not a list of regions", conditionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(conditionKey + "check-placeholder-id")) {
|
||||
if (BukkitConfigUtil.checkList(data.getList(conditionKey + "check-placeholder-id"), String.class)) {
|
||||
final LinkedList<String> id = new LinkedList<>(data.getStringList(conditionKey
|
||||
+ "check-placeholder-id"));
|
||||
condition.setPlaceholdersCheckIdentifier(id);
|
||||
} else {
|
||||
throw new ConditionFormatException("'check-placeholder-id' is not a list of identifiers", conditionKey);
|
||||
}
|
||||
if (BukkitConfigUtil.checkList(data.getList(conditionKey + "check-placeholder-value"), String.class)) {
|
||||
final LinkedList<String> val = new LinkedList<>(data.getStringList(conditionKey
|
||||
+ "check-placeholder-value"));
|
||||
condition.setPlaceholdersCheckValue(val);
|
||||
} else {
|
||||
throw new ConditionFormatException("'check-placeholder-value' is not a list of values", conditionKey);
|
||||
}
|
||||
}
|
||||
return condition;
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class BukkitSettings implements Settings {
|
||||
public class BukkitConfigSettings implements ConfigSettings {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
private int acceptTimeout = 20;
|
||||
|
@ -52,7 +52,7 @@ public class BukkitSettings implements Settings {
|
|||
private boolean translateSubCommands = false;
|
||||
private boolean updateCheck = true;
|
||||
|
||||
public BukkitSettings(final BukkitQuestsPlugin plugin) {
|
||||
public BukkitConfigSettings(final BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,10 @@ public class BukkitSettings implements Settings {
|
|||
public void setUpdateCheck(final boolean updateCheck) {
|
||||
this.updateCheck = updateCheck;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load config from file
|
||||
*/
|
||||
public void init() {
|
||||
final FileConfiguration config = plugin.getConfig();
|
||||
acceptTimeout = config.getInt("accept-timeout", 20);
|
|
@ -23,15 +23,16 @@ import me.pikamug.quests.convo.actions.tasks.ActionTimerPrompt;
|
|||
import me.pikamug.quests.convo.actions.tasks.ActionWeatherPrompt;
|
||||
import me.pikamug.quests.convo.generic.ItemStackPrompt;
|
||||
import me.pikamug.quests.entity.BukkitQuestMob;
|
||||
import me.pikamug.quests.entity.QuestMob;
|
||||
import me.pikamug.quests.events.editor.actions.ActionsEditorPostOpenNumericPromptEvent;
|
||||
import me.pikamug.quests.events.editor.actions.ActionsEditorPostOpenStringPromptEvent;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.quests.Stage;
|
||||
import me.pikamug.quests.util.Key;
|
||||
import me.pikamug.quests.util.BukkitConfigUtil;
|
||||
import me.pikamug.quests.util.BukkitItemUtil;
|
||||
import me.pikamug.quests.util.Language;
|
||||
import me.pikamug.quests.util.BukkitMiscUtil;
|
||||
import me.pikamug.quests.util.Key;
|
||||
import me.pikamug.quests.util.Language;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -139,14 +140,14 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
|
|||
case 10:
|
||||
return "";
|
||||
case 6:
|
||||
if (context.getSessionData(Key.A_MOB_TYPES) == null) {
|
||||
if (context.getSessionData(Key.A_MOBS) == null) {
|
||||
return ChatColor.GRAY + "(" + Language.get("noneSet") + ")";
|
||||
} else {
|
||||
final LinkedList<String> types = (LinkedList<String>) context.getSessionData(Key.A_MOB_TYPES);
|
||||
final LinkedList<QuestMob> mobs = (LinkedList<QuestMob>) context.getSessionData(Key.A_MOBS);
|
||||
final StringBuilder text = new StringBuilder();
|
||||
if (types != null) {
|
||||
for (final String s : types) {
|
||||
final BukkitQuestMob qm = BukkitQuestMob.fromString(s);
|
||||
if (mobs != null) {
|
||||
for (final QuestMob mob : mobs) {
|
||||
final BukkitQuestMob qm = (BukkitQuestMob) mob;
|
||||
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA)
|
||||
.append(qm.getType().name())
|
||||
.append((qm.getName() != null) ? " (" + qm.getName() + ")" : "").append(ChatColor.GRAY)
|
||||
|
@ -350,14 +351,14 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
|
|||
public String getAdditionalText(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
if (context.getSessionData(Key.A_MOB_TYPES) != null) {
|
||||
if (context.getSessionData(Key.A_MOBS) != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final
|
||||
LinkedList<String> types = (LinkedList<String>) context.getSessionData(Key.A_MOB_TYPES);
|
||||
LinkedList<QuestMob> mobs = (LinkedList<QuestMob>) context.getSessionData(Key.A_MOBS);
|
||||
final StringBuilder text = new StringBuilder();
|
||||
if (types != null) {
|
||||
for (final String type : types) {
|
||||
final BukkitQuestMob qm = BukkitQuestMob.fromString(type);
|
||||
if (mobs != null) {
|
||||
for (final QuestMob mob : mobs) {
|
||||
final BukkitQuestMob qm = (BukkitQuestMob) mob;
|
||||
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA)
|
||||
.append(qm.getType().name())
|
||||
.append((qm.getName() != null) ? " (" + qm.getName() + ")" : "")
|
||||
|
@ -398,7 +399,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
|
|||
return new ActionMobPrompt(context, null);
|
||||
case 2:
|
||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Language.get("eventEditorMobSpawnsCleared"));
|
||||
context.setSessionData(Key.A_MOB_TYPES, null);
|
||||
context.setSessionData(Key.A_MOBS, null);
|
||||
return new ActionMobListPrompt(context);
|
||||
case 3:
|
||||
return new ActionMainPrompt(context);
|
||||
|
@ -552,11 +553,11 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
|
|||
context.getForWhom().sendRawMessage(ChatColor.RED + Language.get("eventEditorMustSetMobAmountsFirst"));
|
||||
return new ActionMobPrompt(context, questMob);
|
||||
}
|
||||
final LinkedList<String> list = context.getSessionData(Key.A_MOB_TYPES) == null ? new LinkedList<>()
|
||||
: (LinkedList<String>) context.getSessionData(Key.A_MOB_TYPES);
|
||||
final LinkedList<QuestMob> list = context.getSessionData(Key.A_MOBS) == null ? new LinkedList<>()
|
||||
: (LinkedList<QuestMob>) context.getSessionData(Key.A_MOBS);
|
||||
if (list != null) {
|
||||
list.add(questMob.serialize());
|
||||
context.setSessionData(Key.A_MOB_TYPES, list);
|
||||
list.add(questMob);
|
||||
context.setSessionData(Key.A_MOBS, list);
|
||||
}
|
||||
return new ActionMobListPrompt(context);
|
||||
default:
|
||||
|
@ -1184,7 +1185,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
|
|||
return null;
|
||||
}
|
||||
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Language.get("yesWord"))) {
|
||||
if (plugin.hasLimitedAccess(context.getForWhom()) && !plugin.getSettings().canTrialSave()) {
|
||||
if (plugin.hasLimitedAccess(context.getForWhom()) && !plugin.getConfigSettings().canTrialSave()) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Language.get("modeDeny")
|
||||
.replace("<mode>", Language.get("trialMode")));
|
||||
return new ActionMainPrompt(context);
|
||||
|
|
|
@ -557,7 +557,7 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
|
|||
return null;
|
||||
}
|
||||
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Language.get("yesWord"))) {
|
||||
if (plugin.hasLimitedAccess(context.getForWhom()) && !plugin.getSettings().canTrialSave()) {
|
||||
if (plugin.hasLimitedAccess(context.getForWhom()) && !plugin.getConfigSettings().canTrialSave()) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Language.get("modeDeny")
|
||||
.replace("<mode>", Language.get("trialMode")));
|
||||
return new ConditionMainPrompt(context);
|
||||
|
|
|
@ -73,7 +73,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
|
|||
if (quests != null && number > 0) {
|
||||
if (number < (quests.size() + 1)) {
|
||||
final Quest quest = quests.get(number - 1);
|
||||
if (quester.getCompletedQuestsTemp().contains(quest)) {
|
||||
if (quester.getCompletedQuests().contains(quest)) {
|
||||
return ChatColor.GREEN;
|
||||
} else {
|
||||
return ChatColor.GOLD;
|
||||
|
@ -95,7 +95,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
|
|||
if (quests != null && number > 0) {
|
||||
if (number < (quests.size() + 1)) {
|
||||
final Quest quest = quests.get(number - 1);
|
||||
if (quester.getCompletedQuestsTemp().contains(quest)) {
|
||||
if (quester.getCompletedQuests().contains(quest)) {
|
||||
return ChatColor.GREEN + "" + ChatColor.ITALIC + quest.getName();
|
||||
} else {
|
||||
return ChatColor.YELLOW + "" + ChatColor.ITALIC + quest.getName();
|
||||
|
@ -116,7 +116,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
|
|||
if (quests != null && number > 0) {
|
||||
if (number < (quests.size() + 1)) {
|
||||
final Quest quest = quests.get(number - 1);
|
||||
if (quester.getCompletedQuestsTemp().contains(quest)) {
|
||||
if (quester.getCompletedQuests().contains(quest)) {
|
||||
return ChatColor.GREEN + "" + Language.get("redoCompleted");
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
|
|||
final MiscPostNpcOfferQuestEvent event = new MiscPostNpcOfferQuestEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getSettings().canClickablePrompts()) {
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getConfigSettings().canClickablePrompts()) {
|
||||
final StringBuilder text = new StringBuilder(ChatColor.WHITE + getTitle(context));
|
||||
size = quests.size();
|
||||
for (int i = 1; i <= size + 1; i++) {
|
||||
|
@ -162,7 +162,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
|
|||
final TextComponent choice = new TextComponent("\n" + getNumberColor(context, i) + ChatColor.BOLD + i + ". "
|
||||
+ ChatColor.RESET + getSelectionText(context, i));
|
||||
choice.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/quests choice " + i));
|
||||
if (plugin.getSettings().canShowQuestReqs() && i <= size) {
|
||||
if (plugin.getConfigSettings().canShowQuestReqs() && i <= size) {
|
||||
choice.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(quests.get(i - 1).getDescription()).create()));
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
|
|||
for (final String msg : extracted(plugin, quester).split("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
if (!plugin.getSettings().canConfirmAccept()) {
|
||||
if (!plugin.getConfigSettings().canConfirmAccept()) {
|
||||
quester.takeQuest(q, false);
|
||||
} else {
|
||||
plugin.getConversationFactory().buildConversation(player).begin();
|
||||
|
@ -238,7 +238,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
|
|||
}
|
||||
|
||||
private String extracted(final BukkitQuestsPlugin plugin, final Quester quester) {
|
||||
final Quest quest = plugin.getQuestByIdTemp(quester.getQuestIdToTake());
|
||||
final Quest quest = plugin.getQuestById(quester.getQuestIdToTake());
|
||||
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE,
|
||||
quest.getName(), ChatColor.GOLD, ChatColor.RESET, quest.getDescription());
|
||||
}
|
||||
|
|
|
@ -18,15 +18,6 @@ public class QuestAbandonPrompt extends MiscStringPrompt {
|
|||
private ConversationContext context;
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public QuestAbandonPrompt() {
|
||||
super(null);
|
||||
plugin = null;
|
||||
}
|
||||
|
||||
public QuestAbandonPrompt(BukkitQuestsPlugin plugin) {
|
||||
super(null);
|
||||
this.plugin = plugin;
|
||||
|
@ -90,7 +81,7 @@ public class QuestAbandonPrompt extends MiscStringPrompt {
|
|||
final MiscPostQuestAbandonEvent event = new MiscPostQuestAbandonEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!plugin.getSettings().canClickablePrompts()) {
|
||||
if (!plugin.getConfigSettings().canClickablePrompts()) {
|
||||
return ChatColor.YELLOW + getQueryText(context) + " " + ChatColor.GREEN
|
||||
+ getSelectionText(context, 1) + ChatColor.RESET + " / " + getSelectionText(context, 2);
|
||||
}
|
||||
|
@ -125,7 +116,7 @@ public class QuestAbandonPrompt extends MiscStringPrompt {
|
|||
}
|
||||
final String questIdToQuit = quester.getQuestIdToQuit();
|
||||
try {
|
||||
Quest quest = plugin.getQuestByIdTemp(questIdToQuit);
|
||||
Quest quest = plugin.getQuestById(questIdToQuit);
|
||||
if (quest == null) {
|
||||
plugin.getLogger().info(player.getName() + " attempted to quit quest ID \"" + questIdToQuit
|
||||
+ "\" but something went wrong");
|
||||
|
@ -134,7 +125,7 @@ public class QuestAbandonPrompt extends MiscStringPrompt {
|
|||
} else {
|
||||
final String msg = ChatColor.YELLOW + Language.get("questQuit").replace("<quest>",
|
||||
ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW);
|
||||
quester.quitQuest(plugin.getQuestByIdTemp(questIdToQuit), msg);
|
||||
quester.quitQuest(plugin.getQuestById(questIdToQuit), msg);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -842,7 +842,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
|||
return null;
|
||||
}
|
||||
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Language.get("yesWord"))) {
|
||||
if (plugin.hasLimitedAccess(context.getForWhom()) && !plugin.getSettings().canTrialSave()) {
|
||||
if (plugin.hasLimitedAccess(context.getForWhom()) && !plugin.getConfigSettings().canTrialSave()) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Language.get("modeDeny")
|
||||
.replace("<mode>", Language.get("trialMode")));
|
||||
return new QuestMainPrompt(context);
|
||||
|
|
|
@ -232,7 +232,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
|
|||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Language.get("cmdCancel"))) {
|
||||
final Quest q = plugin.getQuestTemp(input);
|
||||
final Quest q = plugin.getQuest(input);
|
||||
if (q != null) {
|
||||
plugin.getQuestFactory().loadQuest(context, q);
|
||||
return new QuestMainPrompt(context);
|
||||
|
@ -278,7 +278,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
|
|||
}
|
||||
if (!input.equalsIgnoreCase(Language.get("cmdCancel"))) {
|
||||
final LinkedList<String> used = new LinkedList<>();
|
||||
final Quest found = plugin.getQuestTemp(input);
|
||||
final Quest found = plugin.getQuest(input);
|
||||
if (found != null) {
|
||||
for (final Quest q : plugin.getLoadedQuests()) {
|
||||
if (q.getRequirements().getNeededQuestIds().contains(q.getId())
|
||||
|
|
|
@ -75,7 +75,7 @@ public class QuestDateTimePrompt extends QuestsEditorNumericPrompt {
|
|||
dateData += ChatColor.AQUA + timeFormat.format(cal.getTime()) + " ";
|
||||
|
||||
cal.setTimeZone(TimeZone.getTimeZone((String) context.getSessionData("tempZone")));
|
||||
final String[] iso = plugin.getSettings().getLanguage().split("-");
|
||||
final String[] iso = plugin.getConfigSettings().getLanguage().split("-");
|
||||
final Locale loc = new Locale(iso[0], iso[1]);
|
||||
final Double zonedHour = (double) (cal.getTimeZone().getRawOffset() / 60 / 60 / 1000);
|
||||
final String[] sep = String.valueOf(zonedHour).replace("-", "").split("\\.");
|
||||
|
|
|
@ -402,7 +402,7 @@ public class QuestPlannerPrompt extends QuestsEditorNumericPrompt {
|
|||
|
||||
final TimeZone tz = TimeZone.getTimeZone(date[6]);
|
||||
cal.setTimeZone(tz);
|
||||
final String[] iso = plugin.getSettings().getLanguage().split("-");
|
||||
final String[] iso = plugin.getConfigSettings().getLanguage().split("-");
|
||||
final Locale loc = iso.length > 1 ? new Locale(iso[0], iso[1]) : new Locale(iso[0]);
|
||||
final Double zonehour = (double) (cal.getTimeZone().getRawOffset() / 60 / 60 / 1000);
|
||||
final String[] sep = String.valueOf(zonehour).replace("-", "").split("\\.");
|
||||
|
|
|
@ -232,8 +232,8 @@ public class QuestRequirementsPrompt extends QuestsEditorNumericPrompt {
|
|||
final List<String> questReq = (List<String>) context.getSessionData(Key.REQ_QUEST);
|
||||
if (questReq != null) {
|
||||
for (String s : questReq) {
|
||||
if (plugin.getQuestByIdTemp(s) != null) {
|
||||
s = plugin.getQuestByIdTemp(s).getName();
|
||||
if (plugin.getQuestById(s) != null) {
|
||||
s = plugin.getQuestById(s).getName();
|
||||
}
|
||||
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA).append(s);
|
||||
}
|
||||
|
@ -248,8 +248,8 @@ public class QuestRequirementsPrompt extends QuestsEditorNumericPrompt {
|
|||
final List<String> questBlockReq = (List<String>) context.getSessionData(Key.REQ_QUEST_BLOCK);
|
||||
if (questBlockReq != null) {
|
||||
for (String s : questBlockReq) {
|
||||
if (plugin.getQuestByIdTemp(s) != null) {
|
||||
s = plugin.getQuestByIdTemp(s).getName();
|
||||
if (plugin.getQuestById(s) != null) {
|
||||
s = plugin.getQuestById(s).getName();
|
||||
}
|
||||
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA).append(s);
|
||||
}
|
||||
|
@ -916,17 +916,17 @@ public class QuestRequirementsPrompt extends QuestsEditorNumericPrompt {
|
|||
final LinkedList<String> questIds = new LinkedList<>();
|
||||
for (String s : args) {
|
||||
s = s.trim();
|
||||
if (plugin.getQuestTemp(s) == null) {
|
||||
if (plugin.getQuest(s) == null) {
|
||||
String text = Language.get("reqNotAQuestName");
|
||||
text = text.replace("<quest>", ChatColor.LIGHT_PURPLE + s + ChatColor.RED);
|
||||
context.getForWhom().sendRawMessage(text);
|
||||
return new QuestRequirementsQuestListPrompt(context, isRequiredQuest);
|
||||
}
|
||||
if (questIds.contains(plugin.getQuestTemp(s).getId())) {
|
||||
if (questIds.contains(plugin.getQuest(s).getId())) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Language.get("listDuplicate"));
|
||||
return new QuestRequirementsQuestListPrompt(context, isRequiredQuest);
|
||||
}
|
||||
questIds.add(plugin.getQuestTemp(s).getId());
|
||||
questIds.add(plugin.getQuest(s).getId());
|
||||
}
|
||||
if (isRequiredQuest) {
|
||||
context.setSessionData(Key.REQ_QUEST, questIds);
|
||||
|
@ -1446,7 +1446,7 @@ public class QuestRequirementsPrompt extends QuestsEditorNumericPrompt {
|
|||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getSettings().canClickablePrompts()) {
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getConfigSettings().canClickablePrompts()) {
|
||||
final StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + getTitle(context) + "\n");
|
||||
if (plugin.getCustomRequirements().isEmpty()) {
|
||||
text.append(ChatColor.DARK_AQUA).append(ChatColor.UNDERLINE)
|
||||
|
@ -1552,7 +1552,7 @@ public class QuestRequirementsPrompt extends QuestsEditorNumericPrompt {
|
|||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getSettings().canClickablePrompts()) {
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getConfigSettings().canClickablePrompts()) {
|
||||
final StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + getTitle(context) + "\n");
|
||||
if (plugin.getCustomRequirements().isEmpty()) {
|
||||
text.append(ChatColor.DARK_AQUA).append(ChatColor.UNDERLINE)
|
||||
|
|
|
@ -1666,7 +1666,7 @@ public class QuestRewardsPrompt extends QuestsEditorNumericPrompt {
|
|||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getSettings().canClickablePrompts()) {
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getConfigSettings().canClickablePrompts()) {
|
||||
final StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + getTitle(context) + "\n");
|
||||
if (plugin.getCustomRewards().isEmpty()) {
|
||||
text.append(ChatColor.DARK_AQUA).append(ChatColor.UNDERLINE)
|
||||
|
@ -1772,7 +1772,7 @@ public class QuestRewardsPrompt extends QuestsEditorNumericPrompt {
|
|||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getSettings().canClickablePrompts()) {
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getConfigSettings().canClickablePrompts()) {
|
||||
final StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + getTitle(context) + "\n");
|
||||
if (plugin.getCustomRewards().isEmpty()) {
|
||||
text.append(ChatColor.DARK_AQUA).append(ChatColor.UNDERLINE)
|
||||
|
|
|
@ -2350,7 +2350,7 @@ public class QuestStageMainPrompt extends QuestsEditorNumericPrompt {
|
|||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getSettings().canClickablePrompts()) {
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getConfigSettings().canClickablePrompts()) {
|
||||
final StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + getTitle(context) + "\n");
|
||||
if (plugin.getCustomObjectives().isEmpty()) {
|
||||
text.append(ChatColor.DARK_AQUA).append(ChatColor.UNDERLINE)
|
||||
|
@ -2456,7 +2456,7 @@ public class QuestStageMainPrompt extends QuestsEditorNumericPrompt {
|
|||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getSettings().canClickablePrompts()) {
|
||||
if (!(context.getForWhom() instanceof Player) || !plugin.getConfigSettings().canClickablePrompts()) {
|
||||
final StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + "- " + getTitle(context)
|
||||
+ " -\n");
|
||||
if (plugin.getCustomObjectives().isEmpty()) {
|
||||
|
|
|
@ -335,7 +335,7 @@ public class BukkitDependencies implements Dependencies {
|
|||
}
|
||||
|
||||
public void startNpcEffectThread() {
|
||||
if (npcEffectThread == -1 && plugin.getSettings().canNpcEffects()) {
|
||||
if (npcEffectThread == -1 && plugin.getConfigSettings().canNpcEffects()) {
|
||||
npcEffectThread = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin,
|
||||
plugin.getNpcEffectThread(), 20, 20);
|
||||
}
|
||||
|
|
|
@ -154,43 +154,6 @@ public class BukkitQuestMob implements QuestMob {
|
|||
}
|
||||
}
|
||||
|
||||
public String serialize() {
|
||||
final StringBuilder export = new StringBuilder();
|
||||
if (entityType != null) {
|
||||
export.append("type-").append(entityType.name());
|
||||
}
|
||||
if (name != null) {
|
||||
export.append("::name-").append(name);
|
||||
}
|
||||
if (spawnLocation != null) {
|
||||
export.append("::spawn-").append(BukkitConfigUtil.getLocationInfo(spawnLocation));
|
||||
}
|
||||
if (spawnAmounts != null) {
|
||||
export.append("::amounts-").append(spawnAmounts);
|
||||
}
|
||||
if (inventory.length > 0 && inventory[0] != null) {
|
||||
export.append("::hand-").append(BukkitItemUtil.serializeItemStack(inventory[0]));
|
||||
export.append("::hand_drop-").append(dropChances[0]);
|
||||
}
|
||||
if (inventory.length > 1 && inventory[1] != null) {
|
||||
export.append("::boots-").append(BukkitItemUtil.serializeItemStack(inventory[1]));
|
||||
export.append("::boots_drop-").append(dropChances[1]);
|
||||
}
|
||||
if (inventory.length > 2 && inventory[2] != null) {
|
||||
export.append("::leggings-").append(BukkitItemUtil.serializeItemStack(inventory[2]));
|
||||
export.append("::leggings_drop-").append(dropChances[2]);
|
||||
}
|
||||
if (inventory.length > 3 && inventory[3] != null) {
|
||||
export.append("::chest-").append(BukkitItemUtil.serializeItemStack(inventory[3]));
|
||||
export.append("::chest_drop-").append(dropChances[3]);
|
||||
}
|
||||
if (inventory.length > 4 && inventory[4] != null) {
|
||||
export.append("::helmet-").append(BukkitItemUtil.serializeItemStack(inventory[4]));
|
||||
export.append("::helmet_drop-").append(dropChances[4]);
|
||||
}
|
||||
return export.toString();
|
||||
}
|
||||
|
||||
public static BukkitQuestMob fromString(final String str) {
|
||||
String name = null;
|
||||
EntityType entityType = null;
|
||||
|
|
|
@ -75,7 +75,7 @@ public class BukkitQuestJournal {
|
|||
title.setBold(true);
|
||||
final BookUtil.PageBuilder builder = new BookUtil.PageBuilder().add(title).newLine();
|
||||
for (final BukkitObjective obj : ((BukkitQuester)owner).getCurrentObjectivesTemp(quest, false, false)) {
|
||||
if (!plugin.getSettings().canShowCompletedObjs()
|
||||
if (!plugin.getConfigSettings().canShowCompletedObjs()
|
||||
&& obj.getMessage().startsWith(ChatColor.GRAY.toString())) {
|
||||
continue;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public class BukkitQuestJournal {
|
|||
builder.add("" + ChatColor.DARK_AQUA + ChatColor.ITALIC
|
||||
+ goal.getItemMeta().getDisplayName());
|
||||
} else {
|
||||
if (plugin.getSettings().canTranslateNames()) {
|
||||
if (plugin.getConfigSettings().canTranslateNames()) {
|
||||
final TranslatableComponent tc = new TranslatableComponent(plugin.getLocaleManager()
|
||||
.queryItemStack(goal));
|
||||
tc.setColor(net.md_5.bungee.api.ChatColor.DARK_AQUA);
|
||||
|
@ -103,7 +103,7 @@ public class BukkitQuestJournal {
|
|||
if (obj.getMessage().contains("<mob>") && obj.getGoalAsMob() != null) {
|
||||
split = obj.getMessage().split("<mob>");
|
||||
builder.add(split[0]);
|
||||
if (plugin.getSettings().canTranslateNames()) {
|
||||
if (plugin.getConfigSettings().canTranslateNames()) {
|
||||
final TranslatableComponent tc = new TranslatableComponent(plugin.getLocaleManager()
|
||||
.queryEntityType(obj.getGoalAsMob().getEntityType(), null)); // TODO extra data
|
||||
tc.setColor(net.md_5.bungee.api.ChatColor.DARK_RED);
|
||||
|
|
|
@ -111,7 +111,7 @@ public class BukkitBlockListener implements Listener {
|
|||
|
||||
final QuesterPreUpdateObjectiveEvent preEvent
|
||||
= new QuesterPreUpdateObjectiveEvent(quester, quest,
|
||||
new BukkitObjective(placeType, is.getAmount(), toPlace.getAmount()));
|
||||
new BukkitObjective(placeType, null, is.getAmount(), toPlace.getAmount()));
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
final int index = questData.blocksPlaced.indexOf(is);
|
||||
|
@ -121,7 +121,7 @@ public class BukkitBlockListener implements Listener {
|
|||
|
||||
final QuesterPostUpdateObjectiveEvent postEvent
|
||||
= new QuesterPostUpdateObjectiveEvent(quester, quest,
|
||||
new BukkitObjective(placeType, newAmount, toPlace.getAmount()));
|
||||
new BukkitObjective(placeType, null, newAmount, toPlace.getAmount()));
|
||||
plugin.getServer().getPluginManager().callEvent(postEvent);
|
||||
}
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ public class BukkitBlockListener implements Listener {
|
|||
|
||||
final QuesterPreUpdateObjectiveEvent preEvent
|
||||
= new QuesterPreUpdateObjectiveEvent((BukkitQuester) q, cq,
|
||||
new BukkitObjective(placeType, is.getAmount(), toPlace.getAmount()));
|
||||
new BukkitObjective(placeType, null, is.getAmount(), toPlace.getAmount()));
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
final int index = qQuestData.blocksPlaced.indexOf(is);
|
||||
|
@ -152,7 +152,7 @@ public class BukkitBlockListener implements Listener {
|
|||
|
||||
final QuesterPostUpdateObjectiveEvent postEvent
|
||||
= new QuesterPostUpdateObjectiveEvent((BukkitQuester) q, cq,
|
||||
new BukkitObjective(placeType, newAmount, toPlace.getAmount()));
|
||||
new BukkitObjective(placeType, null, newAmount, toPlace.getAmount()));
|
||||
plugin.getServer().getPluginManager().callEvent(postEvent);
|
||||
}
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ public class BukkitBlockListener implements Listener {
|
|||
|
||||
final QuesterPreUpdateObjectiveEvent preEvent
|
||||
= new QuesterPreUpdateObjectiveEvent(quester, quest,
|
||||
new BukkitObjective(placeType, is.getAmount(), toBreak.getAmount()));
|
||||
new BukkitObjective(placeType, null, is.getAmount(), toBreak.getAmount()));
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
final int index = questData.blocksBroken.indexOf(is);
|
||||
|
@ -265,7 +265,7 @@ public class BukkitBlockListener implements Listener {
|
|||
|
||||
final QuesterPostUpdateObjectiveEvent postEvent
|
||||
= new QuesterPostUpdateObjectiveEvent(quester, quest,
|
||||
new BukkitObjective(placeType, newAmount, toBreak.getAmount()));
|
||||
new BukkitObjective(placeType, null, newAmount, toBreak.getAmount()));
|
||||
plugin.getServer().getPluginManager().callEvent(postEvent);
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ public class BukkitBlockListener implements Listener {
|
|||
|
||||
final QuesterPreUpdateObjectiveEvent preEvent
|
||||
= new QuesterPreUpdateObjectiveEvent((BukkitQuester) q, cq,
|
||||
new BukkitObjective(breakType, is.getAmount(), toBreak.getAmount()));
|
||||
new BukkitObjective(breakType, null, is.getAmount(), toBreak.getAmount()));
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
final int index = qQuestData.blocksBroken.indexOf(is);
|
||||
|
@ -296,7 +296,7 @@ public class BukkitBlockListener implements Listener {
|
|||
|
||||
final QuesterPostUpdateObjectiveEvent postEvent
|
||||
= new QuesterPostUpdateObjectiveEvent((BukkitQuester) q, cq,
|
||||
new BukkitObjective(breakType, newAmount, toBreak.getAmount()));
|
||||
new BukkitObjective(breakType, null, newAmount, toBreak.getAmount()));
|
||||
plugin.getServer().getPluginManager().callEvent(postEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ public class BukkitCitizensListener implements Listener {
|
|||
text += (hand.getItemMeta().hasDisplayName() ? ")" : "");
|
||||
}
|
||||
text += " x " + ChatColor.DARK_AQUA + hand.getAmount() + ChatColor.GRAY;
|
||||
if (plugin.getSettings().canTranslateNames() && !hasMeta
|
||||
if (plugin.getConfigSettings().canTranslateNames() && !hasMeta
|
||||
&& !hand.getItemMeta().hasDisplayName()) {
|
||||
plugin.getLocaleManager().sendMessage(player, Language
|
||||
.get(player, "questInvalidDeliveryItem").replace("<item>", text), hand
|
||||
|
@ -220,8 +220,8 @@ public class BukkitCitizensListener implements Listener {
|
|||
continue;
|
||||
}
|
||||
if (bukkitQuest.getNpcStart() != null && bukkitQuest.getNpcStart().equals(event.getNPC().getUniqueId())) {
|
||||
if (plugin.getSettings().canIgnoreLockedQuests()
|
||||
&& (!quester.getCompletedQuestsTemp().contains(bukkitQuest)
|
||||
if (plugin.getConfigSettings().canIgnoreLockedQuests()
|
||||
&& (!quester.getCompletedQuests().contains(bukkitQuest)
|
||||
|| bukkitQuest.getPlanner().getCooldown() > -1)) {
|
||||
if (bukkitQuest.testRequirements(quester)) {
|
||||
npcQuests.add(bukkitQuest);
|
||||
|
@ -229,7 +229,7 @@ public class BukkitCitizensListener implements Listener {
|
|||
hasAtLeastOneGUI = true;
|
||||
}
|
||||
}
|
||||
} else if (!quester.getCompletedQuestsTemp().contains(bukkitQuest) || bukkitQuest.getPlanner().getCooldown() > -1) {
|
||||
} else if (!quester.getCompletedQuests().contains(bukkitQuest) || bukkitQuest.getPlanner().getCooldown() > -1) {
|
||||
npcQuests.add(bukkitQuest);
|
||||
if (bukkitQuest.getGUIDisplay() != null) {
|
||||
hasAtLeastOneGUI = true;
|
||||
|
@ -241,7 +241,7 @@ public class BukkitCitizensListener implements Listener {
|
|||
final BukkitQuest bukkitQuest = (BukkitQuest) npcQuests.get(0);
|
||||
if (quester.canAcceptOffer(bukkitQuest, true)) {
|
||||
quester.setQuestIdToTake(bukkitQuest.getId());
|
||||
if (!plugin.getSettings().canConfirmAccept()) {
|
||||
if (!plugin.getConfigSettings().canConfirmAccept()) {
|
||||
quester.takeQuest(bukkitQuest, false);
|
||||
} else {
|
||||
if (bukkitQuest.getGUIDisplay() != null) {
|
||||
|
@ -332,7 +332,7 @@ public class BukkitCitizensListener implements Listener {
|
|||
}
|
||||
|
||||
private String extracted(final Quester quester) {
|
||||
final Quest quest = plugin.getQuestByIdTemp(quester.getQuestIdToTake());
|
||||
final Quest quest = plugin.getQuestById(quester.getQuestIdToTake());
|
||||
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE,
|
||||
quest.getName(), ChatColor.GOLD, ChatColor.RESET, quest.getDescription());
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ public class BukkitPlayerListener implements Listener {
|
|||
.replace("<journal>", Language.get(event.getPlayer(), "journalTitle")));
|
||||
return;
|
||||
}
|
||||
if (plugin.getSettings().canAllowPranks()
|
||||
if (plugin.getConfigSettings().canAllowPranks()
|
||||
&& event.getClickedBlock().getType().name().contains("PORTAL")) {
|
||||
event.setCancelled(true);
|
||||
Language.send(player, " " + ChatColor.AQUA + ChatColor.UNDERLINE
|
||||
|
@ -206,7 +206,7 @@ public class BukkitPlayerListener implements Listener {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (plugin.getSettings().canAllowPranks()
|
||||
if (plugin.getConfigSettings().canAllowPranks()
|
||||
&& event.getPlayer().getInventory().getHelmet() != null
|
||||
&& (event.getPlayer().getInventory().getHelmet().getType().name().equals("PUMPKIN")
|
||||
|| event.getPlayer().getInventory().getHelmet().getType().name().equals("CARVED_PUMPKIN"))) {
|
||||
|
@ -373,14 +373,14 @@ public class BukkitPlayerListener implements Listener {
|
|||
final BukkitQuest bukkitQuest = (BukkitQuest) quest;
|
||||
if (bukkitQuest.getBlockStart() != null && event.getClickedBlock() != null) {
|
||||
if (bukkitQuest.getBlockStart().equals(event.getClickedBlock().getLocation())) {
|
||||
if (quester.getCurrentQuests().size() >= plugin.getSettings().getMaxQuests()
|
||||
&& plugin.getSettings().getMaxQuests() > 0) {
|
||||
if (quester.getCurrentQuests().size() >= plugin.getConfigSettings().getMaxQuests()
|
||||
&& plugin.getConfigSettings().getMaxQuests() > 0) {
|
||||
String msg = Language.get(player, "questMaxAllowed");
|
||||
msg = msg.replace("<number>", String
|
||||
.valueOf(plugin.getSettings().getMaxQuests()));
|
||||
.valueOf(plugin.getConfigSettings().getMaxQuests()));
|
||||
Language.send(player, ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
if (quester.getCompletedQuestsTemp().contains(bukkitQuest)) {
|
||||
if (quester.getCompletedQuests().contains(bukkitQuest)) {
|
||||
if (bukkitQuest.getPlanner().getCooldown() > -1
|
||||
&& (quester.getRemainingCooldown(bukkitQuest)) > 0) {
|
||||
String early = Language.get(player, "questTooEarly");
|
||||
|
@ -391,7 +391,7 @@ public class BukkitPlayerListener implements Listener {
|
|||
+ ChatColor.YELLOW);
|
||||
Language.send(player, ChatColor.YELLOW + early);
|
||||
continue;
|
||||
} else if (quester.getCompletedQuestsTemp().contains(bukkitQuest)
|
||||
} else if (quester.getCompletedQuests().contains(bukkitQuest)
|
||||
&& bukkitQuest.getPlanner().getCooldown() < 0) {
|
||||
String completed = Language.get(player, "questAlreadyCompleted");
|
||||
completed = completed.replace("<quest>", ChatColor.AQUA
|
||||
|
@ -407,10 +407,10 @@ public class BukkitPlayerListener implements Listener {
|
|||
}
|
||||
}
|
||||
quester.setQuestIdToTake(bukkitQuest.getId());
|
||||
if (!plugin.getSettings().canConfirmAccept()) {
|
||||
if (!plugin.getConfigSettings().canConfirmAccept()) {
|
||||
quester.takeQuest(bukkitQuest, false);
|
||||
} else {
|
||||
final Quest toTake = plugin.getQuestByIdTemp(quester.getQuestIdToTake());
|
||||
final Quest toTake = plugin.getQuestById(quester.getQuestIdToTake());
|
||||
final String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE
|
||||
+ toTake.getName() + ChatColor.GOLD + " -\n" + "\n"
|
||||
+ ChatColor.RESET + toTake.getDescription() + "\n";
|
||||
|
@ -878,7 +878,7 @@ public class BukkitPlayerListener implements Listener {
|
|||
}
|
||||
if (plugin.canUseQuests(player.getUniqueId())) {
|
||||
final Quester noobCheck = new BukkitQuester(plugin, player.getUniqueId());
|
||||
if (plugin.getSettings().canGenFilesOnJoin() && !noobCheck.hasData()) {
|
||||
if (plugin.getConfigSettings().canGenFilesOnJoin() && !noobCheck.hasData()) {
|
||||
noobCheck.saveData();
|
||||
}
|
||||
|
||||
|
@ -889,7 +889,7 @@ public class BukkitPlayerListener implements Listener {
|
|||
if (quester == null) {
|
||||
return;
|
||||
}
|
||||
for (final Quest q : quester.getCompletedQuestsTemp()) {
|
||||
for (final Quest q : quester.getCompletedQuests()) {
|
||||
if (q != null) {
|
||||
if (!quester.getCompletedTimes().containsKey(q) && q.getPlanner().getCooldown() > -1) {
|
||||
quester.getCompletedTimes().put(q, System.currentTimeMillis());
|
||||
|
@ -937,7 +937,7 @@ public class BukkitPlayerListener implements Listener {
|
|||
currentStage.getDisconnectAction().fire(quester, quest);
|
||||
}
|
||||
}
|
||||
if (!plugin.getSettings().canGenFilesOnJoin()) {
|
||||
if (!plugin.getConfigSettings().canGenFilesOnJoin()) {
|
||||
if (quester.hasBaseData()) {
|
||||
quester.saveData();
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public class BukkitZnpcsListener implements Listener {
|
|||
text += (hand.getItemMeta().hasDisplayName() ? ")" : "");
|
||||
}
|
||||
text += " x " + ChatColor.DARK_AQUA + hand.getAmount() + ChatColor.GRAY;
|
||||
if (plugin.getSettings().canTranslateNames() && !hasMeta
|
||||
if (plugin.getConfigSettings().canTranslateNames() && !hasMeta
|
||||
&& !hand.getItemMeta().hasDisplayName()) {
|
||||
plugin.getLocaleManager().sendMessage(player, Language
|
||||
.get(player, "questInvalidDeliveryItem").replace("<item>", text), hand
|
||||
|
@ -209,8 +209,8 @@ public class BukkitZnpcsListener implements Listener {
|
|||
continue;
|
||||
}
|
||||
if (bukkitQuest.getNpcStart() != null && bukkitQuest.getNpcStart().equals(event.getNpc().getUUID())) {
|
||||
if (plugin.getSettings().canIgnoreLockedQuests()
|
||||
&& (!quester.getCompletedQuestsTemp().contains(bukkitQuest)
|
||||
if (plugin.getConfigSettings().canIgnoreLockedQuests()
|
||||
&& (!quester.getCompletedQuests().contains(bukkitQuest)
|
||||
|| bukkitQuest.getPlanner().getCooldown() > -1)) {
|
||||
if (bukkitQuest.testRequirements(quester)) {
|
||||
npcQuests.add(bukkitQuest);
|
||||
|
@ -218,7 +218,7 @@ public class BukkitZnpcsListener implements Listener {
|
|||
hasAtLeastOneGUI = true;
|
||||
}
|
||||
}
|
||||
} else if (!quester.getCompletedQuestsTemp().contains(bukkitQuest) || bukkitQuest.getPlanner().getCooldown() > -1) {
|
||||
} else if (!quester.getCompletedQuests().contains(bukkitQuest) || bukkitQuest.getPlanner().getCooldown() > -1) {
|
||||
npcQuests.add(bukkitQuest);
|
||||
if (bukkitQuest.getGUIDisplay() != null) {
|
||||
hasAtLeastOneGUI = true;
|
||||
|
@ -230,7 +230,7 @@ public class BukkitZnpcsListener implements Listener {
|
|||
final BukkitQuest quest = (BukkitQuest) npcQuests.get(0);
|
||||
if (quester.canAcceptOffer(quest, true)) {
|
||||
quester.setQuestIdToTake(quest.getId());
|
||||
if (!plugin.getSettings().canConfirmAccept()) {
|
||||
if (!plugin.getConfigSettings().canConfirmAccept()) {
|
||||
quester.takeQuest(quest, false);
|
||||
} else {
|
||||
if (quest.getGUIDisplay() != null) {
|
||||
|
@ -261,7 +261,7 @@ public class BukkitZnpcsListener implements Listener {
|
|||
}
|
||||
|
||||
private String extracted(final Quester quester) {
|
||||
final Quest quest = plugin.getQuestByIdTemp(quester.getQuestIdToTake());
|
||||
final Quest quest = plugin.getQuestById(quester.getQuestIdToTake());
|
||||
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE,
|
||||
quest.getName(), ChatColor.GOLD, ChatColor.RESET, quest.getDescription());
|
||||
}
|
||||
|
|
|
@ -245,11 +245,11 @@ public class BukkitCustomObjective implements CustomObjective, Listener {
|
|||
|
||||
final ObjectiveType type = ObjectiveType.CUSTOM;
|
||||
final QuesterPreUpdateObjectiveEvent preEvent
|
||||
= new QuesterPreUpdateObjectiveEvent(quester, bukkitQuest, new BukkitObjective(type, progress, goal));
|
||||
= new QuesterPreUpdateObjectiveEvent(quester, bukkitQuest, new BukkitObjective(type, null, progress, goal));
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
if (progress >= goal) {
|
||||
quester.finishObjective(bukkitQuest, new BukkitObjective(type, new ItemStack(Material.AIR, 1),
|
||||
quester.finishObjective(bukkitQuest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
|
||||
new ItemStack(Material.AIR, goal)), null, null, null, null, null, null, bukkitCustomObj);
|
||||
|
||||
// Multiplayer
|
||||
|
@ -258,14 +258,14 @@ public class BukkitCustomObjective implements CustomObjective, Listener {
|
|||
final BukkitQuestData qBukkitQuestData = (BukkitQuestData) q.getQuestData(bukkitQuest);
|
||||
final int old = qBukkitQuestData.customObjectiveCounts.get(finalIndex);
|
||||
qBukkitQuestData.customObjectiveCounts.set(finalIndex, old + count);
|
||||
q.finishObjective(bukkitQuest, new BukkitObjective(type, new ItemStack(Material.AIR, 1),
|
||||
q.finishObjective(bukkitQuest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
|
||||
new ItemStack(Material.AIR, goal)), null, null, null, null, null, null, bukkitCustomObj);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
final QuesterPostUpdateObjectiveEvent postEvent
|
||||
= new QuesterPostUpdateObjectiveEvent(quester, bukkitQuest, new BukkitObjective(type, progress, goal));
|
||||
= new QuesterPostUpdateObjectiveEvent(quester, bukkitQuest, new BukkitObjective(type, null, progress, goal));
|
||||
plugin.getServer().getPluginManager().callEvent(postEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,34 +64,10 @@ public abstract class BukkitCustomReward implements CustomReward {
|
|||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setItem(String, short)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void addItem(final String type, final short durability) {
|
||||
setItem(type, durability);
|
||||
}
|
||||
|
||||
public void setItem(final String type, final short durability) {
|
||||
this.item = new AbstractMap.SimpleEntry<>(type, durability);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getDisplay()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getRewardName() {
|
||||
return display;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setDisplay(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRewardName(final String name) {
|
||||
display = name;
|
||||
}
|
||||
|
||||
public Map<String, Object> getData() {
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public abstract class BukkitActionBarProvider {
|
|||
try {
|
||||
final String packageName = BukkitActionBarProvider.class.getPackage().getName();
|
||||
if (internalsName.startsWith("v1_8_R")) {
|
||||
loaded = (BukkitActionBarProvider) Class.forName(packageName + ".ActionBarProvider_" + internalsName)
|
||||
loaded = (BukkitActionBarProvider) Class.forName(packageName + ".BukkitActionBarProvider_" + internalsName)
|
||||
.newInstance();
|
||||
} else {
|
||||
// Should not be an issue because single thread, alternatives welcome!
|
||||
|
|
|
@ -29,7 +29,7 @@ public abstract class BukkitParticleProvider {
|
|||
try {
|
||||
final String packageName = BukkitParticleProvider.class.getPackage().getName();
|
||||
if (internalsName.startsWith("v1_8_R")) {
|
||||
loaded = (BukkitParticleProvider) Class.forName(packageName + ".ParticleProvider_" + internalsName)
|
||||
loaded = (BukkitParticleProvider) Class.forName(packageName + ".BukkitParticleProvider_" + internalsName)
|
||||
.newInstance();
|
||||
} else {
|
||||
// Should not be an issue because single thread, alternatives welcome!
|
||||
|
|
|
@ -24,7 +24,7 @@ public abstract class BukkitTitleProvider {
|
|||
try {
|
||||
final String packageName = BukkitTitleProvider.class.getPackage().getName();
|
||||
if (internalsName.startsWith("v1_8_R")) {
|
||||
loaded = (BukkitTitleProvider) Class.forName(packageName + ".TitleProvider_" + internalsName)
|
||||
loaded = (BukkitTitleProvider) Class.forName(packageName + ".BukkitTitleProvider_" + internalsName)
|
||||
.newInstance();
|
||||
} else {
|
||||
// Should not be an issue because single thread, alternatives welcome!
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -25,30 +25,6 @@ public class BukkitObjective implements Objective {
|
|||
private final int goal;
|
||||
private final Object progressObj;
|
||||
private final Object goalObj;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #BukkitObjective(ObjectiveType, String, int, int)} with null message
|
||||
*/
|
||||
public BukkitObjective(final ObjectiveType type, final int progress, final int goal) {
|
||||
this.type = type;
|
||||
this.message = null;
|
||||
this.progress = progress;
|
||||
this.goal = goal;
|
||||
this.progressObj = new Object();
|
||||
this.goalObj = new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #BukkitObjective(ObjectiveType, String, Object, Object)} with null message
|
||||
*/
|
||||
public BukkitObjective(final ObjectiveType type, final ItemStack progress, final ItemStack goal) {
|
||||
this.type = type;
|
||||
this.message = null;
|
||||
this.progress = progress.getAmount();
|
||||
this.goal = goal.getAmount();
|
||||
this.progressObj = progress;
|
||||
this.goalObj = goal;
|
||||
}
|
||||
|
||||
public BukkitObjective(final ObjectiveType type, @Nullable final String message, final int progress,
|
||||
final int goal) {
|
||||
|
|
|
@ -338,7 +338,7 @@ public class BukkitQuest implements Quest {
|
|||
if (stageStartMessage != null) {
|
||||
p.sendMessage(BukkitConfigUtil.parseStringWithPossibleLineBreaks(stageStartMessage, this, p));
|
||||
}
|
||||
plugin.showConditions(this, quester);
|
||||
quester.showCurrentConditions(this, quester);
|
||||
}
|
||||
quester.updateJournal();
|
||||
quester.saveData();
|
||||
|
@ -580,7 +580,7 @@ public class BukkitQuest implements Quest {
|
|||
if (quester.getQuestPoints() < requirements.getQuestPoints()) {
|
||||
return false;
|
||||
}
|
||||
final Set<String> completed = quester.getCompletedQuestsTemp().stream().map(Quest::getId)
|
||||
final Set<String> completed = quester.getCompletedQuests().stream().map(Quest::getId)
|
||||
.collect(Collectors.toSet());
|
||||
if (!requirements.getNeededQuestIds().isEmpty()
|
||||
&& !completed.containsAll(requirements.getNeededQuestIds())) {
|
||||
|
@ -702,7 +702,7 @@ public class BukkitQuest implements Quest {
|
|||
return;
|
||||
}
|
||||
quester.hardQuit(this);
|
||||
quester.getCompletedQuestsTemp().add(this);
|
||||
quester.getCompletedQuests().add(this);
|
||||
for (final Map.Entry<Integer, Quest> entry : quester.getTimers().entrySet()) {
|
||||
if (entry.getValue().getName().equals(getName())) {
|
||||
plugin.getServer().getScheduler().cancelTask(entry.getKey());
|
||||
|
@ -730,7 +730,7 @@ public class BukkitQuest implements Quest {
|
|||
if (rewards.getMoney() > 0 && depends.getVaultEconomy() != null) {
|
||||
depends.getVaultEconomy().depositPlayer(player, rewards.getMoney());
|
||||
issuedReward = true;
|
||||
if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info(player.getUniqueId() + " was rewarded "
|
||||
+ depends.getVaultEconomy().format(rewards.getMoney()));
|
||||
}
|
||||
|
@ -746,7 +746,7 @@ public class BukkitQuest implements Quest {
|
|||
+ "Please contact an administrator.");
|
||||
}
|
||||
issuedReward = true;
|
||||
if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info(player.getUniqueId() + " was rewarded " + i.getType().name() + " x "
|
||||
+ i.getAmount());
|
||||
}
|
||||
|
@ -768,7 +768,7 @@ public class BukkitQuest implements Quest {
|
|||
Bukkit.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command));
|
||||
}
|
||||
issuedReward = true;
|
||||
if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info(player.getUniqueId() + " was rewarded command " + s);
|
||||
}
|
||||
}
|
||||
|
@ -784,7 +784,7 @@ public class BukkitQuest implements Quest {
|
|||
} else {
|
||||
depends.getVaultPermission().playerAdd(world, player, perm);
|
||||
}
|
||||
if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info(player.getUniqueId() + " was rewarded permission " + perm);
|
||||
}
|
||||
issuedReward = true;
|
||||
|
@ -793,7 +793,7 @@ public class BukkitQuest implements Quest {
|
|||
for (final String s : rewards.getMcmmoSkills()) {
|
||||
final int levels = rewards.getMcmmoAmounts().get(rewards.getMcmmoSkills().indexOf(s));
|
||||
UserManager.getOfflinePlayer(player).getProfile().addLevels(plugin.getDependencies().getMcMMOSkill(s), levels);
|
||||
if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info(player.getUniqueId() + " was rewarded " + s + " x " + levels);
|
||||
}
|
||||
issuedReward = true;
|
||||
|
@ -804,7 +804,7 @@ public class BukkitQuest implements Quest {
|
|||
final double expChange = rewards.getHeroesAmounts().get(rewards.getHeroesClasses().indexOf(s));
|
||||
hero.addExp(expChange, plugin.getDependencies().getHeroes().getClassManager().getClass(s),
|
||||
((Player)player).getLocation());
|
||||
if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info(player.getUniqueId() + " was rewarded " + s + " x " + expChange);
|
||||
}
|
||||
issuedReward = true;
|
||||
|
@ -817,7 +817,7 @@ public class BukkitQuest implements Quest {
|
|||
if (party != null) {
|
||||
party.giveExperience(rewards.getPartiesExperience());
|
||||
issuedReward = true;
|
||||
if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info(player.getUniqueId() + " was rewarded "
|
||||
+ rewards.getPartiesExperience() + " party experience");
|
||||
}
|
||||
|
@ -826,14 +826,14 @@ public class BukkitQuest implements Quest {
|
|||
}
|
||||
if (rewards.getExp() > 0 && player.isOnline()) {
|
||||
((Player)player).giveExp(rewards.getExp());
|
||||
if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info(player.getUniqueId() + " was rewarded exp " + rewards.getExp());
|
||||
}
|
||||
issuedReward = true;
|
||||
}
|
||||
if (rewards.getQuestPoints() > 0) {
|
||||
quester.setQuestPoints(quester.getQuestPoints() + rewards.getQuestPoints());
|
||||
if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info(player.getUniqueId() + " was rewarded " + rewards.getQuestPoints() + " "
|
||||
+ Language.get("questPoints"));
|
||||
}
|
||||
|
@ -841,7 +841,7 @@ public class BukkitQuest implements Quest {
|
|||
}
|
||||
if (!rewards.getCustomRewards().isEmpty()) {
|
||||
issuedReward = true;
|
||||
if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
|
||||
for (final String s : rewards.getCustomRewards().keySet()) {
|
||||
plugin.getLogger().info(player.getUniqueId() + " was custom rewarded " + s);
|
||||
}
|
||||
|
@ -853,7 +853,7 @@ public class BukkitQuest implements Quest {
|
|||
final Player p = (Player)player;
|
||||
Language.send(p, ChatColor.GOLD + Language.get(p, "questCompleteTitle").replace("<quest>",
|
||||
ChatColor.YELLOW + name + ChatColor.GOLD));
|
||||
if (plugin.getSettings().canShowQuestTitles()) {
|
||||
if (plugin.getConfigSettings().canShowQuestTitles()) {
|
||||
final String title = ChatColor.GOLD + Language.get(p, "quest") + " " + Language.get(p, "complete");
|
||||
final String subtitle = ChatColor.YELLOW + name;
|
||||
BukkitTitleProvider.sendTitle(p, title, subtitle);
|
||||
|
@ -921,7 +921,7 @@ public class BukkitQuest implements Quest {
|
|||
}
|
||||
text.append(ChatColor.GRAY).append(" x ").append(i.getAmount());
|
||||
}
|
||||
if (plugin.getSettings().canTranslateNames() && text.toString().contains("<item>")) {
|
||||
if (plugin.getConfigSettings().canTranslateNames() && text.toString().contains("<item>")) {
|
||||
if (!plugin.getLocaleManager().sendMessage(p, text.toString(), i.getType(), i.getDurability(),
|
||||
i.getEnchantments())) {
|
||||
for (final Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
||||
|
@ -1088,31 +1088,6 @@ public class BukkitQuest implements Quest {
|
|||
plugin.getServer().getPluginManager().callEvent(postEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if quester is in WorldGuard region start
|
||||
*
|
||||
* @deprecated Use {@link #isInRegionStart(Quester)}
|
||||
* @param quester The quester to check
|
||||
* @return true if quester is in region
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isInRegion(final Quester quester) {
|
||||
return isInRegionStart(quester);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if player is in WorldGuard region start
|
||||
*
|
||||
* @deprecated Use {@link #isInRegionStart(Player)}
|
||||
* @param player The player to check
|
||||
* @return true if player is in region
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("unused")
|
||||
private boolean isInRegion(final Player player) {
|
||||
return isInRegionStart(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if quester is in WorldGuard region start
|
||||
*
|
||||
|
@ -1120,19 +1095,10 @@ public class BukkitQuest implements Quest {
|
|||
* @return true if quester is in region
|
||||
*/
|
||||
public boolean isInRegionStart(final Quester quester) {
|
||||
return isInRegionStart(quester.getPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if player is in WorldGuard region start
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return true if player is in region
|
||||
*/
|
||||
private boolean isInRegionStart(final Player player) {
|
||||
if (regionStart == null) {
|
||||
return false;
|
||||
}
|
||||
final Player player = quester.getPlayer();
|
||||
return plugin.getDependencies().getWorldGuardApi()
|
||||
.getApplicableRegionsIDs(player.getWorld(), player.getLocation()).contains(regionStart);
|
||||
}
|
||||
|
|
|
@ -566,7 +566,7 @@ public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedLi
|
|||
};
|
||||
plugin.reload(callback);
|
||||
context.getForWhom().sendRawMessage(ChatColor.GREEN + Language.get("questDeleted"));
|
||||
if (plugin.getSettings().getConsoleLogging() > 0) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 0) {
|
||||
final String identifier = context.getForWhom() instanceof Player ?
|
||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||
plugin.getLogger().info(identifier + " deleted quest " + quest);
|
||||
|
@ -614,7 +614,7 @@ public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedLi
|
|||
saveRewards(context, section);
|
||||
savePlanner(context, section);
|
||||
saveOptions(context, section);
|
||||
if (plugin.getSettings().getConsoleLogging() > 0) {
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 0) {
|
||||
final String identifier = context.getForWhom() instanceof Player ?
|
||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||
plugin.getLogger().info(identifier + " saved quest " + context.getSessionData(Key.Q_NAME));
|
||||
|
|
|
@ -83,11 +83,11 @@ public class SeparatedYamlStorage implements StorageImplementation {
|
|||
final List<Long> questTimes = data.getLongList("completedQuestTimes");
|
||||
final ConcurrentHashMap<Quest, Long> completedTimes = quester.getCompletedTimes();
|
||||
for (int i = 0; i < questIds.size(); i++) {
|
||||
if (plugin.getQuestByIdTemp(questIds.get(i)) != null) {
|
||||
completedTimes.put(plugin.getQuestByIdTemp(questIds.get(i)), questTimes.get(i));
|
||||
} else if (plugin.getQuestTemp(questIds.get(i)) != null) {
|
||||
if (plugin.getQuestById(questIds.get(i)) != null) {
|
||||
completedTimes.put(plugin.getQuestById(questIds.get(i)), questTimes.get(i));
|
||||
} else if (plugin.getQuest(questIds.get(i)) != null) {
|
||||
// Legacy
|
||||
completedTimes.put(plugin.getQuestTemp(questIds.get(i)), questTimes.get(i));
|
||||
completedTimes.put(plugin.getQuest(questIds.get(i)), questTimes.get(i));
|
||||
}
|
||||
}
|
||||
quester.setCompletedTimes(completedTimes);
|
||||
|
@ -97,29 +97,29 @@ public class SeparatedYamlStorage implements StorageImplementation {
|
|||
final List<Integer> questAmounts = data.getIntegerList("amountsCompleted");
|
||||
final ConcurrentHashMap<Quest, Integer> amountsCompleted = quester.getAmountsCompleted();
|
||||
for (int i = 0; i < questIds.size(); i++) {
|
||||
if (plugin.getQuestByIdTemp(questIds.get(i)) != null) {
|
||||
amountsCompleted.put(plugin.getQuestByIdTemp(questIds.get(i)), questAmounts.get(i));
|
||||
} else if (plugin.getQuestTemp(questIds.get(i)) != null) {
|
||||
if (plugin.getQuestById(questIds.get(i)) != null) {
|
||||
amountsCompleted.put(plugin.getQuestById(questIds.get(i)), questAmounts.get(i));
|
||||
} else if (plugin.getQuest(questIds.get(i)) != null) {
|
||||
// Legacy
|
||||
amountsCompleted.put(plugin.getQuestTemp(questIds.get(i)), questAmounts.get(i));
|
||||
amountsCompleted.put(plugin.getQuest(questIds.get(i)), questAmounts.get(i));
|
||||
}
|
||||
}
|
||||
quester.setAmountsCompleted(amountsCompleted);
|
||||
}
|
||||
quester.setLastKnownName(data.getString("lastKnownName"));
|
||||
quester.setQuestPoints(data.getInt("quest-points"));
|
||||
final ConcurrentSkipListSet<Quest> completedQuests = quester.getCompletedQuestsTemp();
|
||||
final ConcurrentSkipListSet<Quest> completedQuests = quester.getCompletedQuests();
|
||||
if (data.isList("completed-Quests")) {
|
||||
for (final String s : data.getStringList("completed-Quests")) {
|
||||
for (final Quest q : plugin.getLoadedQuests()) {
|
||||
if (q.getId().equals(s)) {
|
||||
if (!quester.getCompletedQuestsTemp().contains(q)) {
|
||||
if (!quester.getCompletedQuests().contains(q)) {
|
||||
completedQuests.add(q);
|
||||
}
|
||||
break;
|
||||
} else if (q.getName().equalsIgnoreCase(s)) {
|
||||
// Legacy
|
||||
if (!quester.getCompletedQuestsTemp().contains(q)) {
|
||||
if (!quester.getCompletedQuests().contains(q)) {
|
||||
completedQuests.add(q);
|
||||
}
|
||||
break;
|
||||
|
@ -134,11 +134,11 @@ public class SeparatedYamlStorage implements StorageImplementation {
|
|||
final int maxSize = Math.min(questIds.size(), questStages.size());
|
||||
final ConcurrentHashMap<Quest, Integer> currentQuests = quester.getCurrentQuests();
|
||||
for (int i = 0; i < maxSize; i++) {
|
||||
if (plugin.getQuestByIdTemp(questIds.get(i)) != null) {
|
||||
currentQuests.put(plugin.getQuestByIdTemp(questIds.get(i)), questStages.get(i));
|
||||
} else if (plugin.getQuestTemp(questIds.get(i)) != null) {
|
||||
if (plugin.getQuestById(questIds.get(i)) != null) {
|
||||
currentQuests.put(plugin.getQuestById(questIds.get(i)), questStages.get(i));
|
||||
} else if (plugin.getQuest(questIds.get(i)) != null) {
|
||||
// Legacy
|
||||
currentQuests.put(plugin.getQuestTemp(questIds.get(i)), questStages.get(i));
|
||||
currentQuests.put(plugin.getQuest(questIds.get(i)), questStages.get(i));
|
||||
}
|
||||
}
|
||||
quester.setCurrentQuests(currentQuests);
|
||||
|
@ -148,7 +148,7 @@ public class SeparatedYamlStorage implements StorageImplementation {
|
|||
}
|
||||
for (final String key : dataSec.getKeys(false)) {
|
||||
final ConfigurationSection questSec = dataSec.getConfigurationSection(key);
|
||||
final Quest quest = plugin.getQuestByIdTemp(key) != null ? plugin.getQuestByIdTemp(key) : plugin.getQuestTemp(key);
|
||||
final Quest quest = plugin.getQuestById(key) != null ? plugin.getQuestById(key) : plugin.getQuest(key);
|
||||
if (quest == null || !quester.getCurrentQuests().containsKey(quest)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ public class SqlStorage implements StorageImplementation {
|
|||
final Set<String> currentQuests = bukkitQuester.getCurrentQuests().keySet().stream().map(Quest::getId).collect(Collectors.toSet());
|
||||
final Set<String> oldCurrentQuests = getQuesterCurrentQuests(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet());
|
||||
oldCurrentQuests.removeAll(currentQuests);
|
||||
final Set<String> completedQuests = bukkitQuester.getCompletedQuestsTemp().stream().map(Quest::getId).collect(Collectors.toSet());
|
||||
final Set<String> completedQuests = bukkitQuester.getCompletedQuests().stream().map(Quest::getId).collect(Collectors.toSet());
|
||||
final Set<String> oldCompletedQuests = getQuesterCompletedQuests(uniqueId).stream().map(Quest::getId).collect(Collectors.toSet());
|
||||
oldCompletedQuests.removeAll(completedQuests);
|
||||
final Set<String> redoableQuests = bukkitQuester.getCompletedTimes().keySet().stream().map(Quest::getId).collect(Collectors.toSet());
|
||||
|
@ -311,7 +311,7 @@ public class SqlStorage implements StorageImplementation {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
for (final Quest quest : bukkitQuester.getCompletedQuestsTemp()) {
|
||||
for (final Quest quest : bukkitQuester.getCompletedQuests()) {
|
||||
try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_COMPLETED_QUESTS_INSERT))) {
|
||||
ps.setString(1, uniqueId.toString());
|
||||
ps.setString(2, quest.getId());
|
||||
|
@ -441,7 +441,7 @@ public class SqlStorage implements StorageImplementation {
|
|||
ps.setString(1, uniqueId.toString());
|
||||
try (final ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
final Quest quest = plugin.getQuestByIdTemp(rs.getString("questid"));
|
||||
final Quest quest = plugin.getQuestById(rs.getString("questid"));
|
||||
if (quest != null) {
|
||||
currentQuests.put(quest, rs.getInt("stageNum"));
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ public class SqlStorage implements StorageImplementation {
|
|||
ps.setString(1, uniqueId.toString());
|
||||
try (final ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
final Quest quest = plugin.getQuestByIdTemp(rs.getString("quest_id"));
|
||||
final Quest quest = plugin.getQuestById(rs.getString("quest_id"));
|
||||
final BukkitQuestData data = new BukkitQuestData(quester);
|
||||
if (quest != null && quester.getCurrentStage(quest) != null) {
|
||||
final BukkitStage stage = (BukkitStage) quester.getCurrentStage(quest);
|
||||
|
@ -515,7 +515,7 @@ public class SqlStorage implements StorageImplementation {
|
|||
ps.setString(1, uniqueId.toString());
|
||||
try (final ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
final Quest quest = plugin.getQuestByIdTemp(rs.getString("questid"));
|
||||
final Quest quest = plugin.getQuestById(rs.getString("questid"));
|
||||
if (quest != null) {
|
||||
completedQuests.add(quest);
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ public class SqlStorage implements StorageImplementation {
|
|||
ps.setString(1, uniqueId.toString());
|
||||
try (final ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
final Quest quest = plugin.getQuestByIdTemp(rs.getString("questid"));
|
||||
final Quest quest = plugin.getQuestById(rs.getString("questid"));
|
||||
if (quest != null) {
|
||||
completedTimes.put(quest, rs.getLong("lasttime"));
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ public class SqlStorage implements StorageImplementation {
|
|||
ps.setString(1, uniqueId.toString());
|
||||
try (final ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
final Quest quest = plugin.getQuestByIdTemp(rs.getString("questid"));
|
||||
final Quest quest = plugin.getQuestById(rs.getString("questid"));
|
||||
if (quest != null) {
|
||||
amountsCompleted.put(quest, rs.getInt("amount"));
|
||||
}
|
||||
|
|
|
@ -68,17 +68,17 @@ public class BukkitNpcEffectThread implements Runnable {
|
|||
UUID uuid = plugin.getDependencies().getUuidFromNpc(entity);
|
||||
if (uuid != null) {
|
||||
final QuesterPostViewEffectEvent event;
|
||||
if (plugin.hasQuest(uuid, quester)) {
|
||||
showEffect(quester.getPlayer(), entity, plugin.getSettings().getEffect());
|
||||
if (quester.canAcceptQuest(uuid)) {
|
||||
showEffect(quester.getPlayer(), entity, plugin.getConfigSettings().getEffect());
|
||||
|
||||
event = new QuesterPostViewEffectEvent(quester, entity,
|
||||
plugin.getSettings().getEffect(), false);
|
||||
plugin.getConfigSettings().getEffect(), false);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
} else if (plugin.hasCompletedRedoableQuest(uuid, quester)) {
|
||||
showEffect(quester.getPlayer(), entity, plugin.getSettings().getRedoEffect());
|
||||
} else if (quester.canAcceptCompletedRedoableQuest(uuid)) {
|
||||
showEffect(quester.getPlayer(), entity, plugin.getConfigSettings().getRedoEffect());
|
||||
|
||||
event = new QuesterPostViewEffectEvent(quester, entity,
|
||||
plugin.getSettings().getEffect(), true);
|
||||
plugin.getConfigSettings().getEffect(), true);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ public class BukkitItemUtil {
|
|||
* Returns an ItemStack based on given values. Checks for legacy pre-1.13 names. Other traits such as
|
||||
* enchantments and lore cannot be added via this method and must be done separately.
|
||||
*
|
||||
* @param material Item name suitable for Material.getMaterial()
|
||||
* @param material Item name suitable for Material#getMaterial
|
||||
* @param amount The number of items in the stack
|
||||
* @param durability The data value of the item, default of 0
|
||||
* @return ItemStack, or null if invalid format
|
||||
|
@ -244,7 +244,7 @@ public class BukkitItemUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get ItemStack from formatted string. See serialize() for reverse function.
|
||||
* Get ItemStack from formatted string. See #serializeItemStack for reverse function.
|
||||
*
|
||||
* <p>Supplied format = name-name:amount-amount:data-data:enchantment-enchantment level:displayname-displayname
|
||||
* :lore-lore
|
||||
|
@ -469,7 +469,7 @@ public class BukkitItemUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get formatted string from ItemStack. See readItemStack() for reverse function.
|
||||
* Get formatted string from ItemStack. See #readItemStack for reverse function.
|
||||
*
|
||||
* <p>Returned format = name-name:amount-amount:data-data:enchantment-enchantment level:displayname-displayname
|
||||
* :lore-lore:
|
||||
|
@ -515,7 +515,7 @@ public class BukkitItemUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Essentially the reverse of ItemMeta.serialize()
|
||||
* Essentially the reverse of ItemMeta#serialize
|
||||
*
|
||||
* @param itemMetaClass metadata class
|
||||
* @param args key/value map of metadata
|
||||
|
|
|
@ -137,18 +137,6 @@ public class BukkitMiscUtil {
|
|||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert EntityType name from snake_case to UpperCamelCase
|
||||
*
|
||||
* @deprecated Use {@link #snakeCaseToUpperCamelCase(String)}
|
||||
* @param type To convert
|
||||
* @return Converted text
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getProperMobName(final EntityType type) {
|
||||
return snakeCaseToUpperCamelCase(type.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets EntityType from name
|
||||
|
|
|
@ -32,7 +32,7 @@ public class BukkitUpdateChecker {
|
|||
}
|
||||
|
||||
public void getVersion(final Consumer<String> consumer) {
|
||||
if (plugin.getSettings().canUpdateCheck()) {
|
||||
if (plugin.getConfigSettings().canUpdateCheck()) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
try (final InputStream inputStream = new URL("https://api.spigotmc.org/legacy/update.php?resource="
|
||||
+ this.resourceId).openStream(); final Scanner scanner = new Scanner(inputStream)) {
|
||||
|
|
|
@ -17,7 +17,8 @@ actions:
|
|||
GiveRod:
|
||||
message: "<green>Here's a rod to get you started!"
|
||||
items:
|
||||
- name-fishing_rod:amount-1
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
type: FISHING_ROD
|
||||
TimerStart:
|
||||
timer: 40
|
||||
CancelTimer:
|
||||
|
|
|
@ -7,9 +7,10 @@ quests:
|
|||
redo-delay: 1800
|
||||
requirements:
|
||||
items:
|
||||
- name-stone_pickaxe:amount-1
|
||||
remove-items:
|
||||
- false
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
type: IRON_PICKAXE
|
||||
remove-items:
|
||||
- false
|
||||
fail-requirement-message: '<red>You must have a <pink>Stone Pickaxe<red> first.'
|
||||
stages:
|
||||
ordered:
|
||||
|
@ -51,7 +52,8 @@ quests:
|
|||
- 1
|
||||
rewards:
|
||||
items:
|
||||
- name-DIAMOND_SWORD:amount-1
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
type: DIAMOND_SWORD
|
||||
exp: 100
|
||||
quest-points: 1
|
||||
default3:
|
||||
|
@ -86,5 +88,6 @@ quests:
|
|||
disconnect-event: CancelTimer
|
||||
rewards:
|
||||
items:
|
||||
- name-GOLD_INGOT:amount-1
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
type: GOLD_INGOT
|
||||
exp: 150
|
Loading…
Reference in New Issue