EconomyResponse error

Discussion in 'Plugin Development' started by vjttq, Dec 29, 2022.

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

    vjttq

    Hi guys, im developing a shop plugin for my server and when i run the plugin and click the item in the gui, appears an error in console telling me there is an error at line 60 (r = econ.withdrawPlayer(nick, 100);) but intellij doesn't report any error.

    there is the code:
    Code:
    public class Events implements Listener {
       private Plugin plugin = DecoiledShop.getPlugin(DecoiledShop.class);
       public static Economy econ = null;
       public static EconomyResponse r;
       private boolean setupEconomy() {
         if (getServer().getPluginManager().getPlugin("Vault") == null) {
           return false;
         }
         RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
         if (rsp == null) {
           return false;
         }
         econ = rsp.getProvider(); return econ != null;
       }
    
       @EventHandler
       public void InvClick(InventoryClickEvent invclick){
         Player player = (Player) invclick.getWhoClicked();
         ClickType click = invclick.getClick();
         Inventory inv = invclick.getClickedInventory();
         ItemStack item = invclick.getCurrentItem();
         if(inv == null){
           return;
         }
         if(inv.getName().equals("§d§lSHOP")){
           invclick.setCancelled(true);
           if(item.equals(null) || !item.hasItemMeta()){
             return;
           }
           if(item.getItemMeta().getDisplayName().equals("§bSpada in Diamante")){
             player.closeInventory();String nick = player.getName();
             r = econ.withdrawPlayer(nick, 100);
             if (r.transactionSuccess()) {
               player.sendMessage("§aHai comprato una §dspada in diamante§a.");
               final Inventory inventory = player.getInventory();
               inventory.addItem(new ItemStack(Material.DIAMOND, 1));
             }else{
               player.sendMessage("§cNon hai i soldi necessari");
             }
           }
         }
       }
    }
    
     
    Last edited by a moderator: Dec 29, 2022
  2. Online

    timtower Administrator Administrator Moderator

    @vjttq What error do you get then?
     
  3. Offline

    bennie3211

    Did you initialize the econ variable? I can't see the function being called within your class.
     
  4. Offline

    vjttq

    i initialized it in the main class
     
Thread Status:
Not open for further replies.

Share This Page