-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3558: Add Translatable interface for fluid creation of TranslatableC…
…omponents
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
chat/src/main/java/net/md_5/bungee/api/chat/TranslationProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package net.md_5.bungee.api.chat; | ||
|
||
/** | ||
* An object capable of being translated by the client in a | ||
* {@link TranslatableComponent}. | ||
*/ | ||
public interface TranslationProvider | ||
{ | ||
|
||
/** | ||
* Get the translation key. | ||
* | ||
* @return the translation key | ||
*/ | ||
String getTranslationKey(); | ||
|
||
/** | ||
* Get this translatable object as a {@link TranslatableComponent}. | ||
* | ||
* @return the translatable component | ||
*/ | ||
default TranslatableComponent asTranslatableComponent() | ||
{ | ||
return asTranslatableComponent( (Object[]) null ); | ||
} | ||
|
||
/** | ||
* Get this translatable object as a {@link TranslatableComponent}. | ||
* | ||
* @param with the {@link String Strings} and | ||
* {@link BaseComponent BaseComponents} to use in the translation | ||
* @return the translatable component | ||
*/ | ||
default TranslatableComponent asTranslatableComponent(Object... with) | ||
{ | ||
return new TranslatableComponent( this, with ); | ||
} | ||
} |