All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bukkit.conversations.PluginNameConversationPrefix Maven / Gradle / Ivy

package org.bukkit.conversations;

import org.bukkit.ChatColor;
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 final 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;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy