Class TabPlaceholder
java.lang.Object
me.neznamy.tab.shared.placeholders.TabPlaceholder
- All Implemented Interfaces:
me.neznamy.tab.api.placeholder.Placeholder
- Direct Known Subclasses:
PlayerPlaceholderImpl,RelationalPlaceholderImpl,ServerPlaceholderImpl
public abstract class TabPlaceholder
extends Object
implements me.neznamy.tab.api.placeholder.Placeholder
General collection of variables and functions shared between all placeholder types
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final StringPlaceholder's identifier including %List of placeholders using this placeholder as a nested placeholder, mutual tracking allows faster parent placeholder changes when a nested placeholder changed value.protected final PlaceholderReplacementPatternConfigured placeholder output replacements -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTabPlaceholder(String identifier, int refresh) Constructs new instance with given parameters and loads placeholder output replacements -
Method Summary
Modifier and TypeMethodDescriptionvoidenableTriggerMode(Runnable onActivation, Runnable onDisable) abstract StringgetLastValue(me.neznamy.tab.api.TabPlayer player) Returns last known value of defined playergetNestedPlaceholders(String output) Returns all nested placeholders in provided output.intReturns placeholder output replacement patternvoidMarks this placeholder as used, which setsactiveto true and ifonActivationis not null, runs it.Replaces this placeholder in given string and returns output.protected StringsetPlaceholders(String text, me.neznamy.tab.api.TabPlayer p) Applies all nested placeholders in outputvoidunload()abstract voidupdateFromNested(me.neznamy.tab.api.TabPlayer player) Updates the placeholder with force mark for requested playervoidupdateParents(me.neznamy.tab.api.TabPlayer player) Updates all placeholders that use this placeholder as a nested placeholder
-
Field Details
-
identifier
Placeholder's identifier including % -
replacements
Configured placeholder output replacements -
parents
List of placeholders using this placeholder as a nested placeholder, mutual tracking allows faster parent placeholder changes when a nested placeholder changed value.
-
-
Constructor Details
-
TabPlaceholder
Constructs new instance with given parameters and loads placeholder output replacements- Parameters:
identifier- placeholder's identifier, must start and end with %refresh- refresh interval in milliseconds, must be divisible by 50 or equal to -1 for trigger placeholders
-
-
Method Details
-
set
Replaces this placeholder in given string and returns output. If the entered string is equal to the placeholder identifier or does not contain the identifier at all, value is returned directly without callingString#replacefor better performance.- Parameters:
string- string to replace this placeholder inplayer- player to set placeholder for- Returns:
- string with this placeholder replaced
-
getNestedPlaceholders
Returns all nested placeholders in provided output. If no placeholders are detected, returns empty list.- Parameters:
output- output to check- Returns:
- List of nested placeholders in provided output
-
setPlaceholders
Applies all nested placeholders in output- Parameters:
text- replaced placeholderp- player to replace for- Returns:
- text with replaced placeholders in output
-
getReplacements
Returns placeholder output replacement pattern- Returns:
- placeholder output replacement pattern
-
markAsUsed
public void markAsUsed()Marks this placeholder as used, which setsactiveto true and ifonActivationis not null, runs it. -
updateParents
public void updateParents(me.neznamy.tab.api.TabPlayer player) Updates all placeholders that use this placeholder as a nested placeholder- Parameters:
player- Player to update placeholders for.
-
updateFromNested
public abstract void updateFromNested(me.neznamy.tab.api.TabPlayer player) Updates the placeholder with force mark for requested player- Parameters:
player- player to update placeholder for
-
getLastValue
Returns last known value of defined player- Parameters:
player- player to get value of- Returns:
- last known value for specified player
-
getIdentifier
- Specified by:
getIdentifierin interfaceme.neznamy.tab.api.placeholder.Placeholder
-
getRefresh
public int getRefresh()- Specified by:
getRefreshin interfaceme.neznamy.tab.api.placeholder.Placeholder
-
unload
public void unload()- Specified by:
unloadin interfaceme.neznamy.tab.api.placeholder.Placeholder
-
enableTriggerMode
- Specified by:
enableTriggerModein interfaceme.neznamy.tab.api.placeholder.Placeholder
-