Skip to content

Commit

Permalink
add an optional context to denizen_proc for Sentinel
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 20, 2019
1 parent 785fee4 commit ed65802
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -251,7 +251,7 @@
<dependency>
<groupId>org.mcmonkey</groupId>
<artifactId>sentinel</artifactId>
<version>1.8.5</version>
<version>1.9.5</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
Expand Down
@@ -1,5 +1,6 @@
package com.denizenscript.depenizen.bukkit.bridges;

import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.depenizen.bukkit.events.sentinel.SentinelAttackScriptEvent;
import com.denizenscript.depenizen.bukkit.Bridge;
import com.denizenscript.denizen.objects.EntityTag;
Expand Down Expand Up @@ -48,7 +49,13 @@ public boolean isTarget(LivingEntity ent, String prefix, String value) {
return true;
}
}
if (prefix.equals("denizen_proc") && ent.getEquipment() != null) {
if (prefix.equals("denizen_proc")) {
String context = null;
int colon = value.indexOf(':');
if (colon > 0) {
context = value.substring(colon + 1);
value = value.substring(0, colon);
}
ScriptTag script = ScriptTag.valueOf(value);
if (script == null) {
Debug.echoError("Invalid procedure script name '" + value + "' (non-existent) in a Sentinel NPC target.");
Expand All @@ -65,13 +72,20 @@ public boolean isTarget(LivingEntity ent, String prefix, String value) {
InstantQueue queue = InstantQueue.getQueue(ScriptQueue.getNextId(script.getContainer().getName()));
queue.addEntries(entries);
String def_name = "entity";
String context_name = "context";
if (script.getContainer().getContents().contains("definitions")) {
List<String> definition_names = CoreUtilities.split(script.getContainer().getString("definitions"), '|');
if (definition_names.size() >= 1) {
def_name = definition_names.get(0);
}
if (definition_names.size() >= 2) {
context_name = definition_names.get(1);
}
}
queue.addDefinition(def_name, new EntityTag(ent).getDenizenObject());
if (context != null) {
queue.addDefinition(context_name, new ElementTag(context));
}
queue.start();
if (queue.determinations != null && queue.determinations.size() > 0) {
return CoreUtilities.toLowerCase(queue.determinations.get(0)).equals("true");
Expand Down
Expand Up @@ -143,11 +143,6 @@ else if (attribute.startsWith("fighters")) {
return fighters.getAttribute(attribute.fulfill(1));
}

// NOTE: Deprecated.
if (attribute.startsWith("playercount") || attribute.startsWith("player_count")) {
return new ElementTag(arena.getFighters().size()).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <PVPArenaArenaTag.type>
// @returns ElementTag
Expand Down

0 comments on commit ed65802

Please sign in to comment.