Search in sources :

Example 6 with Attribute

use of net.aufdemrand.denizencore.tags.Attribute in project Denizen-For-Bukkit by DenizenScript.

the class LocationTags method locationTags.

@TagManager.TagEvents
public void locationTags(ReplaceableTagEvent event) {
    if (!event.matches("location", "l") || event.replaced()) {
        return;
    }
    // Stage the location
    dLocation loc = null;
    // Check name context for a specified location, or check
    // the ScriptEntry for a 'location' context
    String context = event.getNameContext();
    if (event.hasNameContext() && dLocation.matches(context)) {
        loc = dLocation.valueOf(context);
    } else if (event.getScriptEntry().hasObject("location")) {
        loc = (dLocation) event.getScriptEntry().getObject("location");
    }
    // Check if location is null, return null if it is
    if (loc == null) {
        return;
    }
    // Build and fill attributes
    Attribute attribute = event.getAttributes();
    event.setReplaced(loc.getAttribute(attribute.fulfill(1)));
}
Also used : Attribute(net.aufdemrand.denizencore.tags.Attribute) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation)

Example 7 with Attribute

use of net.aufdemrand.denizencore.tags.Attribute in project Denizen-For-Bukkit by DenizenScript.

the class NPCTags method npcTags.

@TagManager.TagEvents
public void npcTags(ReplaceableTagEvent event) {
    if (!event.matches("npc") || event.replaced()) {
        return;
    }
    // Build a new attribute out of the raw_tag supplied in the script to be fulfilled
    Attribute attribute = event.getAttributes();
    // NPCTags require a... dNPC!
    dNPC n = ((BukkitTagContext) event.getContext()).npc;
    // Player tag may specify a new player in the <player[context]...> portion of the tag.
    if (attribute.hasContext(1)) // Check if this is a valid player and update the dPlayer object reference.
    {
        if (dNPC.matches(attribute.getContext(1))) {
            n = dNPC.valueOf(attribute.getContext(1));
        } else {
            if (!event.hasAlternative()) {
                dB.echoError("Could not match '" + attribute.getContext(1) + "' to a valid NPC!");
            }
            return;
        }
    }
    if (n == null || !n.isValid()) {
        if (!event.hasAlternative()) {
            dB.echoError("Invalid or missing NPC for tag <" + event.raw_tag + ">!");
        }
        return;
    }
    event.setReplaced(n.getAttribute(attribute.fulfill(1)));
}
Also used : net.aufdemrand.denizen.objects.dNPC(net.aufdemrand.denizen.objects.dNPC) BukkitTagContext(net.aufdemrand.denizen.tags.BukkitTagContext) Attribute(net.aufdemrand.denizencore.tags.Attribute)

Example 8 with Attribute

use of net.aufdemrand.denizencore.tags.Attribute in project Denizen-For-Bukkit by DenizenScript.

the class NotableLocationTags method notableTags.

@TagManager.TagEvents
public void notableTags(ReplaceableTagEvent event) {
    if (!event.matches("NOTABLE")) {
        return;
    }
    dB.echoError(event.getAttributes().getScriptEntry().getResidingQueue(), "notable: tags are deprecated! Use <l@NotableName>!");
    String tag = event.raw_tag;
    String id = null;
    if (event.hasValue()) {
        id = event.getValue();
        tag = tag.split(":", 2)[1];
    } else if (event.hasNameContext()) {
        id = event.getNameContext();
    }
    if (NotableManager.isType(id, dLocation.class)) {
        dB.echoError("Notable tag '" + event.raw_tag + "': id was not found.");
    }
    dLocation location = (dLocation) NotableManager.getSavedObject(id);
    Attribute attribute = event.getAttributes();
    attribute.fulfill(1);
    tag = location.getAttribute(attribute);
    event.setReplaced(tag);
}
Also used : Attribute(net.aufdemrand.denizencore.tags.Attribute) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation)

Example 9 with Attribute

use of net.aufdemrand.denizencore.tags.Attribute in project Denizen-For-Bukkit by DenizenScript.

the class PlayerTags method playerTags.

//////////
//  ReplaceableTagEvent handler
////////
@TagManager.TagEvents
public void playerTags(ReplaceableTagEvent event) {
    if (!event.matches("player", "pl") || event.replaced()) {
        return;
    }
    // Build a new attribute out of the raw_tag supplied in the script to be fulfilled
    Attribute attribute = event.getAttributes();
    // PlayerTags require a... dPlayer!
    dPlayer p = ((BukkitTagContext) event.getContext()).player;
    // Player tag may specify a new player in the <player[context]...> portion of the tag.
    if (attribute.hasContext(1)) {
        p = dPlayer.valueOf(attribute.getContext(1));
    }
    if (p == null || !p.isValid()) {
        if (!event.hasAlternative()) {
            dB.echoError("Invalid or missing player for tag <" + event.raw_tag + ">!");
        }
        return;
    }
    event.setReplaced(p.getAttribute(attribute.fulfill(1)));
}
Also used : BukkitTagContext(net.aufdemrand.denizen.tags.BukkitTagContext) Attribute(net.aufdemrand.denizencore.tags.Attribute) net.aufdemrand.denizen.objects.dPlayer(net.aufdemrand.denizen.objects.dPlayer)

Example 10 with Attribute

use of net.aufdemrand.denizencore.tags.Attribute in project Denizen-For-Bukkit by DenizenScript.

the class TextTags method colorTags.

