mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-27 21:26:29 +01:00
Fix Denizen linkage
This commit is contained in:
parent
4bd7ffc05f
commit
6c1212b21f
20
src/main/java/me/blackvein/quests/DenizenTrigger.java
Normal file
20
src/main/java/me/blackvein/quests/DenizenTrigger.java
Normal 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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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); }
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user