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; 021 022/** 023 * Provides chat properties to the {@link ChatFormatter} 024 * 025 * <p>The formatting provides only the left most portion (the player name and prompt), not the actual chat message</p> 026 * 027 * @author The TridentSDK Team 028 * @since 0.3-alpha-DP 029 */ 030@FunctionalInterface 031public interface ChatIdentityFormatter { 032 /** 033 * Obtains a formatted string of the chat identifier 034 * 035 * <p> 036 * <ul> 037 * <li>{@code %p} - the default prefix</li> 038 * <li>{@code %n} - the player name</li> 039 * <li>{@code %s} - the default suffix</li> 040 * <li>{@code %d} - the default prompt</li> 041 * </ul> 042 * </p> 043 * 044 * <p>The default is usually {@code %n>}. The default is filled in, but cannot replace the default string.</p> 045 * 046 * <p>Examples: 047 * <pre><code> 048 * // Default is: John> 049 * 050 * // [Prefix]John[Suffix]>> 051 * return "[Prefix]%n[Suffix]>>"; 052 * 053 * // [Prefix]JOHN> 054 * return "[Prefix]" + sender.displayName().toUpperCase() + "%d"; 055 * </code></pre></p> 056 * 057 * <p>It is generally a good idea to use the provided variables than to hardcode them, as the implementation is 058 * allowed to change the chat characters.</p> 059 * 060 * @param message the default identifier 061 * @param sender the player sending the identifier 062 * @return the foratted string 063 */ 064 String format(String message, Player sender); 065 066 /** 067 * A callback indicating the overriding of this provider 068 * 069 * @param other the chat provider that is being set 070 * @param overrider the plugin that is setting the overrider 071 */ 072 default void overriden(ChatIdentityFormatter other, Plugin overrider) { 073 } 074}