// <--[tag]
// @attribute <&0>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Black.
// -->
// <--[tag]
// @attribute <&1>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Dark Blue.
// -->
// <--[tag]
// @attribute <&2>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Dark Green.
// -->
// <--[tag]
// @attribute <&3>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Dark Cyan.
// -->
// <--[tag]
// @attribute <&4>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Dark Red.
// -->
// <--[tag]
// @attribute <&5>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Dark Magenta.
// -->
// <--[tag]
// @attribute <&6>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Gold.
// -->
// <--[tag]
// @attribute <&7>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Light Gray.
// -->
// <--[tag]
// @attribute <&8>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Dark Gray.
// -->
// <--[tag]
// @attribute <&9>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Light Blue.
// -->
// <--[tag]
// @attribute <&a>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Light Green.
// -->
// <--[tag]
// @attribute <&b>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Cyan.
// -->
// <--[tag]
// @attribute <&c>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Light Red.
// -->
// <--[tag]
// @attribute <&d>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Magenta.
// -->
// <--[tag]
// @attribute <&e>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Yellow.
// -->
// <--[tag]
// @attribute <&f>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters White.
// -->
// <--[tag]
// @attribute <&k>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters obfuscated.
// -->
// <--[tag]
// @attribute <&l>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters bold.
// -->
// <--[tag]
// @attribute <&m>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters have a strike-through.
// -->
// <--[tag]
// @attribute <&n>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters have an underline.
// -->
// <--[tag]
// @attribute <&o>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters italicized.
// -->
// <--[tag]
// @attribute <&r>
// @returns Element
// @description
// Returns the ChatColor that resets the following characters to normal.
// -->
// <--[tag]
// @attribute <black>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Black.
// -->
// <--[tag]
// @attribute <dark_blue>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Dark Blue.
// -->
// <--[tag]
// @attribute <dark_green>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Dark Green.
// -->
// <--[tag]
// @attribute <dark_aqua>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Dark Cyan.
// -->
// <--[tag]
// @attribute <dark_red>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Dark Red.
// -->
// <--[tag]
// @attribute <dark_purple>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Dark Magenta.
// -->
// <--[tag]
// @attribute <gold>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Gold.
// -->
// <--[tag]
// @attribute <gray>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Light Gray.
// -->
// <--[tag]
// @attribute <dark_gray>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Dark Gray.
// -->
// <--[tag]
// @attribute <blue>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Light Blue.
// -->
// <--[tag]
// @attribute <green>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Light Green.
// -->
// <--[tag]
// @attribute <aqua>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Cyan.
// -->
// <--[tag]
// @attribute <red>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Light Red.
// -->
// <--[tag]
// @attribute <light_purple>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Magenta.
// -->
// <--[tag]
// @attribute <yellow>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters Yellow.
// -->
// <--[tag]
// @attribute <white>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters White.
// -->
// <--[tag]
// @attribute <magic>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters obfuscated.
// -->
// <--[tag]
// @attribute <bold>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters bold.
// -->
// <--[tag]
// @attribute <strikethrough>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters have a strike-through.
// -->
// <--[tag]
// @attribute <underline>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters have an underline.
// -->
// <--[tag]
// @attribute <italic>
// @returns Element
// @description
// Returns the ChatColor that makes the following characters italicized.
// -->
// <--[tag]
// @attribute <reset>
// @returns Element
// @description
// Returns the ChatColor that resets the following characters to normal.
// -->
@TagManager.TagEvents
public void colorTags(ReplaceableTagEvent event) {
    Attribute attribute = event.getAttributes();
    int i = 0;
    for (ChatColor color : ChatColor.values()) {
        if (i > 22) {
            break;
        }
        if (event.matches(color.name())) {
            event.setReplaced(new Element(color.toString()).getAttribute(attribute.fulfill(1)));
        } else if (event.matches("&" + code[i])) {
            event.setReplaced(new Element(ChatColor.getByChar(code[i]).toString()).getAttribute(attribute.fulfill(1)));
        }
        i++;
    }
}
Also used : Attribute(net.aufdemrand.denizencore.tags.Attribute) Element(net.aufdemrand.denizencore.objects.Element) ChatColor(org.bukkit.ChatColor)

Aggregations

Attribute (net.aufdemrand.denizencore.tags.Attribute)14 Element (net.aufdemrand.denizencore.objects.Element)6 BukkitTagContext (net.aufdemrand.denizen.tags.BukkitTagContext)4 net.aufdemrand.denizen.objects.dLocation (net.aufdemrand.denizen.objects.dLocation)3 net.aufdemrand.denizen.objects.dEntity (net.aufdemrand.denizen.objects.dEntity)2 net.aufdemrand.denizen.objects.dNPC (net.aufdemrand.denizen.objects.dNPC)2 net.aufdemrand.denizen.objects.dPlayer (net.aufdemrand.denizen.objects.dPlayer)2 net.aufdemrand.denizencore.objects.dList (net.aufdemrand.denizencore.objects.dList)2 NPC (net.citizensnpcs.api.npc.NPC)2 File (java.io.File)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 Map (java.util.Map)1 UUID (java.util.UUID)1 Pattern (java.util.regex.Pattern)1 FlagManager (net.aufdemrand.denizen.flags.FlagManager)1 BlockData (net.aufdemrand.denizen.nms.interfaces.BlockData)1 AssignmentTrait (net.aufdemrand.denizen.npc.traits.AssignmentTrait)1 ConstantsTrait (net.aufdemrand.denizen.npc.traits.ConstantsTrait)1 net.aufdemrand.denizen.objects.dCuboid (net.aufdemrand.denizen.objects.dCuboid)1