use of com.denizenscript.denizencore.objects.ObjectTag in project Denizen-For-Bukkit by DenizenScript.
the class EnchantmentTag method registerTags.
public static void registerTags() {
AbstractFlagTracker.registerFlagHandlers(tagProcessor);
// <--[tag]
// @attribute <EnchantmentTag.name>
// @returns ElementTag
// @description
// Gets the name of this enchantment. For vanilla enchantments, uses the vanilla name like 'sharpness'.
// For Denizen custom enchantments, returns the 'id' specified in the script.
// For any other enchantments, returns the full key.
// -->
tagProcessor.registerTag(ElementTag.class, "name", (attribute, object) -> {
return new ElementTag(object.getCleanName());
});
// <--[tag]
// @attribute <EnchantmentTag.key>
// @returns ElementTag
// @description
// Returns the full key for this enchantment, like "minecraft:sharpness".
// -->
tagProcessor.registerTag(ElementTag.class, "key", (attribute, object) -> {
return new ElementTag(object.enchantment.getKey().toString());
});
// <--[tag]
// @attribute <EnchantmentTag.full_name[<level>]>
// @returns ElementTag
// @description
// Returns the full name for this enchantment for a given level, like "Sharpness V".
// For vanilla enchantments, uses language translation keys.
// -->
tagProcessor.registerTag(ElementTag.class, "full_name", (attribute, object) -> {
if (!attribute.hasParam()) {
return null;
}
return new ElementTag(NMSHandler.enchantmentHelper.getFullName(object.enchantment, attribute.getIntParam()));
});
// <--[tag]
// @attribute <EnchantmentTag.script>
// @returns ScriptTag
// @description
// Returns the script that created this enchantment type, if any.
// -->
tagProcessor.registerTag(ScriptTag.class, "script", (attribute, object) -> {
if (!object.enchantment.getKey().getNamespace().equals("denizen")) {
return null;
}
EnchantmentScriptContainer.EnchantmentReference ref = EnchantmentScriptContainer.registeredEnchantmentContainers.get(object.enchantment.getKey().getKey());
if (ref == null) {
return null;
}
return new ScriptTag(ref.script);
});
// <--[tag]
// @attribute <EnchantmentTag.min_level>
// @returns ElementTag(Number)
// @description
// Returns the minimum level of this enchantment. Usually '1'.
// -->
tagProcessor.registerTag(ElementTag.class, "min_level", (attribute, object) -> {
return new ElementTag(object.enchantment.getStartLevel());
});
// <--[tag]
// @attribute <EnchantmentTag.max_level>
// @returns ElementTag(Number)
// @description
// Returns the minimum level of this enchantment. Usually between 1 and 5.
// -->
tagProcessor.registerTag(ElementTag.class, "max_level", (attribute, object) -> {
return new ElementTag(object.enchantment.getMaxLevel());
});
// <--[tag]
// @attribute <EnchantmentTag.treasure_only>
// @returns ElementTag(Boolean)
// @description
// Returns whether this enchantment is only for spawning as treasure.
// -->
tagProcessor.registerTag(ElementTag.class, "treasure_only", (attribute, object) -> {
return new ElementTag(object.enchantment.isTreasure());
});
// <--[tag]
// @attribute <EnchantmentTag.is_tradable>
// @returns ElementTag(Boolean)
// @description
// Returns whether this enchantment is only considered to be tradable. Villagers won't trade this enchantment if set to false.
// -->
tagProcessor.registerTag(ElementTag.class, "is_tradable", (attribute, object) -> {
return new ElementTag(NMSHandler.enchantmentHelper.isTradable(object.enchantment));
});
// <--[tag]
// @attribute <EnchantmentTag.is_discoverable>
// @returns ElementTag(Boolean)
// @description
// Returns whether this enchantment is only considered to be discoverable.
// If true, this will spawn from vanilla sources like the enchanting table. If false, it can only be given directly by script.
// -->
tagProcessor.registerTag(ElementTag.class, "is_discoverable", (attribute, object) -> {
return new ElementTag(NMSHandler.enchantmentHelper.isDiscoverable(object.enchantment));
});
// <--[tag]
// @attribute <EnchantmentTag.is_curse>
// @returns ElementTag(Boolean)
// @description
// Returns whether this enchantment is only considered to be a curse. Curses are removed at grindstones, and spread from crafting table repairs.
// -->
tagProcessor.registerTag(ElementTag.class, "is_curse", (attribute, object) -> {
return new ElementTag(NMSHandler.enchantmentHelper.isCurse(object.enchantment));
});
// <--[tag]
// @attribute <EnchantmentTag.category>
// @returns ElementTag
// @description
// Returns the category of this enchantment. Can be any of: ARMOR, ARMOR_FEET, ARMOR_LEGS, ARMOR_CHEST, ARMOR_HEAD,
// WEAPON, DIGGER, FISHING_ROD, TRIDENT, BREAKABLE, BOW, WEARABLE, CROSSBOW, VANISHABLE
// -->
tagProcessor.registerTag(ElementTag.class, "category", (attribute, object) -> {
return new ElementTag(object.enchantment.getItemTarget().name());
});
// <--[tag]
// @attribute <EnchantmentTag.rarity>
// @returns ElementTag
// @description
// Returns the rarity of this enchantment. Can be any of: COMMON, UNCOMMON, RARE, VERY_RARE
// -->
tagProcessor.registerTag(ElementTag.class, "rarity", (attribute, object) -> {
return new ElementTag(NMSHandler.enchantmentHelper.getRarity(object.enchantment));
});
// <--[tag]
// @attribute <EnchantmentTag.can_enchant[<item>]>
// @returns ElementTag(Boolean)
// @description
// Returns whether this enchantment can enchant the given ItemTag (based on material mainly).
// -->
tagProcessor.registerTag(ElementTag.class, "can_enchant", (attribute, object) -> {
if (!attribute.hasParam()) {
return null;
}
return new ElementTag(object.enchantment.canEnchantItem(attribute.paramAsType(ItemTag.class).getItemStack()));
});
// <--[tag]
// @attribute <EnchantmentTag.is_compatible[<enchantment>]>
// @returns ElementTag(Boolean)
// @description
// Returns whether this enchantment is compatible with another given enchantment.
// -->
tagProcessor.registerTag(ElementTag.class, "is_compatible", (attribute, object) -> {
if (!attribute.hasParam()) {
return null;
}
return new ElementTag(!object.enchantment.conflictsWith(attribute.paramAsType(EnchantmentTag.class).enchantment));
});
// <--[tag]
// @attribute <EnchantmentTag.min_cost[<level>]>
// @returns ElementTag(Decimal)
// @description
// Returns the minimum cost for this enchantment for the given level.
// -->
tagProcessor.registerTag(ElementTag.class, "min_cost", (attribute, object) -> {
if (!attribute.hasParam()) {
return null;
}
return new ElementTag(NMSHandler.enchantmentHelper.getMinCost(object.enchantment, attribute.getIntParam()));
});
// <--[tag]
// @attribute <EnchantmentTag.max_cost[<level>]>
// @returns ElementTag(Decimal)
// @description
// Returns the maximum cost for this enchantment for the given level.
// -->
tagProcessor.registerTag(ElementTag.class, "max_cost", (attribute, object) -> {
if (!attribute.hasParam()) {
return null;
}
return new ElementTag(NMSHandler.enchantmentHelper.getMaxCost(object.enchantment, attribute.getIntParam()));
});
// <--[tag]
// @attribute <EnchantmentTag.damage_bonus[level=<level>;type=<type>]>
// @returns ElementTag(Decimal)
// @description
// Returns the damage bonus this enchantment applies against the given monster type.
// The input is a MapTag with a level value and a monster type specified, where the type can be any of: ARTHROPOD, ILLAGER, WATER, UNDEAD, or UNDEFINED
// For example, <[my_enchantment].damage_bonus[level=3;type=undead]>
// -->
tagProcessor.registerTag(ElementTag.class, "damage_bonus", (attribute, object) -> {
if (!attribute.hasParam()) {
return null;
}
MapTag map = attribute.paramAsType(MapTag.class);
if (map == null) {
attribute.echoError("Invalid MapTag input to damage_bonus - not a valid map.");
return null;
}
ObjectTag level = map.getObject("level");
ObjectTag type = map.getObject("type");
if (level == null || type == null) {
attribute.echoError("Invalid MapTag input to damage_bonus - missing 'level' or 'type'");
return null;
}
return new ElementTag(NMSHandler.enchantmentHelper.getDamageBonus(object.enchantment, new ElementTag(level.toString()).asInt(), CoreUtilities.toLowerCase(type.toString())));
});
// <--[tag]
// @attribute <EnchantmentTag.damage_protection[level=<level>;type=<cause>;attacker=<entity>]>
// @returns ElementTag(Number)
// @description
// Returns the damage protection this enchantment applies against the given damage cause and optional attacker.
// The input is a MapTag with a level value and a damage type specified, where the damage type must be from <@link language Damage Cause>.
// For entity damage causes, optionally specify the entity attacker.
// For example, <[my_enchantment].damage_protection[level=3;type=undead]>
// -->
tagProcessor.registerTag(ElementTag.class, "damage_protection", (attribute, object) -> {
if (!attribute.hasParam()) {
return null;
}
MapTag map = attribute.paramAsType(MapTag.class);
if (map == null) {
attribute.echoError("Invalid MapTag input to damage_protection - not a valid map.");
return null;
}
ObjectTag level = map.getObject("level");
ObjectTag type = map.getObject("type");
if (level == null || type == null) {
attribute.echoError("Invalid MapTag input to damage_protection - missing 'level' or 'type'");
return null;
}
EntityDamageEvent.DamageCause cause;
try {
cause = EntityDamageEvent.DamageCause.valueOf(type.toString().toUpperCase());
} catch (IllegalArgumentException ex) {
attribute.echoError("Invalid MapTag input to damage_protection - cause '" + type.toString() + "' is not a valid DamageCause.");
return null;
}
ObjectTag attacker = map.getObject("attacker");
return new ElementTag(NMSHandler.enchantmentHelper.getDamageProtection(object.enchantment, new ElementTag(level.toString()).asInt(), cause, attacker == null ? null : attacker.asType(EntityTag.class, attribute.context).getBukkitEntity()));
});
}
use of com.denizenscript.denizencore.objects.ObjectTag in project Denizen-For-Bukkit by DenizenScript.
the class ItemScriptContainer method getItemFrom.
public ItemTag getItemFrom(TagContext context) {
if (isProcessing) {
Debug.echoError("Item script contains (or chains to) a reference to itself. Cannot process.");
return null;
}
if (context == null) {
context = new BukkitTagContext(null, null, new ScriptTag(this));
} else {
context = new BukkitTagContext((BukkitTagContext) context);
context.script = new ScriptTag(this);
}
// Try to use this script to make an item.
ItemTag stack;
isProcessing = true;
try {
if (!contains("material", String.class)) {
Debug.echoError("Item script '" + getName() + "' does not contain a material. Script cannot function.");
return null;
}
// Check validity of material
String material = TagManager.tag(getString("material"), context);
if (material.startsWith("m@")) {
material = material.substring(2);
}
stack = ItemTag.valueOf(material, this);
// Make sure we're working with a valid base ItemStack
if (stack == null) {
Debug.echoError("Item script '" + getName() + "' contains an invalid or incorrect material '" + material + "' (did you spell the material name wrong?). Script cannot function.");
return null;
}
// Handle listed mechanisms
if (contains("mechanisms", Map.class)) {
YamlConfiguration mechs = getConfigurationSection("mechanisms");
for (StringHolder key : mechs.getKeys(false)) {
ObjectTag obj = CoreUtilities.objectToTagForm(mechs.get(key.low), context, true, true);
stack.safeAdjust(new Mechanism(key.low, obj, context));
}
}
// Set Display Name
if (contains("display name", String.class)) {
String displayName = TagManager.tag(getString("display name"), context);
NMSHandler.getItemHelper().setDisplayName(stack, displayName);
}
// Set if the object is bound to the player
if (contains("bound", String.class)) {
Deprecations.boundWarning.warn(context);
}
// Set Lore
if (contains("lore", List.class)) {
List<String> lore = NMSHandler.getItemHelper().getLore(stack);
if (lore == null) {
lore = new ArrayList<>();
}
for (String line : getStringList("lore")) {
line = TagManager.tag(line, context);
lore.add(line);
}
CoreUtilities.fixNewLinesToListSeparation(lore);
NMSHandler.getItemHelper().setLore(stack, lore);
}
// Set Durability
if (contains("durability", String.class)) {
short durability = Short.valueOf(getString("durability"));
stack.setDurability(durability);
}
// Set Enchantments
if (contains("enchantments", List.class)) {
for (String enchantment : getStringList("enchantments")) {
enchantment = TagManager.tag(enchantment, context);
try {
// Build enchantment context
int level = 1;
int colon = enchantment.lastIndexOf(':');
if (colon == -1) {
Debug.echoError("Item script '" + getName() + "' has enchantment '" + enchantment + "' without a level.");
} else {
level = Integer.valueOf(enchantment.substring(colon + 1).replace(" ", ""));
enchantment = enchantment.substring(0, colon).replace(" ", "");
}
// Add enchantment
EnchantmentTag ench = EnchantmentTag.valueOf(enchantment, context);
if (ench == null) {
Debug.echoError("Item script '" + getName() + "' specifies enchantment '" + enchantment + "' which is invalid.");
continue;
}
if (stack.getBukkitMaterial() == Material.ENCHANTED_BOOK) {
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) stack.getItemMeta();
meta.addStoredEnchant(ench.enchantment, level, true);
stack.setItemMeta(meta);
} else {
stack.getItemStack().addUnsafeEnchantment(ench.enchantment, level);
stack.resetCache();
}
} catch (Exception ex) {
Debug.echoError("While constructing item script '" + getName() + "', encountered error while applying enchantment '" + enchantment + "':");
Debug.echoError(ex);
}
}
}
// Set Color
if (contains("color", String.class)) {
Deprecations.itemScriptColor.warn(context);
String color = TagManager.tag(getString("color"), context);
LeatherColorer.colorArmor(stack, color);
}
// Set Book
if (contains("book", String.class)) {
BookScriptContainer book = ScriptRegistry.getScriptContainer(TagManager.tag(getString("book"), context).replace("s@", ""));
stack = book.writeBookTo(stack, context);
}
if (contains("flags", Map.class)) {
YamlConfiguration flagSection = getConfigurationSection("flags");
AbstractFlagTracker tracker = stack.getFlagTracker();
for (StringHolder key : flagSection.getKeys(false)) {
tracker.setFlag(key.str, CoreUtilities.objectToTagForm(flagSection.get(key.str), context, true, true), null);
}
stack.reapplyTracker(tracker);
}
stack.setItemScript(this);
} catch (Exception e) {
Debug.echoError("Woah! An exception has been called with this item script!");
Debug.echoError(e);
stack = null;
} finally {
isProcessing = false;
}
return stack;
}
use of com.denizenscript.denizencore.objects.ObjectTag in project Denizen-For-Bukkit by DenizenScript.
the class EntityScriptContainer method getEntityFrom.
public EntityTag getEntityFrom(PlayerTag player, NPCTag npc) {
EntityTag entity;
try {
TagContext context = new BukkitTagContext(player, npc, new ScriptTag(this));
if (contains("entity_type", String.class)) {
String entityType = TagManager.tag((getString("entity_type", "")), context);
entity = EntityTag.valueOf(entityType, context);
} else {
throw new Exception("Missing entity_type argument!");
}
if (contains("flags", Map.class)) {
YamlConfiguration flagSection = getConfigurationSection("flags");
MapTagFlagTracker tracker = new MapTagFlagTracker();
for (StringHolder key : flagSection.getKeys(false)) {
tracker.setFlag(key.str, CoreUtilities.objectToTagForm(flagSection.get(key.str), context, true, true), null);
}
entity.safeAdjust(new Mechanism("flag_map", tracker.map, context));
}
if (contains("mechanisms", Map.class)) {
YamlConfiguration mechSection = getConfigurationSection("mechanisms");
Set<StringHolder> strings = mechSection.getKeys(false);
for (StringHolder string : strings) {
ObjectTag obj = CoreUtilities.objectToTagForm(mechSection.get(string.low), context, true, true);
entity.safeAdjust(new Mechanism(string.low, obj, context));
}
}
boolean any = false;
Set<StringHolder> strings = getContents().getKeys(false);
for (StringHolder string : strings) {
if (!nonMechanismKeys.contains(string.low)) {
any = true;
ObjectTag obj = CoreUtilities.objectToTagForm(getContents().get(string.low), context, true, true);
entity.safeAdjust(new Mechanism(string.low, obj, context));
}
}
if (any) {
Deprecations.entityMechanismsFormat.warn(this);
}
if (entity == null || entity.isUnique()) {
return null;
}
entity.setEntityScript(getName());
} catch (Exception e) {
Debug.echoError("Woah! An exception has been called with this entity script!");
Debug.echoError(e);
entity = null;
}
return entity;
}
use of com.denizenscript.denizencore.objects.ObjectTag in project Denizen-For-Bukkit by DenizenScript.
the class ScoreboardCommand method execute.
@Override
public void execute(final ScriptEntry scriptEntry) {
List<PlayerTag> viewers = (List<PlayerTag>) scriptEntry.getObject("viewers");
ListTag lines = scriptEntry.hasObject("lines") ? ListTag.valueOf(scriptEntry.getElement("lines").asString(), scriptEntry.getContext()) : new ListTag();
ElementTag action = scriptEntry.getElement("action");
ElementTag id = scriptEntry.getElement("id");
ElementTag objective = scriptEntry.getElement("objective");
ElementTag criteria = scriptEntry.getElement("criteria");
ElementTag score = scriptEntry.getElement("score");
ElementTag displaySlot = scriptEntry.getElement("displayslot");
ElementTag displayName = scriptEntry.getElement("displayname");
ElementTag renderType = scriptEntry.getElement("rendertype");
Action act = Action.valueOf(action.asString().toUpperCase());
boolean hadCriteria = criteria != null;
boolean hadDisplaySlot = displaySlot != null;
if (!hadCriteria) {
criteria = new ElementTag("dummy");
}
if (!hadDisplaySlot) {
displaySlot = new ElementTag("sidebar");
}
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), action, id, db("viewers", viewers), objective, lines, score, objective, displaySlot, criteria, displayName, renderType);
}
Scoreboard board = null;
// Get the main scoreboard by default
if (id.asString().equalsIgnoreCase("main")) {
board = ScoreboardHelper.getMain();
} else if (id.asString().equalsIgnoreCase("player")) {
board = Utilities.getEntryPlayer(scriptEntry).getPlayerEntity().getScoreboard();
} else {
// If this scoreboard already exists, get it
if (ScoreboardHelper.hasScoreboard(id.asString())) {
board = ScoreboardHelper.getScoreboard(id.asString());
} else // Else, create a new one if Action is ADD
if (act.equals(Action.ADD)) {
board = ScoreboardHelper.createScoreboard(id.asString());
}
}
// Don't progress if we ended up with a null board
if (board == null) {
Debug.echoError(scriptEntry, "Scoreboard " + id.asString() + " does not exist!");
return;
}
Objective obj;
if (act.equals(Action.ADD)) {
if (objective != null) {
// Try getting the objective from the board
obj = board.getObjective(objective.asString());
boolean existedAlready = obj != null;
// Create the objective if it does not already exist
if (obj == null) {
obj = board.registerNewObjective(objective.asString(), criteria.asString());
} else // recreate the objective
if (hadCriteria && !obj.getCriteria().equals(criteria.asString())) {
obj.unregister();
obj = board.registerNewObjective(objective.asString(), criteria.asString());
}
// Change the objective's display slot
if ((!existedAlready || hadDisplaySlot) && !displaySlot.asString().equalsIgnoreCase("none")) {
obj.setDisplaySlot(DisplaySlot.valueOf(displaySlot.asString().toUpperCase()));
}
if (renderType != null) {
obj.setRenderType(RenderType.valueOf(renderType.asString().toUpperCase()));
}
if (displayName != null) {
obj.setDisplayName(displayName.asString());
} else if (!existedAlready) {
obj.setDisplayName(objective.asString());
}
if (!lines.isEmpty()) {
// use a score of 0
if (score == null) {
score = new ElementTag(0);
}
for (ObjectTag line : lines.objectForms) {
ScoreboardHelper.addScore(obj, checkLine(line), score.asInt());
}
}
} else // the command cannot do anything at all, so print a message about that
if (viewers == null && !lines.isEmpty()) {
Debug.echoDebug(scriptEntry, "Cannot add lines without specifying an objective!");
}
} else if (act.equals(Action.REMOVE)) {
if (objective != null) {
// Try getting the objective from the board
obj = board.getObjective(objective.asString());
if (obj != null) {
// Remove the entire objective if no lines have been specified
if (lines.isEmpty()) {
Debug.echoDebug(scriptEntry, "Removing objective " + obj.getName() + " from scoreboard " + id.asString());
obj.unregister();
} else {
for (ObjectTag line : lines.objectForms) {
ScoreboardHelper.removeScore(obj, checkLine(line));
}
}
} else {
Debug.echoError(scriptEntry, "Objective " + objective.asString() + " does not exist in scoreboard " + id.asString());
}
} else // lines from every objective
if (!lines.isEmpty()) {
Debug.echoDebug(scriptEntry, "Removing lines " + lines.identify() + " from all objectives in scoreboard " + id.asString());
for (ObjectTag line : lines.objectForms) {
ScoreboardHelper.removePlayer(id.asString(), checkLine(line));
}
} else // of viewers should be removed instead)
if (viewers == null) {
Debug.echoDebug(scriptEntry, "Removing scoreboard " + id.asString());
ScoreboardHelper.deleteScoreboard(id.asString());
}
}
if (viewers != null) {
for (PlayerTag viewer : viewers) {
// Add viewers for this scoreboard
if (act.equals(Action.ADD)) {
// to the map of viewers saved by Denizen
if (!id.asString().equalsIgnoreCase("main")) {
ScoreboardHelper.viewerMap.put(viewer.getUUID(), id.asString());
}
// is already online
if (viewer.isOnline()) {
viewer.getPlayerEntity().setScoreboard(board);
}
} else // Remove viewers for this scoreboard
if (act.equals(Action.REMOVE)) {
// Take this player out of the map of viewers
ScoreboardHelper.viewerMap.remove(viewer.getUUID());
// provided by Bukkit)
if (viewer.isOnline()) {
viewer.getPlayerEntity().setScoreboard(ScoreboardHelper.createScoreboard());
}
}
}
}
}
use of com.denizenscript.denizencore.objects.ObjectTag in project Denizen-For-Bukkit by DenizenScript.
the class ChatTrigger method process.
// Technically defined in TriggerTrait, but placing here instead.
// <--[action]
// @Actions
// chat
//
// @Triggers when a player chats to the NPC.
//
// @Context
// <context.message> returns the triggering message
// <context.keyword> returns the keyword matched by a RegEx trigger
//
// @Determine
// "CANCELLED" to stop the player from chatting.
// ElementTag to change the message.
//
// -->
public ChatContext process(Player player, String message) {
NPCTag npc = Utilities.getClosestNPC_ChatTrigger(player.getLocation(), 25);
if (Debug.verbose) {
Debug.log("Processing chat trigger: valid npc? " + (npc != null));
}
if (npc == null) {
return new ChatContext(false);
}
if (Debug.verbose) {
Debug.log("Has trait? " + npc.getCitizen().hasTrait(TriggerTrait.class));
}
if (!npc.getCitizen().hasTrait(TriggerTrait.class)) {
return new ChatContext(false);
}
if (Debug.verbose) {
Debug.log("enabled? " + npc.getCitizen().getOrAddTrait(TriggerTrait.class).isEnabled(name));
}
if (!npc.getCitizen().getOrAddTrait(TriggerTrait.class).isEnabled(name)) {
return new ChatContext(false);
}
if (npc.getTriggerTrait().getRadius(name) < npc.getLocation().distance(player.getLocation())) {
if (Debug.verbose) {
Debug.log("Not in range");
}
return new ChatContext(false);
}
if (Settings.chatMustSeeNPC()) {
if (!player.hasLineOfSight(npc.getEntity())) {
if (Debug.verbose) {
Debug.log("no LOS");
}
return new ChatContext(false);
}
}
if (Settings.chatMustLookAtNPC()) {
if (!NMSHandler.getEntityHelper().isFacingEntity(player, npc.getEntity(), 45)) {
if (Debug.verbose) {
Debug.log("Not facing");
}
return new ChatContext(false);
}
}
boolean ret = false;
Map<String, ObjectTag> context = new HashMap<>();
context.put("message", new ElementTag(message));
TriggerTrait.TriggerContext trigger = npc.getTriggerTrait().trigger(ChatTrigger.this, new PlayerTag(player), context);
if (trigger.hasDetermination()) {
if (trigger.getDeterminations().containsCaseInsensitive("cancelled")) {
if (Debug.verbose) {
Debug.log("Cancelled");
}
return new ChatContext(true);
}
}
if (!trigger.wasTriggered()) {
if (Settings.chatGloballyIfUninteractable()) {
if (Debug.verbose) {
Debug.log(ChatColor.YELLOW + "Resuming. " + ChatColor.WHITE + "The NPC is currently cooling down or engaged.");
}
return new ChatContext(false);
} else {
ret = true;
}
}
if (trigger.hasDetermination()) {
message = trigger.getDeterminations().get(0);
}
List<InteractScriptContainer> scripts = npc.getInteractScripts(new PlayerTag(player), ChatTrigger.class);
if (scripts == null) {
if (Debug.verbose) {
Debug.log("null scripts");
}
return new ChatContext(message, false);
}
ChatContext returnable = new ChatContext(ret);
for (InteractScriptContainer script : scripts) {
processSingle(message, player, npc, context, script, returnable);
}
return returnable;
}
Aggregations