Refactor to core module, part 3

This commit is contained in:
PikaMug 2022-01-13 11:02:43 -05:00
parent b45ca9b8d3
commit 33e4a5661f
60 changed files with 683 additions and 566 deletions

View File

@ -15,7 +15,7 @@
<repositories>
<repository>
<!-- CitizensBooks, DungeonsXL, GPS, LocaleLib, mcMMO Classic, PhatLoots -->
<!-- CitizensBooks, DungeonsXL, GPS, mcMMO Classic, PhatLoots -->
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
@ -129,39 +129,6 @@
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.PikaMug</groupId>
<artifactId>LocaleLib</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.25</version>
<exclusions>
<exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<!-- Do not update until Java 11 is min -->
<version>4.0.3</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.32</version>
</dependency>
</dependencies>
<build>
@ -184,55 +151,6 @@
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>false</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>me.*</include>
<include>com.github.PikaMug:LocaleLib</include>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-simple</include>
<include>org.slf4j:slf4j-api</include>
<include>mysql</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>me.pikamug.localelib</pattern>
<shadedPattern>me.blackvein.quests.libs.localelib</shadedPattern>
</relocation>
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>me.blackvein.quests.libs.hikari</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>me.blackvein.quests.libs.slf4j</shadedPattern>
</relocation>
<relocation>
<pattern>com.mysql</pattern>
<shadedPattern>me.blackvein.quests.libs.mysql</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,70 @@
package me.blackvein.quests;
import com.alessiodp.parties.api.interfaces.PartiesAPI;
import com.codisimus.plugins.phatloots.PhatLoots;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.mcMMO;
import com.herocraftonline.heroes.Heroes;
import com.herocraftonline.heroes.characters.Hero;
import me.blackvein.quests.reflect.denizen.DenizenAPI;
import me.blackvein.quests.reflect.worldguard.WorldGuardAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.pikamug.unite.api.objects.PartyProvider;
import net.citizensnpcs.api.CitizensPlugin;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Location;
import ro.nicuch.citizensbooks.CitizensBooksAPI;
import java.util.Set;
import java.util.UUID;
public interface Dependencies {
Economy getVaultEconomy();
Permission getVaultPermission();
PartyProvider getPartyProvider();
Set<PartyProvider> getPartyProviders();
WorldGuardAPI getWorldGuardApi();
mcMMO getMcmmoClassic();
Heroes getHeroes();
PhatLoots getPhatLoots();
PlaceholderAPIPlugin getPlaceholderApi();
CitizensPlugin getCitizens();
void linkCitizens();
void unlinkCitizens();
DenizenAPI getDenizenApi();
CitizensBooksAPI getCitizensBooksApi();
PartiesAPI getPartiesApi();
boolean isPluginAvailable(final String pluginName);
boolean runDenizenScript(final String scriptName, final Quester quester);
Location getNPCLocation(final int id);
String getNPCName(final int id);
int getMcmmoSkillLevel(final SkillType st, final String player);
Hero getHero(final UUID uuid);
boolean testPrimaryHeroesClass(final String primaryClass, final UUID uuid);
boolean testSecondaryHeroesClass(final String secondaryClass, final UUID uuid);
void init();
}

View File

