Advertisement
Guest User

EconomyService Interface 1.0

a guest
May 7th, 2015
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.38 KB | None | 0 0
  1. public interface EconomyService {
  2.  
  3.     /**
  4.      * Executes the Transaction if not executed already.
  5.      *
  6.      * @param transaction Transaction - The Transaction to execute
  7.      * @return The same Transaction for chaining
  8.      */
  9.     Transaction execute(Transaction transaction);
  10.  
  11.     /**
  12.      * Creates and executes a Transaction.
  13.      *
  14.      * @param source      Player - The source player
  15.      * @param target      Player - The target player
  16.      * @param amount      double - The amount to transfer
  17.      * @param description String - The description to identify what happened in this transaction
  18.      * @return The resulting Transaction - will never be null
  19.      */
  20.     Optional<Transaction> execute(Player source, Player target, double amount, String description);
  21.  
  22.     /**
  23.      * Creates and executes a Transaction.
  24.      *
  25.      * @param source      UUID - The source player
  26.      * @param target      UUID - The target player
  27.      * @param amount      double - The amount to transfer
  28.      * @param description String - The description to identify what happened in this transaction
  29.      * @return The resulting Transaction - will never be null
  30.      */
  31.     Optional<Transaction> execute(UUID source, UUID target, double amount, String description);
  32.  
  33.     /**
  34.      * Creates and executes a Transaction.
  35.      *
  36.      * @param source      String - The source deposit name
  37.      * @param target      String - The target deposit name
  38.      * @param amount      double - The amount to transfer
  39.      * @param description String - The description to identify what happened in this transaction
  40.      * @return The resulting Transaction - will never be null
  41.      */
  42.     Optional<Transaction> execute(String source, String target, double amount, String description);
  43.  
  44.     /**
  45.      * Creates and executes a Transaction.
  46.      *
  47.      * @param target      Player - The target player
  48.      * @param amount      double - The amount to transfer
  49.      * @param description String - The description to identify what happened in this transaction
  50.      * @return The resulting Transaction - will never be null
  51.      */
  52.     Optional<Transaction> execute(Player target, double amount, String description);
  53.  
  54.     /**
  55.      * Creates and executes a Transaction.
  56.      *
  57.      * @param target      UUID - The target uuid/player
  58.      * @param amount      double - The amount to transfer
  59.      * @param description String - The description to identify what happened in this transaction
  60.      * @return The resulting Transaction - will never be null
  61.      */
  62.     Optional<Transaction> execute(UUID target, double amount, String description);
  63.  
  64.     /**
  65.      * Creates and executes a Transaction.
  66.      *
  67.      * @param target      String - The target deposit name
  68.      * @param amount      double - The amount to transfer
  69.      * @param description String - The description to identify what happened in this transaction
  70.      * @return The resulting Transaction - will never be null
  71.      */
  72.     Optional<Transaction> execute(String target, double amount, String description);
  73.  
  74.     /**
  75.      * Tests if the Transaction could be executed.
  76.      *
  77.      * @param source Player - The source player
  78.      * @param target Player - The target player
  79.      * @param amount double - The amount to transfer
  80.      * @return result of the test
  81.      */
  82.     boolean test(Player source, Player target, double amount);
  83.  
  84.     /**
  85.      * Tests if the Transaction could be executed.
  86.      *
  87.      * @param source UUID - The source player
  88.      * @param target UUID - The target player
  89.      * @param amount double - The amount to transfer
  90.      * @return result of the test
  91.      */
  92.     boolean test(UUID source, UUID target, double amount);
  93.  
  94.     /**
  95.      * Tests if the Transaction could be executed.
  96.      *
  97.      * @param source String - The source deposit name
  98.      * @param target String - The target deposit name
  99.      * @param amount double - The amount to transfer
  100.      * @return result of the test
  101.      */
  102.     boolean test(String source, String target, double amount);
  103.  
  104.     /**
  105.      * Tests if the Transaction could be executed.
  106.      *
  107.      * @param target Player - The target player
  108.      * @param amount double - The amount to transfer
  109.      * @return result of the test
  110.      */
  111.     boolean test(Player target, double amount);
  112.  
  113.     /**
  114.      * Tests if the Transaction could be executed.
  115.      *
  116.      * @param target UUID - The target player
  117.      * @param amount double - The amount to transfer
  118.      * @return result of the test
  119.      */
  120.     boolean test(UUID target, double amount);
  121.  
  122.     /**
  123.      * Tests if the Transaction could be executed.
  124.      *
  125.      * @param target String - The target deposit name
  126.      * @param amount double - The amount to transfer
  127.      * @return result of the test
  128.      */
  129.     boolean test(String target, double amount);
  130.  
  131.     /**
  132.      * Rollbacks the given Transaction if not rollbacked already.
  133.      *
  134.      * @param transaction Transaction - The Transaction to rollback
  135.      * @return The same Transaction for chaining
  136.      */
  137.     Optional<Transaction> rollback(Transaction transaction);
  138.  
  139.     /**
  140.      * Gets the deposit of this player, in case he doesn't have one, it will be created.
  141.      *
  142.      * @param player Player - The Player
  143.      * @return The resulting Deposit - will never be null
  144.      */
  145.     Optional<Deposit> getDeposit(Player player);
  146.  
  147.     /**
  148.      * Gets the deposit of a player by his UUID. This will not create one if the player doesn't have a deposit.
  149.      *
  150.      * @param uuid UUID - The UUID of the player
  151.      * @return The resulting Deposit - null if no deposit with this name exists
  152.      */
  153.     Optional<Deposit> getDeposit(UUID uuid);
  154.  
  155.     /**
  156.      * Gets a deposit by name. Deposits of players are formatted like this player:uuid.
  157.      *
  158.      * @param name String - Name of the deposit
  159.      * @return The resulting Deposit - null if no deposit with this name exists
  160.      */
  161.     Optional<Deposit> getDeposit(String name);
  162.  
  163.     /**
  164.      * Gets a deposit by name and optionally create it if not existing. Deposits of players are formatted like this player:uuid.
  165.      *
  166.      * @param name   String - Name of the deposit
  167.      * @param create boolean - Create it if not existing
  168.      * @return The existing/created deposit or null
  169.      */
  170.     Optional<Deposit> getDeposit(String name, boolean create);
  171.  
  172.     /**
  173.      * Get all deposits.
  174.      *
  175.      * @return All existing deposits.
  176.      */
  177.     Optional<Set<Deposit>> getDeposits();
  178.  
  179.     /**
  180.      * Set the major currency used.
  181.      *
  182.      * @param name String - The name of the major currency - example: Euro
  183.      * @param sign String - The sign of the major currency - example: €
  184.      * @return the EconomyService for chaining
  185.      */
  186.     EconomyService setMajorCurrency(String name, String sign);
  187.  
  188.     /**
  189.      * Set the major currency used.
  190.      *
  191.      * @param name String - The name of the minor currency - example: Cent
  192.      * @param sign String - The sign of the minor currency - example: ct
  193.      * @return the EconomyService for chaining
  194.      */
  195.     EconomyService setMinorCurrency(String name, String sign);
  196.  
  197.     /**
  198.      * Set the short format. Use {value} {majorValue} {minorValue} {majorName} {majorSign} [minorName} {minorSign}
  199.      *
  200.      * @param format String - The format to use
  201.      * @return the EconomyService for chaining
  202.      */
  203.     EconomyService setShortFormat(String format);
  204.  
  205.     /**
  206.      * Set the full format. Use {value} {majorValue} {minorValue} {majorName} {majorSign} [minorName} {minorSign}
  207.      *
  208.      * @param format String - The format to use
  209.      * @return the EconomyService for chaining
  210.      */
  211.     EconomyService setFullFormat(String format);
  212.  
  213.     /**
  214.      * Sanitizes the given amount. Will turn 5.386 to 5.38 for example.
  215.      *
  216.      * @param amount double - The amount to sanitize
  217.      * @return The sanitized amount
  218.      */
  219.     double sanitize(double amount);
  220.  
  221.     /**
  222.      * Formats the given value human readable.
  223.      *
  224.      * @param amount double - The amount to format
  225.      * @return The resulting String
  226.      */
  227.     String format(double amount);
  228.  
  229.     /**
  230.      * Formats the given value human readable.
  231.      *
  232.      * @param amount double - The amount to format
  233.      * @param format Format - The type of format to use
  234.      * @return The resulting String
  235.      */
  236.     String format(double amount, Format format);
  237.  
  238.     public enum Format {
  239.         SHORT,
  240.         FULL;
  241.     }
  242.  
  243. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement