Package net.aufdemrand.denizen.tags.core

Source Code of net.aufdemrand.denizen.tags.core.AnchorTags

package net.aufdemrand.denizen.tags.core;

import net.aufdemrand.denizen.Denizen;
import net.aufdemrand.denizen.events.bukkit.ReplaceableTagEvent;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.trait.Anchors;

import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

@Deprecated
public class AnchorTags implements Listener {

    public AnchorTags(Denizen denizen) {
        denizen.getServer().getPluginManager().registerEvents(this, denizen);
    }

    @EventHandler
    public void anchorTags(ReplaceableTagEvent event) {
        if (!event.matches("ANCHOR")) return;

        dB.echoError(event.getAttributes().getScriptEntry().getResidingQueue(), "anchor: tags are deprecated! Use <npc.anchor[]>!");
        NPC npc = null;
        if (event.getType() != null
                && event.getType().matches("\\d+"))
            npc = CitizensAPI.getNPCRegistry().getById(Integer.valueOf(event.getType()));
        else if (event.getNPC() != null)
            npc = event.getNPC().getCitizen();
        if (npc == null) return;

        if (npc.getTrait(Anchors.class).getAnchor(event.getValue()) != null) {
            Location anchor = npc.getTrait(Anchors.class).getAnchor(event.getValue()).getLocation();
            event.setReplaced(anchor.getX() + "," + anchor.getY() + "," + anchor.getZ() + "," + anchor.getWorld().getName());
        }
    }
}
TOP

Related Classes of net.aufdemrand.denizen.tags.core.AnchorTags

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.