Skip to content

Commit

Permalink
Added "String pluginName" parameter to display function
Browse files Browse the repository at this point in the history
I added the "String pluginName" parameter to the function: fractionalDigits, format, getDefaultCurrency, defaultCurrencyNamePlural and defaultCurrencyNameSingular for the creation of an economy plugin that redirects the calls of these functions to different currencies depending on the plugin that calls them

(for example in my multi-currency economy plugin I created a possibility to define a currency on a plugin the modifications I made allow these plugins to display the amounts in the right currency (in case the calling plugin does not support multi-currency))
  • Loading branch information
Fedjoyd authored Oct 6, 2024
1 parent 741f317 commit ff79045
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/main/java/net/milkbowl/vault2/economy/Economy.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,34 +73,37 @@ public interface Economy {
* function returns the number of digits the plugin keeps or -1 if no rounding
* occurs.
*
* @param pluginName The name of the plugin that is calling the method.
* @return number of digits after the decimal point this plugin supports or -1
* if no rounding occurs.
*/
@NotNull
int fractionalDigits();
int fractionalDigits(final String pluginName);

/**
* Plugins use this method to format a given BigDecimal amount into a human-readable
* amount using your economy plugin's currency names/conventions.
*
* @param pluginName The name of the plugin that is calling the method.
* @param amount to format.
*
* @return Human-readable string describing amount, ie 5 Dollars or 5.55 Pounds.
*/
@NotNull
String format(BigDecimal amount);
String format(final String pluginName, BigDecimal amount);

/**
* Plugins use this method to format a given BigDecimal amount into a human-readable
* amount using your economy plugin's currency names/conventions.
*
* @param pluginName The name of the plugin that is calling the method.
* @param amount to format.
* @param currency the currency to use for the format.
*
* @return Human-readable string describing amount, ie 5 Dollars or 5.55 Pounds.
*/
@NotNull
String format(BigDecimal amount, final String currency);
String format(final String pluginName, BigDecimal amount, final String currency);

/**
* Returns true if a currency with the specified name exists.
Expand All @@ -114,30 +117,34 @@ public interface Economy {
/**
* Used to get the default currency. This could be the default currency for the server globally or
* for the default world if the implementation supports multi-world.
*
* @param pluginName The name of the plugin that is calling the method.
* @return The currency that is the default for the server if multi-world support is not available
* otherwise the default for the default world.
*
*/
@NotNull
String getDefaultCurrency();
String getDefaultCurrency(final String pluginName);

/**
* Returns the name of the default currency in plural form. If the economy being used
* does not support currency names then an empty string will be returned.
*
* @param pluginName The name of the plugin that is calling the method.
* @return name of the currency (plural) ie: Dollars or Pounds.
*/
@NotNull
String defaultCurrencyNamePlural();
String defaultCurrencyNamePlural(final String pluginName);

/**
* Returns the name of the default currency in singular form. If the economy being used
* does not support currency names then an empty string will be returned.
*
* @param pluginName The name of the plugin that is calling the method.
* @return name of the currency (singular) ie: Dollar or Pound.
*/
@NotNull
String defaultCurrencyNameSingular();
String defaultCurrencyNameSingular(final String pluginName);

/**
* Returns a list of currencies used by the economy plugin. These are able to be used
Expand Down Expand Up @@ -514,4 +521,4 @@ public interface Economy {
* @return true if the account permission was successfully updated, false otherwise
*/
boolean updateAccountPermission(final String pluginName, final UUID accountID, final UUID uuid, final AccountPermission permission, final boolean value);
}
}

0 comments on commit ff79045

Please sign in to comment.