Advertisement
Guest User

Untitled

a guest
May 31st, 2015
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.04 KB | None | 0 0
  1. public class EconomyService implements Economy {
  2.  
  3.     @Override
  4.     public boolean isEnabled() {
  5.         return true;
  6.     }
  7.  
  8.     @Override
  9.     public String getName() {
  10.         return "MoConomy";
  11.     }
  12.  
  13.     @Override
  14.     public boolean hasBankSupport() {
  15.         return false;
  16.     }
  17.  
  18.     @Override
  19.     public int fractionalDigits() {
  20.         return 2;
  21.     }
  22.  
  23.     @Override
  24.     public String format(double v) {
  25.         return new DecimalFormat("#,##0.00").format(v);
  26.     }
  27.  
  28.     @Override
  29.     public String currencyNamePlural() {
  30.         return MoConomy.config.getProperty("currencyName").toString();
  31.     }
  32.  
  33.     @Override
  34.     public String currencyNameSingular() {
  35.         return MoConomy.config.getProperty("currencyName").toString();
  36.     }
  37.  
  38.     @Override
  39.     public boolean hasAccount(String s) {
  40.         return MoConomy.db.hasPlayer(s);
  41.     }
  42.  
  43.     @Override
  44.     public boolean hasAccount(OfflinePlayer offlinePlayer) {
  45.         return MoConomy.db.hasPlayer(offlinePlayer.getUniqueId());
  46.     }
  47.  
  48.     @Override
  49.     public boolean hasAccount(String s, String s1) {
  50.         return MoConomy.db.hasPlayer(s);
  51.     }
  52.  
  53.     @Override
  54.     public boolean hasAccount(OfflinePlayer offlinePlayer, String s) {
  55.         return MoConomy.db.hasPlayer(offlinePlayer.getUniqueId());
  56.     }
  57.  
  58.     @Override
  59.     public double getBalance(String s) {
  60.         final UUID uuid = MoConomy.uuidFetcher.getUUID(s);
  61.         if(uuid != null && MoConomy.playerCache.containsKey(uuid))
  62.             return MoConomy.playerCache.get(uuid).getBalance().doubleValue();
  63.         else
  64.             return MoConomy.db.getBalance(s).get().doubleValue();
  65.     }
  66.  
  67.     @Override
  68.     public double getBalance(OfflinePlayer offlinePlayer) {
  69.         final UUID uuid = offlinePlayer.getUniqueId();
  70.         if(uuid != null && MoConomy.playerCache.containsKey(uuid))
  71.             return MoConomy.playerCache.get(uuid).getBalance().doubleValue();
  72.         else
  73.             return MoConomy.db.getBalance(uuid).get().doubleValue();
  74.     }
  75.  
  76.     @Override
  77.     public double getBalance(String s, String s1) {
  78.         final UUID uuid = MoConomy.uuidFetcher.getUUID(s);
  79.         if(uuid != null && MoConomy.playerCache.containsKey(uuid))
  80.             return MoConomy.playerCache.get(uuid).getBalance().doubleValue();
  81.         else
  82.             return MoConomy.db.getBalance(s).get().doubleValue();
  83.     }
  84.  
  85.     @Override
  86.     public double getBalance(OfflinePlayer offlinePlayer, String s) {
  87.         final UUID uuid = offlinePlayer.getUniqueId();
  88.         if(uuid != null && MoConomy.playerCache.containsKey(uuid))
  89.             return MoConomy.playerCache.get(uuid).getBalance().doubleValue();
  90.         else
  91.             return MoConomy.db.getBalance(uuid).get().doubleValue();
  92.     }
  93.  
  94.     @Override
  95.     public boolean has(String s, double v) {
  96.         return getBalance(s) >= v;
  97.     }
  98.  
  99.     @Override
  100.     public boolean has(OfflinePlayer offlinePlayer, double v) {
  101.         return getBalance(offlinePlayer) >= v;
  102.     }
  103.  
  104.     @Override
  105.     public boolean has(String s, String s1, double v) {
  106.         return getBalance(s) >= v;
  107.     }
  108.  
  109.     @Override
  110.     public boolean has(OfflinePlayer offlinePlayer, String s, double v) {
  111.         return getBalance(offlinePlayer) >= v;
  112.     }
  113.  
  114.     @Override
  115.     public EconomyResponse withdrawPlayer(String s, double v) {
  116.         final UUID uuid = MoConomy.uuidFetcher.getUUID(s);
  117.         if(uuid != null && MoConomy.playerCache.containsKey(uuid)) {
  118.             MoConomy.playerCache.get(uuid).decreaseBalance(BigDecimal.valueOf(v));
  119.             return new EconomyResponse(v, getBalance(s), EconomyResponse.ResponseType.SUCCESS, "Success");
  120.         } else {
  121.             MoConomy.db.decreaseBalance(s, BigDecimal.valueOf(v));
  122.             return new EconomyResponse(v, getBalance(s), EconomyResponse.ResponseType.SUCCESS, "Success");
  123.         }
  124.     }
  125.  
  126.     @Override
  127.     public EconomyResponse withdrawPlayer(OfflinePlayer offlinePlayer, double v) {
  128.         final UUID uuid = offlinePlayer.getUniqueId();
  129.         if(MoConomy.playerCache.containsKey(uuid)) {
  130.             MoConomy.playerCache.get(uuid).decreaseBalance(BigDecimal.valueOf(v));
  131.             return new EconomyResponse(v, getBalance(offlinePlayer), EconomyResponse.ResponseType.SUCCESS, "Success");
  132.         } else {
  133.             MoConomy.db.decreaseBalance(uuid, BigDecimal.valueOf(v));
  134.             return new EconomyResponse(v, getBalance(offlinePlayer), EconomyResponse.ResponseType.SUCCESS, "Success");
  135.         }
  136.     }
  137.  
  138.     @Override
  139.     public EconomyResponse withdrawPlayer(String s, String s1, double v) {
  140.         final UUID uuid = MoConomy.uuidFetcher.getUUID(s);
  141.         if(uuid != null && MoConomy.playerCache.containsKey(uuid)) {
  142.             MoConomy.playerCache.get(uuid).decreaseBalance(BigDecimal.valueOf(v));
  143.             return new EconomyResponse(v, getBalance(s), EconomyResponse.ResponseType.SUCCESS, "Success");
  144.         } else {
  145.             MoConomy.db.decreaseBalance(s, BigDecimal.valueOf(v));
  146.             return new EconomyResponse(v, getBalance(s), EconomyResponse.ResponseType.SUCCESS, "Success");
  147.         }
  148.     }
  149.  
  150.     @Override
  151.     public EconomyResponse withdrawPlayer(OfflinePlayer offlinePlayer, String s, double v) {
  152.         final UUID uuid = offlinePlayer.getUniqueId();
  153.         if(MoConomy.playerCache.containsKey(uuid)) {
  154.             MoConomy.playerCache.get(uuid).decreaseBalance(BigDecimal.valueOf(v));
  155.             return new EconomyResponse(v, getBalance(offlinePlayer), EconomyResponse.ResponseType.SUCCESS, "Success");
  156.         } else {
  157.             MoConomy.db.decreaseBalance(uuid, BigDecimal.valueOf(v));
  158.             return new EconomyResponse(v, getBalance(offlinePlayer), EconomyResponse.ResponseType.SUCCESS, "Success");
  159.         }
  160.     }
  161.  
  162.     @Override
  163.     public EconomyResponse depositPlayer(String s, double v) {
  164.         final UUID uuid = MoConomy.uuidFetcher.getUUID(s);
  165.         if(uuid != null && MoConomy.playerCache.containsKey(uuid)) {
  166.             MoConomy.playerCache.get(uuid).increaseBalance(BigDecimal.valueOf(v));
  167.             return new EconomyResponse(v, getBalance(s), EconomyResponse.ResponseType.SUCCESS, "Success");
  168.         } else {
  169.             MoConomy.db.increaseBalance(s, BigDecimal.valueOf(v));
  170.             return new EconomyResponse(v, getBalance(s), EconomyResponse.ResponseType.SUCCESS, "Success");
  171.         }
  172.     }
  173.  
  174.     @Override
  175.     public EconomyResponse depositPlayer(OfflinePlayer offlinePlayer, double v) {
  176.         final UUID uuid = offlinePlayer.getUniqueId();
  177.         if(MoConomy.playerCache.containsKey(uuid)) {
  178.             MoConomy.playerCache.get(uuid).increaseBalance(BigDecimal.valueOf(v));
  179.             return new EconomyResponse(v, getBalance(offlinePlayer), EconomyResponse.ResponseType.SUCCESS, "Success");
  180.         } else {
  181.             MoConomy.db.increaseBalance(uuid, BigDecimal.valueOf(v));
  182.             return new EconomyResponse(v, getBalance(offlinePlayer), EconomyResponse.ResponseType.SUCCESS, "Success");
  183.         }
  184.     }
  185.  
  186.     @Override
  187.     public EconomyResponse depositPlayer(String s, String s1, double v) {
  188.         final UUID uuid = MoConomy.uuidFetcher.getUUID(s);
  189.         if(uuid != null && MoConomy.playerCache.containsKey(uuid)) {
  190.             MoConomy.playerCache.get(uuid).increaseBalance(BigDecimal.valueOf(v));
  191.             return new EconomyResponse(v, getBalance(s), EconomyResponse.ResponseType.SUCCESS, "Success");
  192.         } else {
  193.             MoConomy.db.increaseBalance(s, BigDecimal.valueOf(v));
  194.             return new EconomyResponse(v, getBalance(s), EconomyResponse.ResponseType.SUCCESS, "Success");
  195.         }
  196.     }
  197.  
  198.     @Override
  199.     public EconomyResponse depositPlayer(OfflinePlayer offlinePlayer, String s, double v) {
  200.         final UUID uuid = offlinePlayer.getUniqueId();
  201.         if(MoConomy.playerCache.containsKey(uuid)) {
  202.             MoConomy.playerCache.get(uuid).increaseBalance(BigDecimal.valueOf(v));
  203.             return new EconomyResponse(v, getBalance(offlinePlayer), EconomyResponse.ResponseType.SUCCESS, "Success");
  204.         } else {
  205.             MoConomy.db.increaseBalance(uuid, BigDecimal.valueOf(v));
  206.             return new EconomyResponse(v, getBalance(offlinePlayer), EconomyResponse.ResponseType.SUCCESS, "Success");
  207.         }
  208.     }
  209.  
  210.     @Override
  211.     public EconomyResponse createBank(String s, String s1) {
  212.         return null;
  213.     }
  214.  
  215.     @Override
  216.     public EconomyResponse createBank(String s, OfflinePlayer offlinePlayer) {
  217.         return null;
  218.     }
  219.  
  220.     @Override
  221.     public EconomyResponse deleteBank(String s) {
  222.         return null;
  223.     }
  224.  
  225.     @Override
  226.     public EconomyResponse bankBalance(String s) {
  227.         return null;
  228.     }
  229.  
  230.     @Override
  231.     public EconomyResponse bankHas(String s, double v) {
  232.         return null;
  233.     }
  234.  
  235.     @Override
  236.     public EconomyResponse bankWithdraw(String s, double v) {
  237.         return null;
  238.     }
  239.  
  240.     @Override
  241.     public EconomyResponse bankDeposit(String s, double v) {
  242.         return null;
  243.     }
  244.  
  245.     @Override
  246.     public EconomyResponse isBankOwner(String s, String s1) {
  247.         return null;
  248.     }
  249.  
  250.     @Override
  251.     public EconomyResponse isBankOwner(String s, OfflinePlayer offlinePlayer) {
  252.         return null;
  253.     }
  254.  
  255.     @Override
  256.     public EconomyResponse isBankMember(String s, String s1) {
  257.         return null;
  258.     }
  259.  
  260.     @Override
  261.     public EconomyResponse isBankMember(String s, OfflinePlayer offlinePlayer) {
  262.         return null;
  263.     }
  264.  
  265.     @Override
  266.     public List<String> getBanks() {
  267.         return null;
  268.     }
  269.  
  270.     @Override
  271.     public boolean createPlayerAccount(String s) {
  272.         return MoConomy.db.createAccount(s);
  273.     }
  274.  
  275.     @Override
  276.     public boolean createPlayerAccount(OfflinePlayer offlinePlayer) {
  277.         return MoConomy.db.createAccount(offlinePlayer.getUniqueId());
  278.     }
  279.  
  280.     @Override
  281.     public boolean createPlayerAccount(String s, String s1) {
  282.         return MoConomy.db.createAccount(s);
  283.     }
  284.  
  285.     @Override
  286.     public boolean createPlayerAccount(OfflinePlayer offlinePlayer, String s) {
  287.         return MoConomy.db.createAccount(offlinePlayer.getUniqueId());
  288.     }
  289.  
  290. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement