Class Ad
java.lang.Object
me.remigio07.chatplugin.api.server.ad.Ad
Represents an ad handled by the
AdManager
.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets this ad's click action.getClickValue
(Language language) Gets this ad's click value for the specified language.Gets this ad's click values.Gets the list of ranks that will not receive this ad.Gets this ad's hover for the specified language.Gets this ad's hovers.getID()
Gets this ad's ID.Gets this ad's text for the specified language.getTexts()
Gets this ad's texts.setClickAction
(ClickActionAdapter clickAction) Sets this ad's click action.
-
Constructor Details
-
Ad
public Ad(String id, Map<Language, String> texts, Map<Language, String> hovers, ClickActionAdapter clickAction, Map<Language, String> clickValues, List<Rank> disabledRanks) Constructs a new ad.You have two ways to send it to a player:
- using
AdManager.sendAd(Ad, ChatPluginServerPlayer)
- by adding it to
AdManager.getAds()
; in this case it will be removed onChatPluginManager.unload()
- Parameters:
id
- Ad's IDtexts
- Ad's textshovers
- Ad's hoversclickAction
- Ad's click actionclickValues
- Ad's click valuesdisabledRanks
- Ranks that will not receive the ad- Throws:
IllegalArgumentException
- If specified ID!
AdManager.isValidAdID(String)
NoSuchElementException
- Iftexts.get(
(other two maps may containLanguage.getMainLanguage()
) == nullnull
values)
- using
-
-
Method Details
-
getID
Gets this ad's ID.- Returns:
- Ad's ID
-
getTexts
Gets this ad's texts.You may modify the returned map, but it cannot point to a
null
value forLanguage.getMainLanguage()
.- Returns:
- Ad's texts
-
getText
Gets this ad's text for the specified language.Specify
true
asavoidNull
to fall back toLanguage.getMainLanguage()
's text if no text is present for the specified language. Will returnnull
ifgetTexts()
.get(language) == null && !avoidNull
.- Parameters:
language
- Language used to translate the textavoidNull
- Whether to avoid returningnull
- Returns:
- Ad's text
-
getHovers
Gets this ad's hovers.You may modify the returned map.
- Returns:
- Ad's hovers
-
getHover
Gets this ad's hover for the specified language.Will return
null
ifgetHovers()
.get(language) == null
.- Parameters:
language
- Language used to translate the hover- Returns:
- Ad's hover
-
getClickAction
Gets this ad's click action.Will return
null
if the click action has not been specified.- Returns:
- Ad's click action
-
setClickAction
Sets this ad's click action.Specify
null
to not specify a click action.- Parameters:
clickAction
- Ad's click action- Returns:
- This ad
-
getClickValues
Gets this ad's click values.You may modify the returned map.
- Returns:
- Ad's click values
-
getClickValue
Gets this ad's click value for the specified language.Will return
null
ifgetClickValues()
.get(language) == null
.- Parameters:
language
- Language used to translate the click value- Returns:
- Ad's click value
-
getDisabledRanks
Gets the list of ranks that will not receive this ad.You may modify the returned list.
- Returns:
- Ad's disabled ranks
-