Skip to content

Commit

Permalink
Made tags work inside Format scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcernat committed Mar 7, 2013
1 parent ba066f2 commit 5794472
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
6 changes: 1 addition & 5 deletions src/main/java/net/aufdemrand/denizen/Settings.java
Expand Up @@ -6,11 +6,7 @@ public class Settings {

/*
# Default time in seconds of cooldown set to Denizens when a trigger is triggered.
# Not all triggers may use this, it is optional!
#
# Format: [Name] Trigger Default Cooldown in Seconds: #.#
# For example: Click Trigger Default Cooldown in Seconds: 2.0
# Whether Denizen should display debug in the console
*/

Expand Down
Expand Up @@ -14,9 +14,6 @@

public class BookScriptContainer extends ScriptContainer {

Player player = null;
dNPC npc = null;

public BookScriptContainer(ConfigurationSection configurationSection, String scriptContainerName) {
super(configurationSection, scriptContainerName);
}
Expand Down
@@ -1,18 +1,22 @@
package net.aufdemrand.denizen.scripts.containers.core;

import net.aufdemrand.denizen.npc.dNPC;
import net.aufdemrand.denizen.scripts.ScriptEntry;
import net.aufdemrand.denizen.scripts.containers.ScriptContainer;
import net.aufdemrand.denizen.tags.TagManager;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;

public class FormatScriptContainer extends ScriptContainer {
public FormatScriptContainer(ConfigurationSection configurationSection, String scriptContainerName) {
super(configurationSection, scriptContainerName);
}

public String getFormat() {
return getContents().getString("FORMAT", "<text>");
public String getFormat(Player player, dNPC npc) {
String format = getContents().getString("FORMAT", "<text>");
format = TagManager.tag(player, npc, format, false);
return format;
}

public void setFormat(String format) {
Expand All @@ -21,9 +25,7 @@ public void setFormat(String format) {

public String getFormattedText(ScriptEntry entry) {
String text = (String) entry.getObject("text");
String tagText = TagManager.tag(entry.getOfflinePlayer(), entry.getNPC(), text, true, entry);

return getFormat().replace("<text>", tagText);
return getFormat(entry.getPlayer(), entry.getNPC()).replace("<text>", text);
}

}

0 comments on commit 5794472

Please sign in to comment.