@ -5,12 +5,19 @@ import net.citizensnpcs.api.npc.NPC;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import java.util.LinkedList;
public interface Quest extends Comparable<Quest> {
Plugin getPlugin();
void setPlugin(Plugin plugin);
String getId();
void setId(String id);
String getName();
void setName(final String name);

View File

@ -1,4 +1,54 @@
package me.blackvein.quests;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.ConversationFactory;
import org.bukkit.conversations.Prompt;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
public interface QuestFactory {
Map<UUID, Block> getSelectedBlockStarts();
void setSelectedBlockStarts(final Map<UUID, Block> selectedBlockStarts);
Map<UUID, Block> getSelectedKillLocations();
void setSelectedKillLocations(final Map<UUID, Block> selectedKillLocations);
Map<UUID, Block> getSelectedReachLocations();
void setSelectedReachLocations(final Map<UUID, Block> selectedReachLocations);
Set<UUID> getSelectingNpcs();
void setSelectingNpcs(final Set<UUID> selectingNpcs);
List<String> getNamesOfQuestsBeingEdited();
void setNamesOfQuestsBeingEdited(final List<String> questNames);
ConversationFactory getConversationFactory();
Prompt returnToMenu(final ConversationContext context);
void loadQuest(final ConversationContext context, final Quest q);
void deleteQuest(final ConversationContext context);
void saveQuest(final ConversationContext context, final ConfigurationSection section);
/*void saveRequirements(final ConversationContext context, final ConfigurationSection section);
void saveStages(final ConversationContext context, final ConfigurationSection section);
void saveRewards(final ConversationContext context, final ConfigurationSection section);
void savePlanner(final ConversationContext context, final ConfigurationSection section);
void saveOptions(final ConversationContext context, final ConfigurationSection section);*/
}

View File

@ -1,14 +1,85 @@
package me.blackvein.quests;
import me.blackvein.quests.actions.Action;
import me.blackvein.quests.actions.ActionFactory;
import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.conditions.ConditionFactory;
import org.bukkit.command.CommandExecutor;
import org.bukkit.conversations.ConversationFactory;
import org.bukkit.plugin.Plugin;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
public interface QuestsAPI extends Plugin {
boolean isLoading();
String getDetectedServerSoftwareVersion();
Dependencies getDependencies();
Settings getSettings();
List<CustomObjective> getCustomObjectives();
List<CustomReward> getCustomRewards();
List<CustomRequirement> getCustomRequirements();
Collection<Quest> getLoadedQuests();
Collection<Action> getLoadedActions();
Collection<Condition> getLoadedConditions();
Quester getQuester(final UUID id);
Collection<Quester> getOnlineQuesters();
Collection<Quester> getOfflineQuesters();
void setOfflineQuesters(final Collection<Quester> questers);
LinkedList<Integer> getQuestNpcIds();
void setQuestNpcIds(final LinkedList<Integer> questNpcIds);
CommandExecutor getCommandExecutor();
ConversationFactory getConversationFactory();
ConversationFactory getNpcConversationFactory();
QuestFactory getQuestFactory();
ActionFactory getActionFactory();
ConditionFactory getConditionFactory();
/*ConvoListener getConvoListener();
BlockListener getBlockListener();
ItemListener getItemListener();
NpcListener getNpcListener();
PlayerListener getPlayerListener();
UniteListener getUniteListener();
NpcEffectThread getNpcEffectThread();
PlayerMoveThread getPlayerMoveThread();
PartiesListener getPartiesListener();
DenizenTrigger getDenizenTrigger();
LocaleManager getLocaleManager();
Storage getStorage();*/
}

View File

@ -0,0 +1,51 @@
package me.blackvein.quests;
public interface Settings {
int getAcceptTimeout();
void setAcceptTimeout(final int acceptTimeout);
boolean canAllowCommands();
void setAllowCommands(final boolean allowCommands);
boolean canAllowCommandsForNpcQuests();
void setAllowCommandsForNpcQuests(final boolean allowCommandsForNpcQuests);
boolean canAllowPranks();
void setAllowPranks(final boolean allowPranks);
boolean canAskConfirmation();
void setAskConfirmation(final boolean askConfirmation);
boolean canClickablePrompts();
void setClickablePrompts(boolean clickablePrompts);
int getConsoleLogging();
void setConsoleLogging(final int consoleLogging);
boolean canDisableCommandFeedback();
void setDisableCommandFeedback(final boolean disableCommandFeedback);
boolean canGenFilesOnJoin();
void setGenFilesOnJoin(final boolean genFilesOnJoin);
boolean canIgnoreLockedQuests();
void setIgnoreLockedQuests(final boolean ignoreLockedQuests);
int getKillDelay();
void setKillDelay(final int killDelay);
int getMaxQuests();
void setMaxQuests(final int maxQuests);
boolean canNpcEffects();
void setNpcEffects(final boolean npcEffects);
String getEffect();
void setEffect(final String effect);
String getRedoEffect();
void setRedoEffect(final String redoEffect);
boolean canShowQuestReqs();
void setShowQuestReqs(final boolean showQuestReqs);
boolean canShowQuestTitles();
void setShowQuestTitles(final boolean showQuestTitles);
int getStrictPlayerMovement();
void setStrictPlayerMovement(final int strictPlayerMovement);
boolean canTrialSave();
void setTrialSave(final boolean trialSave);
int getTopLimit();
void setTopLimit(final int topLimit);
boolean canTranslateNames();
void setTranslateNames(final boolean translateItems);
boolean canTranslateSubCommands();
void setTranslateSubCommands(final boolean translateSubCommands);
boolean canUpdateCheck();
void setUpdateCheck(final boolean updateCheck);
void init();
}

View File

@ -275,10 +275,14 @@ public interface Stage {
LinkedList<CustomObjective> getCustomObjectives();
boolean addCustomObjectives(final CustomObjective customObjective);
void clearCustomObjectives();
LinkedList<Integer> getCustomObjectiveCounts();
boolean addCustomObjectiveCounts(final Integer customObjectiveCount);
void clearCustomObjectiveCounts();
LinkedList<String> getCustomObjectiveDisplays();
@ -287,6 +291,8 @@ public interface Stage {
LinkedList<Map.Entry<String, Object>> getCustomObjectiveData();
boolean addCustomObjectiveData(final Map.Entry<String, Object> customObjectiveDatum);
void clearCustomObjectiveData();
/**

View File

@ -12,7 +12,7 @@ import org.bukkit.potion.PotionEffect;
import java.util.LinkedList;
import java.util.Map;
public interface Action {
public interface Action extends Comparable<Action> {
String getName();
void setName(final String name);

View File

@ -6,7 +6,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.LinkedList;
public interface Condition {
public interface Condition extends Comparable<Condition> {
String getName();
void setName(final String name);

View File

@ -12,6 +12,7 @@
package me.blackvein.quests.convo;
import me.blackvein.quests.QuestsAPI;
import me.blackvein.quests.util.Lang;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
@ -22,8 +23,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import me.blackvein.quests.Quests;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -67,7 +66,7 @@ public abstract class QuestsNumericPrompt extends NumericPrompt {
if (context.getPlugin() == null) {
return Lang.get("itemCreateCriticalError");
}
if (!(context.getForWhom() instanceof Player) || !((Quests)context.getPlugin()).getSettings().canClickablePrompts()) {
if (!(context.getForWhom() instanceof Player) || !((QuestsAPI)context.getPlugin()).getSettings().canClickablePrompts()) {
return input;
}
final String[] basicText = input.split("\n");

View File

@ -12,18 +12,16 @@
package me.blackvein.quests.convo;
import me.blackvein.quests.QuestsAPI;
import me.blackvein.quests.util.Lang;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.Quests;
import java.util.List;
public abstract class QuestsStringPrompt extends StringPrompt {
@ -61,7 +59,7 @@ public abstract class QuestsStringPrompt extends StringPrompt {
if (context.getPlugin() == null) {
return Lang.get("itemCreateCriticalError");
}
if (!(context.getForWhom() instanceof Player) || !((Quests)context.getPlugin()).getSettings().canClickablePrompts()) {
if (!(context.getForWhom() instanceof Player) || !((QuestsAPI)context.getPlugin()).getSettings().canClickablePrompts()) {
return ChatColor.GOLD + header + "\n" + ChatColor.AQUA + String.join(ChatColor.GRAY + ", " + ChatColor.AQUA, list) + "\n" + ChatColor.YELLOW + footer;
}
final TextComponent component = new TextComponent(header + "\n");

View File

@ -12,12 +12,11 @@
package me.blackvein.quests.convo.actions;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import me.blackvein.quests.Quests;
import me.blackvein.quests.QuestsAPI;
import me.blackvein.quests.actions.ActionFactory;
import me.blackvein.quests.convo.QuestsNumericPrompt;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
public abstract class ActionsEditorNumericPrompt extends QuestsNumericPrompt {
private final ConversationContext context;
@ -26,7 +25,7 @@ public abstract class ActionsEditorNumericPrompt extends QuestsNumericPrompt {
public ActionsEditorNumericPrompt(final ConversationContext context) {
this.context = context;
if (context != null && context.getPlugin() != null) {
this.factory = ((Quests)context.getPlugin()).getActionFactory();
this.factory = ((QuestsAPI)context.getPlugin()).getActionFactory();
}
}

View File

@ -12,11 +12,10 @@
package me.blackvein.quests.convo.actions;
import org.bukkit.conversations.ConversationContext;
import me.blackvein.quests.Quests;
import me.blackvein.quests.QuestsAPI;
import me.blackvein.quests.actions.ActionFactory;
import me.blackvein.quests.convo.QuestsStringPrompt;
import org.bukkit.conversations.ConversationContext;
public abstract class ActionsEditorStringPrompt extends QuestsStringPrompt {
private final ConversationContext context;
@ -25,7 +24,7 @@ public abstract class ActionsEditorStringPrompt extends QuestsStringPrompt {
public ActionsEditorStringPrompt(final ConversationContext context) {
this.context = context;
if (context != null && context.getPlugin() != null) {
this.factory = ((Quests)context.getPlugin()).getActionFactory();
this.factory = ((QuestsAPI)context.getPlugin()).getActionFactory();
}
}

View File

@ -12,12 +12,11 @@
package me.blackvein.quests.convo.conditions;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import me.blackvein.quests.Quests;
import me.blackvein.quests.QuestsAPI;
import me.blackvein.quests.conditions.ConditionFactory;
import me.blackvein.quests.convo.QuestsNumericPrompt;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
public abstract class ConditionsEditorNumericPrompt extends QuestsNumericPrompt {
private final ConversationContext context;
@ -26,7 +25,7 @@ public abstract class ConditionsEditorNumericPrompt extends QuestsNumericPrompt
public ConditionsEditorNumericPrompt(final ConversationContext context) {
this.context = context;
if (context != null && context.getPlugin() != null) {
this.factory = ((Quests)context.getPlugin()).getConditionFactory();
this.factory = ((QuestsAPI)context.getPlugin()).getConditionFactory();
}
}

View File

@ -12,11 +12,10 @@
package me.blackvein.quests.convo.conditions;
import org.bukkit.conversations.ConversationContext;
import me.blackvein.quests.Quests;
import me.blackvein.quests.QuestsAPI;
import me.blackvein.quests.conditions.ConditionFactory;
import me.blackvein.quests.convo.QuestsStringPrompt;
import org.bukkit.conversations.ConversationContext;
public abstract class ConditionsEditorStringPrompt extends QuestsStringPrompt {
private final ConversationContext context;
@ -25,7 +24,7 @@ public abstract class ConditionsEditorStringPrompt extends QuestsStringPrompt {
public ConditionsEditorStringPrompt(final ConversationContext context) {
this.context = context;
if (context != null && context.getPlugin() != null) {
this.factory = ((Quests)context.getPlugin()).getConditionFactory();
this.factory = ((QuestsAPI)context.getPlugin()).getConditionFactory();
}
}

View File

@ -12,26 +12,25 @@
package me.blackvein.quests.convo.quests;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.QuestsAPI;
import me.blackvein.quests.convo.QuestsNumericPrompt;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import me.blackvein.quests.quests.BukkitQuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.QuestsNumericPrompt;
public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt {
private final ConversationContext context;
private BukkitQuestFactory factory;
private QuestFactory factory;
public QuestsEditorNumericPrompt(final ConversationContext context) {
this.context = context;
if (context != null && context.getPlugin() != null) {
factory = ((Quests)context.getPlugin()).getQuestFactory();
factory = ((QuestsAPI)context.getPlugin()).getQuestFactory();
}
}
@Deprecated
public QuestsEditorNumericPrompt(final ConversationContext context, final BukkitQuestFactory factory) {
public QuestsEditorNumericPrompt(final ConversationContext context, final QuestFactory factory) {
this.context = context;
this.factory = factory;
}
@ -45,7 +44,7 @@ public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt {
return context;
}
public BukkitQuestFactory getQuestFactory() {
public QuestFactory getQuestFactory() {
return factory;
}

View File

@ -12,25 +12,24 @@
package me.blackvein.quests.convo.quests;
import org.bukkit.conversations.ConversationContext;
import me.blackvein.quests.quests.BukkitQuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.QuestsAPI;
import me.blackvein.quests.convo.QuestsStringPrompt;
import org.bukkit.conversations.ConversationContext;
public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt {
private final ConversationContext context;
private BukkitQuestFactory factory;
private QuestFactory factory;
public QuestsEditorStringPrompt(final ConversationContext context) {
this.context = context;
if (context != null && context.getPlugin() != null) {
factory = ((Quests)context.getPlugin()).getQuestFactory();
factory = ((QuestsAPI)context.getPlugin()).getQuestFactory();
}
}
@Deprecated
public QuestsEditorStringPrompt(final ConversationContext context, final BukkitQuestFactory factory) {
public QuestsEditorStringPrompt(final ConversationContext context, final QuestFactory factory) {
this.context = context;
this.factory = factory;
}
@ -44,7 +43,7 @@ public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt {
return context;
}
public BukkitQuestFactory getQuestFactory() {
public QuestFactory getQuestFactory() {
return factory;
}

View File

@ -12,13 +12,12 @@
package me.blackvein.quests.events.editor.actions;
import me.blackvein.quests.QuestsAPI;
import me.blackvein.quests.actions.ActionFactory;
import me.blackvein.quests.events.QuestsEvent;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.Quests;
import me.blackvein.quests.actions.ActionFactory;
import me.blackvein.quests.events.QuestsEvent;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
@ -34,14 +33,14 @@ public abstract class ActionsEditorEvent extends QuestsEvent {
public ActionsEditorEvent(final ConversationContext context, final Prompt prompt) {
this.context = context;
this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getActionFactory();
this.factory = ((QuestsAPI) Objects.requireNonNull(context.getPlugin())).getActionFactory();
this.prompt = prompt;
}
public ActionsEditorEvent(final ConversationContext context, final Prompt prompt, final boolean async) {
super(async);
this.context = context;
this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getActionFactory();
this.factory = ((QuestsAPI) Objects.requireNonNull(context.getPlugin())).getActionFactory();
this.prompt = prompt;
}

View File

@ -12,13 +12,12 @@
package me.blackvein.quests.events.editor.conditions;
import me.blackvein.quests.QuestsAPI;
import me.blackvein.quests.conditions.ConditionFactory;
import me.blackvein.quests.events.QuestsEvent;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.Quests;
import me.blackvein.quests.conditions.ConditionFactory;
import me.blackvein.quests.events.QuestsEvent;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
@ -34,14 +33,14 @@ public abstract class ConditionsEditorEvent extends QuestsEvent {
public ConditionsEditorEvent(final ConversationContext context, final Prompt prompt) {
this.context = context;
this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getConditionFactory();
this.factory = ((QuestsAPI) Objects.requireNonNull(context.getPlugin())).getConditionFactory();
this.prompt = prompt;
}
public ConditionsEditorEvent(final ConversationContext context, final Prompt prompt, final boolean async) {
super(async);
this.context = context;
this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getConditionFactory();
this.factory = ((QuestsAPI) Objects.requireNonNull(context.getPlugin())).getConditionFactory();
this.prompt = prompt;
}

View File

@ -12,13 +12,12 @@
package me.blackvein.quests.events.editor.quests;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.QuestsAPI;
import me.blackvein.quests.events.QuestsEvent;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.events.QuestsEvent;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
@ -34,14 +33,14 @@ public abstract class QuestsEditorEvent extends QuestsEvent {
public QuestsEditorEvent(final ConversationContext context, final Prompt prompt) {
this.context = context;
this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getQuestFactory();
this.factory = ((QuestsAPI) Objects.requireNonNull(context.getPlugin())).getQuestFactory();
this.prompt = prompt;
}
public QuestsEditorEvent(final ConversationContext context, final Prompt prompt, final boolean async) {
super(async);
this.context = context;
this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getQuestFactory();
this.factory = ((QuestsAPI) Objects.requireNonNull(context.getPlugin())).getQuestFactory();
this.prompt = prompt;
}

View File

@ -12,10 +12,9 @@
package me.blackvein.quests.events.editor.quests;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
import org.jetbrains.annotations.NotNull;
public class QuestsEditorPostOpenNumericPromptEvent extends QuestsEditorEvent {

View File

@ -12,10 +12,9 @@
package me.blackvein.quests.events.editor.quests;
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
import org.jetbrains.annotations.NotNull;
public class QuestsEditorPostOpenStringPromptEvent extends QuestsEditorEvent {

View File

@ -12,7 +12,7 @@
package me.blackvein.quests.reflect.denizen;
import me.blackvein.quests.Quests;
import me.blackvein.quests.QuestsAPI;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
@ -27,7 +27,7 @@ import java.util.logging.Level;
public class DenizenAPI_1_0_9 {
private static final Quests quests = (Quests) Bukkit.getPluginManager().getPlugin("Quests");
private static final QuestsAPI quests = (QuestsAPI) Bukkit.getPluginManager().getPlugin("Quests");
private static final DenizenAPI api = quests != null ? quests.getDependencies().getDenizenApi() : null;
public static boolean containsScript(final String input) {

View File

@ -16,7 +16,7 @@ import com.denizenscript.denizen.objects.NPCTag;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizencore.scripts.ScriptRegistry;
import com.denizenscript.denizencore.scripts.containers.core.TaskScriptContainer;
import me.blackvein.quests.Quests;
import me.blackvein.quests.QuestsAPI;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -31,7 +31,7 @@ import java.util.logging.Level;
public class DenizenAPI_1_1_0 {
private static final Quests quests = (Quests) Bukkit.getPluginManager().getPlugin("Quests");
private static final QuestsAPI quests = (QuestsAPI) Bukkit.getPluginManager().getPlugin("Quests");
private static final DenizenAPI api = quests != null ? quests.getDependencies().getDenizenApi() : null;
public static boolean containsScript(final String input) {

View File

@ -12,8 +12,7 @@
package me.blackvein.quests.util;
import me.blackvein.quests.Dependencies;
import me.blackvein.quests.Quests;
import me.blackvein.quests.QuestsAPI;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -126,7 +125,7 @@ public class Lang {
}
}
public static void init(final Quests plugin) throws InvalidConfigurationException, IOException {
public static void init(final QuestsAPI plugin) throws InvalidConfigurationException, IOException {
final File langFile = new File(plugin.getDataFolder(), File.separator + "lang" + File.separator + iso + File.separator
+ "strings.yml");
final File langFile_new = new File(plugin.getDataFolder(), File.separator + "lang" + File.separator + iso
@ -278,7 +277,7 @@ public class Lang {
}
s = convertString(s);
if (Bukkit.getServer().getPluginManager().getPlugin("PlaceholderAPI") != null ) {
if (Dependencies.placeholder.isEnabled()) {
if (Bukkit.getServer().getPluginManager().getPlugin("PlaceholderAPI").isEnabled()) {
s = PlaceholderAPI.setPlaceholders(p, s);
}
}

View File

@ -165,7 +165,7 @@
<dependency>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-api</artifactId>
<version>${version}</version>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -21,9 +21,13 @@ import me.blackvein.quests.actions.BukkitAction;
import me.blackvein.quests.actions.BukkitActionFactory;
import me.blackvein.quests.conditions.BukkitCondition;
import me.blackvein.quests.conditions.BukkitConditionFactory;
import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.conditions.ConditionFactory;
import me.blackvein.quests.config.BukkitSettings;
import me.blackvein.quests.convo.misc.MiscStringPrompt;
import me.blackvein.quests.convo.misc.NpcOfferQuestPrompt;
import me.blackvein.quests.dependencies.BukkitDependencies;
import me.blackvein.quests.dependencies.DenizenTrigger;
import me.blackvein.quests.entity.BukkitQuestMob;
import me.blackvein.quests.entity.QuestMob;
import me.blackvein.quests.events.misc.MiscPostQuestAcceptEvent;
@ -40,7 +44,9 @@ import me.blackvein.quests.listeners.NpcListener;
import me.blackvein.quests.listeners.PartiesListener;
import me.blackvein.quests.listeners.PlayerListener;
import me.blackvein.quests.listeners.UniteListener;
import me.blackvein.quests.module.BukkitCustomObjective;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.quests.BukkitQuestFactory;
import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.statistics.Metrics;
@ -135,8 +141,8 @@ public class Quests extends JavaPlugin implements QuestsAPI {
private final List<CustomReward> customRewards = new LinkedList<>();
private Collection<Quester> questers = new ConcurrentSkipListSet<>();
private final Collection<Quest> quests = new ConcurrentSkipListSet<>();
private Collection<BukkitAction> actions = new ConcurrentSkipListSet<>();
private Collection<BukkitCondition> conditions = new ConcurrentSkipListSet<>();
private Collection<Action> actions = new ConcurrentSkipListSet<>();
private Collection<Condition> conditions = new ConcurrentSkipListSet<>();
private LinkedList<Integer> questNpcIds = new LinkedList<>();
private CommandExecutor cmdExecutor;
private ConversationFactory conversationFactory;
@ -163,7 +169,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
// 1 - Initialize variables
bukkitVersion = Bukkit.getServer().getBukkitVersion().split("-")[0];
settings = new Settings(this);
settings = new BukkitSettings(this);
try {
Class.forName("me.blackvein.quests.libs.localelib.LocaleManager");
localeManager = new LocaleManager();
@ -182,7 +188,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
questFactory = new BukkitQuestFactory(this);
actionFactory = new BukkitActionFactory(this);
conditionFactory = new BukkitConditionFactory(this);
depends = new Dependencies(this);
depends = new BukkitDependencies(this);
trigger = new DenizenTrigger(this);
final Metrics metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.SimplePie("language", Lang::getISO));
@ -280,7 +286,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
return loading;
}
public String getDetectedBukkitVersion() {
public String getDetectedServerSoftwareVersion() {
return bukkitVersion;
}
@ -334,17 +340,6 @@ public class Quests extends JavaPlugin implements QuestsAPI {
return Optional.empty();
}
/**
* Get every Quest loaded in memory
*
* @deprecated Use {@link #getLoadedQuests()}
* @return a list of all Quests
*/
@Deprecated
public LinkedList<Quest> getQuests() {
return new LinkedList<>(quests);
}
/**
* Get every Quest loaded in memory
*
@ -354,23 +349,12 @@ public class Quests extends JavaPlugin implements QuestsAPI {
return quests;
}
/**
* Get every Action loaded in memory
*
* @deprecated Use {@link #getLoadedActions()}
* @return a list of all Actions
*/
@Deprecated
public LinkedList<BukkitAction> getActions() {
return new LinkedList<>(actions);
}
/**
* Get every Action loaded in memory
*
* @return a collection of all Actions
*/
public Collection<BukkitAction> getLoadedActions() {
public Collection<Action> getLoadedActions() {
return actions;
}
@ -380,7 +364,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
* @deprecated Use {@link #setLoadedActions(Collection)}
*/
@Deprecated
public void setActions(final LinkedList<BukkitAction> actions) {
public void setActions(final LinkedList<Action> actions) {
this.actions = actions;
}
@ -388,27 +372,16 @@ public class Quests extends JavaPlugin implements QuestsAPI {
* Set every Action loaded in memory
*
*/
public void setLoadedActions(final Collection<BukkitAction> actions) {
public void setLoadedActions(final Collection<Action> actions) {
this.actions = actions;
}
/**
* Get every Action loaded in memory
*
* @deprecated Use {@link #getLoadedConditions()}
* @return a list of all Conditions
*/
@Deprecated
public LinkedList<BukkitCondition> getConditions() {
return new LinkedList<>(conditions);
}
/**
* Get every Condition loaded in memory
*
* @return a collection of all Conditions
*/
public Collection<BukkitCondition> getLoadedConditions() {
public Collection<Condition> getLoadedConditions() {
return conditions;
}
@ -418,7 +391,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
* @deprecated Use {@link #setLoadedConditions(Collection)}
*/
@Deprecated
public void setConditions(final LinkedList<BukkitCondition> conditions) {
public void setConditions(final LinkedList<Condition> conditions) {
this.conditions = conditions;
}
@ -426,7 +399,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
* Set every Condition loaded in memory
*
*/
public void setLoadedConditions(final Collection<BukkitCondition> conditions) {
public void setLoadedConditions(final Collection<Condition> conditions) {
this.conditions = conditions;
}
@ -457,28 +430,6 @@ public class Quests extends JavaPlugin implements QuestsAPI {
return q;
}
/**
* Get every Quester that has ever played on this server
*
* @deprecated Use {@link #getOfflineQuesters()}
* @return a list of all Questers
*/
@Deprecated
public LinkedList<Quester> getQuesters() {
return new LinkedList<>(questers);
}
/**
* Set every Quester that has ever played on this server
*
* @deprecated Use {@link #setOfflineQuesters(Collection)}
* @param questers a list of Questers
*/
@Deprecated
public void setQuesters(final LinkedList<Quester> questers) {
this.questers = new ConcurrentSkipListSet<>(questers);
}
/**
* Get every online Quester playing on this server
*
@ -879,7 +830,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
if (config.contains("quests." + questKey + ".options")) {
loadQuestOptions(config, quest, questKey);
}
quest.plugin = this;
quest.setPlugin(this);
loadQuestStages(quest, config, questKey);
loadQuestRewards(config, quest, questKey);
quests.add(quest);
@ -976,7 +927,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
final Class<? extends CustomRequirement> requirementClass = c.asSubclass(CustomRequirement.class);
final Constructor<? extends CustomRequirement> constructor = requirementClass.getConstructor();
final CustomRequirement requirement = constructor.newInstance();
final Optional<CustomRequirement>oo = getCustomRequirement(requirement.getClass().getName());
final Optional<CustomRequirement> oo = getCustomRequirement(requirement.getClass().getName());
oo.ifPresent(customRequirements::remove);
customRequirements.add(requirement);
final String name = requirement.getName() == null ? "[" + jar.getName() + "]" : requirement.getName();
@ -987,7 +938,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
final Class<? extends CustomReward> rewardClass = c.asSubclass(CustomReward.class);
final Constructor<? extends CustomReward> constructor = rewardClass.getConstructor();
final CustomReward reward = constructor.newInstance();
final Optional<CustomReward>oo = getCustomReward(reward.getClass().getName());
final Optional<CustomReward> oo = getCustomReward(reward.getClass().getName());
oo.ifPresent(customRewards::remove);
customRewards.add(reward);
final String name = reward.getName() == null ? "[" + jar.getName() + "]" : reward.getName();
@ -995,12 +946,12 @@ public class Quests extends JavaPlugin implements QuestsAPI {
count++;
getLogger().info("Loaded \"" + name + "\" by " + author);
} else if (CustomObjective.class.isAssignableFrom(c)) {
final Class<? extends CustomObjective> objectiveClass = c.asSubclass(CustomObjective.class);
final Constructor<? extends CustomObjective> constructor = objectiveClass.getConstructor();
final CustomObjective objective = constructor.newInstance();
final Optional<CustomObjective>oo = getCustomObjective(objective.getClass().getName());
if (oo.isPresent()) {
HandlerList.unregisterAll(oo.get());
final Class<? extends BukkitCustomObjective> objectiveClass = c.asSubclass(BukkitCustomObjective.class);
final Constructor<? extends BukkitCustomObjective> constructor = objectiveClass.getConstructor();
final BukkitCustomObjective objective = constructor.newInstance();
final Optional<CustomObjective> oo = getCustomObjective(objective.getClass().getName());
if (oo.isPresent() && oo.get() instanceof BukkitCustomObjective) {
HandlerList.unregisterAll((BukkitCustomObjective)oo.get());
customObjectives.remove(oo.get());
}
customObjectives.add(objective);
@ -1636,9 +1587,9 @@ public class Quests extends JavaPlugin implements QuestsAPI {
int fromOrder = (page - 1) * rows;
final List<Quest> subQuests;
if (quests.size() >= (fromOrder + rows)) {
subQuests = getQuests().subList((fromOrder), (fromOrder + rows));
subQuests = new LinkedList<>(getLoadedQuests()).subList((fromOrder), (fromOrder + rows));
} else {
subQuests = getQuests().subList((fromOrder), quests.size());
subQuests = new LinkedList<>(getLoadedQuests()).subList((fromOrder), quests.size());
}
fromOrder++;
for (final Quest q : subQuests) {
@ -1786,7 +1737,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
@SuppressWarnings("deprecation")
private Quest loadQuest(final FileConfiguration config, final String questKey) throws QuestFormatException,
ActionFormatException {
final Quest quest = new Quest();
final Quest quest = new BukkitQuest(this);
quest.setId(questKey);
if (config.contains("quests." + questKey + ".name")) {
quest.setName(ConfigUtil.parseString(config.getString("quests." + questKey + ".name"), quest));
@ -2461,7 +2412,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
is = ItemUtil.processItemStack(s, breakAmounts.get(breakIndex), (short) 0);
}
if (Material.matchMaterial(s) != null) {
oStage.addBlocksToBreak(is);
oStage.addBlockToBreak(is);
} else {
throw new StageFormatException("break-block-names has invalid item name " + s, quest, stageNum);
}
@ -3969,12 +3920,12 @@ public class Quests extends JavaPlugin implements QuestsAPI {
}
}
if (found.isPresent()) {
oStage.customObjectives.add(found.get());
oStage.customObjectiveCounts.add(Math.max(count, 0));
oStage.addCustomObjectives(found.get());
oStage.addCustomObjectiveCounts(Math.max(count, 0));
final ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data");
for (final Entry<String,Object> prompt : found.get().getData()) {
final Entry<String, Object> data = populateCustoms(sec2, prompt);
oStage.customObjectiveData.add(data);
oStage.addCustomObjectiveData(data);
}
} else {
throw new QuestFormatException(name + " custom objective not found for Stage "
@ -4314,21 +4265,21 @@ public class Quests extends JavaPlugin implements QuestsAPI {
* @param name Name of the action
* @return Closest match or null if not found
*/
public BukkitAction getAction(final String name) {
public Action getAction(final String name) {
if (name == null) {
return null;
}
for (final BukkitAction a : actions) {
for (final Action a : actions) {
if (a.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) {
return a;
}
}
for (final BukkitAction a : actions) {
for (final Action a : actions) {
if (a.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
return a;
}
}
for (final BukkitAction a : actions) {
for (final Action a : actions) {
if (a.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
return a;
}
@ -4342,21 +4293,21 @@ public class Quests extends JavaPlugin implements QuestsAPI {
* @param name Name of the condition
* @return Closest match or null if not found
*/
public BukkitCondition getCondition(final String name) {
public Condition getCondition(final String name) {
if (name == null) {
return null;
}
for (final BukkitCondition c : conditions) {
for (final Condition c : conditions) {
if (c.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) {
return c;
}
}
for (final BukkitCondition c : conditions) {
for (final Condition c : conditions) {
if (c.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
return c;
}
}
for (final BukkitCondition c : conditions) {
for (final Condition c : conditions) {
if (c.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
return c;
}

View File

@ -31,7 +31,7 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
public class BukkitAction implements Action, Comparable<BukkitAction> {
public class BukkitAction implements Action {
private final Quests plugin;
private String name = "";
@ -82,9 +82,9 @@ public class BukkitAction implements Action, Comparable<BukkitAction> {
public BukkitAction(final Quests plugin) {
this.plugin = plugin;
}
@Override
public int compareTo(final BukkitAction action) {
public int compareTo(final Action action) {
return name.compareTo(action.getName());
}

View File

@ -340,7 +340,7 @@ public class BukkitActionFactory implements ActionFactory, ConversationAbandoned
if (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<BukkitAction> temp = plugin.getLoadedActions();
final Collection<Action> temp = plugin.getLoadedActions();
temp.remove(plugin.getAction((String) context.getSessionData(CK.E_OLD_EVENT)));
plugin.setLoadedActions(temp);
}

View File

@ -24,7 +24,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.LinkedList;
import java.util.Objects;
public class BukkitCondition implements Condition, Comparable<BukkitCondition> {
public class BukkitCondition implements Condition {
private final Quests plugin;
private String name = "";
@ -44,7 +44,7 @@ public class BukkitCondition implements Condition, Comparable<BukkitCondition> {
}
@Override
public int compareTo(final BukkitCondition condition) {
public int compareTo(final Condition condition) {
return name.compareTo(condition.getName());
}

View File

@ -85,7 +85,7 @@ public class BukkitConditionFactory implements ConditionFactory, ConversationAba
return new ConditionMainPrompt(context);
}
public void loadData(final BukkitCondition condition, final ConversationContext context) {
public void loadData(final Condition condition, final ConversationContext context) {
if (condition.isFailQuest()) {
context.setSessionData(CK.C_FAIL_QUEST, Lang.get("yesWord"));
} else {
@ -201,7 +201,7 @@ public class BukkitConditionFactory implements ConditionFactory, ConversationAba
if (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<BukkitCondition> temp = plugin.getLoadedConditions();
final Collection<Condition> temp = plugin.getLoadedConditions();
temp.remove(plugin.getCondition((String) context.getSessionData(CK.C_OLD_CONDITION)));
plugin.setLoadedConditions(temp);
}

View File

@ -10,8 +10,10 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests;
package me.blackvein.quests.config;
import me.blackvein.quests.Quests;
import me.blackvein.quests.Settings;
import me.blackvein.quests.util.Lang;
import org.bukkit.configuration.file.FileConfiguration;
@ -19,7 +21,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Objects;
public class Settings {
public class BukkitSettings implements Settings {
private final Quests plugin;
private int acceptTimeout = 20;
@ -46,7 +48,7 @@ public class Settings {
private boolean translateSubCommands = false;
private boolean updateCheck = true;
public Settings(final Quests plugin) {
public BukkitSettings(final Quests plugin) {
this.plugin = plugin;
}

View File

@ -15,7 +15,7 @@ package me.blackvein.quests.convo.conditions.main;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quests;
import me.blackvein.quests.Stage;
import me.blackvein.quests.conditions.BukkitCondition;
import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt;
import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt;
@ -204,7 +204,7 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
return null;
}
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
for (final BukkitCondition c : plugin.getLoadedConditions()) {
for (final Condition c : plugin.getLoadedConditions()) {
if (c.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorExists"));
return new ConditionNamePrompt(context);

View File

@ -12,10 +12,10 @@
package me.blackvein.quests.convo.conditions.menu;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quests;
import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.conditions.BukkitCondition;
import me.blackvein.quests.Stage;
import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt;
import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt;
@ -185,7 +185,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
}
input = input.trim();
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
for (final BukkitCondition c : plugin.getLoadedConditions()) {
for (final Condition c : plugin.getLoadedConditions()) {
if (c.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorExists"));
return new ConditionSelectCreatePrompt(context);
@ -235,7 +235,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
final ConditionsEditorPostOpenStringPromptEvent event
= new ConditionsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
final List<String> names = plugin.getLoadedConditions().stream().map(BukkitCondition::getName).collect(Collectors.toList());
final List<String> names = plugin.getLoadedConditions().stream().map(Condition::getName).collect(Collectors.toList());
return sendClickableMenu(getTitle(context), names, getQueryText(context), context);
}
@ -245,7 +245,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
return null;
}
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final BukkitCondition c = plugin.getCondition(input);
final Condition c = plugin.getCondition(input);
if (c != null) {
context.setSessionData(CK.C_OLD_CONDITION, c.getName());
context.setSessionData(CK.C_NAME, c.getName());
@ -281,7 +281,8 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
final ConditionsEditorPostOpenStringPromptEvent event
= new ConditionsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
final List<String> names = plugin.getLoadedConditions().stream().map(BukkitCondition::getName).collect(Collectors.toList());
final List<String> names = plugin.getLoadedConditions().stream().map(Condition::getName)
.collect(Collectors.toList());
return sendClickableMenu(getTitle(context), names, getQueryText(context), context);
}
@ -292,10 +293,10 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
}
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final LinkedList<String> used = new LinkedList<>();
final BukkitCondition c = plugin.getCondition(input);
final Condition c = plugin.getCondition(input);
if (c != null) {
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final BukkitStage stage : quest.getStages()) {
for (final Quest quest : plugin.getLoadedQuests()) {
for (final Stage stage : quest.getStages()) {
if (stage.getCondition() != null
&& stage.getCondition().getName().equalsIgnoreCase(c.getName())) {
used.add(quest.getName());

View File

@ -12,10 +12,11 @@
package me.blackvein.quests.convo.misc;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.events.misc.MiscPostNpcOfferQuestEvent;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.util.Lang;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
@ -64,12 +65,12 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
@SuppressWarnings("unchecked")
public ChatColor getNumberColor(final ConversationContext context, final int number) {
final Quests plugin = (Quests)context.getPlugin();
final LinkedList<BukkitQuest> quests = (LinkedList<BukkitQuest>) context.getSessionData("npcQuests");
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests");
if (plugin != null) {
final BukkitQuester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
if (quests != null && number > 0) {
if (number < (quests.size() + 1)) {
final BukkitQuest quest = quests.get(number - 1);
final Quest quest = quests.get(number - 1);
if (quester.getCompletedQuests().contains(quest)) {
return ChatColor.GREEN;
} else {
@ -87,12 +88,12 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
@SuppressWarnings("unchecked")
public String getSelectionText(final ConversationContext context, final int number) {
final Quests plugin = (Quests)context.getPlugin();
final LinkedList<BukkitQuest> quests = (LinkedList<BukkitQuest>) context.getSessionData("npcQuests");
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests");
if (plugin != null) {
final BukkitQuester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
if (quests != null && number > 0) {
if (number < (quests.size() + 1)) {
final BukkitQuest quest = quests.get(number - 1);
final Quest quest = quests.get(number - 1);
if (quester.getCompletedQuests().contains(quest)) {
return ChatColor.GREEN + "" + ChatColor.ITALIC + quest.getName();
} else {
@ -109,12 +110,12 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
@SuppressWarnings("unchecked")
public String getAdditionalText(final ConversationContext context, final int number) {
final Quests plugin = (Quests)context.getPlugin();
final LinkedList<BukkitQuest> quests = (LinkedList<BukkitQuest>) context.getSessionData("npcQuests");
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests");
if (plugin != null) {
final BukkitQuester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
if (quests != null && number > 0) {
if (number < (quests.size() + 1)) {
final BukkitQuest quest = quests.get(number - 1);
final Quest quest = quests.get(number - 1);
if (quester.getCompletedQuests().contains(quest)) {
return ChatColor.GREEN + "" + Lang.get("redoCompleted");
}
@ -179,11 +180,11 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
final Quests plugin = (Quests)context.getPlugin();
final LinkedList<BukkitQuest> quests = (LinkedList<BukkitQuest>) context.getSessionData("npcQuests");
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests");
if (plugin == null || quests == null) {
return Prompt.END_OF_CONVERSATION;
}
final BukkitQuester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
int numInput = -1;
try {
numInput = Integer.parseInt(input);
@ -194,15 +195,15 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("cancelled"));
return Prompt.END_OF_CONVERSATION;
} else {
BukkitQuest q = null;
for (final BukkitQuest quest : quests) {
Quest q = null;
for (final Quest quest : quests) {
if (quest.getName().equalsIgnoreCase(input)) {
q = quest;
break;
}
}
if (q == null) {
for (final BukkitQuest quest : quests) {
for (final Quest quest : quests) {
if (numInput == (quests.indexOf(quest) + 1)) {
q = quest;
break;
@ -210,7 +211,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
}
}
if (q == null) {
for (final BukkitQuest quest : quests) {
for (final Quest quest : quests) {
if (quest.getName().toLowerCase().contains(input.toLowerCase())) {
q = quest;
break;
@ -238,8 +239,8 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
}
}
private String extracted(final Quests plugin, final BukkitQuester quester) {
final BukkitQuest quest = plugin.getQuestById(quester.getQuestIdToTake());
private String extracted(final Quests plugin, final Quester quester) {
final Quest quest = plugin.getQuestById(quester.getQuestIdToTake());
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE,
quest.getName(), ChatColor.GOLD, ChatColor.RESET, quest.getDescription());
}

View File

@ -13,7 +13,7 @@
package me.blackvein.quests.convo.quests.main;
import com.sk89q.worldguard.protection.managers.RegionManager;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.generic.ItemStackPrompt;
@ -341,7 +341,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
return null;
}
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
for (final BukkitQuest q : plugin.getLoadedQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
if (q.getName().equalsIgnoreCase(input)) {
String s = null;
if (context.getSessionData(CK.ED_QUEST_EDIT) != null) {
@ -732,7 +732,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData("tempStack") != null) {
final ItemStack stack = (ItemStack) context.getSessionData("tempStack");
boolean failed = false;
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (quest.getGUIDisplay() != null) {
if (ItemUtil.compareItems(stack, quest.getGUIDisplay(), false) == 0) {
String error = Lang.get("questGUIError");

View File

@ -12,7 +12,7 @@
package me.blackvein.quests.convo.quests.menu;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
@ -169,7 +169,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
}
input = input.trim();
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
for (final BukkitQuest q : plugin.getLoadedQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
if (q.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNameExists"));
return new QuestSelectCreatePrompt(context);
@ -221,7 +221,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
final List<String> names = plugin.getLoadedQuests().stream().map(BukkitQuest::getName).collect(Collectors.toList());
final List<String> names = plugin.getLoadedQuests().stream().map(Quest::getName).collect(Collectors.toList());
return sendClickableMenu(getTitle(context), names, getQueryText(context), context);
}
@ -231,7 +231,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
return null;
}
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final BukkitQuest q = plugin.getQuest(input);
final Quest q = plugin.getQuest(input);
if (q != null) {
plugin.getQuestFactory().loadQuest(context, q);
return new QuestMainPrompt(context);
@ -264,7 +264,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
final List<String> names = plugin.getLoadedQuests().stream().map(BukkitQuest::getName).collect(Collectors.toList());
final List<String> names = plugin.getLoadedQuests().stream().map(Quest::getName).collect(Collectors.toList());
return sendClickableMenu(getTitle(context), names, getQueryText(context), context);
}
@ -275,9 +275,9 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
}
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final LinkedList<String> used = new LinkedList<>();
final BukkitQuest found = plugin.getQuest(input);
final Quest found = plugin.getQuest(input);
if (found != null) {
for (final BukkitQuest q : plugin.getLoadedQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
if (q.getRequirements().getNeededQuests().contains(q)
|| q.getRequirements().getBlockQuests().contains(q)) {
used.add(q.getName());

View File

@ -15,7 +15,7 @@ package me.blackvein.quests.convo.quests.requirements;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.herocraftonline.heroes.characters.classes.HeroClass;
import me.blackvein.quests.CustomRequirement;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.generic.ItemStackPrompt;
import me.blackvein.quests.convo.generic.OverridePrompt;
@ -173,8 +173,8 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + moneyReq + " "
+ (moneyReq > 1 ? plugin.getDependencies().getCurrency(true)
: plugin.getDependencies().getCurrency(false)) + ChatColor.GRAY + ")";
+ (moneyReq > 1 ? plugin.getDependencies().getVaultEconomy().currencyNamePlural()
: plugin.getDependencies().getVaultEconomy().currencyNameSingular() + ChatColor.GRAY + ")");
}
} else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
@ -854,7 +854,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + getTitle(context) + "\n"
+ ChatColor.DARK_PURPLE);
boolean none = true;
for (final BukkitQuest q : plugin.getLoadedQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
text.append(q.getName()).append(", ");
none = false;
}

View File

@ -14,8 +14,8 @@ package me.blackvein.quests.convo.quests.stages;
import me.blackvein.quests.CustomObjective;
import me.blackvein.quests.Quests;
import me.blackvein.quests.actions.BukkitAction;
import me.blackvein.quests.conditions.BukkitCondition;
import me.blackvein.quests.actions.Action;
import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.generic.OverridePrompt;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
@ -1438,7 +1438,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none")).append("\n");
} else {
for (final BukkitAction a : plugin.getLoadedActions()) {
for (final Action a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
}
}
@ -1450,8 +1450,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1505,7 +1505,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else {
for (final BukkitAction a : plugin.getLoadedActions()) {
for (final Action a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
}
}
@ -1517,8 +1517,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1572,7 +1572,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else {
for (final BukkitAction a : plugin.getLoadedActions()) {
for (final Action a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
}
}
@ -1584,8 +1584,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1639,7 +1639,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none")).append("\n");
} else {
for (final BukkitAction a : plugin.getLoadedActions()) {
for (final Action a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
}
}
@ -1651,8 +1651,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1706,7 +1706,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else {
for (final BukkitAction a : plugin.getLoadedActions()) {
for (final Action a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
}
}
@ -1718,8 +1718,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1773,7 +1773,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else {
for (final BukkitAction a : plugin.getLoadedActions()) {
for (final Action a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
}
}
@ -1785,8 +1785,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1915,7 +1915,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else {
for (final BukkitAction a : plugin.getLoadedActions()) {
for (final Action a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
}
}
@ -1927,8 +1927,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -2058,7 +2058,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedConditions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none")).append("\n");
} else {
for (final BukkitCondition c : plugin.getLoadedConditions()) {
for (final Condition c : plugin.getLoadedConditions()) {
text.append(ChatColor.GREEN).append("- ").append(c.getName()).append("\n");
}
}
@ -2070,8 +2070,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
BukkitCondition found = null;
for (final BukkitCondition c : plugin.getLoadedConditions()) {
Condition found = null;
for (final Condition c : plugin.getLoadedConditions()) {
if (c.getName().equalsIgnoreCase(input)) {
found = c;
break;

View File

@ -10,7 +10,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests;
package me.blackvein.quests.dependencies;
import com.alessiodp.parties.api.Parties;
import com.alessiodp.parties.api.interfaces.PartiesAPI;
@ -21,8 +21,10 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.herocraftonline.heroes.Heroes;
import com.herocraftonline.heroes.characters.Hero;
import me.blackvein.quests.Dependencies;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.listeners.NpcListener;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.reflect.denizen.DenizenAPI;
import me.blackvein.quests.reflect.worldguard.WorldGuardAPI;
import me.blackvein.quests.util.Lang;
@ -44,7 +46,7 @@ import java.util.Objects;
import java.util.Set;
import java.util.UUID;
public class Dependencies {
public class BukkitDependencies implements Dependencies {
private final Quests plugin;
private static Economy economy = null;
@ -61,7 +63,7 @@ public class Dependencies {
private static CitizensBooksAPI citizensBooks = null;
private static PartiesAPI parties = null;
public Dependencies(final Quests plugin) {
public BukkitDependencies(final Quests plugin) {
this.plugin = plugin;
}
@ -71,6 +73,7 @@ public class Dependencies {
plugin.getLogger().warning("Economy provider not found.");
}
}
placeholder.isEnabled();
return economy;
}
@ -230,21 +233,6 @@ public class Dependencies {
}
return false;
}
void init() {
getCitizens();
getWorldGuardApi();
getDenizenApi();
getMcmmoClassic();
getHeroes();
getPhatLoots();
getPlaceholderApi();
getCitizensBooksApi();
getPartiesApi();
getPartyProvider();
getVaultEconomy();
getVaultPermission();
}
private boolean setupEconomy() {
try {
@ -306,7 +294,7 @@ public class Dependencies {
}
}
public boolean runDenizenScript(final String scriptName, final BukkitQuester quester) {
public boolean runDenizenScript(final String scriptName, final Quester quester) {
return plugin.getDenizenTrigger().runDenizenScript(scriptName, quester);
}
@ -344,4 +332,19 @@ public class Dependencies {
final Hero hero = getHero(uuid);
return hero.getSecondClass().getName().equalsIgnoreCase(secondaryClass);
}
public void init() {
getCitizens();
getWorldGuardApi();
getDenizenApi();
getMcmmoClassic();
getHeroes();
getPhatLoots();
getPlaceholderApi();
getCitizensBooksApi();
getPartiesApi();
getPartyProvider();
getVaultEconomy();
getVaultPermission();
}
}

View File

@ -10,7 +10,10 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests;
package me.blackvein.quests.dependencies;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
public class DenizenTrigger {
private final Quests plugin;

View File

@ -12,8 +12,8 @@
package me.blackvein.quests.item;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.util.Lang;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -27,10 +27,10 @@ import java.util.stream.Collectors;
public class QuestJournal {
final BukkitQuester owner;
final Quester owner;
ItemStack journal = new ItemStack(Material.WRITTEN_BOOK);
public QuestJournal(final BukkitQuester owner) {
public QuestJournal(final Quester owner) {
this.owner = owner;
final BookMeta book = (BookMeta) journal.getItemMeta();
if (book != null) {
@ -45,10 +45,10 @@ public class QuestJournal {
int currentLength = 0;
int currentLines = 0;
StringBuilder page = new StringBuilder();
final List<BukkitQuest> sortedList = owner.getCurrentQuests().keySet().stream()
.sorted(Comparator.comparing(BukkitQuest::getName))
final List<Quest> sortedList = owner.getCurrentQuests().keySet().stream()
.sorted(Comparator.comparing(Quest::getName))
.collect(Collectors.toList());
for (final BukkitQuest quest : sortedList) {
for (final Quest quest : sortedList) {
if ((currentLength + quest.getName().length() > 240) || (currentLines
+ ((quest.getName().length() % 19) == 0 ? (quest.getName().length() / 19)
: ((quest.getName().length() / 19) + 1))) > 13) {
@ -90,7 +90,7 @@ public class QuestJournal {
}
}
public BukkitQuester getOwner() {
public Quester getOwner() {
return owner;
}

View File

@ -12,14 +12,14 @@
package me.blackvein.quests.listeners;
import me.blackvein.quests.quests.BukkitObjective;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.Stage;
import me.blackvein.quests.enums.ObjectiveType;
import me.blackvein.quests.events.quester.QuesterPostUpdateObjectiveEvent;
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
import me.blackvein.quests.quests.BukkitObjective;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import org.bukkit.ChatColor;
@ -55,20 +55,20 @@ public class BlockListener implements Listener {
if (plugin.canUseQuests(player.getUniqueId())) {
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState()
.getData().toItemStack().getDurability());
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType breakType = ObjectiveType.BREAK_BLOCK;
final ObjectiveType placeType = ObjectiveType.PLACE_BLOCK;
final ObjectiveType cutType = ObjectiveType.CUT_BLOCK;
final Set<String> dispatchedBreakQuestIDs = new HashSet<>();
final Set<String> dispatchedPlaceQuestIDs = new HashSet<>();
final Set<String> dispatchedCutQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!evt.isCancelled()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
if (quester.getCurrentQuests().containsKey(quest)) {
final BukkitStage currentStage = quester.getCurrentStage(quest);
final Stage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) {
plugin.getLogger().severe("Player " + player.getName() + " (" + player.getUniqueId()
+ ") has invalid stage for quest " + quest.getName() + " (" + quest.getId() + ")");
@ -84,7 +84,7 @@ public class BlockListener implements Listener {
// Multiplayer
dispatchedBreakQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, breakType,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedBreakQuestIDs.contains(cq.getId())) {
q.breakBlock(cq, blockItemStack);
}
@ -120,7 +120,7 @@ public class BlockListener implements Listener {
}
}
dispatchedPlaceQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, placeType,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedPlaceQuestIDs.contains(cq.getId())) {
for (final ItemStack is : q.getQuestData(cq).blocksPlaced) {
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
@ -156,7 +156,7 @@ public class BlockListener implements Listener {
}
}
dispatchedCutQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, cutType,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedCutQuestIDs.contains(cq.getId())) {
if (player.getItemInHand().getType().equals(Material.SHEARS)) {
q.cutBlock(cq, blockItemStack);
@ -177,10 +177,10 @@ public class BlockListener implements Listener {
if (plugin.canUseQuests(player.getUniqueId())) {
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState()
.getData().toItemStack().getDurability());
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.DAMAGE_BLOCK;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -191,7 +191,7 @@ public class BlockListener implements Listener {
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.placeBlock(cq, blockItemStack);
}
@ -208,10 +208,10 @@ public class BlockListener implements Listener {
if (plugin.canUseQuests(player.getUniqueId())) {
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState()
.getData().toItemStack().getDurability());
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.PLACE_BLOCK;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!evt.isCancelled()) {
if (!quester.meetsCondition(quest, true)) {
continue;
@ -223,7 +223,7 @@ public class BlockListener implements Listener {
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.placeBlock(cq, blockItemStack);
}
@ -246,7 +246,7 @@ public class BlockListener implements Listener {
if (e == null || e.equals(EquipmentSlot.HAND)) { //If the event is fired by HAND (main hand)
final Player player = evt.getPlayer();
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
if (quester.isSelectingBlock()) {
return;
}
@ -256,7 +256,7 @@ public class BlockListener implements Listener {
.getClickedBlock().getState().getData().toItemStack().getDurability());
final ObjectiveType type = ObjectiveType.USE_BLOCK;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -267,7 +267,7 @@ public class BlockListener implements Listener {
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.useBlock(cq, blockItemStack);
}

View File

@ -12,17 +12,18 @@
package me.blackvein.quests.listeners;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.quests.BukkitRequirements;
import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.Requirements;
import me.blackvein.quests.Stage;
import me.blackvein.quests.events.command.QuestsCommandPreQuestsEditorEvent;
import me.blackvein.quests.events.command.QuestsCommandPreQuestsJournalEvent;
import me.blackvein.quests.events.command.QuestsCommandPreQuestsListEvent;
import me.blackvein.quests.events.quest.QuestQuitEvent;
import me.blackvein.quests.interfaces.ReloadCallback;
import me.blackvein.quests.item.QuestJournal;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.storage.Storage;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
@ -196,10 +197,10 @@ public class CmdExecutor implements CommandExecutor {
if (cs.hasPermission("quests.quest")) {
if (args.length == 0) {
final Player player = (Player) cs;
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
if (!quester.getCurrentQuests().isEmpty()) {
for (final BukkitQuest q : quester.getCurrentQuests().keySet()) {
final BukkitStage stage = quester.getCurrentStage(q);
for (final Quest q : quester.getCurrentQuests().keySet()) {
final Stage stage = quester.getCurrentStage(q);
q.updateCompass(quester, stage);
if (plugin.getQuester(player.getUniqueId()).getQuestData(q).getDelayStartTime() == 0) {
final String msg = Lang.get(player, "questObjectivesTitle")
@ -344,10 +345,10 @@ public class CmdExecutor implements CommandExecutor {
index++;
}
}
final BukkitQuest q = plugin.getQuest(name.toString());
final Quest q = plugin.getQuest(name.toString());
if (q != null) {
final Player player = (Player) cs;
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
cs.sendMessage(ChatColor.GOLD + "- " + q.getName() + " -");
cs.sendMessage(" ");
if (q.getNpcStart() != null) {
@ -360,7 +361,7 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(" ");
if (plugin.getSettings().canShowQuestReqs()) {
cs.sendMessage(ChatColor.GOLD + Lang.get("requirements"));
final BukkitRequirements reqs = q.getRequirements();
final Requirements reqs = q.getRequirements();
if (!reqs.getPermissions().isEmpty()) {
for (final String perm : reqs.getPermissions()) {
if (plugin.getDependencies().getVaultPermission().has(player, perm)) {
@ -415,21 +416,15 @@ public class CmdExecutor implements CommandExecutor {
if (reqs.getMoney() != 0) {
if (plugin.getDependencies().getVaultEconomy() != null && plugin.getDependencies()
.getVaultEconomy().getBalance(quester.getOfflinePlayer()) >= reqs.getMoney()) {
if (reqs.getMoney() == 1) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " "
+ plugin.getDependencies().getCurrency(false));
} else {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " "
+ plugin.getDependencies().getCurrency(true));
}
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " "
+ (reqs.getMoney() > 1 ? plugin.getDependencies().getVaultEconomy()
.currencyNamePlural() : plugin.getDependencies().getVaultEconomy()
.currencyNameSingular()));
} else {
if (reqs.getMoney() == 1) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " "
+ plugin.getDependencies().getCurrency(false));
} else {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " "
+ plugin.getDependencies().getCurrency(true));
}
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " "
+ (reqs.getMoney() > 1 ? plugin.getDependencies().getVaultEconomy()
.currencyNamePlural() : plugin.getDependencies().getVaultEconomy()
.currencyNameSingular()));
}
}
if (!reqs.getItems().isEmpty()) {
@ -442,7 +437,7 @@ public class CmdExecutor implements CommandExecutor {
}
}
if (!reqs.getNeededQuests().isEmpty()) {
for (final BukkitQuest quest : reqs.getNeededQuests()) {
for (final Quest quest : reqs.getNeededQuests()) {
if (quester.getCompletedQuests().contains(quest)) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + Lang.get("complete") + " "
+ ChatColor.ITALIC + quest.getName());
@ -453,7 +448,7 @@ public class CmdExecutor implements CommandExecutor {
}
}
if (!reqs.getBlockQuests().isEmpty()) {
for (final BukkitQuest quest : reqs.getBlockQuests()) {
for (final Quest quest : reqs.getBlockQuests()) {
if (quester.getCompletedQuests().contains(quest)) {
String msg = Lang.get("haveCompleted");
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE
@ -526,7 +521,7 @@ public class CmdExecutor implements CommandExecutor {
if (!c.isConversing()) {
final Conversation cn = plugin.getQuestFactory().getConversationFactory().buildConversation(c);
if (cs instanceof Player) {
final BukkitQuester quester = plugin.getQuester(((Player)cs).getUniqueId());
final Quester quester = plugin.getQuester(((Player)cs).getUniqueId());
final QuestsCommandPreQuestsEditorEvent event
= new QuestsCommandPreQuestsEditorEvent(quester, cn.getContext());
plugin.getServer().getPluginManager().callEvent(event);
@ -619,7 +614,7 @@ public class CmdExecutor implements CommandExecutor {
} else {
target = Bukkit.getOfflinePlayer(((Player)cs).getUniqueId());
}
final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
final Quester quester = plugin.getQuester(target.getUniqueId());
cs.sendMessage(ChatColor.GOLD + "- " + target.getName() + " -");
cs.sendMessage(ChatColor.YELLOW + Lang.get("questPoints") + " - " + ChatColor.DARK_PURPLE
+ quester.getQuestPoints());
@ -627,8 +622,8 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.YELLOW + Lang.get("currentQuest") + " " + ChatColor.DARK_PURPLE+ Lang.get("none"));
} else {
cs.sendMessage(ChatColor.YELLOW + Lang.get("currentQuest"));
for (final Entry<BukkitQuest, Integer> set : quester.getCurrentQuests().entrySet()) {
final BukkitQuest q = set.getKey();
for (final Entry<Quest, Integer> set : quester.getCurrentQuests().entrySet()) {
final Quest q = set.getKey();
final String msg = ChatColor.LIGHT_PURPLE + " - " + ChatColor.DARK_PURPLE + q.getName()
+ ChatColor.LIGHT_PURPLE + " (" + Lang.get("stageEditorStage") + " " + (set.getValue() + 1) + ")";
cs.sendMessage(msg);
@ -641,7 +636,7 @@ public class CmdExecutor implements CommandExecutor {
} else {
final StringBuilder completed = new StringBuilder(" ");
int index = 1;
for (final BukkitQuest q : quester.getCompletedQuests()) {
for (final Quest q : quester.getCompletedQuests()) {
completed.append(ChatColor.DARK_PURPLE).append(q.getName());
if (quester.getAmountsCompleted().containsKey(q) && quester.getAmountsCompleted().get(q) > 1) {
completed.append(ChatColor.LIGHT_PURPLE).append(" (x").append(quester.getAmountsCompleted()
@ -660,7 +655,7 @@ public class CmdExecutor implements CommandExecutor {
@SuppressWarnings("deprecation")
private void questsJournal(final Player player) {
if (player.hasPermission("quests.journal")) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final QuestsCommandPreQuestsJournalEvent preEvent = new QuestsCommandPreQuestsJournalEvent(quester);
plugin.getServer().getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled()) {
@ -702,9 +697,9 @@ public class CmdExecutor implements CommandExecutor {
Lang.send(player, ChatColor.RED + Lang.get(player, "COMMAND_QUIT_HELP"));
return;
}
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
if (!quester.getCurrentQuests().isEmpty()) {
final BukkitQuest quest = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' '));
final Quest quest = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' '));
if (quest != null) {
if (quest.getOptions().canAllowQuitting()) {
final QuestQuitEvent event = new QuestQuitEvent(quest, quester);
@ -735,10 +730,10 @@ public class CmdExecutor implements CommandExecutor {
if (args.length == 1) {
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "COMMAND_TAKE_USAGE"));
} else {
final BukkitQuest questToFind = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' '));
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quest questToFind = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' '));
final Quester quester = plugin.getQuester(player.getUniqueId());
if (questToFind != null) {
for (final BukkitQuest q : quester.getCurrentQuests().keySet()) {
for (final Quest q : quester.getCurrentQuests().keySet()) {
if (q.getId().equals(questToFind.getId())) {
Lang.send(player, ChatColor.RED + Lang.get(player, "questAlreadyOn"));
return;
@ -762,7 +757,7 @@ public class CmdExecutor implements CommandExecutor {
if (!(cs instanceof Player)) {
int num = 1;
cs.sendMessage(ChatColor.GOLD + Lang.get("questListTitle"));
for (final BukkitQuest q : plugin.getLoadedQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
cs.sendMessage(ChatColor.YELLOW + "" + num + ". " + q.getName());
num++;
}
@ -770,7 +765,7 @@ public class CmdExecutor implements CommandExecutor {
}
final Player player = (Player)cs;
if (args.length == 1) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final QuestsCommandPreQuestsListEvent preEvent = new QuestsCommandPreQuestsListEvent(quester, 1);
plugin.getServer().getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled()) {
@ -785,7 +780,7 @@ public class CmdExecutor implements CommandExecutor {
if (page < 1) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("pageSelectionPosNum"));
} else {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final QuestsCommandPreQuestsListEvent preEvent = new QuestsCommandPreQuestsListEvent(quester, page);
plugin.getServer().getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled()) {
@ -941,7 +936,7 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
return;
}
final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
final Quester quester = plugin.getQuester(target.getUniqueId());
quester.setQuestPoints(quester.getQuestPoints() + Math.abs(points));
String msg1 = Lang.get("giveQuestPoints").replace("<points>", Lang.get("questPoints"));
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
@ -978,7 +973,7 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
return;
}
final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
final Quester quester = plugin.getQuester(target.getUniqueId());
quester.setQuestPoints(quester.getQuestPoints() - Math.abs(points));
String msg1 = Lang.get("takeQuestPoints").replace("<points>", Lang.get("questPoints"));
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
@ -1015,7 +1010,7 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
return;
}
final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
final Quester quester = plugin.getQuester(target.getUniqueId());
quester.setQuestPoints(points);
String msg1 = Lang.get("setQuestPoints").replace("<points>", Lang.get("questPoints"));
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
@ -1045,7 +1040,7 @@ public class CmdExecutor implements CommandExecutor {
return;
}
}
final BukkitQuest questToGive;
final Quest questToGive;
StringBuilder name = new StringBuilder();
if (args.length == 3) {
name = new StringBuilder(args[2].toLowerCase());
@ -1063,8 +1058,8 @@ public class CmdExecutor implements CommandExecutor {
if (questToGive == null) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("questNotFound"));
} else {
final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
for (final BukkitQuest q : quester.getCurrentQuests().keySet()) {
final Quester quester = plugin.getQuester(target.getUniqueId());
for (final Quest q : quester.getCurrentQuests().keySet()) {
if (q.getName().equalsIgnoreCase(questToGive.getName())) {
String msg = Lang.get("questsPlayerHasQuestAlready");
msg = msg.replace("<player>", ChatColor.ITALIC + "" + ChatColor.GREEN + target.getName()
@ -1109,7 +1104,7 @@ public class CmdExecutor implements CommandExecutor {
}
cs.sendMessage(ChatColor.YELLOW + Lang.get("settingAllQuestPoints")
.replace("<points>", Lang.get("questPoints")));
for (final BukkitQuester q : plugin.getOfflineQuesters()) {
for (final Quester q : plugin.getOfflineQuesters()) {
q.setQuestPoints(amount);
}
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
@ -1164,13 +1159,13 @@ public class CmdExecutor implements CommandExecutor {
return;
}
}
final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
final Quester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty() && target.getName() != null) {
String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg);
} else {
final BukkitQuest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
final Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return;
@ -1216,13 +1211,13 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.YELLOW + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_USAGE"));
return;
}
final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
final Quester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty() && target.getName() != null) {
String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg);
} else {
final BukkitQuest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 2, ' '));
final Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 2, ' '));
if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return;
@ -1252,13 +1247,13 @@ public class CmdExecutor implements CommandExecutor {
return;
}
}
final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
final Quester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty() && target.getName() != null) {
String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg);
} else {
final BukkitQuest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
final Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return;
@ -1293,13 +1288,13 @@ public class CmdExecutor implements CommandExecutor {
return;
}
}
final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
final Quester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty() && target.getName() != null) {
String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg);
} else {
final BukkitQuest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
final Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return;
@ -1330,10 +1325,10 @@ public class CmdExecutor implements CommandExecutor {
}
}
final UUID id = target.getUniqueId();
final ConcurrentSkipListSet<BukkitQuester> temp = (ConcurrentSkipListSet<BukkitQuester>) plugin.getOfflineQuesters();
final ConcurrentSkipListSet<Quester> temp = (ConcurrentSkipListSet<Quester>) plugin.getOfflineQuesters();
temp.removeIf(quester -> quester.getUUID().equals(id));
plugin.setOfflineQuesters(temp);
BukkitQuester quester = plugin.getQuester(id);
Quester quester = plugin.getQuester(id);
try {
quester.hardClear();
quester.saveData();
@ -1353,7 +1348,7 @@ public class CmdExecutor implements CommandExecutor {
}
quester = new BukkitQuester(plugin, id);
quester.saveData();
final ConcurrentSkipListSet<BukkitQuester> temp2 = (ConcurrentSkipListSet<BukkitQuester>) plugin.getOfflineQuesters();
final ConcurrentSkipListSet<Quester> temp2 = (ConcurrentSkipListSet<Quester>) plugin.getOfflineQuesters();
temp2.add(quester);
plugin.setOfflineQuesters(temp2);
} else {
@ -1380,12 +1375,12 @@ public class CmdExecutor implements CommandExecutor {
return;
}
}
final BukkitQuest toRemove = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
final Quest toRemove = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
if (toRemove == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return;
}
final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
final Quester quester = plugin.getQuester(target.getUniqueId());
String msg = Lang.get("questRemoved");
if (target.getName() != null) {
msg = msg.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);

View File

@ -12,8 +12,8 @@
package me.blackvein.quests.listeners;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.enums.ObjectiveType;
import org.bukkit.Material;
@ -49,10 +49,10 @@ public class ItemListener implements Listener {
final Player player = (Player) evt.getWhoClicked();
if (plugin.canUseQuests(player.getUniqueId())) {
final ItemStack craftedItem = getCraftedItem(evt);
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.CRAFT_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -62,7 +62,7 @@ public class ItemListener implements Listener {
quester.craftItem(quest, craftedItem);
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final BukkitQuester q, final BukkitQuest cq) -> {
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.craftItem(cq, craftedItem);
}
@ -100,10 +100,10 @@ public class ItemListener implements Listener {
|| evt.getInventory().getType().name().equals("BLAST_FURNACE")
|| evt.getInventory().getType().name().equals("SMOKER")) {
if (evt.getSlotType() == SlotType.RESULT) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.SMELT_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -113,7 +113,7 @@ public class ItemListener implements Listener {
quester.smeltItem(quest, evt.getCurrentItem());
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final BukkitQuester q, final BukkitQuest cq) -> {
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.smeltItem(cq, evt.getCurrentItem());
}
@ -123,10 +123,10 @@ public class ItemListener implements Listener {
}
} else if (evt.getInventory().getType() == InventoryType.BREWING) {
if (evt.getSlotType() == SlotType.CRAFTING) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.BREW_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -136,7 +136,7 @@ public class ItemListener implements Listener {
quester.brewItem(quest, evt.getCurrentItem());
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final BukkitQuester q, final BukkitQuest cq) -> {
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.brewItem(cq, evt.getCurrentItem());
}
@ -154,10 +154,10 @@ public class ItemListener implements Listener {
final ItemStack enchantedItem = evt.getItem().clone();
enchantedItem.setAmount(1);
enchantedItem.addUnsafeEnchantments(evt.getEnchantsToAdd());
final BukkitQuester quester = plugin.getQuester(evt.getEnchanter().getUniqueId());
final Quester quester = plugin.getQuester(evt.getEnchanter().getUniqueId());
final ObjectiveType type = ObjectiveType.ENCHANT_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -171,7 +171,7 @@ public class ItemListener implements Listener {
}
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final BukkitQuester q, final BukkitQuest cq) -> {
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
if (enchantedItem.getType().equals(Material.BOOK)) {
q.enchantBook(cq, enchantedItem, evt.getEnchantsToAdd());
@ -191,10 +191,10 @@ public class ItemListener implements Listener {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final ItemStack consumedItem = evt.getItem().clone();
consumedItem.setAmount(1);
final BukkitQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
final ObjectiveType type = ObjectiveType.CONSUME_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -204,7 +204,7 @@ public class ItemListener implements Listener {
quester.consumeItem(quest, consumedItem);
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final BukkitQuester q, final BukkitQuest cq) -> {
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.consumeItem(cq, consumedItem);
}

View File

@ -12,8 +12,8 @@
package me.blackvein.quests.listeners;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.enums.ObjectiveType;
import me.blackvein.quests.util.ItemUtil;
@ -64,8 +64,8 @@ public class NpcListener implements Listener {
}
if (!evt.getClicker().isConversing()) {
final Player player = evt.getClicker();
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
final Quester quester = plugin.getQuester(player.getUniqueId());
for (final Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.DELIVER_ITEM)) {
final ItemStack hand = player.getItemInHand();
int currentIndex = -1;
@ -183,7 +183,7 @@ public class NpcListener implements Listener {
}
if (plugin.getQuestNpcIds().contains(evt.getNPC().getId())) {
boolean hasObjective = false;
for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
for (final Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.TALK_TO_NPC)) {
final int npcIndex
= quester.getCurrentStage(quest).getCitizensToInteract().indexOf(evt.getNPC().getId());
@ -196,8 +196,8 @@ public class NpcListener implements Listener {
}
if (!hasObjective) {
boolean hasAtLeastOneGUI = false;
final LinkedList<BukkitQuest> npcQuests = new LinkedList<>();
for (final BukkitQuest q : plugin.getLoadedQuests()) {
final LinkedList<Quest> npcQuests = new LinkedList<>();
for (final Quest q : plugin.getLoadedQuests()) {
if (quester.getCurrentQuests().containsKey(q))
continue;
if (q.getNpcStart() != null && q.getNpcStart().getId() == evt.getNPC().getId()) {
@ -219,7 +219,7 @@ public class NpcListener implements Listener {
}
}
if (npcQuests.size() == 1) {
final BukkitQuest q = npcQuests.get(0);
final Quest q = npcQuests.get(0);
if (quester.canAcceptOffer(q, true)) {
quester.setQuestIdToTake(q.getId());
if (!plugin.getSettings().canAskConfirmation()) {
@ -289,8 +289,8 @@ public class NpcListener implements Listener {
player = (Player) damager;
}
if (player != null) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
final Quester quester = plugin.getQuester(player.getUniqueId());
for (final Quest quest : quester.getCurrentQuests().keySet()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -301,7 +301,7 @@ public class NpcListener implements Listener {
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.killNPC(cq, evt.getNPC());
}
@ -312,8 +312,8 @@ public class NpcListener implements Listener {
}
}
private String extracted(final BukkitQuester quester) {
final BukkitQuest quest = plugin.getQuestById(quester.getQuestIdToTake());
private String extracted(final Quester quester) {
final Quest quest = plugin.getQuestById(quester.getQuestIdToTake());
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE,
quest.getName(), ChatColor.GOLD, ChatColor.RESET, quest.getDescription());
}

View File

@ -12,11 +12,12 @@
package me.blackvein.quests.listeners;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.Stage;
import me.blackvein.quests.enums.ObjectiveType;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
@ -119,12 +120,12 @@ public class PlayerListener implements Listener {
return;
}
}
final BukkitQuester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
final Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
final Player player = (Player) evt.getWhoClicked();
if (evt.getView().getTitle().contains(Lang.get(player, "quests"))) {
final ItemStack clicked = evt.getCurrentItem();
if (ItemUtil.isItem(clicked)) {
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (quest.getGUIDisplay() != null) {
if (ItemUtil.compareItems(clicked, quest.getGUIDisplay(), false) == 0) {
if (quester.canAcceptOffer(quest, true)) {
@ -213,14 +214,14 @@ public class PlayerListener implements Listener {
}
}
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final BukkitQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
final Player player = evt.getPlayer();
if (evt.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
boolean hasObjective = false;
if (!evt.isCancelled()) {
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (quester.getCurrentQuests().containsKey(quest)
&& quester.getCurrentStage(quest).containsObjective("useBlock")) {
&& quester.getCurrentStage(quest).containsObjective(ObjectiveType.USE_BLOCK)) {
hasObjective = true;
}
}
@ -363,7 +364,7 @@ public class PlayerListener implements Listener {
}
evt.setCancelled(true);
} else if (!player.isConversing()) {
for (final BukkitQuest q : plugin.getLoadedQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
if (q.getBlockStart() != null && evt.getClickedBlock() != null) {
if (q.getBlockStart().equals(evt.getClickedBlock().getLocation())) {
if (quester.getCurrentQuests().size() >= plugin.getSettings().getMaxQuests()
@ -375,12 +376,12 @@ public class PlayerListener implements Listener {
} else {
if (quester.getCompletedQuests().contains(q)) {
if (q.getPlanner().getCooldown() > -1
&& (quester.getCooldownDifference(q)) > 0) {
&& (quester.getRemainingCooldown(q)) > 0) {
String early = Lang.get(player, "questTooEarly");
early = early.replace("<quest>", ChatColor.AQUA + q.getName()
+ ChatColor.YELLOW);
early = early.replace("<time>", ChatColor.DARK_PURPLE
+ MiscUtil.getTime(quester.getCooldownDifference(q))
+ MiscUtil.getTime(quester.getRemainingCooldown(q))
+ ChatColor.YELLOW);
Lang.send(player, ChatColor.YELLOW + early);
continue;
@ -397,7 +398,7 @@ public class PlayerListener implements Listener {
if (!plugin.getSettings().canAskConfirmation()) {
quester.takeQuest(q, false);
} else {
final BukkitQuest quest = plugin.getQuestById(quester.getQuestIdToTake());
final Quest quest = plugin.getQuestById(quester.getQuestIdToTake());
final String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE
+ quest.getName() + ChatColor.GOLD + " -\n" + "\n"
+ ChatColor.RESET + quest.getDescription() + "\n";
@ -449,10 +450,10 @@ public class PlayerListener implements Listener {
if (evt.getItemStack() != null && evt.getItemStack().getType() == Material.MILK_BUCKET) {
final Player player = evt.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.MILK_COW;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -463,7 +464,7 @@ public class PlayerListener implements Listener {
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.milkCow(cq);
}
@ -477,14 +478,14 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerChat(final AsyncPlayerChatEvent evt) {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final BukkitQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
if (quester.getCurrentQuests().containsKey(quest)) {
final BukkitStage currentStage = quester.getCurrentStage(quest);
final Stage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) {
continue;
}
@ -515,7 +516,7 @@ public class PlayerListener implements Listener {
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.sayPassword(cq, evt);
}
@ -529,9 +530,9 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent evt) {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final BukkitQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
if (!quester.getCurrentQuests().isEmpty()) {
for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
for (final Quest quest : quester.getCurrentQuests().keySet()) {
if (!quest.getOptions().canAllowCommands()) {
if (!evt.getMessage().startsWith("/quest")) {
final Player player = evt.getPlayer();
@ -544,7 +545,7 @@ public class PlayerListener implements Listener {
return;
}
}
final BukkitStage currentStage = quester.getCurrentStage(quest);
final Stage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) {
plugin.getLogger().severe("currentStage was null for " + quester.getUUID().toString()
+ " on command for quest " + quest.getName());
@ -569,10 +570,10 @@ public class PlayerListener implements Listener {
final Player player = evt.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) {
final Sheep sheep = (Sheep) evt.getEntity();
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.SHEAR_SHEEP;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -583,7 +584,7 @@ public class PlayerListener implements Listener {
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.shearSheep(cq, sheep.getColor());
}
@ -599,10 +600,10 @@ public class PlayerListener implements Listener {
if (evt.getOwner() instanceof Player) {
final Player player = (Player) evt.getOwner();
if (plugin.canUseQuests(player.getUniqueId())) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.TAME_MOB;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -613,7 +614,7 @@ public class PlayerListener implements Listener {
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.tameMob(cq, evt.getEntityType());
}
@ -644,7 +645,7 @@ public class PlayerListener implements Listener {
} else if (damager instanceof Wolf) {
final Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && wolf.getOwner() != null) {
final BukkitQuester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
final Quester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
if (quester != null) {
preKillPlayer(quester.getPlayer(), evt.getEntity());
}
@ -670,10 +671,10 @@ public class PlayerListener implements Listener {
if (plugin.getDependencies().getCitizens() != null && CitizensAPI.getNPCRegistry().isNPC(target)) {
return;
}
final BukkitQuester quester = plugin.getQuester(damager.getUniqueId());
final Quester quester = plugin.getQuester(damager.getUniqueId());
final ObjectiveType type = ObjectiveType.KILL_MOB;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -686,7 +687,7 @@ public class PlayerListener implements Listener {
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.killMob(cq, target.getLocation(), target.getType());
}
@ -721,7 +722,7 @@ public class PlayerListener implements Listener {
} else if (damager instanceof Wolf) {
final Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && wolf.getOwner() != null) {
final BukkitQuester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
final Quester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
preKillPlayer(quester.getPlayer(), evt.getEntity());
}
} else {
@ -731,9 +732,9 @@ public class PlayerListener implements Listener {
final Player target = evt.getEntity();
if (plugin.canUseQuests(target.getUniqueId())) {
final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
final BukkitStage stage = quester.getCurrentStage(quest);
final Quester quester = plugin.getQuester(target.getUniqueId());
for (final Quest quest : quester.getCurrentQuests().keySet()) {
final Stage stage = quester.getCurrentStage(quest);
if (stage != null && stage.getDeathAction() != null) {
quester.getCurrentStage(quest).getDeathAction().fire(quester, quest);
}
@ -774,10 +775,10 @@ public class PlayerListener implements Listener {
return;
}
}
final BukkitQuester quester = plugin.getQuester(damager.getUniqueId());
final Quester quester = plugin.getQuester(damager.getUniqueId());
final ObjectiveType type = ObjectiveType.KILL_PLAYER;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -790,7 +791,7 @@ public class PlayerListener implements Listener {
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.killPlayer(cq, (Player)target);
}
@ -804,10 +805,10 @@ public class PlayerListener implements Listener {
public void onPlayerFish(final PlayerFishEvent evt) {
final Player player = evt.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.CATCH_FISH;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -819,7 +820,7 @@ public class PlayerListener implements Listener {
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.catchFish(cq);
}
@ -834,9 +835,9 @@ public class PlayerListener implements Listener {
public void onPlayerChangeWorld(final PlayerChangedWorldEvent event) {
final Player player = event.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
quester.findCompassTarget();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
quester.meetsCondition(quest, true);
}
}
@ -846,7 +847,7 @@ public class PlayerListener implements Listener {
public void onPlayerRespawn(final PlayerRespawnEvent event) {
final Player player = event.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
Bukkit.getScheduler().runTaskLater(plugin, quester::findCompassTarget, 10);
}
}
@ -865,29 +866,29 @@ public class PlayerListener implements Listener {
});
}
if (plugin.canUseQuests(player.getUniqueId())) {
final BukkitQuester noobCheck = new BukkitQuester(plugin, player.getUniqueId());
final Quester noobCheck = new BukkitQuester(plugin, player.getUniqueId());
if (plugin.getSettings().canGenFilesOnJoin() && !noobCheck.hasData()) {
noobCheck.saveData();
}
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
final CompletableFuture<BukkitQuester> cf = plugin.getStorage().loadQuester(player.getUniqueId());
final CompletableFuture<Quester> cf = plugin.getStorage().loadQuester(player.getUniqueId());
try {
final BukkitQuester quester = cf.get();
final Quester quester = cf.get();
if (quester == null) {
return;
}
for (final BukkitQuest q : quester.getCompletedQuests()) {
for (final Quest q : quester.getCompletedQuests()) {
if (q != null) {
if (!quester.getCompletedTimes().containsKey(q) && q.getPlanner().getCooldown() > -1) {
quester.getCompletedTimes().put(q, System.currentTimeMillis());
}
}
}
for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
for (final Quest quest : quester.getCurrentQuests().keySet()) {
quester.checkQuest(quest);
}
for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
for (final Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.getCurrentStage(quest).getDelay() > -1) {
quester.startStageTimer(quest);
}
@ -910,9 +911,9 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerQuit(final PlayerQuitEvent evt) {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final BukkitQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
final BukkitStage currentStage = quester.getCurrentStage(quest);
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (final Quest quest : quester.getCurrentQuests().keySet()) {
final Stage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) {
plugin.getLogger().severe("currentStage was null for " + quester.getUUID().toString()
+ " on quit for quest " + quest.getName());
@ -945,7 +946,7 @@ public class PlayerListener implements Listener {
temp.remove(evt.getPlayer().getUniqueId());
plugin.getQuestFactory().setSelectingNpcs(temp);
}
final ConcurrentSkipListSet<BukkitQuester> temp = (ConcurrentSkipListSet<BukkitQuester>) plugin.getOfflineQuesters();
final ConcurrentSkipListSet<Quester> temp = (ConcurrentSkipListSet<Quester>) plugin.getOfflineQuesters();
temp.removeIf(q -> q.getUUID().equals(quester.getUUID()));
plugin.setOfflineQuesters(temp);
}
@ -978,12 +979,12 @@ public class PlayerListener implements Listener {
*/
public void playerMove(final UUID uuid, final Location location) {
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
final BukkitQuester quester = plugin.getQuester(uuid);
final Quester quester = plugin.getQuester(uuid);
if (quester != null) {
if (plugin.canUseQuests(uuid)) {
final ObjectiveType type = ObjectiveType.REACH_LOCATION;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -997,7 +998,7 @@ public class PlayerListener implements Listener {
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final BukkitQuester q, final BukkitQuest cq) -> {
(final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
plugin.getServer().getScheduler().runTask(plugin, () -> q
.reachLocation(cq, location));

View File

@ -14,14 +14,14 @@ package me.blackvein.quests.module;
import me.blackvein.quests.CustomObjective;
import me.blackvein.quests.Quest;
import me.blackvein.quests.quests.BukkitObjective;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.Stage;
import me.blackvein.quests.enums.ObjectiveType;
import me.blackvein.quests.events.quester.QuesterPostUpdateObjectiveEvent;
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
import me.blackvein.quests.quests.BukkitObjective;
import me.blackvein.quests.quests.BukkitQuest;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
@ -165,9 +165,9 @@ public abstract class BukkitCustomObjective implements CustomObjective, Listener
@Override
public Map<String, Object> getDataForPlayer(final Player player, final CustomObjective customObj,
final Quest quest) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
if (quester != null) {
final BukkitStage currentStage = quester.getCurrentStage((BukkitQuest) quest);
final Stage currentStage = quester.getCurrentStage((BukkitQuest) quest);
if (currentStage == null) {
return null;
}
@ -197,8 +197,8 @@ public abstract class BukkitCustomObjective implements CustomObjective, Listener
@Override
public void incrementObjective(final Player player, final CustomObjective obj, final int count, final Quest quest) {
final BukkitQuest bQuest = (BukkitQuest) quest;
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quest bQuest = (BukkitQuest) quest;
final Quester quester = plugin.getQuester(player.getUniqueId());
if (quester != null) {
if (quester.hasCustomObjective(bQuest, obj.getName())) {
int index = -1;
@ -232,7 +232,7 @@ public abstract class BukkitCustomObjective implements CustomObjective, Listener
// Multiplayer
final int finalIndex = index;
quester.dispatchMultiplayerObjectives(bQuest, quester.getCurrentStage(bQuest), (final BukkitQuester q) -> {
quester.dispatchMultiplayerObjectives(bQuest, quester.getCurrentStage(bQuest), (final Quester q) -> {
final int old = q.getQuestData(bQuest).customObjectiveCounts.get(finalIndex);
q.getQuestData(bQuest).customObjectiveCounts.set(finalIndex, old + count);
q.finishObjective(bQuest, new BukkitObjective(type, new ItemStack(Material.AIR, 1),

View File

@ -37,7 +37,6 @@ import me.blackvein.quests.events.quester.QuesterPreStartQuestEvent;
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
import me.blackvein.quests.item.QuestJournal;
import me.blackvein.quests.quests.BukkitObjective;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.storage.Storage;
import me.blackvein.quests.tasks.StageTimer;
import me.blackvein.quests.util.ConfigUtil;
@ -299,7 +298,7 @@ public class BukkitQuester implements Quester {
* @return Quest or null
*/
@Override
public BukkitQuest getCompassTarget() {
public Quest getCompassTarget() {
return compassTargetQuestId != null ? plugin.getQuestById(compassTargetQuestId) : null;
}
@ -771,10 +770,10 @@ public class BukkitQuester implements Quester {
final LinkedList<String> finishedRequirements = new LinkedList<>();
final LinkedList<String> current = new LinkedList<>();
final OfflinePlayer player = getPlayer();
if (requirements.getMoney() > 0) {
final String currency = plugin.getDependencies().getCurrency(requirements.getMoney() != 1);
if (plugin.getDependencies().getVaultEconomy() != null
&& plugin.getDependencies().getVaultEconomy().getBalance(player) >= requirements.getMoney()) {
if (requirements.getMoney() > 0 && plugin.getDependencies().getVaultEconomy() != null) {
final String currency = requirements.getMoney() > 1 ? plugin.getDependencies().getVaultEconomy()
.currencyNamePlural() : plugin.getDependencies().getVaultEconomy().currencyNameSingular();
if (plugin.getDependencies().getVaultEconomy().getBalance(player) >= requirements.getMoney()) {
unfinishedRequirements.add(ChatColor.GREEN + "" + requirements.getMoney() + " " + currency);
} else {
finishedRequirements.add(ChatColor.GRAY + "" + requirements.getMoney() + " " + currency);

View File

@ -64,6 +64,7 @@ import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import java.util.LinkedList;
import java.util.List;
@ -90,6 +91,10 @@ public class BukkitQuest implements Quest {
private final BukkitRewards rewards = new BukkitRewards();
private final BukkitOptions options = new BukkitOptions();
public BukkitQuest(final Quests plugin) {
this.plugin = plugin;
}
@Override
public int compareTo(final Quest quest) {
return id.compareTo(quest.getId());
@ -99,8 +104,10 @@ public class BukkitQuest implements Quest {
return plugin;
}
public void setPlugin(Quests plugin) {
this.plugin = plugin;
public void setPlugin(Plugin plugin) {
if (plugin instanceof Quests) {
this.plugin = (Quests)plugin;
}
}
@Override
@ -108,6 +115,7 @@ public class BukkitQuest implements Quest {
return id;
}
@Override
public void setId(String id) {
if (plugin != null) {
this.id = id;

View File

@ -119,22 +119,6 @@ public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedLi
public void setSelectingNpcs(final Set<UUID> selectingNpcs) {
this.selectingNpcs = selectingNpcs;
}
/**
* @deprecated Use {@link#getNamesOfQuestsBeingEdited}
*/
@Deprecated
public List<String> getNames() {
return editingQuestNames;
}
/**
* @deprecated Use {@link#setNamesOfQuestsBeingEdited}
*/
@Deprecated
public void setNames(final List<String> names) {
this.editingQuestNames = names;
}
public List<String> getNamesOfQuestsBeingEdited() {
return editingQuestNames;
@ -166,7 +150,7 @@ public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedLi
}
@SuppressWarnings("deprecation")
public void loadQuest(final ConversationContext context, final BukkitQuest q) {
public void loadQuest(final ConversationContext context, final Quest q) {
context.setSessionData(CK.ED_QUEST_EDIT, q.getName());
context.setSessionData(CK.Q_ID, q.getId());
context.setSessionData(CK.Q_NAME, q.getName());

View File

@ -698,6 +698,10 @@ public class BukkitStage implements Stage {
return customObjectives;
}
public boolean addCustomObjectives(final CustomObjective customObjective) {
return customObjectives.add(customObjective);
}
public void clearCustomObjectives() {
customObjectives.clear();
}
@ -706,6 +710,10 @@ public class BukkitStage implements Stage {
return customObjectiveCounts;
}
public boolean addCustomObjectiveCounts(final Integer customObjectiveCount) {
return customObjectiveCounts.add(customObjectiveCount);
}
public void clearCustomObjectiveCounts() {
customObjectiveCounts.clear();
}
@ -722,6 +730,10 @@ public class BukkitStage implements Stage {
return customObjectiveData;
}
public boolean addCustomObjectiveData(final Entry<String, Object> customObjectiveDatum) {
return this.customObjectiveData.add(customObjectiveDatum);
}
public void clearCustomObjectiveData() {
customObjectiveData.clear();
}

View File

@ -394,7 +394,7 @@ public class SeparatedYamlStorage implements StorageImplementation {
@Override
public String getQuesterLastKnownName(final UUID uniqueId) throws Exception {
BukkitQuester quester = plugin.getQuester(uniqueId);
Quester quester = plugin.getQuester(uniqueId);
if (quester != null) {
quester.hardClear();
} else {

View File

@ -12,7 +12,7 @@
package me.blackvein.quests.tasks;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.particle.ParticleProvider;
import net.citizensnpcs.api.npc.NPC;
@ -33,7 +33,7 @@ public class NpcEffectThread implements Runnable {
@Override
public void run() {
for (final Player player : plugin.getServer().getOnlinePlayers()) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final List<Entity> nearby = player.getNearbyEntities(32.0, 32.0, 32.0);
if (!nearby.isEmpty()) {
for (final Entity e : nearby) {

View File

@ -12,7 +12,7 @@
package me.blackvein.quests.util;
import me.blackvein.quests.Dependencies;
import me.blackvein.quests.dependencies.BukkitDependencies;
import me.blackvein.quests.Quest;
import me.clip.placeholderapi.PlaceholderAPI;
import net.citizensnpcs.api.npc.NPC;
@ -109,7 +109,7 @@ public class ConfigUtil {
Bukkit.getLogger().warning(quest.getName() + " quest uses <npc> tag but doesn't have an NPC start set");
}
}
if (Dependencies.placeholder != null && player != null) {
if (BukkitDependencies.placeholder != null && player != null) {
parsed = PlaceholderAPI.setPlaceholders(player, parsed);
}
return parsed.split("\n");
@ -149,7 +149,7 @@ public class ConfigUtil {
public static String parseString(final String s, final Quest quest, final Player player) {
String parsed = parseString(s, quest);
if (Dependencies.placeholder != null && player != null) {
if (BukkitDependencies.placeholder != null && player != null) {
parsed = PlaceholderAPI.setPlaceholders(player, parsed);
}
return parsed;

View File

@ -796,7 +796,6 @@ requirementsItemFail: "Unable to collect required item. Is it in your off-hand?"
conditionFailQuit: "Condition failed. You have quit <quest>."
conditionFailRetry: "Condition not yet met for this stage of <quest>."
optionSilkTouchFail: "Unable to progress <quest> with the Silk Touch enchantment."
money: "Money"
with: "with"
to: "to"
blocksWithin: "within <amount> blocks of"