001/*
002 * Trident - A Multithreaded Server Alternative
003 * Copyright 2014 The TridentSDK Team
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package net.tridentsdk.service;
018
019import net.tridentsdk.entity.living.Player;
020import net.tridentsdk.plugin.Plugin;
021import net.tridentsdk.registry.Registry;
022
023import javax.annotation.concurrent.ThreadSafe;
024
025/**
026 * Handles server side chat communication
027 *
028 * <p>To access this handler, use this code:
029 * <pre><code>
030 *     ChatFormatter handler = Registered.chatFormatter();
031 * </code></pre></p>
032 *
033 * @author The TridentSDK Team
034 * @since 0.3-alpha-DP
035 */
036@ThreadSafe
037public interface ChatFormatter extends Registry<ChatIdentityFormatter> {
038    /**
039     * Sets the provider of the chat format, performing the default overriding logic of the original provider
040     *
041     * <p>The provider is notified before it is replaced, so do not try to replace the provider in the
042     * overriden method</p>
043     *
044     * @param provider the provider to use
045     * @param plugin the plugin that registers the new provider
046     */
047    void setFormatter(ChatIdentityFormatter provider, Plugin plugin);
048
049    /**
050     * Obtains the formatted string, not including the message that will be sent
051     *
052     * @param message the default chat identifier
053     * @param player the player that is sending the message
054     * @return the formatted string from the provider
055     */
056    String format(String message, Player player);
057}