Class NovaPlayer
java.lang.Object
us.teaminceptus.novaconomy.api.player.NovaPlayer
Class representing a Player used in the Plugin
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds to the balance of this playervoidAdds a Price to the balance of this playerbooleanWhether this Nova Player can afford a Product.voidDeposits an amount to the global bankbooleanFetches a Map of Economies to how much they have donated to the global bank.doublegetBalance(@NotNull Economy econ) Fetches the balance of this playerdoublegetDonatedAmount(@Nullable Economy econ) Fetches the total amount of money this player has donated to the global bank.@NotNull PlayerDepositEventFetches an Event Representation of the last bank deposit of this player@NotNull PlayerWithdrawEventFetches an Event Representation of the last bank withdraw of this player@NotNull DategetLastRating(@Nullable Business b) Fetches a Date representation of when this Player last rated@Nullable PlayerFetch the online player this class belongs to@NotNull Map<OfflinePlayer,Bounty> Fetches all of the Bounties this player owns.@NotNull OfflinePlayerFetch the player this class belongs toFetches a mutable Map Representation of the player's data.@NotNull StringFetches this player's name.Fetches an immutable copy of all of the purchases this player has made.getPurchases(@NotNull Material m) Fetches an immutable copy of all of the purchases this player has made for a specific Material.@Nullable RatingFetches the Rating for this Business.@NotNull StringgetRatingComment(@NotNull Business b) Fetches the comment on the rating for this Business.intgetRatingLevel(@NotNull Business b) Fetches the rating value for this Business.Fetches all of the Bounties that this player is the target of.booleangetSetting(Settings.Personal setting) Fetches a Personal Setting for this Player.@NotNull PlayerStatisticsFetches the statistics of this Player.@NotNull List<Map.Entry<OfflinePlayer,Bounty>> Fetches a sorted list of Bounties this player owns, descending, by their amount, with no maximum.@NotNull List<Map.Entry<OfflinePlayer,Bounty>> getTopBounties(int max) Fetches a sorted list of Bounties this player owns, descending, by their amount.static @NotNull List<NovaPlayer>getTopDonators(Economy econ) Fetches a sorted list of the top donators of this Economy to the global bank, descending.static @NotNull List<NovaPlayer>getTopDonators(Economy econ, int max) Fetches a sorted list of the top donators of this Economy to the global bank, descending.Fetches a sorted list of Bounties that have this player as their target, descending, by their amount, with no maximum.getTopSelfBounties(int max) Fetches a sorted list of Bounties that have this player as their target, descending, by their amount.doubleFetches and adds all of the balances fromgetBalance(Economy).inthashCode()booleanWhether this player can access the Novaconomy Market.booleanUtility setting forSettings.Personal.NOTIFICATIONS
This method is not overridden byNovaConfig.hasNotifications().booleanWhether this player has a rating for this Business.booleanisOnline()Whether this Nova Player is online.voidRemoves from the balance of this playervoidRemoves a Price from the balance of this playervoidsave()Saves this player's information to the file.voidsetBalance(@NotNull Economy econ, double newBal) Sets the balance of this playervoidsetMarketAccess(boolean value) Sets whether this player can access the Novaconomy Market.voidSets the rating value for this Business.voidSets the rating for this Business by this player.voidSets the rating for this Business by this player.voidsetSetting(Settings.Personal setting, boolean value) Sets a Personal Setting for this Player.voidWithdraws an amount from the global bank
-
Constructor Details
-
NovaPlayer
Creates a new NovaPlayer.- Parameters:
p- OfflinePlayer to use- Throws:
IllegalArgumentException- if player is null
-
-
Method Details
-
getPlayerData
Fetches a mutable Map Representation of the player's data.- Returns:
- Map of Player Data
-
getPlayer
Fetch the player this class belongs to- Returns:
- OfflinePlayer of this object
-
getOnlinePlayer
Fetch the online player this class belongs to- Returns:
- Player if online, else null
-
getPlayerName
Fetches this player's name.- Returns:
- Name of this player
-
getBalance
Fetches the balance of this player- Parameters:
econ- Economy to use- Returns:
- Player Balance
- Throws:
IllegalArgumentException- if economy is null
-
setBalance
public void setBalance(@NotNull @NotNull Economy econ, double newBal) throws IllegalArgumentException Sets the balance of this player- Parameters:
econ- Economy to usenewBal- Amount to set- Throws:
IllegalArgumentException- if economy is null
-
save
public void save()Saves this player's information to the file.
Information will be automatically saved with wrapper methods, so this method does not need to be called again.
-
getStatistics
Fetches the statistics of this Player.- Returns:
- PlayerStatistics of this player
-
add
Adds to the balance of this player- Parameters:
econ- Economy to useadd- Amount to add- Throws:
IllegalArgumentException- if economy is null
-
remove
Removes from the balance of this player- Parameters:
econ- Economy to useremove- Amount to remove- Throws:
IllegalArgumentException- if economy is null
-
remove
Removes a Price from the balance of this player- Parameters:
price- Price to remove
-
add
Adds a Price to the balance of this player- Parameters:
price- Price to use- Throws:
IllegalArgumentException- if price is null
-
canAfford
Whether this Nova Player can afford a Product.- Parameters:
p- Product to buy- Returns:
- true if can afford, else false
-
getLastBankWithdraw
Fetches an Event Representation of the last bank withdraw of this player- Returns:
PlayerWithdrawEventrepresenting last withdraw; Player may be null ifisOnline()returns false
-
getLastBankDeposit
Fetches an Event Representation of the last bank deposit of this player- Returns:
PlayerDepositEventrepresenting last deposit; Player may be null ifisOnline()returns false
-
withdraw
public void withdraw(@NotNull @NotNull Economy econ, double amount) throws IllegalArgumentException, UnsupportedOperationException Withdraws an amount from the global bank- Parameters:
econ- Economy to withdraw fromamount- Amount to withdraw- Throws:
IllegalArgumentException- if economy is null, or amount is negative or greater than the current bank balanceUnsupportedOperationException- if amount is greater than the max withdraw or already withdrawn in the last 24 hours
-
deposit
public void deposit(@NotNull @NotNull Economy econ, double firstAmount) throws IllegalArgumentException Deposits an amount to the global bank- Parameters:
econ- Economy to deposit tofirstAmount- Amount to deposit- Throws:
IllegalArgumentException- if economy is null, or amount is negative
-
getAllDonatedAmounts
Fetches a Map of Economies to how much they have donated to the global bank.- Returns:
- Donation Map
-
getDonatedAmount
Fetches the total amount of money this player has donated to the global bank.- Parameters:
econ- Economy to check- Returns:
- Total amount donated, or 0 if not found or economy is null
-
getTopDonators
Fetches a sorted list of the top donators of this Economy to the global bank, descending.- Parameters:
econ- Economy donated tomax- Amount of top donators to fetch- Returns:
- List of top donators
-
getTotalBalance
public double getTotalBalance()Fetches and adds all of the balances fromgetBalance(Economy).- Returns:
- total balance of all economies
-
getTopDonators
Fetches a sorted list of the top donators of this Economy to the global bank, descending.- Parameters:
econ- Economy donated to- Returns:
- List of top donators
-
isOnline
public boolean isOnline()Whether this Nova Player is online.- Returns:
- true if online, else false
-
getOwnedBounties
Fetches all of the Bounties this player owns.- Returns:
- Map of Owned Bounties
-
getTopBounties
Fetches a sorted list of Bounties this player owns, descending, by their amount.- Parameters:
max- Amount of top bounties to fetch- Returns:
- List of top bounties
-
getTopBounties
Fetches a sorted list of Bounties this player owns, descending, by their amount, with no maximum.- Returns:
- List of top bounties
-
getTopSelfBounties
Fetches a sorted list of Bounties that have this player as their target, descending, by their amount.- Parameters:
max- Amount of top bounties to fetch- Returns:
- List of top bounties
-
getTopSelfBounties
Fetches a sorted list of Bounties that have this player as their target, descending, by their amount, with no maximum.- Returns:
- List of top bounties
-
equals
-
hashCode
public int hashCode() -
getSelfBounties
Fetches all of the Bounties that this player is the target of.- Returns:
- Set of Bounties with
getPlayer()as their target
-
getSetting
Fetches a Personal Setting for this Player.- Parameters:
setting- Setting to fetch- Returns:
- Setting value, default if not found, or false if null
-
setSetting
public void setSetting(@NotNull Settings.Personal setting, boolean value) throws IllegalArgumentException Sets a Personal Setting for this Player.- Parameters:
setting- Setting to setvalue- Value for the setting- Throws:
IllegalArgumentException- if setting is null
-
hasNotifications
public boolean hasNotifications()Utility setting forSettings.Personal.NOTIFICATIONS
This method is not overridden byNovaConfig.hasNotifications().- Returns:
- true if notifications are enabled, else false
-
setRating
public void setRating(@NotNull @NotNull UUID id, int rating, @Nullable @Nullable String comment) throws IllegalArgumentException Sets the rating value for this Business.- Parameters:
id- ID of the Business to set the rating forrating- Rating to setcomment- Comment on the rating- Throws:
IllegalArgumentException- if rating is less than 0 (no rating) / greater than 5, or business ID is null
-
setRating
public void setRating(@NotNull @NotNull Business business, int rating, @Nullable @Nullable String comment) throws IllegalArgumentException Sets the rating for this Business by this player.- Parameters:
business- Business to set the rating forrating- Rating to setcomment- Comment on the rating- Throws:
IllegalArgumentException- if rating is less than 0 (no rating) / greater than 5, or business is null
-
setRating
Sets the rating for this Business by this player.- Parameters:
r- Rating to set
-
getRating
Fetches the Rating for this Business.- Parameters:
b- Business to fetch the rating for- Returns:
- Rating for this Business, or null if not found / business is null
-
getLastRating
Fetches a Date representation of when this Player last rated- Parameters:
b- Business to search- Returns:
- Date of when this Player last rated, or current time if not found / Business is null
-
getRatingLevel
Fetches the rating value for this Business.- Parameters:
b- Business to fetch the rating for- Returns:
- Rating value, or 0 if not found
- Throws:
IllegalArgumentException- if business is null
-
getRatingComment
@NotNull public @NotNull String getRatingComment(@NotNull @NotNull Business b) throws IllegalArgumentException Fetches the comment on the rating for this Business.- Parameters:
b- Business to fetch the comment for- Returns:
- Comment on the rating, may be empty
- Throws:
IllegalArgumentException- if business is null
-
hasRating
Whether this player has a rating for this Business.- Parameters:
b- Business to check- Returns:
- true if this player has a rating for this Business, else false
-
hasMarketAccess
public boolean hasMarketAccess()Whether this player can access the Novaconomy Market.
If
NovaMarket.isMarketMembershipEnabled()returns false or Player hasnovaconomy.admin.market.bypass_membership, this method will always return true.- Returns:
- true if this player can access the market, else false
-
setMarketAccess
public void setMarketAccess(boolean value) Sets whether this player can access the Novaconomy Market.
If
NovaMarket.isMarketMembershipEnabled()returns false or Player hasnovaconomy.admin.market.bypass_membership, this method will do nothing.- Parameters:
value- true if this player can access the market, else false
-
getPurchases
Fetches an immutable copy of all of the purchases this player has made.- Returns:
- All Purchases
-
getPurchases
Fetches an immutable copy of all of the purchases this player has made for a specific Material.- Parameters:
m- Material to search for- Returns:
- All Purchases for this Material
-