mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-29 14:16:09 +01:00
Improve code syntax, part 1
This commit is contained in:
parent
61f9f2ede2
commit
27b6f97c2b
@ -64,7 +64,7 @@ public class Quest implements Comparable<Quest> {
|
|||||||
protected String description;
|
protected String description;
|
||||||
protected String finished;
|
protected String finished;
|
||||||
protected ItemStack guiDisplay = null;
|
protected ItemStack guiDisplay = null;
|
||||||
private final LinkedList<Stage> orderedStages = new LinkedList<Stage>();
|
private final LinkedList<Stage> orderedStages = new LinkedList<>();
|
||||||
protected NPC npcStart;
|
protected NPC npcStart;
|
||||||
protected Location blockStart;
|
protected Location blockStart;
|
||||||
protected String regionStart = null;
|
protected String regionStart = null;
|
||||||
@ -216,11 +216,11 @@ public class Quest implements Comparable<Quest> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
if (opts.getShareProgressLevel() == 3) {
|
if (allowSharedProgress && opts.getShareProgressLevel() == 3) {
|
||||||
final List<Quester> mq = quester.getMultiplayerQuesters(this);
|
final List<Quester> mq = quester.getMultiplayerQuesters(this);
|
||||||
for (final Quester qq : mq) {
|
for (final Quester qq : mq) {
|
||||||
if (currentStage.equals(qq.getCurrentStage(this))) {
|
if (currentStage.equals(qq.getCurrentStage(this))) {
|
||||||
nextStage(qq, allowSharedProgress);
|
nextStage(qq, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,10 +303,7 @@ public class Quest implements Comparable<Quest> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Quest quest = this;
|
final Quest quest = this;
|
||||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Location targetLocation = null;
|
Location targetLocation = null;
|
||||||
if (stage.citizensToInteract != null && stage.citizensToInteract.size() > 0) {
|
if (stage.citizensToInteract != null && stage.citizensToInteract.size() > 0) {
|
||||||
targetLocation = plugin.getDependencies().getNPCLocation(stage.citizensToInteract.getFirst());
|
targetLocation = plugin.getDependencies().getNPCLocation(stage.citizensToInteract.getFirst());
|
||||||
@ -418,7 +415,6 @@ public class Quest implements Comparable<Quest> {
|
|||||||
quester.getPlayer().setCompassTarget(lockedTarget);
|
quester.getPlayer().setCompassTarget(lockedTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -574,13 +570,7 @@ public class Quest implements Comparable<Quest> {
|
|||||||
final Player p = (Player)player;
|
final Player p = (Player)player;
|
||||||
final String[] ps = ConfigUtil.parseStringWithPossibleLineBreaks(ChatColor.AQUA
|
final String[] ps = ConfigUtil.parseStringWithPossibleLineBreaks(ChatColor.AQUA
|
||||||
+ finished, this, p);
|
+ finished, this, p);
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
Bukkit.getScheduler().runTaskLater(plugin, () -> p.sendMessage(ps), 40);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
p.sendMessage(ps);
|
|
||||||
}
|
|
||||||
}, 40);
|
|
||||||
}
|
}
|
||||||
if (pln.getCooldown() > -1) {
|
if (pln.getCooldown() > -1) {
|
||||||
quester.completedTimes.put(this, System.currentTimeMillis());
|
quester.completedTimes.put(this, System.currentTimeMillis());
|
||||||
@ -691,9 +681,9 @@ public class Quest implements Comparable<Quest> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final LinkedList<ItemStack> phatLootItems = new LinkedList<ItemStack>();
|
final LinkedList<ItemStack> phatLootItems = new LinkedList<>();
|
||||||
int phatLootExp = 0;
|
int phatLootExp = 0;
|
||||||
final LinkedList<String> phatLootMessages = new LinkedList<String>();
|
final LinkedList<String> phatLootMessages = new LinkedList<>();
|
||||||
for (final String s : rews.getPhatLoots()) {
|
for (final String s : rews.getPhatLoots()) {
|
||||||
final LootBundle lb = PhatLootsAPI.getPhatLoot(s).rollForLoot();
|
final LootBundle lb = PhatLootsAPI.getPhatLoot(s).rollForLoot();
|
||||||
if (lb.getExp() > 0) {
|
if (lb.getExp() > 0) {
|
||||||
@ -789,77 +779,72 @@ public class Quest implements Comparable<Quest> {
|
|||||||
+ Lang.get(p, "questPoints"));
|
+ Lang.get(p, "questPoints"));
|
||||||
}
|
}
|
||||||
for (final ItemStack i : rews.getItems()) {
|
for (final ItemStack i : rews.getItems()) {
|
||||||
String text = "error";
|
StringBuilder text;
|
||||||
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
|
if (i.getItemMeta() != null && i.getItemMeta().hasDisplayName()) {
|
||||||
if (i.getEnchantments().isEmpty()) {
|
if (i.getEnchantments().isEmpty()) {
|
||||||
text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
|
text = new StringBuilder("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
|
||||||
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount();
|
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount());
|
||||||
} else {
|
} else {
|
||||||
text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
|
text = new StringBuilder("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
|
||||||
+ ChatColor.RESET;
|
+ ChatColor.RESET);
|
||||||
try {
|
try {
|
||||||
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
|
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
|
||||||
text += ChatColor.GRAY + " " + Lang.get(p, "with") + ChatColor.DARK_PURPLE;
|
text.append(ChatColor.GRAY).append(" ").append(Lang.get(p, "with")).append(ChatColor.DARK_PURPLE);
|
||||||
for (final Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
for (final Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
||||||
text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":"
|
text.append(" ").append(ItemUtil.getPrettyEnchantmentName(e.getKey())).append(":").append(e.getValue());
|
||||||
+ e.getValue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Throwable tr) {
|
} catch (final Throwable tr) {
|
||||||
// Do nothing, hasItemFlag() not introduced until 1.8.6
|
// Do nothing, hasItemFlag() not introduced until 1.8.6
|
||||||
}
|
}
|
||||||
text += ChatColor.GRAY + " x " + i.getAmount();
|
text.append(ChatColor.GRAY).append(" x ").append(i.getAmount());
|
||||||
}
|
}
|
||||||
} else if (i.getDurability() != 0) {
|
} else if (i.getDurability() != 0) {
|
||||||
text = "- " + ChatColor.DARK_GREEN + "<item>:" + i.getDurability();
|
text = new StringBuilder("- " + ChatColor.DARK_GREEN + "<item>:" + i.getDurability());
|
||||||
if (i.getEnchantments().isEmpty()) {
|
if (!i.getEnchantments().isEmpty()) {
|
||||||
text += ChatColor.GRAY + " x " + i.getAmount();
|
text.append(ChatColor.GRAY).append(" ").append(Lang.get(p, "with"));
|
||||||
} else {
|
|
||||||
text += ChatColor.GRAY + " " + Lang.get(p, "with");
|
|
||||||
for (int iz = 0; iz < i.getEnchantments().size(); iz++) {
|
for (int iz = 0; iz < i.getEnchantments().size(); iz++) {
|
||||||
text += " <enchantment> <level>";
|
text.append(" <enchantment> <level>");
|
||||||
}
|
}
|
||||||
text += ChatColor.GRAY + " x " + i.getAmount();
|
|
||||||
}
|
}
|
||||||
|
text.append(ChatColor.GRAY).append(" x ").append(i.getAmount());
|
||||||
} else {
|
} else {
|
||||||
text = "- " + ChatColor.DARK_GREEN + "<item>";
|
text = new StringBuilder("- " + ChatColor.DARK_GREEN + "<item>");
|
||||||
if (i.getEnchantments().isEmpty()) {
|
if (!i.getEnchantments().isEmpty()) {
|
||||||
text += ChatColor.GRAY + " x " + i.getAmount();
|
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
|
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
|
||||||
text += ChatColor.GRAY + " " + Lang.get(p, "with");
|
text.append(ChatColor.GRAY).append(" ").append(Lang.get(p, "with"));
|
||||||
for (int iz = 0; iz < i.getEnchantments().size(); iz++) {
|
for (int iz = 0; iz < i.getEnchantments().size(); iz++) {
|
||||||
text += " <enchantment> <level>";
|
text.append(" <enchantment> <level>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Throwable tr) {
|
} catch (final Throwable tr) {
|
||||||
// Do nothing, hasItemFlag() not introduced until 1.8.6
|
// Do nothing, hasItemFlag() not introduced until 1.8.6
|
||||||
}
|
}
|
||||||
text += ChatColor.GRAY + " x " + i.getAmount();
|
|
||||||
}
|
}
|
||||||
|
text.append(ChatColor.GRAY).append(" x ").append(i.getAmount());
|
||||||
}
|
}
|
||||||
if (plugin.getSettings().canTranslateNames() && text.contains("<item>")) {
|
if (plugin.getSettings().canTranslateNames() && text.toString().contains("<item>")) {
|
||||||
if (!plugin.getLocaleManager().sendMessage(p, text, i.getType(), i.getDurability(),
|
if (!plugin.getLocaleManager().sendMessage(p, text.toString(), i.getType(), i.getDurability(),
|
||||||
i.getEnchantments())) {
|
i.getEnchantments())) {
|
||||||
for (final Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
for (final Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
||||||
text = text.replaceFirst("<enchantment>", ItemUtil.getPrettyEnchantmentName(
|
text = new StringBuilder(text.toString().replaceFirst("<enchantment>", ItemUtil.getPrettyEnchantmentName(
|
||||||
e.getKey()));
|
e.getKey())));
|
||||||
text = text.replaceFirst("<level>", RomanNumeral.getNumeral(e.getValue()));
|
text = new StringBuilder(text.toString().replaceFirst("<level>", RomanNumeral.getNumeral(e.getValue())));
|
||||||
}
|
}
|
||||||
quester.sendMessage(text.replace("<item>", ItemUtil.getName(i)));
|
quester.sendMessage(text.toString().replace("<item>", ItemUtil.getName(i)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (final Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
for (final Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
||||||
text = text.replaceFirst("<enchantment>", ItemUtil.getPrettyEnchantmentName(
|
text = new StringBuilder(text.toString().replaceFirst("<enchantment>", ItemUtil.getPrettyEnchantmentName(
|
||||||
e.getKey()));
|
e.getKey())));
|
||||||
text = text.replaceFirst("<level>", RomanNumeral.getNumeral(e.getValue()));
|
text = new StringBuilder(text.toString().replaceFirst("<level>", RomanNumeral.getNumeral(e.getValue())));
|
||||||
}
|
}
|
||||||
quester.sendMessage(text.replace("<item>", ItemUtil.getName(i)));
|
quester.sendMessage(text.toString().replace("<item>", ItemUtil.getName(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (final ItemStack i : phatLootItems) {
|
for (final ItemStack i : phatLootItems) {
|
||||||
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
|
if (i.getItemMeta() != null && i.getItemMeta().hasDisplayName()) {
|
||||||
if (i.getEnchantments().isEmpty()) {
|
if (i.getEnchantments().isEmpty()) {
|
||||||
quester.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC
|
quester.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC
|
||||||
+ i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x "
|
+ i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x "
|
||||||
|
@ -18,6 +18,7 @@ import me.blackvein.quests.convo.quests.stages.StageMenuPrompt;
|
|||||||
import me.blackvein.quests.interfaces.ReloadCallback;
|
import me.blackvein.quests.interfaces.ReloadCallback;
|
||||||
import me.blackvein.quests.util.CK;
|
import me.blackvein.quests.util.CK;
|
||||||
import me.blackvein.quests.util.ConfigUtil;
|
import me.blackvein.quests.util.ConfigUtil;
|
||||||
|
import me.blackvein.quests.util.FakeConversable;
|
||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
import me.blackvein.quests.util.MiscUtil;
|
import me.blackvein.quests.util.MiscUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -37,6 +38,7 @@ import org.bukkit.conversations.Prompt;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -46,6 +48,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -54,23 +57,24 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
|
|
||||||
private final Quests plugin;
|
private final Quests plugin;
|
||||||
private final ConversationFactory convoCreator;
|
private final ConversationFactory convoCreator;
|
||||||
private Map<UUID, Block> selectedBlockStarts = new HashMap<UUID, Block>();
|
private Map<UUID, Block> selectedBlockStarts = new HashMap<>();
|
||||||
private Map<UUID, Block> selectedKillLocations = new HashMap<UUID, Block>();
|
private Map<UUID, Block> selectedKillLocations = new HashMap<>();
|
||||||
private Map<UUID, Block> selectedReachLocations = new HashMap<UUID, Block>();
|
private Map<UUID, Block> selectedReachLocations = new HashMap<>();
|
||||||
private Set<UUID> selectingNpcs = new HashSet<UUID>();
|
private Set<UUID> selectingNpcs = new HashSet<>();
|
||||||
private List<String> editingQuestNames = new LinkedList<String>();
|
private List<String> editingQuestNames = new LinkedList<>();
|
||||||
|
|
||||||
public QuestFactory(final Quests plugin) {
|
public QuestFactory(final Quests plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
// Ensure to initialize convoCreator last so that 'this' is fully initialized before it is passed
|
// Ensure to initialize convoCreator last so that 'this' is fully initialized before it is passed
|
||||||
this.convoCreator = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
|
this.convoCreator = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
|
||||||
.withFirstPrompt(new QuestMenuPrompt(new ConversationContext(plugin, null, null))).withTimeout(3600)
|
.withFirstPrompt(new QuestMenuPrompt(new ConversationContext(plugin, new FakeConversable(),
|
||||||
|
new HashMap<>()))).withTimeout(3600)
|
||||||
.withPrefix(new LineBreakPrefix()).addConversationAbandonedListener(this);
|
.withPrefix(new LineBreakPrefix()).addConversationAbandonedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LineBreakPrefix implements ConversationPrefix {
|
public static class LineBreakPrefix implements ConversationPrefix {
|
||||||
@Override
|
@Override
|
||||||
public String getPrefix(final ConversationContext context) {
|
public @NotNull String getPrefix(final @NotNull ConversationContext context) {
|
||||||
return "\n";
|
return "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,7 +142,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
@Override
|
@Override
|
||||||
public void conversationAbandoned(final ConversationAbandonedEvent abandonedEvent) {
|
public void conversationAbandoned(final ConversationAbandonedEvent abandonedEvent) {
|
||||||
if (abandonedEvent.getContext().getSessionData(CK.Q_NAME) != null) {
|
if (abandonedEvent.getContext().getSessionData(CK.Q_NAME) != null) {
|
||||||
editingQuestNames.remove(abandonedEvent.getContext().getSessionData(CK.Q_NAME));
|
editingQuestNames.remove((String) abandonedEvent.getContext().getSessionData(CK.Q_NAME));
|
||||||
}
|
}
|
||||||
if (abandonedEvent.getContext().getForWhom() instanceof Player) {
|
if (abandonedEvent.getContext().getForWhom() instanceof Player) {
|
||||||
final UUID uuid = ((Player) abandonedEvent.getContext().getForWhom()).getUniqueId();
|
final UUID uuid = ((Player) abandonedEvent.getContext().getForWhom()).getUniqueId();
|
||||||
@ -205,8 +209,8 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, reqs.getHeroesSecondaryClass());
|
context.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, reqs.getHeroesSecondaryClass());
|
||||||
}
|
}
|
||||||
if (!reqs.getCustomRequirements().isEmpty()) {
|
if (!reqs.getCustomRequirements().isEmpty()) {
|
||||||
final LinkedList<String> list = new LinkedList<String>();
|
final LinkedList<String> list = new LinkedList<>();
|
||||||
final LinkedList<Map<String, Object>> datamapList = new LinkedList<Map<String, Object>>();
|
final LinkedList<Map<String, Object>> datamapList = new LinkedList<>();
|
||||||
for (final Entry<String, Map<String, Object>> entry : reqs.getCustomRequirements().entrySet()) {
|
for (final Entry<String, Map<String, Object>> entry : reqs.getCustomRequirements().entrySet()) {
|
||||||
list.add(entry.getKey());
|
list.add(entry.getKey());
|
||||||
datamapList.add(entry.getValue());
|
datamapList.add(entry.getValue());
|
||||||
@ -257,7 +261,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(CK.REW_PHAT_LOOTS, rews.getPhatLoots());
|
context.setSessionData(CK.REW_PHAT_LOOTS, rews.getPhatLoots());
|
||||||
}
|
}
|
||||||
if (!rews.getCustomRewards().isEmpty()) {
|
if (!rews.getCustomRewards().isEmpty()) {
|
||||||
context.setSessionData(CK.REW_CUSTOM, new LinkedList<String>(rews.getCustomRewards().keySet()));
|
context.setSessionData(CK.REW_CUSTOM, new LinkedList<>(rews.getCustomRewards().keySet()));
|
||||||
context.setSessionData(CK.REW_CUSTOM_DATA, new LinkedList<Object>(rews.getCustomRewards().values()));
|
context.setSessionData(CK.REW_CUSTOM_DATA, new LinkedList<Object>(rews.getCustomRewards().values()));
|
||||||
}
|
}
|
||||||
if (!rews.getDetailsOverride().isEmpty()) {
|
if (!rews.getDetailsOverride().isEmpty()) {
|
||||||
@ -294,9 +298,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
index++;
|
index++;
|
||||||
context.setSessionData(pref, Boolean.TRUE);
|
context.setSessionData(pref, Boolean.TRUE);
|
||||||
if (!stage.getBlocksToBreak().isEmpty()) {
|
if (!stage.getBlocksToBreak().isEmpty()) {
|
||||||
final LinkedList<String> names = new LinkedList<String>();
|
final LinkedList<String> names = new LinkedList<>();
|
||||||
final LinkedList<Integer> amnts = new LinkedList<Integer>();
|
final LinkedList<Integer> amnts = new LinkedList<>();
|
||||||
final LinkedList<Short> durab = new LinkedList<Short>();
|
final LinkedList<Short> durab = new LinkedList<>();
|
||||||
for (final ItemStack e : stage.getBlocksToBreak()) {
|
for (final ItemStack e : stage.getBlocksToBreak()) {
|
||||||
names.add(e.getType().name());
|
names.add(e.getType().name());
|
||||||
amnts.add(e.getAmount());
|
amnts.add(e.getAmount());
|
||||||
@ -307,9 +311,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(pref + CK.S_BREAK_DURABILITY, durab);
|
context.setSessionData(pref + CK.S_BREAK_DURABILITY, durab);
|
||||||
}
|
}
|
||||||
if (!stage.getBlocksToDamage().isEmpty()) {
|
if (!stage.getBlocksToDamage().isEmpty()) {
|
||||||
final LinkedList<String> names = new LinkedList<String>();
|
final LinkedList<String> names = new LinkedList<>();
|
||||||
final LinkedList<Integer> amnts = new LinkedList<Integer>();
|
final LinkedList<Integer> amnts = new LinkedList<>();
|
||||||
final LinkedList<Short> durab = new LinkedList<Short>();
|
final LinkedList<Short> durab = new LinkedList<>();
|
||||||
for (final ItemStack e : stage.getBlocksToDamage()) {
|
for (final ItemStack e : stage.getBlocksToDamage()) {
|
||||||
names.add(e.getType().name());
|
names.add(e.getType().name());
|
||||||
amnts.add(e.getAmount());
|
amnts.add(e.getAmount());
|
||||||
@ -320,9 +324,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, durab);
|
context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, durab);
|
||||||
}
|
}
|
||||||
if (!stage.getBlocksToPlace().isEmpty()) {
|
if (!stage.getBlocksToPlace().isEmpty()) {
|
||||||
final LinkedList<String> names = new LinkedList<String>();
|
final LinkedList<String> names = new LinkedList<>();
|
||||||
final LinkedList<Integer> amnts = new LinkedList<Integer>();
|
final LinkedList<Integer> amnts = new LinkedList<>();
|
||||||
final LinkedList<Short> durab = new LinkedList<Short>();
|
final LinkedList<Short> durab = new LinkedList<>();
|
||||||
for (final ItemStack e : stage.getBlocksToPlace()) {
|
for (final ItemStack e : stage.getBlocksToPlace()) {
|
||||||
names.add(e.getType().name());
|
names.add(e.getType().name());
|
||||||
amnts.add(e.getAmount());
|
amnts.add(e.getAmount());
|
||||||
@ -333,9 +337,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(pref + CK.S_PLACE_DURABILITY, durab);
|
context.setSessionData(pref + CK.S_PLACE_DURABILITY, durab);
|
||||||
}
|
}
|
||||||
if (!stage.getBlocksToUse().isEmpty()) {
|
if (!stage.getBlocksToUse().isEmpty()) {
|
||||||
final LinkedList<String> names = new LinkedList<String>();
|
final LinkedList<String> names = new LinkedList<>();
|
||||||
final LinkedList<Integer> amnts = new LinkedList<Integer>();
|
final LinkedList<Integer> amnts = new LinkedList<>();
|
||||||
final LinkedList<Short> durab = new LinkedList<Short>();
|
final LinkedList<Short> durab = new LinkedList<>();
|
||||||
for (final ItemStack e : stage.getBlocksToUse()) {
|
for (final ItemStack e : stage.getBlocksToUse()) {
|
||||||
names.add(e.getType().name());
|
names.add(e.getType().name());
|
||||||
amnts.add(e.getAmount());
|
amnts.add(e.getAmount());
|
||||||
@ -346,9 +350,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(pref + CK.S_USE_DURABILITY, durab);
|
context.setSessionData(pref + CK.S_USE_DURABILITY, durab);
|
||||||
}
|
}
|
||||||
if (!stage.getBlocksToCut().isEmpty()) {
|
if (!stage.getBlocksToCut().isEmpty()) {
|
||||||
final LinkedList<String> names = new LinkedList<String>();
|
final LinkedList<String> names = new LinkedList<>();
|
||||||
final LinkedList<Integer> amnts = new LinkedList<Integer>();
|
final LinkedList<Integer> amnts = new LinkedList<>();
|
||||||
final LinkedList<Short> durab = new LinkedList<Short>();
|
final LinkedList<Short> durab = new LinkedList<>();
|
||||||
for (final ItemStack e : stage.getBlocksToCut()) {
|
for (final ItemStack e : stage.getBlocksToCut()) {
|
||||||
names.add(e.getType().name());
|
names.add(e.getType().name());
|
||||||
amnts.add(e.getAmount());
|
amnts.add(e.getAmount());
|
||||||
@ -359,23 +363,23 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(pref + CK.S_CUT_DURABILITY, durab);
|
context.setSessionData(pref + CK.S_CUT_DURABILITY, durab);
|
||||||
}
|
}
|
||||||
if (!stage.getItemsToCraft().isEmpty()) {
|
if (!stage.getItemsToCraft().isEmpty()) {
|
||||||
final LinkedList<ItemStack> items = new LinkedList<ItemStack>(stage.getItemsToCraft());
|
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToCraft());
|
||||||
context.setSessionData(pref + CK.S_CRAFT_ITEMS, items);
|
context.setSessionData(pref + CK.S_CRAFT_ITEMS, items);
|
||||||
}
|
}
|
||||||
if (!stage.getItemsToSmelt().isEmpty()) {
|
if (!stage.getItemsToSmelt().isEmpty()) {
|
||||||
final LinkedList<ItemStack> items = new LinkedList<ItemStack>(stage.getItemsToSmelt());
|
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToSmelt());
|
||||||
context.setSessionData(pref + CK.S_SMELT_ITEMS, items);
|
context.setSessionData(pref + CK.S_SMELT_ITEMS, items);
|
||||||
}
|
}
|
||||||
if (!stage.getItemsToEnchant().isEmpty()) {
|
if (!stage.getItemsToEnchant().isEmpty()) {
|
||||||
final LinkedList<ItemStack> items = new LinkedList<ItemStack>(stage.getItemsToEnchant());
|
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToEnchant());
|
||||||
context.setSessionData(pref + CK.S_ENCHANT_ITEMS, items);
|
context.setSessionData(pref + CK.S_ENCHANT_ITEMS, items);
|
||||||
}
|
}
|
||||||
if (!stage.getItemsToBrew().isEmpty()) {
|
if (!stage.getItemsToBrew().isEmpty()) {
|
||||||
final LinkedList<ItemStack> items = new LinkedList<ItemStack>(stage.getItemsToBrew());
|
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToBrew());
|
||||||
context.setSessionData(pref + CK.S_BREW_ITEMS, items);
|
context.setSessionData(pref + CK.S_BREW_ITEMS, items);
|
||||||
}
|
}
|
||||||
if (!stage.getItemsToConsume().isEmpty()) {
|
if (!stage.getItemsToConsume().isEmpty()) {
|
||||||
final LinkedList<ItemStack> items = new LinkedList<ItemStack>(stage.getItemsToConsume());
|
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToConsume());
|
||||||
context.setSessionData(pref + CK.S_CONSUME_ITEMS, items);
|
context.setSessionData(pref + CK.S_CONSUME_ITEMS, items);
|
||||||
}
|
}
|
||||||
if (stage.getCowsToMilk() != null) {
|
if (stage.getCowsToMilk() != null) {
|
||||||
@ -388,30 +392,30 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(pref + CK.S_PLAYER_KILL, stage.getPlayersToKill());
|
context.setSessionData(pref + CK.S_PLAYER_KILL, stage.getPlayersToKill());
|
||||||
}
|
}
|
||||||
if (!stage.getItemsToDeliver().isEmpty()) {
|
if (!stage.getItemsToDeliver().isEmpty()) {
|
||||||
final LinkedList<ItemStack> items = new LinkedList<ItemStack>(stage.getItemsToDeliver());
|
final LinkedList<ItemStack> items = new LinkedList<>(stage.getItemsToDeliver());
|
||||||
final LinkedList<Integer> npcs = new LinkedList<Integer>(stage.getItemDeliveryTargets());
|
final LinkedList<Integer> npcs = new LinkedList<>(stage.getItemDeliveryTargets());
|
||||||
context.setSessionData(pref + CK.S_DELIVERY_ITEMS, items);
|
context.setSessionData(pref + CK.S_DELIVERY_ITEMS, items);
|
||||||
context.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs);
|
context.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs);
|
||||||
context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, stage.getDeliverMessages());
|
context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, stage.getDeliverMessages());
|
||||||
}
|
}
|
||||||
if (!stage.getCitizensToInteract().isEmpty()) {
|
if (!stage.getCitizensToInteract().isEmpty()) {
|
||||||
final LinkedList<Integer> npcs = new LinkedList<Integer>(stage.getCitizensToInteract());
|
final LinkedList<Integer> npcs = new LinkedList<>(stage.getCitizensToInteract());
|
||||||
context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, npcs);
|
context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, npcs);
|
||||||
}
|
}
|
||||||
if (!stage.getCitizensToKill().isEmpty()) {
|
if (!stage.getCitizensToKill().isEmpty()) {
|
||||||
final LinkedList<Integer> npcs = new LinkedList<Integer>(stage.getCitizensToKill());
|
final LinkedList<Integer> npcs = new LinkedList<>(stage.getCitizensToKill());
|
||||||
context.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs);
|
context.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs);
|
||||||
context.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, stage.getCitizenNumToKill());
|
context.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, stage.getCitizenNumToKill());
|
||||||
}
|
}
|
||||||
if (!stage.getMobsToKill().isEmpty()) {
|
if (!stage.getMobsToKill().isEmpty()) {
|
||||||
final LinkedList<String> mobs = new LinkedList<String>();
|
final LinkedList<String> mobs = new LinkedList<>();
|
||||||
for (final EntityType et : stage.getMobsToKill()) {
|
for (final EntityType et : stage.getMobsToKill()) {
|
||||||
mobs.add(MiscUtil.getPrettyMobName(et));
|
mobs.add(MiscUtil.getPrettyMobName(et));
|
||||||
}
|
}
|
||||||
context.setSessionData(pref + CK.S_MOB_TYPES, mobs);
|
context.setSessionData(pref + CK.S_MOB_TYPES, mobs);
|
||||||
context.setSessionData(pref + CK.S_MOB_AMOUNTS, stage.getMobNumToKill());
|
context.setSessionData(pref + CK.S_MOB_AMOUNTS, stage.getMobNumToKill());
|
||||||
if (!stage.getLocationsToKillWithin().isEmpty()) {
|
if (!stage.getLocationsToKillWithin().isEmpty()) {
|
||||||
final LinkedList<String> locs = new LinkedList<String>();
|
final LinkedList<String> locs = new LinkedList<>();
|
||||||
for (final Location l : stage.getLocationsToKillWithin()) {
|
for (final Location l : stage.getLocationsToKillWithin()) {
|
||||||
locs.add(ConfigUtil.getLocationInfo(l));
|
locs.add(ConfigUtil.getLocationInfo(l));
|
||||||
}
|
}
|
||||||
@ -421,7 +425,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!stage.getLocationsToReach().isEmpty()) {
|
if (!stage.getLocationsToReach().isEmpty()) {
|
||||||
final LinkedList<String> locs = new LinkedList<String>();
|
final LinkedList<String> locs = new LinkedList<>();
|
||||||
for (final Location l : stage.getLocationsToReach()) {
|
for (final Location l : stage.getLocationsToReach()) {
|
||||||
locs.add(ConfigUtil.getLocationInfo(l));
|
locs.add(ConfigUtil.getLocationInfo(l));
|
||||||
}
|
}
|
||||||
@ -430,21 +434,21 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, stage.getLocationNames());
|
context.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, stage.getLocationNames());
|
||||||
}
|
}
|
||||||
if (!stage.getMobsToTame().isEmpty()) {
|
if (!stage.getMobsToTame().isEmpty()) {
|
||||||
final LinkedList<String> mobs = new LinkedList<String>();
|
final LinkedList<String> mobs = new LinkedList<>();
|
||||||
for (final EntityType e : stage.getMobsToTame()) {
|
for (final EntityType e : stage.getMobsToTame()) {
|
||||||
mobs.add(MiscUtil.getPrettyMobName(e));
|
mobs.add(MiscUtil.getPrettyMobName(e));
|
||||||
}
|
}
|
||||||
final LinkedList<Integer> amts = new LinkedList<Integer>(stage.getMobNumToTame());
|
final LinkedList<Integer> amts = new LinkedList<>(stage.getMobNumToTame());
|
||||||
context.setSessionData(pref + CK.S_TAME_TYPES, mobs);
|
context.setSessionData(pref + CK.S_TAME_TYPES, mobs);
|
||||||
context.setSessionData(pref + CK.S_TAME_AMOUNTS, amts);
|
context.setSessionData(pref + CK.S_TAME_AMOUNTS, amts);
|
||||||
}
|
}
|
||||||
if (!stage.getSheepToShear().isEmpty()) {
|
if (!stage.getSheepToShear().isEmpty()) {
|
||||||
final LinkedList<String> colors = new LinkedList<String>();
|
final LinkedList<String> colors = new LinkedList<>();
|
||||||
for (final DyeColor d : stage.getSheepToShear()) {
|
for (final DyeColor d : stage.getSheepToShear()) {
|
||||||
colors.add(MiscUtil.getPrettyDyeColorName(d));
|
colors.add(MiscUtil.getPrettyDyeColorName(d));
|
||||||
|
|
||||||
}
|
}
|
||||||
final LinkedList<Integer> amts = new LinkedList<Integer>(stage.sheepNumToShear);
|
final LinkedList<Integer> amts = new LinkedList<>(stage.sheepNumToShear);
|
||||||
context.setSessionData(pref + CK.S_SHEAR_COLORS, colors);
|
context.setSessionData(pref + CK.S_SHEAR_COLORS, colors);
|
||||||
context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, amts);
|
context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, amts);
|
||||||
}
|
}
|
||||||
@ -453,14 +457,13 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(pref + CK.S_PASSWORD_PHRASES, stage.getPasswordPhrases());
|
context.setSessionData(pref + CK.S_PASSWORD_PHRASES, stage.getPasswordPhrases());
|
||||||
}
|
}
|
||||||
if (!stage.getCustomObjectives().isEmpty()) {
|
if (!stage.getCustomObjectives().isEmpty()) {
|
||||||
final LinkedList<String> list = new LinkedList<String>();
|
final LinkedList<String> list = new LinkedList<>();
|
||||||
final LinkedList<Integer> countList = new LinkedList<Integer>();
|
final LinkedList<Integer> countList = new LinkedList<>();
|
||||||
for (int i = 0; i < stage.getCustomObjectives().size(); i++) {
|
for (int i = 0; i < stage.getCustomObjectives().size(); i++) {
|
||||||
list.add(stage.getCustomObjectives().get(i).getName());
|
list.add(stage.getCustomObjectives().get(i).getName());
|
||||||
countList.add(stage.getCustomObjectiveCounts().get(i));
|
countList.add(stage.getCustomObjectiveCounts().get(i));
|
||||||
}
|
}
|
||||||
final LinkedList<Entry<String, Object>> datamapList
|
final LinkedList<Entry<String, Object>> datamapList = new LinkedList<>(stage.getCustomObjectiveData());
|
||||||
= new LinkedList<Entry<String, Object>>(stage.getCustomObjectiveData());
|
|
||||||
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, list);
|
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, list);
|
||||||
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, countList);
|
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, countList);
|
||||||
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, datamapList);
|
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, datamapList);
|
||||||
@ -481,8 +484,8 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(pref + CK.S_DISCONNECT_EVENT, stage.getDisconnectAction().getName());
|
context.setSessionData(pref + CK.S_DISCONNECT_EVENT, stage.getDisconnectAction().getName());
|
||||||
}
|
}
|
||||||
if (!stage.getChatActions().isEmpty()) {
|
if (!stage.getChatActions().isEmpty()) {
|
||||||
final LinkedList<String> chatEvents = new LinkedList<String>();
|
final LinkedList<String> chatEvents = new LinkedList<>();
|
||||||
final LinkedList<String> chatEventTriggers = new LinkedList<String>();
|
final LinkedList<String> chatEventTriggers = new LinkedList<>();
|
||||||
for (final String s : stage.getChatActions().keySet()) {
|
for (final String s : stage.getChatActions().keySet()) {
|
||||||
chatEventTriggers.add(s);
|
chatEventTriggers.add(s);
|
||||||
chatEvents.add(stage.getChatActions().get(s).getName());
|
chatEvents.add(stage.getChatActions().get(s).getName());
|
||||||
@ -491,8 +494,8 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, chatEventTriggers);
|
context.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, chatEventTriggers);
|
||||||
}
|
}
|
||||||
if (!stage.getCommandActions().isEmpty()) {
|
if (!stage.getCommandActions().isEmpty()) {
|
||||||
final LinkedList<String> commandEvents = new LinkedList<String>();
|
final LinkedList<String> commandEvents = new LinkedList<>();
|
||||||
final LinkedList<String> commandEventTriggers = new LinkedList<String>();
|
final LinkedList<String> commandEventTriggers = new LinkedList<>();
|
||||||
for (final String s : stage.getCommandActions().keySet()) {
|
for (final String s : stage.getCommandActions().keySet()) {
|
||||||
commandEventTriggers.add(s);
|
commandEventTriggers.add(s);
|
||||||
commandEvents.add(stage.getCommandActions().get(s).getName());
|
commandEvents.add(stage.getCommandActions().get(s).getName());
|
||||||
@ -529,12 +532,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
final File questsFile = new File(plugin.getDataFolder(), "quests.yml");
|
final File questsFile = new File(plugin.getDataFolder(), "quests.yml");
|
||||||
try {
|
try {
|
||||||
data.load(questsFile);
|
data.load(questsFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException | InvalidConfigurationException e) {
|
||||||
e.printStackTrace();
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
|
||||||
.replace("<quest>", questsFile.getName()));
|
|
||||||
return;
|
|
||||||
} catch (final InvalidConfigurationException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
||||||
.replace("<quest>", questsFile.getName()));
|
.replace("<quest>", questsFile.getName()));
|
||||||
@ -542,25 +540,25 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
final String quest = (String) context.getSessionData(CK.ED_QUEST_DELETE);
|
final String quest = (String) context.getSessionData(CK.ED_QUEST_DELETE);
|
||||||
final ConfigurationSection sec = data.getConfigurationSection("quests");
|
final ConfigurationSection sec = data.getConfigurationSection("quests");
|
||||||
|
if (sec != null) {
|
||||||
for (final String key : sec.getKeys(false)) {
|
for (final String key : sec.getKeys(false)) {
|
||||||
if (sec.getString(key + ".name").equalsIgnoreCase(quest)) {
|
if (sec.getString(key + ".name") != null
|
||||||
|
&& Objects.requireNonNull(sec.getString(key + ".name")).equalsIgnoreCase(quest)) {
|
||||||
sec.set(key, null);
|
sec.set(key, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
data.save(questsFile);
|
data.save(questsFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ReloadCallback<Boolean> callback = new ReloadCallback<Boolean>() {
|
final ReloadCallback<Boolean> callback = response -> {
|
||||||
@Override
|
|
||||||
public void execute(final Boolean response) {
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
plugin.reload(callback);
|
plugin.reload(callback);
|
||||||
context.getForWhom().sendRawMessage(ChatColor.GREEN + Lang.get("questDeleted"));
|
context.getForWhom().sendRawMessage(ChatColor.GREEN + Lang.get("questDeleted"));
|
||||||
@ -578,6 +576,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
if (edit != null) {
|
if (edit != null) {
|
||||||
final ConfigurationSection questList = section.getParent();
|
final ConfigurationSection questList = section.getParent();
|
||||||
|
if (questList != null) {
|
||||||
for (final String key : questList.getKeys(false)) {
|
for (final String key : questList.getKeys(false)) {
|
||||||
final String name = questList.getString(key + ".name");
|
final String name = questList.getString(key + ".name");
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
@ -588,22 +587,24 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
section.set("name", context.getSessionData(CK.Q_NAME) != null
|
section.set("name", context.getSessionData(CK.Q_NAME) != null
|
||||||
? (String) context.getSessionData(CK.Q_NAME) : null);
|
? context.getSessionData(CK.Q_NAME) : null);
|
||||||
section.set("ask-message", context.getSessionData(CK.Q_ASK_MESSAGE) != null
|
section.set("ask-message", context.getSessionData(CK.Q_ASK_MESSAGE) != null
|
||||||
? (String) context.getSessionData(CK.Q_ASK_MESSAGE) : null);
|
? context.getSessionData(CK.Q_ASK_MESSAGE) : null);
|
||||||
section.set("finish-message", context.getSessionData(CK.Q_FINISH_MESSAGE) != null
|
section.set("finish-message", context.getSessionData(CK.Q_FINISH_MESSAGE) != null
|
||||||
? (String) context.getSessionData(CK.Q_FINISH_MESSAGE) : null);
|
? context.getSessionData(CK.Q_FINISH_MESSAGE) : null);
|
||||||
section.set("npc-giver-id", context.getSessionData(CK.Q_START_NPC) != null
|
section.set("npc-giver-id", context.getSessionData(CK.Q_START_NPC) != null
|
||||||
? (Integer) context.getSessionData(CK.Q_START_NPC) : null);
|
? context.getSessionData(CK.Q_START_NPC) : null);
|
||||||
section.set("block-start", context.getSessionData(CK.Q_START_BLOCK) != null
|
section.set("block-start", context.getSessionData(CK.Q_START_BLOCK) != null
|
||||||
? ConfigUtil.getLocationInfo((Location) context.getSessionData(CK.Q_START_BLOCK)) : null);
|
? ConfigUtil.getLocationInfo((Location) Objects.requireNonNull(context
|
||||||
|
.getSessionData(CK.Q_START_BLOCK))) : null);
|
||||||
section.set("event", context.getSessionData(CK.Q_INITIAL_EVENT) != null
|
section.set("event", context.getSessionData(CK.Q_INITIAL_EVENT) != null
|
||||||
? (String) context.getSessionData(CK.Q_INITIAL_EVENT) : null);
|
? context.getSessionData(CK.Q_INITIAL_EVENT) : null);
|
||||||
section.set("region", context.getSessionData(CK.Q_REGION) != null
|
section.set("region", context.getSessionData(CK.Q_REGION) != null
|
||||||
? (String) context.getSessionData(CK.Q_REGION) : null);
|
? context.getSessionData(CK.Q_REGION) : null);
|
||||||
section.set("gui-display", context.getSessionData(CK.Q_GUIDISPLAY) != null
|
section.set("gui-display", context.getSessionData(CK.Q_GUIDISPLAY) != null
|
||||||
? (ItemStack) context.getSessionData(CK.Q_GUIDISPLAY) : null);
|
? context.getSessionData(CK.Q_GUIDISPLAY) : null);
|
||||||
saveRequirements(context, section);
|
saveRequirements(context, section);
|
||||||
saveStages(context, section);
|
saveStages(context, section);
|
||||||
saveRewards(context, section);
|
saveRewards(context, section);
|
||||||
@ -612,7 +613,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
if (plugin.getSettings().getConsoleLogging() > 0) {
|
if (plugin.getSettings().getConsoleLogging() > 0) {
|
||||||
final String identifier = context.getForWhom() instanceof Player ?
|
final String identifier = context.getForWhom() instanceof Player ?
|
||||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||||
plugin.getLogger().info(identifier + " saved quest " + (String) context.getSessionData(CK.Q_NAME));
|
plugin.getLogger().info(identifier + " saved quest " + context.getSessionData(CK.Q_NAME));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -620,32 +621,32 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
private void saveRequirements(final ConversationContext context, final ConfigurationSection section) {
|
private void saveRequirements(final ConversationContext context, final ConfigurationSection section) {
|
||||||
final ConfigurationSection reqs = section.createSection("requirements");
|
final ConfigurationSection reqs = section.createSection("requirements");
|
||||||
reqs.set("money", context.getSessionData(CK.REQ_MONEY) != null
|
reqs.set("money", context.getSessionData(CK.REQ_MONEY) != null
|
||||||
? (Integer) context.getSessionData(CK.REQ_MONEY) : null);
|
? context.getSessionData(CK.REQ_MONEY) : null);
|
||||||
reqs.set("quest-points", context.getSessionData(CK.REQ_QUEST_POINTS) != null
|
reqs.set("quest-points", context.getSessionData(CK.REQ_QUEST_POINTS) != null
|
||||||
? (Integer) context.getSessionData(CK.REQ_QUEST_POINTS) : null);
|
? context.getSessionData(CK.REQ_QUEST_POINTS) : null);
|
||||||
reqs.set("items", context.getSessionData(CK.REQ_ITEMS) != null
|
reqs.set("items", context.getSessionData(CK.REQ_ITEMS) != null
|
||||||
? (List<ItemStack>) context.getSessionData(CK.REQ_ITEMS) : null);
|
? context.getSessionData(CK.REQ_ITEMS) : null);
|
||||||
reqs.set("remove-items", context.getSessionData(CK.REQ_ITEMS_REMOVE) != null
|
reqs.set("remove-items", context.getSessionData(CK.REQ_ITEMS_REMOVE) != null
|
||||||
? (List<Boolean>) context.getSessionData(CK.REQ_ITEMS_REMOVE) : null);
|
? context.getSessionData(CK.REQ_ITEMS_REMOVE) : null);
|
||||||
reqs.set("permissions", context.getSessionData(CK.REQ_PERMISSION) != null
|
reqs.set("permissions", context.getSessionData(CK.REQ_PERMISSION) != null
|
||||||
? (List<String>) context.getSessionData(CK.REQ_PERMISSION) : null);
|
? context.getSessionData(CK.REQ_PERMISSION) : null);
|
||||||
reqs.set("quests", context.getSessionData(CK.REQ_QUEST) != null
|
reqs.set("quests", context.getSessionData(CK.REQ_QUEST) != null
|
||||||
? (List<String>) context.getSessionData(CK.REQ_QUEST) : null);
|
? context.getSessionData(CK.REQ_QUEST) : null);
|
||||||
reqs.set("quest-blocks", context.getSessionData(CK.REQ_QUEST_BLOCK) != null
|
reqs.set("quest-blocks", context.getSessionData(CK.REQ_QUEST_BLOCK) != null
|
||||||
? (List<String>) context.getSessionData(CK.REQ_QUEST_BLOCK) : null);
|
? context.getSessionData(CK.REQ_QUEST_BLOCK) : null);
|
||||||
reqs.set("mcmmo-skills", context.getSessionData(CK.REQ_MCMMO_SKILLS) != null
|
reqs.set("mcmmo-skills", context.getSessionData(CK.REQ_MCMMO_SKILLS) != null
|
||||||
? (List<String>) context.getSessionData(CK.REQ_MCMMO_SKILLS) : null);
|
? context.getSessionData(CK.REQ_MCMMO_SKILLS) : null);
|
||||||
reqs.set("mcmmo-amounts", context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) != null
|
reqs.set("mcmmo-amounts", context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) != null
|
||||||
? (List<Integer>) context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) : null);
|
? context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) : null);
|
||||||
reqs.set("heroes-primary-class", context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null
|
reqs.set("heroes-primary-class", context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null
|
||||||
? (String) context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) : null);
|
? context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) : null);
|
||||||
reqs.set("heroes-secondary-class", context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null
|
reqs.set("heroes-secondary-class", context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null
|
||||||
? (String) context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) : null);
|
? context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) : null);
|
||||||
final LinkedList<String> customReqs = context.getSessionData(CK.REQ_CUSTOM) != null
|
final LinkedList<String> customReqs = context.getSessionData(CK.REQ_CUSTOM) != null
|
||||||
? (LinkedList<String>) context.getSessionData(CK.REQ_CUSTOM) : null;
|
? (LinkedList<String>) context.getSessionData(CK.REQ_CUSTOM) : null;
|
||||||
final LinkedList<Map<String, Object>> customReqsData = context.getSessionData(CK.REQ_CUSTOM_DATA) != null
|
final LinkedList<Map<String, Object>> customReqsData = context.getSessionData(CK.REQ_CUSTOM_DATA) != null
|
||||||
? (LinkedList<Map<String, Object>>) context.getSessionData(CK.REQ_CUSTOM_DATA) : null;
|
? (LinkedList<Map<String, Object>>) context.getSessionData(CK.REQ_CUSTOM_DATA) : null;
|
||||||
if (customReqs != null) {
|
if (customReqs != null && customReqsData != null) {
|
||||||
final ConfigurationSection customReqsSec = reqs.createSection("custom-requirements");
|
final ConfigurationSection customReqsSec = reqs.createSection("custom-requirements");
|
||||||
for (int i = 0; i < customReqs.size(); i++) {
|
for (int i = 0; i < customReqs.size(); i++) {
|
||||||
final ConfigurationSection customReqSec = customReqsSec.createSection("req" + (i + 1));
|
final ConfigurationSection customReqSec = customReqsSec.createSection("req" + (i + 1));
|
||||||
@ -654,7 +655,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
reqs.set("fail-requirement-message", context.getSessionData(CK.REQ_FAIL_MESSAGE) != null
|
reqs.set("fail-requirement-message", context.getSessionData(CK.REQ_FAIL_MESSAGE) != null
|
||||||
? (List<String>)context.getSessionData(CK.REQ_FAIL_MESSAGE) : null);
|
? context.getSessionData(CK.REQ_FAIL_MESSAGE) : null);
|
||||||
if (reqs.getKeys(false).isEmpty()) {
|
if (reqs.getKeys(false).isEmpty()) {
|
||||||
section.set("requirements", null);
|
section.set("requirements", null);
|
||||||
}
|
}
|
||||||
@ -669,91 +670,91 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
pref = "stage" + i;
|
pref = "stage" + i;
|
||||||
final ConfigurationSection stage = ordered.createSection("" + i);
|
final ConfigurationSection stage = ordered.createSection("" + i);
|
||||||
stage.set("break-block-names", context.getSessionData(pref + CK.S_BREAK_NAMES) != null
|
stage.set("break-block-names", context.getSessionData(pref + CK.S_BREAK_NAMES) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_BREAK_NAMES) : null);
|
? context.getSessionData(pref + CK.S_BREAK_NAMES) : null);
|
||||||
stage.set("break-block-amounts", context.getSessionData(pref + CK.S_BREAK_AMOUNTS) != null
|
stage.set("break-block-amounts", context.getSessionData(pref + CK.S_BREAK_AMOUNTS) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_BREAK_AMOUNTS) : null);
|
? context.getSessionData(pref + CK.S_BREAK_AMOUNTS) : null);
|
||||||
stage.set("break-block-durability", context.getSessionData(pref + CK.S_BREAK_DURABILITY) != null
|
stage.set("break-block-durability", context.getSessionData(pref + CK.S_BREAK_DURABILITY) != null
|
||||||
? (LinkedList<Short>) context.getSessionData(pref + CK.S_BREAK_DURABILITY) : null);
|
? context.getSessionData(pref + CK.S_BREAK_DURABILITY) : null);
|
||||||
stage.set("damage-block-names", context.getSessionData(pref + CK.S_DAMAGE_NAMES) != null
|
stage.set("damage-block-names", context.getSessionData(pref + CK.S_DAMAGE_NAMES) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_DAMAGE_NAMES) : null);
|
? context.getSessionData(pref + CK.S_DAMAGE_NAMES) : null);
|
||||||
stage.set("damage-block-amounts", context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS) != null
|
stage.set("damage-block-amounts", context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS) : null);
|
? context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS) : null);
|
||||||
stage.set("damage-block-durability", context.getSessionData(pref + CK.S_DAMAGE_DURABILITY) != null
|
stage.set("damage-block-durability", context.getSessionData(pref + CK.S_DAMAGE_DURABILITY) != null
|
||||||
? (LinkedList<Short>) context.getSessionData(pref + CK.S_DAMAGE_DURABILITY) : null);
|
? context.getSessionData(pref + CK.S_DAMAGE_DURABILITY) : null);
|
||||||
stage.set("place-block-names", context.getSessionData(pref + CK.S_PLACE_NAMES) != null
|
stage.set("place-block-names", context.getSessionData(pref + CK.S_PLACE_NAMES) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_PLACE_NAMES) : null);
|
? context.getSessionData(pref + CK.S_PLACE_NAMES) : null);
|
||||||
stage.set("place-block-amounts", context.getSessionData(pref + CK.S_PLACE_AMOUNTS) != null
|
stage.set("place-block-amounts", context.getSessionData(pref + CK.S_PLACE_AMOUNTS) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_PLACE_AMOUNTS) : null);
|
? context.getSessionData(pref + CK.S_PLACE_AMOUNTS) : null);
|
||||||
stage.set("place-block-durability", context.getSessionData(pref + CK.S_PLACE_DURABILITY) != null
|
stage.set("place-block-durability", context.getSessionData(pref + CK.S_PLACE_DURABILITY) != null
|
||||||
? (LinkedList<Short>) context.getSessionData(pref + CK.S_PLACE_DURABILITY) : null);
|
? context.getSessionData(pref + CK.S_PLACE_DURABILITY) : null);
|
||||||
stage.set("use-block-names", context.getSessionData(pref + CK.S_USE_NAMES) != null
|
stage.set("use-block-names", context.getSessionData(pref + CK.S_USE_NAMES) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_USE_NAMES) : null);
|
? context.getSessionData(pref + CK.S_USE_NAMES) : null);
|
||||||
stage.set("use-block-amounts", context.getSessionData(pref + CK.S_USE_AMOUNTS) != null
|
stage.set("use-block-amounts", context.getSessionData(pref + CK.S_USE_AMOUNTS) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_USE_AMOUNTS) : null);
|
? context.getSessionData(pref + CK.S_USE_AMOUNTS) : null);
|
||||||
stage.set("use-block-durability", context.getSessionData(pref + CK.S_USE_DURABILITY) != null
|
stage.set("use-block-durability", context.getSessionData(pref + CK.S_USE_DURABILITY) != null
|
||||||
? (LinkedList<Short>) context.getSessionData(pref + CK.S_USE_DURABILITY) : null);
|
? context.getSessionData(pref + CK.S_USE_DURABILITY) : null);
|
||||||
stage.set("cut-block-names", context.getSessionData(pref + CK.S_CUT_NAMES) != null
|
stage.set("cut-block-names", context.getSessionData(pref + CK.S_CUT_NAMES) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_CUT_NAMES) : null);
|
? context.getSessionData(pref + CK.S_CUT_NAMES) : null);
|
||||||
stage.set("cut-block-amounts", context.getSessionData(pref + CK.S_CUT_AMOUNTS) != null
|
stage.set("cut-block-amounts", context.getSessionData(pref + CK.S_CUT_AMOUNTS) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_CUT_AMOUNTS) : null);
|
? context.getSessionData(pref + CK.S_CUT_AMOUNTS) : null);
|
||||||
stage.set("cut-block-durability", context.getSessionData(pref + CK.S_CUT_DURABILITY) != null
|
stage.set("cut-block-durability", context.getSessionData(pref + CK.S_CUT_DURABILITY) != null
|
||||||
? (LinkedList<Short>) context.getSessionData(pref + CK.S_CUT_DURABILITY) : null);
|
? context.getSessionData(pref + CK.S_CUT_DURABILITY) : null);
|
||||||
stage.set("items-to-craft", context.getSessionData(pref + CK.S_CRAFT_ITEMS) != null
|
stage.set("items-to-craft", context.getSessionData(pref + CK.S_CRAFT_ITEMS) != null
|
||||||
? (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_ITEMS) : null);
|
? context.getSessionData(pref + CK.S_CRAFT_ITEMS) : null);
|
||||||
stage.set("items-to-smelt", context.getSessionData(pref + CK.S_SMELT_ITEMS) != null
|
stage.set("items-to-smelt", context.getSessionData(pref + CK.S_SMELT_ITEMS) != null
|
||||||
? (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_SMELT_ITEMS) : null);
|
? context.getSessionData(pref + CK.S_SMELT_ITEMS) : null);
|
||||||
stage.set("items-to-enchant", context.getSessionData(pref + CK.S_ENCHANT_ITEMS) != null
|
stage.set("items-to-enchant", context.getSessionData(pref + CK.S_ENCHANT_ITEMS) != null
|
||||||
? (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_ENCHANT_ITEMS) : null);
|
? context.getSessionData(pref + CK.S_ENCHANT_ITEMS) : null);
|
||||||
stage.set("items-to-brew", context.getSessionData(pref + CK.S_BREW_ITEMS) != null
|
stage.set("items-to-brew", context.getSessionData(pref + CK.S_BREW_ITEMS) != null
|
||||||
? (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_BREW_ITEMS) : null);
|
? context.getSessionData(pref + CK.S_BREW_ITEMS) : null);
|
||||||
stage.set("items-to-consume", context.getSessionData(pref + CK.S_CONSUME_ITEMS) != null
|
stage.set("items-to-consume", context.getSessionData(pref + CK.S_CONSUME_ITEMS) != null
|
||||||
? (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CONSUME_ITEMS) : null);
|
? context.getSessionData(pref + CK.S_CONSUME_ITEMS) : null);
|
||||||
stage.set("cows-to-milk", context.getSessionData(pref + CK.S_COW_MILK) != null
|
stage.set("cows-to-milk", context.getSessionData(pref + CK.S_COW_MILK) != null
|
||||||
? (Integer) context.getSessionData(pref + CK.S_COW_MILK) : null);
|
? context.getSessionData(pref + CK.S_COW_MILK) : null);
|
||||||
stage.set("fish-to-catch", context.getSessionData(pref + CK.S_FISH) != null
|
stage.set("fish-to-catch", context.getSessionData(pref + CK.S_FISH) != null
|
||||||
? (Integer) context.getSessionData(pref + CK.S_FISH) : null);
|
? context.getSessionData(pref + CK.S_FISH) : null);
|
||||||
stage.set("players-to-kill", context.getSessionData(pref + CK.S_PLAYER_KILL) != null
|
stage.set("players-to-kill", context.getSessionData(pref + CK.S_PLAYER_KILL) != null
|
||||||
? (Integer) context.getSessionData(pref + CK.S_PLAYER_KILL) : null);
|
? context.getSessionData(pref + CK.S_PLAYER_KILL) : null);
|
||||||
stage.set("items-to-deliver", context.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null
|
stage.set("items-to-deliver", context.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null
|
||||||
? (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_DELIVERY_ITEMS) : null);
|
? context.getSessionData(pref + CK.S_DELIVERY_ITEMS) : null);
|
||||||
stage.set("npc-delivery-ids", context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null
|
stage.set("npc-delivery-ids", context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS) : null);
|
? context.getSessionData(pref + CK.S_DELIVERY_NPCS) : null);
|
||||||
stage.set("delivery-messages", context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) != null
|
stage.set("delivery-messages", context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) != null
|
||||||
? (LinkedList<String>) context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) : null);
|
? context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) : null);
|
||||||
stage.set("npc-ids-to-talk-to", context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) != null
|
stage.set("npc-ids-to-talk-to", context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) : null);
|
? context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) : null);
|
||||||
stage.set("npc-ids-to-kill", context.getSessionData(pref + CK.S_NPCS_TO_KILL) != null
|
stage.set("npc-ids-to-kill", context.getSessionData(pref + CK.S_NPCS_TO_KILL) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL) : null);
|
? context.getSessionData(pref + CK.S_NPCS_TO_KILL) : null);
|
||||||
stage.set("npc-kill-amounts", context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) != null
|
stage.set("npc-kill-amounts", context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) : null);
|
? context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) : null);
|
||||||
stage.set("mobs-to-kill", context.getSessionData(pref + CK.S_MOB_TYPES) != null
|
stage.set("mobs-to-kill", context.getSessionData(pref + CK.S_MOB_TYPES) != null
|
||||||
? (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_TYPES) : null);
|
? context.getSessionData(pref + CK.S_MOB_TYPES) : null);
|
||||||
stage.set("mob-amounts", context.getSessionData(pref + CK.S_MOB_AMOUNTS) != null
|
stage.set("mob-amounts", context.getSessionData(pref + CK.S_MOB_AMOUNTS) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_AMOUNTS) : null);
|
? context.getSessionData(pref + CK.S_MOB_AMOUNTS) : null);
|
||||||
stage.set("locations-to-kill", context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) != null
|
stage.set("locations-to-kill", context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) != null
|
||||||
? (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) : null);
|
? context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) : null);
|
||||||
stage.set("kill-location-radii", context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) != null
|
stage.set("kill-location-radii", context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) : null);
|
? context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) : null);
|
||||||
stage.set("kill-location-names", context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) != null
|
stage.set("kill-location-names", context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) != null
|
||||||
? (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) : null);
|
? context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) : null);
|
||||||
stage.set("locations-to-reach", context.getSessionData(pref + CK.S_REACH_LOCATIONS) != null
|
stage.set("locations-to-reach", context.getSessionData(pref + CK.S_REACH_LOCATIONS) != null
|
||||||
? (LinkedList<String>) context.getSessionData(pref + CK.S_REACH_LOCATIONS) : null);
|
? context.getSessionData(pref + CK.S_REACH_LOCATIONS) : null);
|
||||||
stage.set("reach-location-radii", context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS) != null
|
stage.set("reach-location-radii", context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS) : null);
|
? context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS) : null);
|
||||||
stage.set("reach-location-names", context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES) != null
|
stage.set("reach-location-names", context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES) != null
|
||||||
? (LinkedList<String>) context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES) : null);
|
? context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES) : null);
|
||||||
stage.set("mobs-to-tame", context.getSessionData(pref + CK.S_TAME_TYPES) != null
|
stage.set("mobs-to-tame", context.getSessionData(pref + CK.S_TAME_TYPES) != null
|
||||||
? (LinkedList<String>) context.getSessionData(pref + CK.S_TAME_TYPES) : null);
|
? context.getSessionData(pref + CK.S_TAME_TYPES) : null);
|
||||||
stage.set("mob-tame-amounts", context.getSessionData(pref + CK.S_TAME_AMOUNTS) != null
|
stage.set("mob-tame-amounts", context.getSessionData(pref + CK.S_TAME_AMOUNTS) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_TAME_AMOUNTS) : null);
|
? context.getSessionData(pref + CK.S_TAME_AMOUNTS) : null);
|
||||||
stage.set("sheep-to-shear", context.getSessionData(pref + CK.S_SHEAR_COLORS) != null
|
stage.set("sheep-to-shear", context.getSessionData(pref + CK.S_SHEAR_COLORS) != null
|
||||||
? (LinkedList<String>) context.getSessionData(pref + CK.S_SHEAR_COLORS) : null);
|
? context.getSessionData(pref + CK.S_SHEAR_COLORS) : null);
|
||||||
stage.set("sheep-amounts", context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) != null
|
stage.set("sheep-amounts", context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) != null
|
||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) : null);
|
? context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) : null);
|
||||||
stage.set("password-displays", context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) != null
|
stage.set("password-displays", context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) != null
|
||||||
? (LinkedList<String>) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) : null);
|
? context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) : null);
|
||||||
stage.set("password-phrases", context.getSessionData(pref + CK.S_PASSWORD_PHRASES) != null
|
stage.set("password-phrases", context.getSessionData(pref + CK.S_PASSWORD_PHRASES) != null
|
||||||
? (LinkedList<String>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES) : null);
|
? context.getSessionData(pref + CK.S_PASSWORD_PHRASES) : null);
|
||||||
final LinkedList<String> customObjs = (LinkedList<String>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES);
|
final LinkedList<String> customObjs = (LinkedList<String>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES);
|
||||||
final LinkedList<Integer> customObjCounts
|
final LinkedList<Integer> customObjCounts
|
||||||
= (LinkedList<Integer>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT);
|
= (LinkedList<Integer>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT);
|
||||||
@ -761,6 +762,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
= (LinkedList<Entry<String, Object>>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA);
|
= (LinkedList<Entry<String, Object>>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA);
|
||||||
if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) != null) {
|
if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) != null) {
|
||||||
final ConfigurationSection sec = stage.createSection("custom-objectives");
|
final ConfigurationSection sec = stage.createSection("custom-objectives");
|
||||||
|
if (customObjs == null || customObjCounts == null || customObjsData == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (int index = 0; index < customObjs.size(); index++) {
|
for (int index = 0; index < customObjs.size(); index++) {
|
||||||
final ConfigurationSection sec2 = sec.createSection("custom" + (index + 1));
|
final ConfigurationSection sec2 = sec.createSection("custom" + (index + 1));
|
||||||
sec2.set("name", customObjs.get(index));
|
sec2.set("name", customObjs.get(index));
|
||||||
@ -772,6 +776,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (found == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
final ConfigurationSection sec3 = sec2.createSection("data");
|
final ConfigurationSection sec3 = sec2.createSection("data");
|
||||||
for (final Entry<String, Object> datamap : found.getData()) {
|
for (final Entry<String, Object> datamap : found.getData()) {
|
||||||
for (final Entry<String, Object> e : customObjsData) {
|
for (final Entry<String, Object> e : customObjsData) {
|
||||||
@ -829,38 +836,38 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
private void saveRewards(final ConversationContext context, final ConfigurationSection section) {
|
private void saveRewards(final ConversationContext context, final ConfigurationSection section) {
|
||||||
final ConfigurationSection rews = section.createSection("rewards");
|
final ConfigurationSection rews = section.createSection("rewards");
|
||||||
rews.set("items", context.getSessionData(CK.REW_ITEMS) != null
|
rews.set("items", context.getSessionData(CK.REW_ITEMS) != null
|
||||||
? (List<ItemStack>) context.getSessionData(CK.REW_ITEMS) : null);
|
? context.getSessionData(CK.REW_ITEMS) : null);
|
||||||
rews.set("money", context.getSessionData(CK.REW_MONEY) != null
|
rews.set("money", context.getSessionData(CK.REW_MONEY) != null
|
||||||
? (Integer) context.getSessionData(CK.REW_MONEY) : null);
|
? context.getSessionData(CK.REW_MONEY) : null);
|
||||||
rews.set("quest-points", context.getSessionData(CK.REW_QUEST_POINTS) != null
|
rews.set("quest-points", context.getSessionData(CK.REW_QUEST_POINTS) != null
|
||||||
? (Integer) context.getSessionData(CK.REW_QUEST_POINTS) : null);
|
? context.getSessionData(CK.REW_QUEST_POINTS) : null);
|
||||||
rews.set("exp", context.getSessionData(CK.REW_EXP) != null
|
rews.set("exp", context.getSessionData(CK.REW_EXP) != null
|
||||||
? (Integer) context.getSessionData(CK.REW_EXP) : null);
|
? context.getSessionData(CK.REW_EXP) : null);
|
||||||
rews.set("commands", context.getSessionData(CK.REW_COMMAND) != null
|
rews.set("commands", context.getSessionData(CK.REW_COMMAND) != null
|
||||||
? (List<String>) context.getSessionData(CK.REW_COMMAND) : null);
|
? context.getSessionData(CK.REW_COMMAND) : null);
|
||||||
rews.set("commands-override-display", context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) != null
|
rews.set("commands-override-display", context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) != null
|
||||||
? (List<String>) context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) : null);
|
? context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) : null);
|
||||||
rews.set("permissions", context.getSessionData(CK.REW_PERMISSION) != null
|
rews.set("permissions", context.getSessionData(CK.REW_PERMISSION) != null
|
||||||
? (List<String>)context.getSessionData(CK.REW_PERMISSION) : null);
|
? context.getSessionData(CK.REW_PERMISSION) : null);
|
||||||
rews.set("permission-worlds", context.getSessionData(CK.REW_PERMISSION_WORLDS) != null
|
rews.set("permission-worlds", context.getSessionData(CK.REW_PERMISSION_WORLDS) != null
|
||||||
? (List<String>)context.getSessionData(CK.REW_PERMISSION_WORLDS) : null);
|
? context.getSessionData(CK.REW_PERMISSION_WORLDS) : null);
|
||||||
rews.set("mcmmo-skills", context.getSessionData(CK.REW_MCMMO_SKILLS) != null
|
rews.set("mcmmo-skills", context.getSessionData(CK.REW_MCMMO_SKILLS) != null
|
||||||
? (List<String>) context.getSessionData(CK.REW_MCMMO_SKILLS) : null);
|
? context.getSessionData(CK.REW_MCMMO_SKILLS) : null);
|
||||||
rews.set("mcmmo-levels", context.getSessionData(CK.REW_MCMMO_AMOUNTS) != null
|
rews.set("mcmmo-levels", context.getSessionData(CK.REW_MCMMO_AMOUNTS) != null
|
||||||
? (List<Integer>) context.getSessionData(CK.REW_MCMMO_AMOUNTS) : null);
|
? context.getSessionData(CK.REW_MCMMO_AMOUNTS) : null);
|
||||||
rews.set("heroes-exp-classes", context.getSessionData(CK.REW_HEROES_CLASSES) != null
|
rews.set("heroes-exp-classes", context.getSessionData(CK.REW_HEROES_CLASSES) != null
|
||||||
? (List<String>) context.getSessionData(CK.REW_HEROES_CLASSES) : null);
|
? context.getSessionData(CK.REW_HEROES_CLASSES) : null);
|
||||||
rews.set("heroes-exp-amounts", context.getSessionData(CK.REW_HEROES_AMOUNTS) != null
|
rews.set("heroes-exp-amounts", context.getSessionData(CK.REW_HEROES_AMOUNTS) != null
|
||||||
? (List<Double>) context.getSessionData(CK.REW_HEROES_AMOUNTS) : null);
|
? context.getSessionData(CK.REW_HEROES_AMOUNTS) : null);
|
||||||
rews.set("parties-experience", context.getSessionData(CK.REW_PARTIES_EXPERIENCE) != null
|
rews.set("parties-experience", context.getSessionData(CK.REW_PARTIES_EXPERIENCE) != null
|
||||||
? (Integer) context.getSessionData(CK.REW_PARTIES_EXPERIENCE) : null);
|
? context.getSessionData(CK.REW_PARTIES_EXPERIENCE) : null);
|
||||||
rews.set("phat-loots", context.getSessionData(CK.REW_PHAT_LOOTS) != null
|
rews.set("phat-loots", context.getSessionData(CK.REW_PHAT_LOOTS) != null
|
||||||
? (List<String>) context.getSessionData(CK.REW_PHAT_LOOTS) : null);
|
? context.getSessionData(CK.REW_PHAT_LOOTS) : null);
|
||||||
final LinkedList<String> customRews = context.getSessionData(CK.REW_CUSTOM) != null
|
final LinkedList<String> customRews = context.getSessionData(CK.REW_CUSTOM) != null
|
||||||
? (LinkedList<String>) context.getSessionData(CK.REW_CUSTOM) : null;
|
? (LinkedList<String>) context.getSessionData(CK.REW_CUSTOM) : null;
|
||||||
final LinkedList<Map<String, Object>> customRewsData = context.getSessionData(CK.REW_CUSTOM_DATA) != null
|
final LinkedList<Map<String, Object>> customRewsData = context.getSessionData(CK.REW_CUSTOM_DATA) != null
|
||||||
? (LinkedList<Map<String, Object>>) context.getSessionData(CK.REW_CUSTOM_DATA) : null;
|
? (LinkedList<Map<String, Object>>) context.getSessionData(CK.REW_CUSTOM_DATA) : null;
|
||||||
if (customRews != null) {
|
if (customRews != null && customRewsData != null) {
|
||||||
final ConfigurationSection customRewsSec = rews.createSection("custom-rewards");
|
final ConfigurationSection customRewsSec = rews.createSection("custom-rewards");
|
||||||
for (int i = 0; i < customRews.size(); i++) {
|
for (int i = 0; i < customRews.size(); i++) {
|
||||||
final ConfigurationSection customRewSec = customRewsSec.createSection("req" + (i + 1));
|
final ConfigurationSection customRewSec = customRewsSec.createSection("req" + (i + 1));
|
||||||
@ -869,7 +876,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
rews.set("details-override", context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null
|
rews.set("details-override", context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null
|
||||||
? (List<String>)context.getSessionData(CK.REW_DETAILS_OVERRIDE) : null);
|
? context.getSessionData(CK.REW_DETAILS_OVERRIDE) : null);
|
||||||
if (rews.getKeys(false).isEmpty()) {
|
if (rews.getKeys(false).isEmpty()) {
|
||||||
section.set("rewards", null);
|
section.set("rewards", null);
|
||||||
}
|
}
|
||||||
@ -878,15 +885,15 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
private void savePlanner(final ConversationContext context, final ConfigurationSection section) {
|
private void savePlanner(final ConversationContext context, final ConfigurationSection section) {
|
||||||
final ConfigurationSection pln = section.createSection("planner");
|
final ConfigurationSection pln = section.createSection("planner");
|
||||||
pln.set("start", context.getSessionData(CK.PLN_START_DATE) != null
|
pln.set("start", context.getSessionData(CK.PLN_START_DATE) != null
|
||||||
? (String) context.getSessionData(CK.PLN_START_DATE) : null);
|
? context.getSessionData(CK.PLN_START_DATE) : null);
|
||||||
pln.set("end", context.getSessionData(CK.PLN_END_DATE) != null
|
pln.set("end", context.getSessionData(CK.PLN_END_DATE) != null
|
||||||
? (String) context.getSessionData(CK.PLN_END_DATE) : null);
|
? context.getSessionData(CK.PLN_END_DATE) : null);
|
||||||
pln.set("repeat", context.getSessionData(CK.PLN_REPEAT_CYCLE) != null
|
final Long repeatCycle = (Long) context.getSessionData(CK.PLN_REPEAT_CYCLE);
|
||||||
? ((Long) context.getSessionData(CK.PLN_REPEAT_CYCLE) / 1000L) : null);
|
pln.set("repeat", repeatCycle != null ? (repeatCycle / 1000L) : null);
|
||||||
pln.set("cooldown", context.getSessionData(CK.PLN_COOLDOWN) != null
|
final Long cooldown = (Long) context.getSessionData(CK.PLN_COOLDOWN);
|
||||||
? ((Long) context.getSessionData(CK.PLN_COOLDOWN) / 1000L) : null);
|
pln.set("cooldown", cooldown != null ? (cooldown / 1000L) : null);
|
||||||
pln.set("override", context.getSessionData(CK.PLN_OVERRIDE) != null
|
pln.set("override", context.getSessionData(CK.PLN_OVERRIDE) != null
|
||||||
? (Boolean) context.getSessionData(CK.PLN_OVERRIDE) : null);
|
? context.getSessionData(CK.PLN_OVERRIDE) : null);
|
||||||
if (pln.getKeys(false).isEmpty()) {
|
if (pln.getKeys(false).isEmpty()) {
|
||||||
section.set("planner", null);
|
section.set("planner", null);
|
||||||
}
|
}
|
||||||
@ -895,23 +902,23 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
private void saveOptions(final ConversationContext context, final ConfigurationSection section) {
|
private void saveOptions(final ConversationContext context, final ConfigurationSection section) {
|
||||||
final ConfigurationSection opts = section.createSection("options");
|
final ConfigurationSection opts = section.createSection("options");
|
||||||
opts.set("allow-commands", context.getSessionData(CK.OPT_ALLOW_COMMANDS) != null
|
opts.set("allow-commands", context.getSessionData(CK.OPT_ALLOW_COMMANDS) != null
|
||||||
? (Boolean) context.getSessionData(CK.OPT_ALLOW_COMMANDS) : null);
|
? context.getSessionData(CK.OPT_ALLOW_COMMANDS) : null);
|
||||||
opts.set("allow-quitting", context.getSessionData(CK.OPT_ALLOW_QUITTING) != null
|
opts.set("allow-quitting", context.getSessionData(CK.OPT_ALLOW_QUITTING) != null
|
||||||
? (Boolean) context.getSessionData(CK.OPT_ALLOW_QUITTING) : null);
|
? context.getSessionData(CK.OPT_ALLOW_QUITTING) : null);
|
||||||
opts.set("ignore-silk-touch", context.getSessionData(CK.OPT_IGNORE_SILK_TOUCH) != null
|
opts.set("ignore-silk-touch", context.getSessionData(CK.OPT_IGNORE_SILK_TOUCH) != null
|
||||||
? (Boolean) context.getSessionData(CK.OPT_IGNORE_SILK_TOUCH) : null);
|
? context.getSessionData(CK.OPT_IGNORE_SILK_TOUCH) : null);
|
||||||
opts.set("use-dungeonsxl-plugin", context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) != null
|
opts.set("use-dungeonsxl-plugin", context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) != null
|
||||||
? (Boolean) context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) : null);
|
? context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) : null);
|
||||||
opts.set("use-parties-plugin", context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) != null
|
opts.set("use-parties-plugin", context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) != null
|
||||||
? (Boolean) context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) : null);
|
? context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) : null);
|
||||||
opts.set("share-progress-level", context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) != null
|
opts.set("share-progress-level", context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) != null
|
||||||
? (Integer) context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) : null);
|
? context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) : null);
|
||||||
opts.set("same-quest-only", context.getSessionData(CK.OPT_SHARE_SAME_QUEST_ONLY) != null
|
opts.set("same-quest-only", context.getSessionData(CK.OPT_SHARE_SAME_QUEST_ONLY) != null
|
||||||
? (Boolean) context.getSessionData(CK.OPT_SHARE_SAME_QUEST_ONLY) : null);
|
? context.getSessionData(CK.OPT_SHARE_SAME_QUEST_ONLY) : null);
|
||||||
opts.set("share-distance", context.getSessionData(CK.OPT_SHARE_DISTANCE) != null
|
opts.set("share-distance", context.getSessionData(CK.OPT_SHARE_DISTANCE) != null
|
||||||
? (Double) context.getSessionData(CK.OPT_SHARE_DISTANCE) : null);
|
? context.getSessionData(CK.OPT_SHARE_DISTANCE) : null);
|
||||||
opts.set("handle-offline-players", context.getSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS) != null
|
opts.set("handle-offline-players", context.getSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS) != null
|
||||||
? (Boolean) context.getSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS) : null);
|
? context.getSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS) : null);
|
||||||
if (opts.getKeys(false).isEmpty()) {
|
if (opts.getKeys(false).isEmpty()) {
|
||||||
section.set("options", null);
|
section.set("options", null);
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,9 @@ public class QuestMob {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void spawn() {
|
public void spawn() {
|
||||||
final World world = spawnLocation.getWorld();
|
final World world = spawnLocation.getWorld();
|
||||||
|
if (world == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (int i = 0; i < spawnAmounts; i++) {
|
for (int i = 0; i < spawnAmounts; i++) {
|
||||||
final LivingEntity entity = (LivingEntity) world.spawnEntity(spawnLocation, entityType);
|
final LivingEntity entity = (LivingEntity) world.spawnEntity(spawnLocation, entityType);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
@ -125,6 +128,9 @@ public class QuestMob {
|
|||||||
entity.setCustomNameVisible(true);
|
entity.setCustomNameVisible(true);
|
||||||
}
|
}
|
||||||
final EntityEquipment eq = entity.getEquipment();
|
final EntityEquipment eq = entity.getEquipment();
|
||||||
|
if (eq == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
eq.setItemInHand(inventory[0]);
|
eq.setItemInHand(inventory[0]);
|
||||||
eq.setBoots(inventory[1]);
|
eq.setBoots(inventory[1]);
|
||||||
eq.setLeggings(inventory[2]);
|
eq.setLeggings(inventory[2]);
|
||||||
@ -252,7 +258,7 @@ public class QuestMob {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final QuestMob qm = new QuestMob(entityType, loc, amounts);
|
final QuestMob qm = new QuestMob(entityType, loc, amounts != null ? amounts : 1);
|
||||||
qm.setName(name);
|
qm.setName(name);
|
||||||
qm.inventory = inventory;
|
qm.inventory = inventory;
|
||||||
qm.dropChances = dropChances;
|
qm.dropChances = dropChances;
|
||||||
|
@ -11,18 +11,6 @@
|
|||||||
*/
|
*/
|
||||||
package me.blackvein.quests.actions;
|
package me.blackvein.quests.actions;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Effect;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
|
|
||||||
import me.blackvein.quests.Quest;
|
import me.blackvein.quests.Quest;
|
||||||
import me.blackvein.quests.QuestMob;
|
import me.blackvein.quests.QuestMob;
|
||||||
import me.blackvein.quests.Quester;
|
import me.blackvein.quests.Quester;
|
||||||
@ -31,6 +19,17 @@ import me.blackvein.quests.tasks.ActionTimer;
|
|||||||
import me.blackvein.quests.util.ConfigUtil;
|
import me.blackvein.quests.util.ConfigUtil;
|
||||||
import me.blackvein.quests.util.InventoryUtil;
|
import me.blackvein.quests.util.InventoryUtil;
|
||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class Action implements Comparable<Action> {
|
public class Action implements Comparable<Action> {
|
||||||
|
|
||||||
@ -39,9 +38,9 @@ public class Action implements Comparable<Action> {
|
|||||||
protected String message = null;
|
protected String message = null;
|
||||||
protected boolean clearInv = false;
|
protected boolean clearInv = false;
|
||||||
protected boolean failQuest = false;
|
protected boolean failQuest = false;
|
||||||
protected LinkedList<Location> explosions = new LinkedList<Location>();
|
protected LinkedList<Location> explosions = new LinkedList<>();
|
||||||
protected Map<Location, Effect> effects = new HashMap<Location, Effect>();
|
protected Map<Location, Effect> effects = new HashMap<>();
|
||||||
protected LinkedList<ItemStack> items = new LinkedList<ItemStack>();
|
protected LinkedList<ItemStack> items = new LinkedList<>();
|
||||||
protected World stormWorld = null;
|
protected World stormWorld = null;
|
||||||
protected int stormDuration = 0;
|
protected int stormDuration = 0;
|
||||||
protected World thunderWorld = null;
|
protected World thunderWorld = null;
|
||||||
@ -62,7 +61,7 @@ public class Action implements Comparable<Action> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < size(); i++) {
|
for (int i = 0; i < size(); i++) {
|
||||||
if (get(i).equals(other.get(i)) == false) {
|
if (!get(i).equals(other.get(i))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,9 +69,9 @@ public class Action implements Comparable<Action> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
protected LinkedList<Location> lightningStrikes = new LinkedList<Location>();
|
protected LinkedList<Location> lightningStrikes = new LinkedList<>();
|
||||||
protected LinkedList<String> commands = new LinkedList<String>();
|
protected LinkedList<String> commands = new LinkedList<>();
|
||||||
protected LinkedList<PotionEffect> potionEffects = new LinkedList<PotionEffect>();
|
protected LinkedList<PotionEffect> potionEffects = new LinkedList<>();
|
||||||
protected int hunger = -1;
|
protected int hunger = -1;
|
||||||
protected int saturation = -1;
|
protected int saturation = -1;
|
||||||
protected float health = -1;
|
protected float health = -1;
|
||||||
@ -278,20 +277,24 @@ public class Action implements Comparable<Action> {
|
|||||||
if (message != null) {
|
if (message != null) {
|
||||||
player.sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(message, quest, player));
|
player.sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(message, quest, player));
|
||||||
}
|
}
|
||||||
if (clearInv == true) {
|
if (clearInv) {
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
}
|
}
|
||||||
if (explosions.isEmpty() == false) {
|
if (!explosions.isEmpty()) {
|
||||||
for (final Location l : explosions) {
|
for (final Location l : explosions) {
|
||||||
|
if (l.getWorld() != null) {
|
||||||
l.getWorld().createExplosion(l, 4F, false);
|
l.getWorld().createExplosion(l, 4F, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (effects.isEmpty() == false) {
|
}
|
||||||
|
if (!effects.isEmpty()) {
|
||||||
for (final Location l : effects.keySet()) {
|
for (final Location l : effects.keySet()) {
|
||||||
|
if (l.getWorld() != null) {
|
||||||
l.getWorld().playEffect(l, effects.get(l), 1);
|
l.getWorld().playEffect(l, effects.get(l), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (items.isEmpty() == false) {
|
}
|
||||||
|
if (!items.isEmpty()) {
|
||||||
for (final ItemStack is : items) {
|
for (final ItemStack is : items) {
|
||||||
try {
|
try {
|
||||||
InventoryUtil.addItem(player, is);
|
InventoryUtil.addItem(player, is);
|
||||||
@ -311,23 +314,25 @@ public class Action implements Comparable<Action> {
|
|||||||
thunderWorld.setThundering(true);
|
thunderWorld.setThundering(true);
|
||||||
thunderWorld.setThunderDuration(thunderDuration);
|
thunderWorld.setThunderDuration(thunderDuration);
|
||||||
}
|
}
|
||||||
if (mobSpawns.isEmpty() == false) {
|
if (!mobSpawns.isEmpty()) {
|
||||||
for (final QuestMob questMob : mobSpawns) {
|
for (final QuestMob questMob : mobSpawns) {
|
||||||
questMob.spawn();
|
questMob.spawn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lightningStrikes.isEmpty() == false) {
|
if (!lightningStrikes.isEmpty()) {
|
||||||
for (final Location l : lightningStrikes) {
|
for (final Location l : lightningStrikes) {
|
||||||
|
if (l.getWorld() != null) {
|
||||||
l.getWorld().strikeLightning(l);
|
l.getWorld().strikeLightning(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (commands.isEmpty() == false) {
|
}
|
||||||
|
if (!commands.isEmpty()) {
|
||||||
for (final String s : commands) {
|
for (final String s : commands) {
|
||||||
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(),
|
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(),
|
||||||
s.replace("<player>", quester.getPlayer().getName()));
|
s.replace("<player>", quester.getPlayer().getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (potionEffects.isEmpty() == false) {
|
if (!potionEffects.isEmpty()) {
|
||||||
for (final PotionEffect p : potionEffects) {
|
for (final PotionEffect p : potionEffects) {
|
||||||
player.addPotionEffect(p);
|
player.addPotionEffect(p);
|
||||||
}
|
}
|
||||||
@ -359,7 +364,7 @@ public class Action implements Comparable<Action> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (failQuest == true) {
|
if (failQuest) {
|
||||||
quest.failQuest(quester, true);
|
quest.failQuest(quester, true);
|
||||||
}
|
}
|
||||||
if (timer > 0) {
|
if (timer > 0) {
|
||||||
@ -367,38 +372,38 @@ public class Action implements Comparable<Action> {
|
|||||||
.replace("<time>", ChatColor.RED + String.valueOf(timer) + ChatColor.GREEN));
|
.replace("<time>", ChatColor.RED + String.valueOf(timer) + ChatColor.GREEN));
|
||||||
if (timer > 60) {
|
if (timer > 60) {
|
||||||
quester.getTimers().put(new ActionTimer(quester, quest, 60, false)
|
quester.getTimers().put(new ActionTimer(quester, quest, 60, false)
|
||||||
.runTaskLater(plugin, (timer-60)*20).getTaskId(), quest);
|
.runTaskLater(plugin, (timer - 60) * 20L).getTaskId(), quest);
|
||||||
}
|
}
|
||||||
if (timer > 30) {
|
if (timer > 30) {
|
||||||
quester.getTimers().put(new ActionTimer(quester, quest, 30, false)
|
quester.getTimers().put(new ActionTimer(quester, quest, 30, false)
|
||||||
.runTaskLater(plugin, (timer-30)*20).getTaskId(), quest);
|
.runTaskLater(plugin, (timer - 30) * 20L).getTaskId(), quest);
|
||||||
}
|
}
|
||||||
if (timer > 10) {
|
if (timer > 10) {
|
||||||
quester.getTimers().put(new ActionTimer(quester, quest, 10, false)
|
quester.getTimers().put(new ActionTimer(quester, quest, 10, false)
|
||||||
.runTaskLater(plugin, (timer-10)*20).getTaskId(), quest);
|
.runTaskLater(plugin, (timer - 10) * 20L).getTaskId(), quest);
|
||||||
}
|
}
|
||||||
if (timer > 5) {
|
if (timer > 5) {
|
||||||
quester.getTimers().put(new ActionTimer(quester, quest, 5, false)
|
quester.getTimers().put(new ActionTimer(quester, quest, 5, false)
|
||||||
.runTaskLater(plugin, (timer-5)*20).getTaskId(), quest);
|
.runTaskLater(plugin, (timer - 5) * 20L).getTaskId(), quest);
|
||||||
}
|
}
|
||||||
if (timer > 4) {
|
if (timer > 4) {
|
||||||
quester.getTimers().put(new ActionTimer(quester, quest, 4, false)
|
quester.getTimers().put(new ActionTimer(quester, quest, 4, false)
|
||||||
.runTaskLater(plugin, (timer-4)*20).getTaskId(), quest);
|
.runTaskLater(plugin, (timer - 4) * 20L).getTaskId(), quest);
|
||||||
}
|
}
|
||||||
if (timer > 3) {
|
if (timer > 3) {
|
||||||
quester.getTimers().put(new ActionTimer(quester, quest, 3, false)
|
quester.getTimers().put(new ActionTimer(quester, quest, 3, false)
|
||||||
.runTaskLater(plugin, (timer-3)*20).getTaskId(), quest);
|
.runTaskLater(plugin, (timer - 3) * 20L).getTaskId(), quest);
|
||||||
}
|
}
|
||||||
if (timer > 2) {
|
if (timer > 2) {
|
||||||
quester.getTimers().put(new ActionTimer(quester, quest, 2, false)
|
quester.getTimers().put(new ActionTimer(quester, quest, 2, false)
|
||||||
.runTaskLater(plugin, (timer-2)*20).getTaskId(), quest);
|
.runTaskLater(plugin, (timer - 2) * 20L).getTaskId(), quest);
|
||||||
}
|
}
|
||||||
if (timer > 1) {
|
if (timer > 1) {
|
||||||
quester.getTimers().put(new ActionTimer(quester, quest, 1, false)
|
quester.getTimers().put(new ActionTimer(quester, quest, 1, false)
|
||||||
.runTaskLater(plugin, (timer-1)*20).getTaskId(), quest);
|
.runTaskLater(plugin, (timer - 1) * 20L).getTaskId(), quest);
|
||||||
}
|
}
|
||||||
quester.getTimers().put(new ActionTimer(quester, quest, 0, true)
|
quester.getTimers().put(new ActionTimer(quester, quest, 0, true)
|
||||||
.runTaskLater(plugin, timer*20).getTaskId(), quest);
|
.runTaskLater(plugin, timer * 20L).getTaskId(), quest);
|
||||||
}
|
}
|
||||||
if (cancelTimer) {
|
if (cancelTimer) {
|
||||||
for (final Map.Entry<Integer, Quest> entry : quester.getTimers().entrySet()) {
|
for (final Map.Entry<Integer, Quest> entry : quester.getTimers().entrySet()) {
|
||||||
|
@ -12,16 +12,18 @@
|
|||||||
|
|
||||||
package me.blackvein.quests.actions;
|
package me.blackvein.quests.actions;
|
||||||
|
|
||||||
import java.io.File;
|
import me.blackvein.quests.Quest;
|
||||||
import java.io.IOException;
|
import me.blackvein.quests.QuestMob;
|
||||||
import java.util.Collection;
|
import me.blackvein.quests.Quester;
|
||||||
import java.util.HashMap;
|
import me.blackvein.quests.Quests;
|
||||||
import java.util.LinkedList;
|
import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
|
||||||
import java.util.List;
|
import me.blackvein.quests.convo.actions.menu.ActionMenuPrompt;
|
||||||
import java.util.Map;
|
import me.blackvein.quests.interfaces.ReloadCallback;
|
||||||
import java.util.Map.Entry;
|
import me.blackvein.quests.util.CK;
|
||||||
import java.util.UUID;
|
import me.blackvein.quests.util.ConfigUtil;
|
||||||
|
import me.blackvein.quests.util.FakeConversable;
|
||||||
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
|
import me.blackvein.quests.util.Lang;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -38,41 +40,42 @@ import org.bukkit.conversations.Prompt;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import me.blackvein.quests.Quest;
|
import java.io.File;
|
||||||
import me.blackvein.quests.QuestMob;
|
import java.io.IOException;
|
||||||
import me.blackvein.quests.Quester;
|
import java.util.Collection;
|
||||||
import me.blackvein.quests.Quests;
|
import java.util.HashMap;
|
||||||
import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
|
import java.util.LinkedList;
|
||||||
import me.blackvein.quests.convo.actions.menu.ActionMenuPrompt;
|
import java.util.List;
|
||||||
import me.blackvein.quests.interfaces.ReloadCallback;
|
import java.util.Map;
|
||||||
import me.blackvein.quests.util.CK;
|
import java.util.Map.Entry;
|
||||||
import me.blackvein.quests.util.ConfigUtil;
|
import java.util.Objects;
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
import java.util.UUID;
|
||||||
import me.blackvein.quests.util.Lang;
|
|
||||||
|
|
||||||
public class ActionFactory implements ConversationAbandonedListener {
|
public class ActionFactory implements ConversationAbandonedListener {
|
||||||
|
|
||||||
private final Quests plugin;
|
private final Quests plugin;
|
||||||
private final ConversationFactory convoCreator;
|
private final ConversationFactory convoCreator;
|
||||||
private Map<UUID, Block> selectedExplosionLocations = new HashMap<UUID, Block>();
|
private Map<UUID, Block> selectedExplosionLocations = new HashMap<>();
|
||||||
private Map<UUID, Block> selectedEffectLocations = new HashMap<UUID, Block>();
|
private Map<UUID, Block> selectedEffectLocations = new HashMap<>();
|
||||||
private Map<UUID, Block> selectedMobLocations = new HashMap<UUID, Block>();
|
private Map<UUID, Block> selectedMobLocations = new HashMap<>();
|
||||||
private Map<UUID, Block> selectedLightningLocations = new HashMap<UUID, Block>();
|
private Map<UUID, Block> selectedLightningLocations = new HashMap<>();
|
||||||
private Map<UUID, Block> selectedTeleportLocations = new HashMap<UUID, Block>();
|
private Map<UUID, Block> selectedTeleportLocations = new HashMap<>();
|
||||||
private List<String> editingActionNames = new LinkedList<String>();
|
private List<String> editingActionNames = new LinkedList<>();
|
||||||
|
|
||||||
public ActionFactory(final Quests plugin) {
|
public ActionFactory(final Quests plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
// Ensure to initialize convoCreator last so that 'this' is fully initialized before it is passed
|
// Ensure to initialize convoCreator last so that 'this' is fully initialized before it is passed
|
||||||
this.convoCreator = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
|
this.convoCreator = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
|
||||||
.withFirstPrompt(new ActionMenuPrompt(new ConversationContext(plugin, null, null))).withTimeout(3600)
|
.withFirstPrompt(new ActionMenuPrompt(new ConversationContext(plugin, new FakeConversable(),
|
||||||
|
new HashMap<>()))).withTimeout(3600)
|
||||||
.withPrefix(new LineBreakPrefix()).addConversationAbandonedListener(this);
|
.withPrefix(new LineBreakPrefix()).addConversationAbandonedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LineBreakPrefix implements ConversationPrefix {
|
public static class LineBreakPrefix implements ConversationPrefix {
|
||||||
@Override
|
@Override
|
||||||
public String getPrefix(final ConversationContext context) {
|
public @NotNull String getPrefix(final @NotNull ConversationContext context) {
|
||||||
return "\n";
|
return "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,31 +155,30 @@ public class ActionFactory implements ConversationAbandonedListener {
|
|||||||
if (event.message != null) {
|
if (event.message != null) {
|
||||||
context.setSessionData(CK.E_MESSAGE, event.message);
|
context.setSessionData(CK.E_MESSAGE, event.message);
|
||||||
}
|
}
|
||||||
if (event.clearInv == true) {
|
if (event.clearInv) {
|
||||||
context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("yesWord"));
|
context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("yesWord"));
|
||||||
} else {
|
} else {
|
||||||
context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("noWord"));
|
context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("noWord"));
|
||||||
}
|
}
|
||||||
if (event.failQuest == true) {
|
if (event.failQuest) {
|
||||||
context.setSessionData(CK.E_FAIL_QUEST, Lang.get("yesWord"));
|
context.setSessionData(CK.E_FAIL_QUEST, Lang.get("yesWord"));
|
||||||
} else {
|
} else {
|
||||||
context.setSessionData(CK.E_FAIL_QUEST, Lang.get("noWord"));
|
context.setSessionData(CK.E_FAIL_QUEST, Lang.get("noWord"));
|
||||||
}
|
}
|
||||||
if (event.items != null && event.items.isEmpty() == false) {
|
if (event.items != null && !event.items.isEmpty()) {
|
||||||
final LinkedList<ItemStack> items = new LinkedList<ItemStack>();
|
final LinkedList<ItemStack> items = new LinkedList<>(event.items);
|
||||||
items.addAll(event.items);
|
|
||||||
context.setSessionData(CK.E_ITEMS, items);
|
context.setSessionData(CK.E_ITEMS, items);
|
||||||
}
|
}
|
||||||
if (event.explosions != null && event.explosions.isEmpty() == false) {
|
if (event.explosions != null && !event.explosions.isEmpty()) {
|
||||||
final LinkedList<String> locs = new LinkedList<String>();
|
final LinkedList<String> locs = new LinkedList<>();
|
||||||
for (final Location loc : event.explosions) {
|
for (final Location loc : event.explosions) {
|
||||||
locs.add(ConfigUtil.getLocationInfo(loc));
|
locs.add(ConfigUtil.getLocationInfo(loc));
|
||||||
}
|
}
|
||||||
context.setSessionData(CK.E_EXPLOSIONS, locs);
|
context.setSessionData(CK.E_EXPLOSIONS, locs);
|
||||||
}
|
}
|
||||||
if (event.effects != null && event.effects.isEmpty() == false) {
|
if (event.effects != null && !event.effects.isEmpty()) {
|
||||||
final LinkedList<String> locs = new LinkedList<String>();
|
final LinkedList<String> locs = new LinkedList<>();
|
||||||
final LinkedList<String> effs = new LinkedList<String>();
|
final LinkedList<String> effs = new LinkedList<>();
|
||||||
for (final Entry<Location, Effect> e : event.effects.entrySet()) {
|
for (final Entry<Location, Effect> e : event.effects.entrySet()) {
|
||||||
locs.add(ConfigUtil.getLocationInfo(e.getKey()));
|
locs.add(ConfigUtil.getLocationInfo(e.getKey()));
|
||||||
effs.add(e.getValue().toString());
|
effs.add(e.getValue().toString());
|
||||||
@ -192,24 +194,24 @@ public class ActionFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(CK.E_WORLD_THUNDER, event.thunderWorld.getName());
|
context.setSessionData(CK.E_WORLD_THUNDER, event.thunderWorld.getName());
|
||||||
context.setSessionData(CK.E_WORLD_THUNDER_DURATION, event.thunderDuration);
|
context.setSessionData(CK.E_WORLD_THUNDER_DURATION, event.thunderDuration);
|
||||||
}
|
}
|
||||||
if (event.mobSpawns != null && event.mobSpawns.isEmpty() == false) {
|
if (event.mobSpawns != null && !event.mobSpawns.isEmpty()) {
|
||||||
final LinkedList<String> questMobs = new LinkedList<String>();
|
final LinkedList<String> questMobs = new LinkedList<>();
|
||||||
for (final QuestMob questMob : event.mobSpawns) {
|
for (final QuestMob questMob : event.mobSpawns) {
|
||||||
questMobs.add(questMob.serialize());
|
questMobs.add(questMob.serialize());
|
||||||
}
|
}
|
||||||
context.setSessionData(CK.E_MOB_TYPES, questMobs);
|
context.setSessionData(CK.E_MOB_TYPES, questMobs);
|
||||||
}
|
}
|
||||||
if (event.lightningStrikes != null && event.lightningStrikes.isEmpty() == false) {
|
if (event.lightningStrikes != null && !event.lightningStrikes.isEmpty()) {
|
||||||
final LinkedList<String> locs = new LinkedList<String>();
|
final LinkedList<String> locs = new LinkedList<>();
|
||||||
for (final Location loc : event.lightningStrikes) {
|
for (final Location loc : event.lightningStrikes) {
|
||||||
locs.add(ConfigUtil.getLocationInfo(loc));
|
locs.add(ConfigUtil.getLocationInfo(loc));
|
||||||
}
|
}
|
||||||
context.setSessionData(CK.E_LIGHTNING, locs);
|
context.setSessionData(CK.E_LIGHTNING, locs);
|
||||||
}
|
}
|
||||||
if (event.potionEffects != null && event.potionEffects.isEmpty() == false) {
|
if (event.potionEffects != null && !event.potionEffects.isEmpty()) {
|
||||||
final LinkedList<String> types = new LinkedList<String>();
|
final LinkedList<String> types = new LinkedList<>();
|
||||||
final LinkedList<Long> durations = new LinkedList<Long>();
|
final LinkedList<Long> durations = new LinkedList<>();
|
||||||
final LinkedList<Integer> mags = new LinkedList<Integer>();
|
final LinkedList<Integer> mags = new LinkedList<>();
|
||||||
for (final PotionEffect pe : event.potionEffects) {
|
for (final PotionEffect pe : event.potionEffects) {
|
||||||
types.add(pe.getType().getName());
|
types.add(pe.getType().getName());
|
||||||
durations.add((long) pe.getDuration());
|
durations.add((long) pe.getDuration());
|
||||||
@ -276,12 +278,7 @@ public class ActionFactory implements ConversationAbandonedListener {
|
|||||||
final File actionsFile = new File(plugin.getDataFolder(), "actions.yml");
|
final File actionsFile = new File(plugin.getDataFolder(), "actions.yml");
|
||||||
try {
|
try {
|
||||||
data.load(actionsFile);
|
data.load(actionsFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException | InvalidConfigurationException e) {
|
||||||
e.printStackTrace();
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
|
||||||
.replace("<file>", actionsFile.getName()));
|
|
||||||
return;
|
|
||||||
} catch (final InvalidConfigurationException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
||||||
.replace("<file>", actionsFile.getName()));
|
.replace("<file>", actionsFile.getName()));
|
||||||
@ -294,20 +291,19 @@ public class ActionFactory implements ConversationAbandonedListener {
|
|||||||
key = "events";
|
key = "events";
|
||||||
sec = data.getConfigurationSection(key);
|
sec = data.getConfigurationSection(key);
|
||||||
}
|
}
|
||||||
|
if (sec != null && action != null) {
|
||||||
sec.set(action, null);
|
sec.set(action, null);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
data.save(actionsFile);
|
data.save(actionsFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ReloadCallback<Boolean> callback = new ReloadCallback<Boolean>() {
|
final ReloadCallback<Boolean> callback = response -> {
|
||||||
@Override
|
|
||||||
public void execute(final Boolean response) {
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
plugin.reload(callback);
|
plugin.reload(callback);
|
||||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorDeleted"));
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorDeleted"));
|
||||||
@ -330,43 +326,37 @@ public class ActionFactory implements ConversationAbandonedListener {
|
|||||||
final File actionsFile = new File(plugin.getDataFolder(), "actions.yml");
|
final File actionsFile = new File(plugin.getDataFolder(), "actions.yml");
|
||||||
try {
|
try {
|
||||||
data.load(actionsFile);
|
data.load(actionsFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException | InvalidConfigurationException e) {
|
||||||
e.printStackTrace();
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
|
||||||
.replace("<file>", actionsFile.getName()));
|
|
||||||
return;
|
|
||||||
} catch (final InvalidConfigurationException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
||||||
.replace("<file>", actionsFile.getName()));
|
.replace("<file>", actionsFile.getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String key = "actions";
|
String key = "actions";
|
||||||
ConfigurationSection sec = data.getConfigurationSection(key);
|
if (data.getConfigurationSection(key) == null) {
|
||||||
if (sec == null) {
|
|
||||||
key = "events";
|
key = "events";
|
||||||
sec = data.getConfigurationSection(key);
|
|
||||||
}
|
}
|
||||||
if (((String) context.getSessionData(CK.E_OLD_EVENT)).isEmpty() == false) {
|
if (context.getSessionData(CK.E_OLD_EVENT) != null
|
||||||
data.set(key + "." + (String) context.getSessionData(CK.E_OLD_EVENT), null);
|
&& !((String) Objects.requireNonNull(context.getSessionData(CK.E_OLD_EVENT))).isEmpty()) {
|
||||||
|
data.set(key + "." + context.getSessionData(CK.E_OLD_EVENT), null);
|
||||||
final Collection<Action> temp = plugin.getLoadedActions();
|
final Collection<Action> temp = plugin.getLoadedActions();
|
||||||
temp.remove(plugin.getAction((String) context.getSessionData(CK.E_OLD_EVENT)));
|
temp.remove(plugin.getAction((String) context.getSessionData(CK.E_OLD_EVENT)));
|
||||||
plugin.setLoadedActions(temp);
|
plugin.setLoadedActions(temp);
|
||||||
}
|
}
|
||||||
final ConfigurationSection section = data.createSection(key + "." + (String) context.getSessionData(CK.E_NAME));
|
final ConfigurationSection section = data.createSection(key + "." + context.getSessionData(CK.E_NAME));
|
||||||
editingActionNames.remove(context.getSessionData(CK.E_NAME));
|
editingActionNames.remove((String) context.getSessionData(CK.E_NAME));
|
||||||
if (context.getSessionData(CK.E_MESSAGE) != null) {
|
if (context.getSessionData(CK.E_MESSAGE) != null) {
|
||||||
section.set("message", context.getSessionData(CK.E_MESSAGE));
|
section.set("message", context.getSessionData(CK.E_MESSAGE));
|
||||||
}
|
}
|
||||||
if (context.getSessionData(CK.E_CLEAR_INVENTORY) != null) {
|
if (context.getSessionData(CK.E_CLEAR_INVENTORY) != null) {
|
||||||
final String s = (String) context.getSessionData(CK.E_CLEAR_INVENTORY);
|
final String s = (String) context.getSessionData(CK.E_CLEAR_INVENTORY);
|
||||||
if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
if (s != null && s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
section.set("clear-inventory", true);
|
section.set("clear-inventory", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (context.getSessionData(CK.E_FAIL_QUEST) != null) {
|
if (context.getSessionData(CK.E_FAIL_QUEST) != null) {
|
||||||
final String s = (String) context.getSessionData(CK.E_FAIL_QUEST);
|
final String s = (String) context.getSessionData(CK.E_FAIL_QUEST);
|
||||||
if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
if (s != null && s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
section.set("fail-quest", true);
|
section.set("fail-quest", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -391,13 +381,14 @@ public class ActionFactory implements ConversationAbandonedListener {
|
|||||||
try {
|
try {
|
||||||
if (context.getSessionData(CK.E_MOB_TYPES) != null) {
|
if (context.getSessionData(CK.E_MOB_TYPES) != null) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (final String s : (LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES)) {
|
for (final String s : (LinkedList<String>) Objects.requireNonNull(context
|
||||||
|
.getSessionData(CK.E_MOB_TYPES))) {
|
||||||
ConfigurationSection ss = section.getConfigurationSection("mob-spawns." + count);
|
ConfigurationSection ss = section.getConfigurationSection("mob-spawns." + count);
|
||||||
if (ss == null) {
|
if (ss == null) {
|
||||||
ss = section.createSection("mob-spawns." + count);
|
ss = section.createSection("mob-spawns." + count);
|
||||||
}
|
}
|
||||||
final QuestMob questMob = QuestMob.fromString(s);
|
final QuestMob questMob = QuestMob.fromString(s);
|
||||||
if (questMob == null) {
|
if (questMob.getName() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ss.set("name", questMob.getName());
|
ss.set("name", questMob.getName());
|
||||||
@ -425,7 +416,7 @@ public class ActionFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
if (context.getSessionData(CK.E_COMMANDS) != null) {
|
if (context.getSessionData(CK.E_COMMANDS) != null) {
|
||||||
final LinkedList<String> commands = (LinkedList<String>) context.getSessionData(CK.E_COMMANDS);
|
final LinkedList<String> commands = (LinkedList<String>) context.getSessionData(CK.E_COMMANDS);
|
||||||
if (commands.isEmpty() == false) {
|
if (commands != null && !commands.isEmpty()) {
|
||||||
section.set("commands", commands);
|
section.set("commands", commands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -446,12 +437,15 @@ public class ActionFactory implements ConversationAbandonedListener {
|
|||||||
if (context.getSessionData(CK.E_TELEPORT) != null) {
|
if (context.getSessionData(CK.E_TELEPORT) != null) {
|
||||||
section.set("teleport-location", context.getSessionData(CK.E_TELEPORT));
|
section.set("teleport-location", context.getSessionData(CK.E_TELEPORT));
|
||||||
}
|
}
|
||||||
if (context.getSessionData(CK.E_TIMER) != null && (int) context.getSessionData(CK.E_TIMER) > 0) {
|
if (context.getSessionData(CK.E_TIMER) != null) {
|
||||||
|
final Integer i = (Integer) context.getSessionData(CK.E_TIMER);
|
||||||
|
if (i != null && i > 0) {
|
||||||
section.set("timer", context.getSessionData(CK.E_TIMER));
|
section.set("timer", context.getSessionData(CK.E_TIMER));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (context.getSessionData(CK.E_CANCEL_TIMER) != null) {
|
if (context.getSessionData(CK.E_CANCEL_TIMER) != null) {
|
||||||
final String s = (String) context.getSessionData(CK.E_CANCEL_TIMER);
|
final String s = (String) context.getSessionData(CK.E_CANCEL_TIMER);
|
||||||
if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
if (s != null && s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
section.set("cancel-timer", true);
|
section.set("cancel-timer", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -464,20 +458,17 @@ public class ActionFactory implements ConversationAbandonedListener {
|
|||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ReloadCallback<Boolean> callback = new ReloadCallback<Boolean>() {
|
final ReloadCallback<Boolean> callback = response -> {
|
||||||
@Override
|
|
||||||
public void execute(final Boolean response) {
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
plugin.reload(callback);
|
plugin.reload(callback);
|
||||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorSaved"));
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorSaved"));
|
||||||
if (plugin.getSettings().getConsoleLogging() > 0) {
|
if (plugin.getSettings().getConsoleLogging() > 0) {
|
||||||
final String identifier = context.getForWhom() instanceof Player ?
|
final String identifier = context.getForWhom() instanceof Player ?
|
||||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||||
plugin.getLogger().info(identifier + " saved action " + (String) context.getSessionData(CK.E_NAME));
|
plugin.getLogger().info(identifier + " saved action " + context.getSessionData(CK.E_NAME));
|
||||||
}
|
}
|
||||||
for (final Quester q : plugin.getOfflineQuesters()) {
|
for (final Quester q : plugin.getOfflineQuesters()) {
|
||||||
for (final Quest quest : q.getCurrentQuests().keySet()) {
|
for (final Quest quest : q.getCurrentQuests().keySet()) {
|
||||||
|
@ -12,32 +12,32 @@
|
|||||||
|
|
||||||
package me.blackvein.quests.conditions;
|
package me.blackvein.quests.conditions;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import me.blackvein.quests.Quest;
|
import me.blackvein.quests.Quest;
|
||||||
import me.blackvein.quests.Quester;
|
import me.blackvein.quests.Quester;
|
||||||
import me.blackvein.quests.Quests;
|
import me.blackvein.quests.Quests;
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
import me.blackvein.quests.util.MiscUtil;
|
import me.blackvein.quests.util.MiscUtil;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Condition implements Comparable<Condition> {
|
public class Condition implements Comparable<Condition> {
|
||||||
|
|
||||||
private final Quests plugin;
|
private final Quests plugin;
|
||||||
private String name = "";
|
private String name = "";
|
||||||
private boolean failQuest = false;
|
private boolean failQuest = false;
|
||||||
private LinkedList<String> entitiesWhileRiding = new LinkedList<String>();
|
private LinkedList<String> entitiesWhileRiding = new LinkedList<>();
|
||||||
private LinkedList<Integer> npcsWhileRiding = new LinkedList<Integer>();
|
private LinkedList<Integer> npcsWhileRiding = new LinkedList<>();
|
||||||
private LinkedList<String> permissions = new LinkedList<String>();
|
private LinkedList<String> permissions = new LinkedList<>();
|
||||||
private LinkedList<ItemStack> itemsWhileHoldingMainHand = new LinkedList<ItemStack>();
|
private LinkedList<ItemStack> itemsWhileHoldingMainHand = new LinkedList<>();
|
||||||
private LinkedList<String> worldsWhileStayingWithin = new LinkedList<String>();
|
private LinkedList<String> worldsWhileStayingWithin = new LinkedList<>();
|
||||||
private LinkedList<String> biomesWhileStayingWithin = new LinkedList<String>();
|
private LinkedList<String> biomesWhileStayingWithin = new LinkedList<>();
|
||||||
private LinkedList<String> regionsWhileStayingWithin = new LinkedList<String>();
|
private LinkedList<String> regionsWhileStayingWithin = new LinkedList<>();
|
||||||
private LinkedList<String> placeholdersCheckIdentifier = new LinkedList<String>();
|
private LinkedList<String> placeholdersCheckIdentifier = new LinkedList<>();
|
||||||
private LinkedList<String> placeholdersCheckValue = new LinkedList<String>();
|
private LinkedList<String> placeholdersCheckValue = new LinkedList<>();
|
||||||
|
|
||||||
public Condition(final Quests plugin) {
|
public Condition(final Quests plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -141,7 +141,7 @@ public class Condition implements Comparable<Condition> {
|
|||||||
final Player player = quester.getPlayer();
|
final Player player = quester.getPlayer();
|
||||||
if (!entitiesWhileRiding.isEmpty()) {
|
if (!entitiesWhileRiding.isEmpty()) {
|
||||||
for (final String e : entitiesWhileRiding) {
|
for (final String e : entitiesWhileRiding) {
|
||||||
if (player.isInsideVehicle() && player.getVehicle().getType().equals(MiscUtil.getProperMobType(e))) {
|
if (player.getVehicle() != null && player.getVehicle().getType().equals(MiscUtil.getProperMobType(e))) {
|
||||||
return true;
|
return true;
|
||||||
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||||
plugin.getLogger().info("DEBUG: Condition entity mismatch for " + player.getName() + ": " + e);
|
plugin.getLogger().info("DEBUG: Condition entity mismatch for " + player.getName() + ": " + e);
|
||||||
@ -150,7 +150,7 @@ public class Condition implements Comparable<Condition> {
|
|||||||
} else if (!npcsWhileRiding.isEmpty()) {
|
} else if (!npcsWhileRiding.isEmpty()) {
|
||||||
for (final int n : npcsWhileRiding) {
|
for (final int n : npcsWhileRiding) {
|
||||||
if (plugin.getDependencies().getCitizens() != null) {
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
if (player.isInsideVehicle() && player.getVehicle()
|
if (player.getVehicle() != null && player.getVehicle()
|
||||||
.equals(plugin.getDependencies().getCitizens().getNPCRegistry().getById(n).getEntity())) {
|
.equals(plugin.getDependencies().getCitizens().getNPCRegistry().getById(n).getEntity())) {
|
||||||
return true;
|
return true;
|
||||||
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||||
@ -189,8 +189,11 @@ public class Condition implements Comparable<Condition> {
|
|||||||
}
|
}
|
||||||
} else if (!biomesWhileStayingWithin.isEmpty()) {
|
} else if (!biomesWhileStayingWithin.isEmpty()) {
|
||||||
for (final String b : biomesWhileStayingWithin) {
|
for (final String b : biomesWhileStayingWithin) {
|
||||||
|
if (MiscUtil.getProperBiome(b) == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (player.getWorld().getBiome(player.getLocation().getBlockX(), player.getLocation().getBlockZ())
|
if (player.getWorld().getBiome(player.getLocation().getBlockX(), player.getLocation().getBlockZ())
|
||||||
.name().equalsIgnoreCase(MiscUtil.getProperBiome(b).name())) {
|
.name().equalsIgnoreCase(Objects.requireNonNull(MiscUtil.getProperBiome(b)).name())) {
|
||||||
return true;
|
return true;
|
||||||
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||||
plugin.getLogger().info("DEBUG: Condition biome mismatch for " + player.getName() + ": "
|
plugin.getLogger().info("DEBUG: Condition biome mismatch for " + player.getName() + ": "
|
||||||
|
@ -12,12 +12,15 @@
|
|||||||
|
|
||||||
package me.blackvein.quests.conditions;
|
package me.blackvein.quests.conditions;
|
||||||
|
|
||||||
import java.io.File;
|
import me.blackvein.quests.Quest;
|
||||||
import java.io.IOException;
|
import me.blackvein.quests.Quester;
|
||||||
import java.util.Collection;
|
import me.blackvein.quests.Quests;
|
||||||
import java.util.LinkedList;
|
import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt;
|
||||||
import java.util.List;
|
import me.blackvein.quests.convo.conditions.menu.ConditionMenuPrompt;
|
||||||
|
import me.blackvein.quests.interfaces.ReloadCallback;
|
||||||
|
import me.blackvein.quests.util.CK;
|
||||||
|
import me.blackvein.quests.util.FakeConversable;
|
||||||
|
import me.blackvein.quests.util.Lang;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
@ -30,33 +33,34 @@ import org.bukkit.conversations.ConversationPrefix;
|
|||||||
import org.bukkit.conversations.Prompt;
|
import org.bukkit.conversations.Prompt;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import me.blackvein.quests.Quest;
|
import java.io.File;
|
||||||
import me.blackvein.quests.Quester;
|
import java.io.IOException;
|
||||||
import me.blackvein.quests.Quests;
|
import java.util.Collection;
|
||||||
import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt;
|
import java.util.HashMap;
|
||||||
import me.blackvein.quests.convo.conditions.menu.ConditionMenuPrompt;
|
import java.util.LinkedList;
|
||||||
import me.blackvein.quests.interfaces.ReloadCallback;
|
import java.util.List;
|
||||||
import me.blackvein.quests.util.CK;
|
import java.util.Objects;
|
||||||
import me.blackvein.quests.util.Lang;
|
|
||||||
|
|
||||||
public class ConditionFactory implements ConversationAbandonedListener {
|
public class ConditionFactory implements ConversationAbandonedListener {
|
||||||
|
|
||||||
private final Quests plugin;
|
private final Quests plugin;
|
||||||
private final ConversationFactory convoCreator;
|
private final ConversationFactory convoCreator;
|
||||||
private List<String> editingConditionNames = new LinkedList<String>();
|
private List<String> editingConditionNames = new LinkedList<>();
|
||||||
|
|
||||||
public ConditionFactory(final Quests plugin) {
|
public ConditionFactory(final Quests plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
// Ensure to initialize convoCreator last so that 'this' is fully initialized before it is passed
|
// Ensure to initialize convoCreator last so that 'this' is fully initialized before it is passed
|
||||||
this.convoCreator = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
|
this.convoCreator = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
|
||||||
.withFirstPrompt(new ConditionMenuPrompt(new ConversationContext(plugin, null, null))).withTimeout(3600)
|
.withFirstPrompt(new ConditionMenuPrompt(new ConversationContext(plugin, new FakeConversable(),
|
||||||
|
new HashMap<>()))).withTimeout(3600)
|
||||||
.withPrefix(new LineBreakPrefix()).addConversationAbandonedListener(this);
|
.withPrefix(new LineBreakPrefix()).addConversationAbandonedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LineBreakPrefix implements ConversationPrefix {
|
public static class LineBreakPrefix implements ConversationPrefix {
|
||||||
@Override
|
@Override
|
||||||
public String getPrefix(final ConversationContext context) {
|
public @NotNull String getPrefix(final @NotNull ConversationContext context) {
|
||||||
return "\n";
|
return "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,7 +78,7 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void conversationAbandoned(final ConversationAbandonedEvent abandonedEvent) {
|
public void conversationAbandoned(final @NotNull ConversationAbandonedEvent abandonedEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Prompt returnToMenu(final ConversationContext context) {
|
public Prompt returnToMenu(final ConversationContext context) {
|
||||||
@ -82,63 +86,46 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadData(final Condition condition, final ConversationContext context) {
|
public void loadData(final Condition condition, final ConversationContext context) {
|
||||||
if (condition.isFailQuest() == true) {
|
if (condition.isFailQuest()) {
|
||||||
context.setSessionData(CK.C_FAIL_QUEST, Lang.get("yesWord"));
|
context.setSessionData(CK.C_FAIL_QUEST, Lang.get("yesWord"));
|
||||||
} else {
|
} else {
|
||||||
context.setSessionData(CK.C_FAIL_QUEST, Lang.get("noWord"));
|
context.setSessionData(CK.C_FAIL_QUEST, Lang.get("noWord"));
|
||||||
}
|
}
|
||||||
if (condition.getEntitiesWhileRiding() != null
|
if (condition.getEntitiesWhileRiding() != null && !condition.getEntitiesWhileRiding().isEmpty()) {
|
||||||
&& condition.getEntitiesWhileRiding().isEmpty() == false) {
|
final LinkedList<String> entities = new LinkedList<>(condition.getEntitiesWhileRiding());
|
||||||
final LinkedList<String> entities = new LinkedList<String>();
|
|
||||||
entities.addAll(condition.getEntitiesWhileRiding());
|
|
||||||
context.setSessionData(CK.C_WHILE_RIDING_ENTITY, entities);
|
context.setSessionData(CK.C_WHILE_RIDING_ENTITY, entities);
|
||||||
}
|
}
|
||||||
if (condition.getNpcsWhileRiding() != null
|
if (condition.getNpcsWhileRiding() != null && !condition.getNpcsWhileRiding().isEmpty()) {
|
||||||
&& condition.getNpcsWhileRiding().isEmpty() == false) {
|
final LinkedList<Integer> npcs = new LinkedList<>(condition.getNpcsWhileRiding());
|
||||||
final LinkedList<Integer> npcs = new LinkedList<Integer>();
|
|
||||||
npcs.addAll(condition.getNpcsWhileRiding());
|
|
||||||
context.setSessionData(CK.C_WHILE_RIDING_NPC, npcs);
|
context.setSessionData(CK.C_WHILE_RIDING_NPC, npcs);
|
||||||
}
|
}
|
||||||
if (condition.getPermissions() != null
|
if (condition.getPermissions() != null && !condition.getPermissions().isEmpty()) {
|
||||||
&& condition.getPermissions().isEmpty() == false) {
|
final LinkedList<String> permissions = new LinkedList<>(condition.getPermissions());
|
||||||
final LinkedList<String> permissions = new LinkedList<String>();
|
|
||||||
permissions.addAll(condition.getPermissions());
|
|
||||||
context.setSessionData(CK.C_WHILE_PERMISSION, permissions);
|
context.setSessionData(CK.C_WHILE_PERMISSION, permissions);
|
||||||
}
|
}
|
||||||
if (condition.getItemsWhileHoldingMainHand() != null
|
if (condition.getItemsWhileHoldingMainHand() != null && !condition.getItemsWhileHoldingMainHand().isEmpty()) {
|
||||||
&& condition.getItemsWhileHoldingMainHand().isEmpty() == false) {
|
final LinkedList<ItemStack> items = new LinkedList<>(condition.getItemsWhileHoldingMainHand());
|
||||||
final LinkedList<ItemStack> items = new LinkedList<ItemStack>();
|
|
||||||
items.addAll(condition.getItemsWhileHoldingMainHand());
|
|
||||||
context.setSessionData(CK.C_WHILE_HOLDING_MAIN_HAND, items);
|
context.setSessionData(CK.C_WHILE_HOLDING_MAIN_HAND, items);
|
||||||
}
|
}
|
||||||
if (condition.getWorldsWhileStayingWithin() != null
|
if (condition.getWorldsWhileStayingWithin() != null && !condition.getWorldsWhileStayingWithin().isEmpty()) {
|
||||||
&& condition.getWorldsWhileStayingWithin().isEmpty() == false) {
|
final LinkedList<String> worlds = new LinkedList<>(condition.getBiomesWhileStayingWithin());
|
||||||
final LinkedList<String> worlds = new LinkedList<String>();
|
|
||||||
worlds.addAll(condition.getBiomesWhileStayingWithin());
|
|
||||||
context.setSessionData(CK.C_WHILE_WITHIN_WORLD, worlds);
|
context.setSessionData(CK.C_WHILE_WITHIN_WORLD, worlds);
|
||||||
}
|
}
|
||||||
if (condition.getBiomesWhileStayingWithin() != null
|
if (condition.getBiomesWhileStayingWithin() != null && !condition.getBiomesWhileStayingWithin().isEmpty()) {
|
||||||
&& condition.getBiomesWhileStayingWithin().isEmpty() == false) {
|
final LinkedList<String> biomes = new LinkedList<>(condition.getBiomesWhileStayingWithin());
|
||||||
final LinkedList<String> biomes = new LinkedList<String>();
|
|
||||||
biomes.addAll(condition.getBiomesWhileStayingWithin());
|
|
||||||
context.setSessionData(CK.C_WHILE_WITHIN_BIOME, biomes);
|
context.setSessionData(CK.C_WHILE_WITHIN_BIOME, biomes);
|
||||||
}
|
}
|
||||||
if (condition.getRegionsWhileStayingWithin() != null
|
if (condition.getRegionsWhileStayingWithin() != null && !condition.getRegionsWhileStayingWithin().isEmpty()) {
|
||||||
&& condition.getRegionsWhileStayingWithin().isEmpty() == false) {
|
final LinkedList<String> regions = new LinkedList<>(condition.getRegionsWhileStayingWithin());
|
||||||
final LinkedList<String> regions = new LinkedList<String>();
|
|
||||||
regions.addAll(condition.getRegionsWhileStayingWithin());
|
|
||||||
context.setSessionData(CK.C_WHILE_WITHIN_REGION, regions);
|
context.setSessionData(CK.C_WHILE_WITHIN_REGION, regions);
|
||||||
}
|
}
|
||||||
if (condition.getPlaceholdersCheckIdentifier() != null
|
if (condition.getPlaceholdersCheckIdentifier() != null
|
||||||
&& condition.getPlaceholdersCheckIdentifier().isEmpty() == false) {
|
&& !condition.getPlaceholdersCheckIdentifier().isEmpty()) {
|
||||||
final LinkedList<String> identifiers = new LinkedList<String>();
|
final LinkedList<String> identifiers = new LinkedList<>(condition.getPlaceholdersCheckIdentifier());
|
||||||
identifiers.addAll(condition.getPlaceholdersCheckIdentifier());
|
|
||||||
context.setSessionData(CK.C_WHILE_PLACEHOLDER_ID, identifiers);
|
context.setSessionData(CK.C_WHILE_PLACEHOLDER_ID, identifiers);
|
||||||
}
|
}
|
||||||
if (condition.getPlaceholdersCheckValue() != null
|
if (condition.getPlaceholdersCheckValue() != null && !condition.getPlaceholdersCheckValue().isEmpty()) {
|
||||||
&& condition.getPlaceholdersCheckValue().isEmpty() == false) {
|
final LinkedList<String> values = new LinkedList<>(condition.getPlaceholdersCheckValue());
|
||||||
final LinkedList<String> values = new LinkedList<String>();
|
|
||||||
values.addAll(condition.getPlaceholdersCheckValue());
|
|
||||||
context.setSessionData(CK.C_WHILE_PLACEHOLDER_VAL, values);
|
context.setSessionData(CK.C_WHILE_PLACEHOLDER_VAL, values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,12 +150,7 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
|||||||
final File conditionsFile = new File(plugin.getDataFolder(), "conditions.yml");
|
final File conditionsFile = new File(plugin.getDataFolder(), "conditions.yml");
|
||||||
try {
|
try {
|
||||||
data.load(conditionsFile);
|
data.load(conditionsFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException | InvalidConfigurationException e) {
|
||||||
e.printStackTrace();
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
|
||||||
.replace("<file>", conditionsFile.getName()));
|
|
||||||
return;
|
|
||||||
} catch (final InvalidConfigurationException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
||||||
.replace("<file>", conditionsFile.getName()));
|
.replace("<file>", conditionsFile.getName()));
|
||||||
@ -176,20 +158,19 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
final String condition = (String) context.getSessionData(CK.ED_CONDITION_DELETE);
|
final String condition = (String) context.getSessionData(CK.ED_CONDITION_DELETE);
|
||||||
final ConfigurationSection sec = data.getConfigurationSection("conditions");
|
final ConfigurationSection sec = data.getConfigurationSection("conditions");
|
||||||
|
if (sec != null && condition != null) {
|
||||||
sec.set(condition, null);
|
sec.set(condition, null);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
data.save(conditionsFile);
|
data.save(conditionsFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ReloadCallback<Boolean> callback = new ReloadCallback<Boolean>() {
|
final ReloadCallback<Boolean> callback = response -> {
|
||||||
@Override
|
|
||||||
public void execute(final Boolean response) {
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
plugin.reload(callback);
|
plugin.reload(callback);
|
||||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("conditionEditorDeleted"));
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("conditionEditorDeleted"));
|
||||||
@ -211,28 +192,24 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
|||||||
final File conditionsFile = new File(plugin.getDataFolder(), "conditions.yml");
|
final File conditionsFile = new File(plugin.getDataFolder(), "conditions.yml");
|
||||||
try {
|
try {
|
||||||
data.load(conditionsFile);
|
data.load(conditionsFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException | InvalidConfigurationException e) {
|
||||||
e.printStackTrace();
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
|
||||||
.replace("<file>", conditionsFile.getName()));
|
|
||||||
return;
|
|
||||||
} catch (final InvalidConfigurationException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
|
||||||
.replace("<file>", conditionsFile.getName()));
|
.replace("<file>", conditionsFile.getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (((String) context.getSessionData(CK.C_OLD_CONDITION)).isEmpty() == false) {
|
if (context.getSessionData(CK.C_OLD_CONDITION) != null
|
||||||
data.set("conditions." + (String) context.getSessionData(CK.C_OLD_CONDITION), null);
|
&& !((String) Objects.requireNonNull(context.getSessionData(CK.C_OLD_CONDITION))).isEmpty()) {
|
||||||
|
data.set("conditions." + context.getSessionData(CK.C_OLD_CONDITION), null);
|
||||||
final Collection<Condition> temp = plugin.getLoadedConditions();
|
final Collection<Condition> temp = plugin.getLoadedConditions();
|
||||||
temp.remove(plugin.getCondition((String) context.getSessionData(CK.C_OLD_CONDITION)));
|
temp.remove(plugin.getCondition((String) context.getSessionData(CK.C_OLD_CONDITION)));
|
||||||
plugin.setLoadedConditions(temp);
|
plugin.setLoadedConditions(temp);
|
||||||
}
|
}
|
||||||
final ConfigurationSection section = data.createSection("conditions." + (String) context.getSessionData(CK.C_NAME));
|
final ConfigurationSection section = data.createSection("conditions." + context.getSessionData(CK.C_NAME));
|
||||||
editingConditionNames.remove(context.getSessionData(CK.C_NAME));
|
editingConditionNames.remove((String) context.getSessionData(CK.C_NAME));
|
||||||
if (context.getSessionData(CK.C_FAIL_QUEST) != null) {
|
if (context.getSessionData(CK.C_FAIL_QUEST) != null) {
|
||||||
final String s = (String) context.getSessionData(CK.C_FAIL_QUEST);
|
final String s = (String) context.getSessionData(CK.C_FAIL_QUEST);
|
||||||
if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
if (s != null && s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
section.set("fail-quest", true);
|
section.set("fail-quest", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,20 +255,17 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
|||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ReloadCallback<Boolean> callback = new ReloadCallback<Boolean>() {
|
final ReloadCallback<Boolean> callback = response -> {
|
||||||
@Override
|
|
||||||
public void execute(final Boolean response) {
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
plugin.reload(callback);
|
plugin.reload(callback);
|
||||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("conditionEditorSaved"));
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("conditionEditorSaved"));
|
||||||
if (plugin.getSettings().getConsoleLogging() > 0) {
|
if (plugin.getSettings().getConsoleLogging() > 0) {
|
||||||
final String identifier = context.getForWhom() instanceof Player ?
|
final String identifier = context.getForWhom() instanceof Player ?
|
||||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||||
plugin.getLogger().info(identifier + " saved condition " + (String) context.getSessionData(CK.C_NAME));
|
plugin.getLogger().info(identifier + " saved condition " + context.getSessionData(CK.C_NAME));
|
||||||
}
|
}
|
||||||
for (final Quester q : plugin.getOfflineQuesters()) {
|
for (final Quester q : plugin.getOfflineQuesters()) {
|
||||||
for (final Quest quest : q.getCurrentQuests().keySet()) {
|
for (final Quest quest : q.getCurrentQuests().keySet()) {
|
||||||
|
119
main/src/main/java/me/blackvein/quests/util/FakeConversable.java
Normal file
119
main/src/main/java/me/blackvein/quests/util/FakeConversable.java
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||||
|
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.blackvein.quests.util;
|
||||||
|
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.conversations.Conversable;
|
||||||
|
import org.bukkit.conversations.Conversation;
|
||||||
|
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||||
|
import org.bukkit.permissions.Permission;
|
||||||
|
import org.bukkit.permissions.PermissionAttachment;
|
||||||
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For use when creating a new ConversationContext
|
||||||
|
*/
|
||||||
|
public class FakeConversable implements Conversable {
|
||||||
|
public String lastSentMessage;
|
||||||
|
public Conversation begunConversation;
|
||||||
|
public Conversation abandonedConverstion;
|
||||||
|
public ConversationAbandonedEvent abandonedConversationEvent;
|
||||||
|
|
||||||
|
public boolean isConversing() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void acceptConversationInput(@NotNull String input) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean beginConversation(Conversation conversation) {
|
||||||
|
begunConversation = conversation;
|
||||||
|
conversation.outputNextPrompt();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void abandonConversation(@NotNull Conversation conversation) {
|
||||||
|
abandonedConverstion = conversation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void abandonConversation(@NotNull Conversation conversation, @NotNull ConversationAbandonedEvent details) {
|
||||||
|
abandonedConverstion = conversation;
|
||||||
|
abandonedConversationEvent = details;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendRawMessage(@NotNull String message) {
|
||||||
|
lastSentMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Server getServer() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPermissionSet(String name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPermissionSet(Permission perm) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPermission(String name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPermission(Permission perm) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PermissionAttachment addAttachment(Plugin plugin) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAttachment(PermissionAttachment attachment) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void recalculatePermissions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOp() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOp(boolean value) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user