Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Denizen 1.2.2+, fixes #1877. Bump version
- Loading branch information
Showing
11 changed files
with
151 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
api/src/main/java/me/blackvein/quests/reflect/denizen/DenizenAPI_1_2_2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters