summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java')
-rw-r--r--src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java b/src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java
new file mode 100644
index 00000000..ec2492b1
--- /dev/null
+++ b/src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java
@@ -0,0 +1,39 @@
+package org.bukkit.conversations;
+
+import org.bukkit.ChatColor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.plugin.Plugin;
+
+/**
+ * PluginNameConversationPrefix is a {@link ConversationPrefix} implementation that displays the plugin name in front of
+ * conversation output.
+ */
+public class PluginNameConversationPrefix implements ConversationPrefix {
+
+ protected String separator;
+ protected ChatColor prefixColor;
+ protected Plugin plugin;
+
+ private String cachedPrefix;
+
+ public PluginNameConversationPrefix(Plugin plugin) {
+ this(plugin, " > ", ChatColor.LIGHT_PURPLE);
+ }
+
+ public PluginNameConversationPrefix(Plugin plugin, String separator, ChatColor prefixColor) {
+ this.separator = separator;
+ this.prefixColor = prefixColor;
+ this.plugin = plugin;
+
+ cachedPrefix = prefixColor + plugin.getDescription().getName() + separator + ChatColor.WHITE;
+ }
+
+ /**
+ * Prepends each conversation message with the plugin name.
+ * @param context Context information about the conversation.
+ * @return An empty string.
+ */
+ public String getPrefix(ConversationContext context) {
+ return cachedPrefix;
+ }
+}