Solved help with Vault API

Discussion in 'Plugin Development' started by SM3XY_jAMES, Apr 7, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    SM3XY_jAMES

    Error: would anyone be able to assist me I have having a difficult time implementing Vault Economy from my plugin to this plugin <Edit by Moderator: Redacted not allowed paid resource url>

    Side Notes: _Player.getBalance(p) > Returns a Double

    Code:
    Code:
    package net.JameZ.data;
    
    import java.util.List;
    
    import org.bukkit.Bukkit;
    import org.bukkit.OfflinePlayer;
    
    import net.JameZ.Cucumber;
    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.economy.EconomyResponse;
    import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
    
    public class _Economy implements Economy {
     
    private Cucumber plugin;
       
      public _Economy(Cucumber plugin)
    
      {
            this.plugin = plugin;
      }
        @Override
        public boolean isEnabled()
        {
            return Bukkit.getServer().getPluginManager().getPlugin("Vault").isEnabled();
        }
     
        @Override
        public boolean hasBankSupport() {return false;}
     
        @Override
        public EconomyResponse bankBalance(String arg0) {return null;}
    
        @Override
        public EconomyResponse bankDeposit(String arg0, double arg1) {return null;}
    
        @Override
        public EconomyResponse bankHas(String arg0, double arg1) {return null;}
    
        @Override
        public EconomyResponse bankWithdraw(String arg0, double arg1) {    return null;}
    
        @Override
        public EconomyResponse createBank(String arg0, String arg1) {return null;}
    
        @Override
        public EconomyResponse createBank(String arg0, OfflinePlayer arg1) {return null;}
    
        @Override
        public EconomyResponse isBankMember(String arg0, String arg1) {return null;}
    
        @Override
        public EconomyResponse isBankMember(String arg0, OfflinePlayer arg1) {return null;}
    
        @Override
        public EconomyResponse isBankOwner(String arg0, String arg1) {return null;}
    
        @Override
        public EconomyResponse isBankOwner(String arg0, OfflinePlayer arg1) {return null;}
     
        @Override
        public EconomyResponse deleteBank(String arg0) {    return null;}
     
        @Override
        public boolean hasAccount(String arg0) {    return false;}
    
        @Override
        public boolean hasAccount(OfflinePlayer arg0) {    return false;}
    
        @Override
        public boolean hasAccount(String arg0, String arg1) {return false;}
    
        @Override
        public boolean hasAccount(OfflinePlayer arg0, String arg1) {return false;}
     
        @Override
        public List<String> getBanks() {return null;}
     
     
     
        @Override
        public boolean createPlayerAccount(String player)
        {
            _Player.setMoney(Bukkit.getPlayer(player), 0.0D);
            return true;
        }
    
        @Override
        public boolean createPlayerAccount(OfflinePlayer player)
        {
            _Player.setMoney(Bukkit.getPlayer(player.getUniqueId()), 0.0D);
            return true;
        }
    
        @Override
        public boolean createPlayerAccount(String player, String world)
        {
            return createPlayerAccount(player);
        }
    
        @Override
        public boolean createPlayerAccount(OfflinePlayer player, String world)
        {
            return createPlayerAccount(player);
        }
    
     
     
     
     
        @Override
        public String currencyNamePlural()
        {
            return "Dollars";
        }
    
        @Override
        public String currencyNameSingular()
        {
            return "Dollar";
        }
     
     
     
     
    
    
    
        @Override
        public EconomyResponse depositPlayer(String player, double amount)
        {
            _Player.addMoney(Bukkit.getPlayer(player), amount);
            return new EconomyResponse(amount, _Player.getBalance(Bukkit.getPlayer(player)), ResponseType.SUCCESS, "");
        }
    
        @Override
        public EconomyResponse depositPlayer(OfflinePlayer player, double amount)
        {
            _Player.addMoney(Bukkit.getPlayer(player.getName()), amount);
            return new EconomyResponse(amount, _Player.getBalance(Bukkit.getPlayer(player.getName())), ResponseType.SUCCESS, "");
        }
    
        @Override
        public EconomyResponse depositPlayer(String player, String world, double amount)
        {
            return depositPlayer(player, amount);
        }
    
        @Override
        public EconomyResponse depositPlayer(OfflinePlayer player, String world, double amount)
        {
            return depositPlayer(player, amount);
        }
     
     
     
     
        @Override
        public String format(double amount)
        {
            return _Server.getFormattedNumber(amount);
        }
    
        @Override
        public int fractionalDigits()
        {
            return 2;
        }
    
     
     
     
     
        @Override
        public double getBalance(String player)
        {
            return _Player.getBalance(Bukkit.getPlayer(player));
        }
    
        @Override
        public double getBalance(OfflinePlayer player)
        {
            return _Player.getBalance(Bukkit.getPlayer(player.getUniqueId()));
        }
    
        @Override
        public double getBalance(String player, String world)
        {
            return getBalance(player);
        }
    
        @Override
        public double getBalance(OfflinePlayer player, String world)
        {
            return getBalance(player);
        }
    
    
        @Override
        public String getName()
        {
            return "Cucumber_Econ";
        }
    
     
     
     
     
        @Override
        public boolean has(String player, double amount)
        {
            return _Player.getBalance(Bukkit.getPlayer(player)) >= amount;
        }
    
        @Override
        public boolean has(OfflinePlayer player, double amount)
        {
            return _Player.getBalance(Bukkit.getPlayer(player.getUniqueId())) >= amount;
        }
    
        @Override
        public boolean has(String player, String world, double amount)
        {
            return has(player, amount);
        }
    
        @Override
        public boolean has(OfflinePlayer player, String world, double amount)
        {
            return has(player, amount);
        }
     
     
     
    
        public boolean removeMoney(String p, double amount)
        {
            if (_Player.getBalance(Bukkit.getPlayer(p).getUniqueId().toString()) < 0.0)
            {
                return false;         
            }
            _Player.setMoney(Bukkit.getPlayer(p), (_Player.getBalance(Bukkit.getPlayer(p))- amount));
            return true;
        } 
     
        @Override
        public EconomyResponse withdrawPlayer(String player, double amount)
        {
            return new EconomyResponse(amount, _Player.getBalance(Bukkit.getPlayer(player).getUniqueId().toString()) - amount, removeMoney(player, amount) ? ResponseType.SUCCESS : ResponseType.FAILURE, this.plugin.getMessage(true, "money.not-enough") );
        }
     
        @Override
        public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount)
        {
            rerturn new EconomyResponse(amount, _Player.getBalance(Bukkit.getPlayer(player.getUniqueId().toString())) - amount, removeMoney(player.getUniqueId().toString(), amount) ? ResponseType.SUCCESS : ResponseType.FAILURE, this.plugin.getMessage(true, "money.not-enough") );
        }
     
        @Override
        public EconomyResponse withdrawPlayer(String player, String world, double amount)
        {
            return withdrawPlayer(player, amount);
        }
    
        @Override
        public EconomyResponse withdrawPlayer(OfflinePlayer player, String world, double amount)
        {
            return withdrawPlayer(player, amount);
        }
    
    }

    Stacktrace:
    Code:
    > [06:56:37 INFO]: ItZ_JameZ_ issued server command: /shop blocks
    > [06:56:38 ERROR]: Could not pass event InventoryClickEvent to ShopGUIPlus v1.19.1
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[server.jar:git-Spigot-5f38d38-12698ea]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[server.jar:git-Spigot-5f38d38-12698ea]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [server.jar:git-Spigot-5f38d38-12698ea]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [server.jar:git-Spigot-5f38d38-12698ea]
    at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1630) [server.jar:git-Spigot-5f38d38-12698ea]
    at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(SourceFile:31) [server.jar:git-Spigot-5f38d38-12698ea]
    at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(SourceFile:9) [server.jar:git-Spigot-5f38d38-12698ea]
    at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [server.jar:git-Spigot-5f38d38-12698ea]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_202]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_202]
    at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [server.jar:git-Spigot-5f38d38-12698ea]
    at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [server.jar:git-Spigot-5f38d38-12698ea]
    at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [server.jar:git-Spigot-5f38d38-12698ea]
    at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [server.jar:git-Spigot-5f38d38-12698ea]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [server.jar:git-Spigot-5f38d38-12698ea]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_202]
    Caused by: java.lang.StackOverflowError
    at net.JameZ.data._Economy.withdrawPlayer(_Economy.java:268) ~[?:?]
    at net.JameZ.data._Economy.withdrawPlayer(_Economy.java:268) ~[?:?]
    at net.JameZ.data._Economy.withdrawPlayer(_Economy.java:268) ~[?:?]
    at net.JameZ.data._Economy.withdrawPlayer(_Economy.java:268) ~[?:?]
    at net.JameZ.data._Economy.withdrawPlayer(_Economy.java:268) ~[?:?]
    at net.JameZ.data._Economy.withdrawPlayer(_Economy.java:268) ~[?:?]
    at net.JameZ.data._Economy.withdrawPlayer(_Economy.java:268) ~[?:?]
    at net.JameZ.data._Economy.withdrawPlayer(_Economy.java:268) ~[?:?]
    at net.JameZ.data._Economy.withdrawPlayer(_Economy.java:268) ~[?:?]
    at net.JameZ.data._Economy.withdrawPlayer(_Economy.java:268) ~[?:?]
    at net.JameZ.data._Economy.withdrawPlayer(_Economy.java:268) ~[?:?]
    at net.JameZ.data._Economy.withdrawPlayer(_Economy.java:268) ~[?:?]
    at net.JameZ.data._Economy.withdrawPlayer(_Economy.java:268) ~[?:?]
     
  2. Offline

    Shqep

    It’s a StackOverflowError at line #268. It seems like there was an endless loop of calling the metthod withdrawPlayer().
     
    Last edited: Apr 7, 2019
  3. Offline

    SM3XY_jAMES

    .
     
    Last edited: Apr 12, 2019
Thread Status:
Not open for further replies.

Share This Page