Fix Denizen linkage

This commit is contained in:
BuildTools 2019-01-13 00:48:20 -05:00
parent 4bd7ffc05f
commit 6c1212b21f
5 changed files with 38 additions and 22 deletions

View File

@ -0,0 +1,20 @@
package me.blackvein.quests;
import net.aufdemrand.denizen.BukkitScriptEntryData;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizencore.scripts.ScriptRegistry;
import net.aufdemrand.denizencore.scripts.containers.core.TaskScriptContainer;
public class DenizenTrigger {
protected boolean runDenizenScript(String scriptName, Quester quester) {
if (scriptName == null) {
return false;
}
if (ScriptRegistry.containsScript(scriptName)) {
TaskScriptContainer task_script = ScriptRegistry.getScriptContainerAs(scriptName, TaskScriptContainer.class);
BukkitScriptEntryData entryData = new BukkitScriptEntryData(dPlayer.mirrorBukkitPlayer(quester.getPlayer()), null);
task_script.runTaskScript(entryData, null);
}
return true;
}
}

View File

@ -3,7 +3,11 @@ package me.blackvein.quests;
import org.bukkit.plugin.RegisteredServiceProvider;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import net.aufdemrand.denizen.BukkitScriptEntryData;
import net.aufdemrand.denizen.Denizen;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizencore.scripts.ScriptRegistry;
import net.aufdemrand.denizencore.scripts.containers.core.TaskScriptContainer;
import net.citizensnpcs.api.CitizensPlugin;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
@ -163,4 +167,8 @@ public class Dependencies {
}
return (permission != null);
}
public boolean runDenizenScript(String scriptName, Quester quester) {
return plugin.getDenizenTrigger().runDenizenScript(scriptName, quester);
}
}

View File

@ -168,7 +168,7 @@ public class Quest {
if (q.getCurrentStage(this).delay < 0) {
if (q.currentQuests.get(this) == (orderedStages.size() - 1)) {
if (q.getCurrentStage(this).script != null) {
plugin.runDenizenScript(q.getCurrentStage(this).script, q);
plugin.getDenizenTrigger().runDenizenScript(q.getCurrentStage(this).script, q);
}
if (q.getCurrentStage(this).finishEvent != null) {
q.getCurrentStage(this).finishEvent.fire(q, this);
@ -222,7 +222,7 @@ public class Quest {
quester.hardStagePut(this, stage);
quester.addEmptiesFor(this, stage);
if (currentStage.script != null) {
plugin.runDenizenScript(quester.getCurrentStage(this).script, quester);
plugin.getDenizenTrigger().runDenizenScript(quester.getCurrentStage(this).script, quester);
}
/*
* if (quester.getCurrentStage(this).finishEvent != null) { quester.getCurrentStage(this).finishEvent.fire(quester); }

View File

@ -90,10 +90,7 @@ import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.LocaleQuery;
import me.blackvein.quests.util.MiscUtil;
import me.clip.placeholderapi.PlaceholderAPI;
import net.aufdemrand.denizen.BukkitScriptEntryData;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizencore.scripts.ScriptRegistry;
import net.aufdemrand.denizencore.scripts.containers.core.TaskScriptContainer;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
@ -119,6 +116,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
private NpcListener npcListener;
private NpcEffectThread effThread;
private PartiesListener partiesListener;
private DenizenTrigger trigger;
private Lang lang;
private LocaleQuery localeQuery;
@ -290,6 +288,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
return eventFactory;
}
public DenizenTrigger getDenizenTrigger() {
return trigger;
}
public Lang getLang() {
return lang;
}
@ -1303,6 +1305,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
// Denizen script load
if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".script-to-run")) {
if (ScriptRegistry.containsScript(config.getString("quests." + questKey + ".stages.ordered." + s2 + ".script-to-run"))) {
trigger = new DenizenTrigger();
oStage.script = config.getString("quests." + questKey + ".stages.ordered." + s2 + ".script-to-run");
} else {
stageFailed("script-to-run: in Stage " + s2 + " of Quest " + quest.getName() + " is not a Denizen script!");
@ -2641,21 +2644,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
return depends.getHeroes().getCharacterManager().getHero(p);
}
public boolean runDenizenScript(String scriptName, Quester quester) {
if (scriptName == null) {
return false;
}
if (depends.getDenizen() == null) {
return false;
}
if (ScriptRegistry.containsScript(scriptName)) {
TaskScriptContainer task_script = ScriptRegistry.getScriptContainerAs(scriptName, TaskScriptContainer.class);
BukkitScriptEntryData entryData = new BukkitScriptEntryData(dPlayer.mirrorBukkitPlayer(quester.getPlayer()), null);
task_script.runTaskScript(entryData, null);
}
return true;
}
public boolean testPrimaryHeroesClass(String primaryClass, UUID uuid) {
Hero hero = getHero(uuid);

View File

@ -38,7 +38,7 @@ public class StageTimer implements Runnable {
if (quester.getQuestData(quest).delayOver) {
if (quest.getStages().indexOf(quester.getCurrentStage(quest)) == (quest.getStages().size() - 1)) {
if (quester.getCurrentStage(quest).getScript() != null) {
plugin.runDenizenScript(quester.getCurrentStage(quest).getScript(), quester);
plugin.getDependencies().runDenizenScript(quester.getCurrentStage(quest).getScript(), quester);
}
if (quester.getCurrentStage(quest).getFinishEvent() != null) {
quester.getCurrentStage(quest).getFinishEvent().fire(quester, quest);
@ -49,7 +49,7 @@ public class StageTimer implements Runnable {
int stageNum = quester.getCurrentQuests().get(quest) + 1;
quester.hardQuit(quest);
if (currentStage.getScript() != null) {
plugin.runDenizenScript(currentStage.getScript(), quester);
plugin.getDependencies().runDenizenScript(currentStage.getScript(), quester);
}
if (currentStage.getFinishEvent() != null) {
currentStage.getFinishEvent().fire(quester, quest);