mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-21 18:15:32 +01:00
Support Denizen 1.2.2+, fixes #1877. Bump version
This commit is contained in:
parent
2c92e6cd46
commit
7c05200909
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<version>4.2.1</version>
|
||||
</parent>
|
||||
<artifactId>quests-api</artifactId>
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
<dependency>
|
||||
<groupId>com.denizenscript</groupId>
|
||||
<artifactId>denizen</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.3-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -24,6 +24,7 @@ public class DenizenAPI {
|
||||
private Class<?> denizen_1_0_9 = null;
|
||||
private Class<?> denizen_1_1_0 = null;
|
||||
private Class<?> denizen_1_1_1 = null;
|
||||
private Class<?> denizen_1_2_2 = null;
|
||||
protected Class<?> scriptRegistry = null;
|
||||
protected Method containsScriptMethod = null;
|
||||
protected Method getScriptNamesMethod = null;
|
||||
@ -38,12 +39,21 @@ public class DenizenAPI {
|
||||
protected Class<?> bukkitScriptEntryData = null;
|
||||
|
||||
public DenizenAPI() {
|
||||
try {
|
||||
Class.forName("com.denizenscript.denizencore.utilities.ScriptUtilities");
|
||||
denizen_1_2_2 = Class.forName("com.denizenscript.denizen.Denizen");
|
||||
return;
|
||||
} catch (final Exception e) {
|
||||
// Fail silently
|
||||
}
|
||||
try {
|
||||
bukkitScriptEntryData
|
||||
= Class.forName("com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData");
|
||||
denizen_1_1_1 = Class.forName("com.denizenscript.denizen.Denizen");
|
||||
|
||||
containsScriptMethod = scriptRegistry.getMethod("containsScript", String.class);
|
||||
return;
|
||||
} catch (final Exception e2) {
|
||||
} catch (final Exception e) {
|
||||
// Fail silently
|
||||
}
|
||||
try {
|
||||
@ -57,10 +67,11 @@ public class DenizenAPI {
|
||||
scriptEntryData = Class.forName("com.denizenscript.denizencore.scripts.ScriptEntryData");
|
||||
bukkitScriptEntryData = Class.forName("com.denizenscript.denizen.BukkitScriptEntryData");
|
||||
denizen_1_1_0 = Class.forName("com.denizenscript.denizen.Denizen");
|
||||
|
||||
|
||||
containsScriptMethod = scriptRegistry.getMethod("containsScript", String.class);
|
||||
getScriptNamesMethod = scriptRegistry.getMethod("_getScriptNames");
|
||||
return;
|
||||
} catch (final Exception e1) {
|
||||
} catch (final Exception e) {
|
||||
// Fail silently
|
||||
}
|
||||
try {
|
||||
@ -86,12 +97,14 @@ public class DenizenAPI {
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return denizen_1_1_1 != null || denizen_1_1_0 != null || denizen_1_0_9 != null;
|
||||
return denizen_1_2_2 != null || denizen_1_1_1 != null || denizen_1_1_0 != null || denizen_1_0_9 != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Class<?> getDenizenClass() {
|
||||
if (denizen_1_1_1 != null) {
|
||||
if (denizen_1_2_2 != null) {
|
||||
return denizen_1_2_2;
|
||||
} else if (denizen_1_1_1 != null) {
|
||||
return denizen_1_1_1;
|
||||
} else if (denizen_1_1_0 != null) {
|
||||
return denizen_1_1_0;
|
||||
@ -102,7 +115,9 @@ public class DenizenAPI {
|
||||
}
|
||||
|
||||
public boolean containsScript(final String input) {
|
||||
if (denizen_1_1_1 != null) {
|
||||
if (denizen_1_2_2 != null) {
|
||||
return DenizenAPI_1_2_2.containsScript(input);
|
||||
} else if (denizen_1_1_1 != null) {
|
||||
return DenizenAPI_1_1_1.containsScript(input);
|
||||
} else if (denizen_1_1_0 != null) {
|
||||
return DenizenAPI_1_1_0.containsScript(input);
|
||||
@ -114,7 +129,9 @@ public class DenizenAPI {
|
||||
|
||||
@Nullable
|
||||
public String getScriptContainerName(final String input) {
|
||||
if (denizen_1_1_1 != null) {
|
||||
if (denizen_1_2_2 != null) {
|
||||
return DenizenAPI_1_2_2.getScriptContainerName(input);
|
||||
} else if (denizen_1_1_1 != null) {
|
||||
return DenizenAPI_1_1_1.getScriptContainerName(input);
|
||||
} else if (denizen_1_1_0 != null) {
|
||||
return DenizenAPI_1_1_0.getScriptContainerName(input);
|
||||
@ -126,7 +143,9 @@ public class DenizenAPI {
|
||||
|
||||
@Nullable
|
||||
public Set<String> getScriptNames() {
|
||||
if (denizen_1_1_1 != null) {
|
||||
if (denizen_1_2_2 != null) {
|
||||
return DenizenAPI_1_2_2.getScriptNames();
|
||||
} else if (denizen_1_1_1 != null) {
|
||||
return DenizenAPI_1_1_1.getScriptNames();
|
||||
} else if (denizen_1_1_0 != null) {
|
||||
return DenizenAPI_1_1_0.getScriptNames();
|
||||
@ -138,7 +157,9 @@ public class DenizenAPI {
|
||||
|
||||
@Nullable
|
||||
public Object getScriptContainerAs(final String scriptName) {
|
||||
if (denizen_1_1_1 != null) {
|
||||
if (denizen_1_2_2 != null) {
|
||||
return DenizenAPI_1_2_2.getScriptContainerAs(scriptName);
|
||||
} else if (denizen_1_1_1 != null) {
|
||||
return DenizenAPI_1_1_1.getScriptContainerAs(scriptName);
|
||||
} else if (denizen_1_1_0 != null) {
|
||||
return DenizenAPI_1_1_0.getScriptContainerAs(scriptName);
|
||||
@ -150,7 +171,9 @@ public class DenizenAPI {
|
||||
|
||||
@Nullable
|
||||
public Object mirrorBukkitPlayer(final Player player) {
|
||||
if (denizen_1_1_1 != null) {
|
||||
if (denizen_1_2_2 != null) {
|
||||
return DenizenAPI_1_2_2.mirrorBukkitPlayer(player);
|
||||
} else if (denizen_1_1_1 != null) {
|
||||
return DenizenAPI_1_1_1.mirrorBukkitPlayer(player);
|
||||
} else if (denizen_1_1_0 != null) {
|
||||
return DenizenAPI_1_1_0.mirrorBukkitPlayer(player);
|
||||
@ -162,7 +185,9 @@ public class DenizenAPI {
|
||||
|
||||
@Nullable
|
||||
public Object mirrorCitizensNPC(final NPC npc) {
|
||||
if (denizen_1_1_1 != null) {
|
||||
if (denizen_1_2_2 != null) {
|
||||
return DenizenAPI_1_2_2.mirrorCitizensNPC(npc);
|
||||
} else if (denizen_1_1_1 != null) {
|
||||
return DenizenAPI_1_1_1.mirrorCitizensNPC(npc);
|
||||
} else if (denizen_1_1_0 != null) {
|
||||
return DenizenAPI_1_1_0.mirrorCitizensNPC(npc);
|
||||
@ -173,7 +198,9 @@ public class DenizenAPI {
|
||||
}
|
||||
|
||||
public void runTaskScript(final String scriptName, final Player player) {
|
||||
if (denizen_1_1_1 != null) {
|
||||
if (denizen_1_2_2 != null) {
|
||||
DenizenAPI_1_2_2.runTaskScript(scriptName, player);
|
||||
} else if (denizen_1_1_1 != null) {
|
||||
DenizenAPI_1_1_1.runTaskScript(scriptName, player);
|
||||
} else if (denizen_1_1_0 != null) {
|
||||
DenizenAPI_1_1_0.runTaskScript(scriptName, player);
|
||||
|
@ -33,9 +33,16 @@ public class DenizenAPI_1_1_0 {
|
||||
|
||||
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) {
|
||||
return ScriptRegistry.containsScript(input);
|
||||
if (quests == null || api.scriptRegistry == null || api.containsScriptMethod == null) return false;
|
||||
boolean script = false;
|
||||
try {
|
||||
script = (boolean)api.containsScriptMethod.invoke(api.scriptRegistry, input);
|
||||
} catch (final Exception e) {
|
||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen ScriptRegistry#containsScript", e);
|
||||
}
|
||||
return script;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -67,7 +74,7 @@ public class DenizenAPI_1_1_0 {
|
||||
}
|
||||
|
||||
public static @NotNull Object mirrorCitizensNPC(final NPC npc) {
|
||||
return NPCTag.mirrorCitizensNPC(npc);
|
||||
return NPCTag.fromEntity(npc.getEntity());
|
||||
}
|
||||
|
||||
public static void runTaskScript(final String scriptName, final Player player) {
|
||||
|
@ -17,19 +17,33 @@ import com.denizenscript.denizen.objects.PlayerTag;
|
||||
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
|
||||
import com.denizenscript.denizencore.scripts.ScriptRegistry;
|
||||
import com.denizenscript.denizencore.scripts.containers.core.TaskScriptContainer;
|
||||
import com.denizenscript.denizencore.scripts.queues.ScriptQueue;
|
||||
import com.denizenscript.denizencore.scripts.queues.core.InstantQueue;
|
||||
import me.blackvein.quests.QuestsAPI;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class DenizenAPI_1_1_1 {
|
||||
|
||||
|
||||
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) {
|
||||
return ScriptRegistry.containsScript(input);
|
||||
if (quests == null || api.scriptRegistry == null || api.containsScriptMethod == null) return false;
|
||||
boolean script = false;
|
||||
try {
|
||||
script = (boolean)api.containsScriptMethod.invoke(api.scriptRegistry, input);
|
||||
} catch (final Exception e) {
|
||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen ScriptRegistry#containsScript", e);
|
||||
}
|
||||
return script;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -52,14 +66,23 @@ public class DenizenAPI_1_1_1 {
|
||||
}
|
||||
|
||||
public static @NotNull Object mirrorCitizensNPC(final NPC npc) {
|
||||
return NPCTag.mirrorCitizensNPC(npc);
|
||||
return NPCTag.fromEntity(npc.getEntity());
|
||||
}
|
||||
|
||||
|
||||
public static void runTaskScript(final String scriptName, final Player player) {
|
||||
final TaskScriptContainer taskScript = ScriptRegistry.getScriptContainerAs(scriptName, TaskScriptContainer.class);
|
||||
final BukkitScriptEntryData entryData = new BukkitScriptEntryData(PlayerTag.mirrorBukkitPlayer(player), null);
|
||||
final ScriptQueue queue = new InstantQueue(taskScript.getName())
|
||||
.addEntries(taskScript.getBaseEntries(entryData.clone()));
|
||||
queue.start();
|
||||
final InstantQueue queue = new InstantQueue(taskScript.getName());
|
||||
|
||||
if (quests == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Method addEntries = queue.getClass().getMethod("addEntries", List.class);
|
||||
addEntries.invoke(queue, taskScript.getBaseEntries(entryData.clone()));
|
||||
queue.start();
|
||||
} catch (final Exception e) {
|
||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen InstantQueue#addEntries", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.reflect.denizen;
|
||||
|
||||
import com.denizenscript.denizen.objects.NPCTag;
|
||||
import com.denizenscript.denizen.objects.PlayerTag;
|
||||
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
|
||||
import com.denizenscript.denizencore.scripts.ScriptRegistry;
|
||||
import com.denizenscript.denizencore.scripts.containers.core.TaskScriptContainer;
|
||||
import com.denizenscript.denizencore.utilities.ScriptUtilities;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class DenizenAPI_1_2_2 {
|
||||
|
||||
public static boolean containsScript(final String input) {
|
||||
return ScriptRegistry.containsScript(input, TaskScriptContainer.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getScriptContainerName(final String input) {
|
||||
return ScriptRegistry.getScriptContainer(input).getName();
|
||||
}
|
||||
|
||||
public static @NotNull Set<String> getScriptNames() {
|
||||
return ScriptRegistry.scriptContainers.keySet();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Object getScriptContainerAs(final String scriptName) {
|
||||
return ScriptRegistry.getScriptContainerAs(scriptName, TaskScriptContainer.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Object mirrorBukkitPlayer(final Player player) {
|
||||
return PlayerTag.mirrorBukkitPlayer(player);
|
||||
}
|
||||
|
||||
public static @NotNull Object mirrorCitizensNPC(final NPC npc) {
|
||||
return NPCTag.fromEntity(npc.getEntity());
|
||||
}
|
||||
|
||||
public static void runTaskScript(final String scriptName, final Player player) {
|
||||
final TaskScriptContainer taskScript = ScriptRegistry.getScriptContainerAs(scriptName, TaskScriptContainer.class);
|
||||
final BukkitScriptEntryData entryData = new BukkitScriptEntryData(PlayerTag.mirrorBukkitPlayer(player), null);
|
||||
ScriptUtilities.createAndStartQueue(taskScript, null, entryData);
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<version>4.2.1</version>
|
||||
</parent>
|
||||
<artifactId>quests-core</artifactId>
|
||||
|
||||
|
2
dist/pom.xml
vendored
2
dist/pom.xml
vendored
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<version>4.2.1</version>
|
||||
</parent>
|
||||
<artifactId>quests-dist</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
4
pom.xml
4
pom.xml
@ -6,12 +6,12 @@
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<version>4.2.1</version>
|
||||
<name>quests</name>
|
||||
<url>https://github.com/PikaMug/Quests/</url>
|
||||
|
||||
<properties>
|
||||
<revision>4.2.0</revision>
|
||||
<revision>4.2.1</revision>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<version>4.2.1</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<version>4.2.1</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<version>4.2.1</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
Loading…
Reference in New Issue
Block a user