Skip to content

Commit

Permalink
Make notable tags work. Example tag: <notable:Wizard Tower>
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcernat committed Jun 28, 2013
1 parent ce3fb39 commit dcda6c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/main/java/net/aufdemrand/denizen/tags/TagManager.java
Expand Up @@ -41,6 +41,7 @@ public void registerCoreTags() {
new AnchorTags(denizen);
new ContextTags(denizen);
new LocationTags(denizen);
new NotableLocationTags(denizen);
new SpecialCharacterTags(denizen);
new TextTags(denizen);
new ForeignCharacterTags(denizen);
Expand Down
Expand Up @@ -5,10 +5,7 @@
import net.aufdemrand.denizen.tags.Attribute;
import net.aufdemrand.denizen.utilities.arguments.dLocation;
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;

Expand All @@ -19,30 +16,31 @@ public NotableLocationTags(Denizen denizen) {
}

@EventHandler
public void constantTags(ReplaceableTagEvent event) {
public void notableTags(ReplaceableTagEvent event) {

if (!event.matches("NOTABLE")) return;

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 (dLocation.isSavedLocation(id)) {
dB.echoError("Notable tag '" + event.raw_tag + "': id was not found.");
}

dLocation location = dLocation.getSavedLocation(id);

Attribute attribute = new Attribute(event.raw_tag, event.getScriptEntry());

attribute.fulfill(1);

event.setReplaced(location.getAttribute(attribute));
tag = location.getAttribute(attribute);

event.setReplaced(tag.substring("location:".length()));

}
}

0 comments on commit dcda6c1

Please sign in to comment.