Class NovaPlayer

java.lang.Object
us.teaminceptus.novaconomy.api.player.NovaPlayer

public final class NovaPlayer extends Object
Class representing a Player used in the Plugin
  • Constructor Details

  • Method Details

    • getPlayerData

      @NotNull public @NotNull Map<String,Object> getPlayerData()
      Fetches a mutable Map Representation of the player's data.
      Returns:
      Map of Player Data
    • getPlayer

      @NotNull public @NotNull OfflinePlayer getPlayer()
      Fetch the player this class belongs to
      Returns:
      OfflinePlayer of this object
    • getOnlinePlayer

      @Nullable public @Nullable Player getOnlinePlayer()
      Fetch the online player this class belongs to
      Returns:
      Player if online, else null
    • getPlayerName

      @NotNull public @NotNull String getPlayerName()
      Fetches this player's name.
      Returns:
      Name of this player
    • getBalance

      public double getBalance(@NotNull @NotNull Economy econ) throws IllegalArgumentException
      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 use
      newBal - 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

      @NotNull public @NotNull PlayerStatistics getStatistics()
      Fetches the statistics of this Player.
      Returns:
      PlayerStatistics of this player
    • add

      public void add(@NotNull @NotNull Economy econ, double add) throws IllegalArgumentException
      Adds to the balance of this player
      Parameters:
      econ - Economy to use
      add - Amount to add
      Throws:
      IllegalArgumentException - if economy is null
    • remove

      public void remove(@NotNull @NotNull Economy econ, double remove) throws IllegalArgumentException
      Removes from the balance of this player
      Parameters:
      econ - Economy to use
      remove - Amount to remove
      Throws:
      IllegalArgumentException - if economy is null
    • remove

      public void remove(@NotNull @NotNull Price price)
      Removes a Price from the balance of this player
      Parameters:
      price - Price to remove
    • add

      public void add(@NotNull @NotNull Price price) throws IllegalArgumentException
      Adds a Price to the balance of this player
      Parameters:
      price - Price to use
      Throws:
      IllegalArgumentException - if price is null
    • canAfford

      public boolean canAfford(@Nullable @Nullable Product p)
      Whether this Nova Player can afford a Product.
      Parameters:
      p - Product to buy
      Returns:
      true if can afford, else false
    • getLastBankWithdraw

      @NotNull public @NotNull PlayerWithdrawEvent getLastBankWithdraw()
      Fetches an Event Representation of the last bank withdraw of this player
      Returns:
      PlayerWithdrawEvent representing last withdraw; Player may be null if isOnline() returns false
    • getLastBankDeposit

      @NotNull public @NotNull PlayerDepositEvent getLastBankDeposit()
      Fetches an Event Representation of the last bank deposit of this player
      Returns:
      PlayerDepositEvent representing last deposit; Player may be null if isOnline() 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 from
      amount - Amount to withdraw
      Throws:
      IllegalArgumentException - if economy is null, or amount is negative or greater than the current bank balance
      UnsupportedOperationException - 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 to
      firstAmount - Amount to deposit
      Throws:
      IllegalArgumentException - if economy is null, or amount is negative
    • getAllDonatedAmounts

      @NotNull public @NotNull Map<Economy,Double> getAllDonatedAmounts()
      Fetches a Map of Economies to how much they have donated to the global bank.
      Returns:
      Donation Map
    • getDonatedAmount

      public double getDonatedAmount(@Nullable @Nullable Economy econ)
      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

      @NotNull public 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.
      Parameters:
      econ - Economy donated to
      max - Amount of top donators to fetch
      Returns:
      List of top donators
    • getTotalBalance

      public double getTotalBalance()
      Fetches and adds all of the balances from getBalance(Economy).
      Returns:
      total balance of all economies
    • getTopDonators

      @NotNull public static @NotNull List<NovaPlayer> getTopDonators(Economy econ)
      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

      @NotNull public @NotNull Map<OfflinePlayer,Bounty> getOwnedBounties()
      Fetches all of the Bounties this player owns.
      Returns:
      Map of Owned Bounties
    • getTopBounties

      @NotNull public @NotNull List<Map.Entry<OfflinePlayer,Bounty>> getTopBounties(int max)
      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

      @NotNull public @NotNull List<Map.Entry<OfflinePlayer,Bounty>> getTopBounties()
      Fetches a sorted list of Bounties this player owns, descending, by their amount, with no maximum.
      Returns:
      List of top bounties
    • getTopSelfBounties

      @NotNull public @NotNull List<Bounty> getTopSelfBounties(int max)
      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

      @NotNull public @NotNull List<Bounty> 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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getSelfBounties

      @NotNull public @NotNull Set<Bounty> getSelfBounties()
      Fetches all of the Bounties that this player is the target of.
      Returns:
      Set of Bounties with getPlayer() as their target
    • getSetting

      public boolean getSetting(@Nullable Settings.Personal setting)
      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 set
      value - Value for the setting
      Throws:
      IllegalArgumentException - if setting is null
    • hasNotifications

      public boolean hasNotifications()
      Utility setting for Settings.Personal.NOTIFICATIONS

      This method is not overridden by NovaConfig.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 for
      rating - Rating to set
      comment - 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 for
      rating - Rating to set
      comment - Comment on the rating
      Throws:
      IllegalArgumentException - if rating is less than 0 (no rating) / greater than 5, or business is null
    • setRating

      public void setRating(@NotNull @NotNull Rating r)
      Sets the rating for this Business by this player.
      Parameters:
      r - Rating to set
    • getRating

      @Nullable public @Nullable Rating getRating(@Nullable @Nullable Business b)
      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

      @NotNull public @NotNull Date getLastRating(@Nullable @Nullable Business b)
      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

      public int getRatingLevel(@NotNull @NotNull Business b) throws IllegalArgumentException
      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

      public boolean hasRating(@Nullable @Nullable Business b)
      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 has novaconomy.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 has novaconomy.admin.market.bypass_membership, this method will do nothing.

      Parameters:
      value - true if this player can access the market, else false
    • getPurchases

      @NotNull public @NotNull Set<Receipt> getPurchases()
      Fetches an immutable copy of all of the purchases this player has made.
      Returns:
      All Purchases
    • getPurchases

      @NotNull public @NotNull Set<Receipt> getPurchases(@NotNull @NotNull Material m)
      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