001 package org.bukkit.conversations; 002 003 import org.bukkit.ChatColor; 004 import org.bukkit.command.CommandSender; 005 import org.bukkit.plugin.Plugin; 006 007 /** 008 * PluginNameConversationPrefix is a {@link ConversationPrefix} implementation 009 * that displays the plugin name in front of conversation output. 010 */ 011 public class PluginNameConversationPrefix implements ConversationPrefix { 012 013 protected String separator; 014 protected ChatColor prefixColor; 015 protected Plugin plugin; 016 017 private String cachedPrefix; 018 019 public PluginNameConversationPrefix(Plugin plugin) { 020 this(plugin, " > ", ChatColor.LIGHT_PURPLE); 021 } 022 023 public PluginNameConversationPrefix(Plugin plugin, String separator, ChatColor prefixColor) { 024 this.separator = separator; 025 this.prefixColor = prefixColor; 026 this.plugin = plugin; 027 028 cachedPrefix = prefixColor + plugin.getDescription().getName() + separator + ChatColor.WHITE; 029 } 030 031 /** 032 * Prepends each conversation message with the plugin name. 033 * 034 * @param context Context information about the conversation. 035 * @return An empty string. 036 */ 037 public String getPrefix(ConversationContext context) { 038 return cachedPrefix; 039 } 040 }