Economy is Deprecated Warning

Discussion in 'Plugin Development' started by 6zero, Sep 4, 2019.

  1. Offline

    6zero

    Minecraft Version 1.9 (how does that matter)

    Code:
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.PlayerInventory;
    import org.bukkit.plugin.RegisteredServiceProvider;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.economy.EconomyResponse;
    
    public class Main extends JavaPlugin implements Listener {
    
        public static Economy econ = null;
    
        public void onEnable() {
            if (!setupEconomy()) {
                getLogger().severe(
                        String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
                getServer().getPluginManager().disablePlugin(this);
                return;
            }
        }
    
        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;
        }
    
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "Only players can get kits!");
                return true;
            }
    
            Player p = (Player) sender;
            PlayerInventory pi = p.getInventory();
    
            if (cmd.getName().equalsIgnoreCase("kit")) {
                EconomyResponse r = econ.withdrawPlayer(p.getName(), 10);
                if (r.transactionSuccess()) {
                    pi.addItem(new ItemStack(Material.APPLE, 5));
                    p.sendMessage(ChatColor.GREEN + "You got your kit!");
                    return true;
                } else {
                    p.sendMessage(ChatColor.RED + "You cannot get a kit at this time.");
                    return true;
                }
            }
    
            if (cmd.getName().equalsIgnoreCase("ci")) {
                pi.clear();
                p.sendMessage(ChatColor.GREEN + "Inventory Cleared!");
            }
            return true;
        }
    }

    Code:
    @SuppressWarnings("deprecation")
                EconomyResponse r = econ.withdrawPlayer(p.getName(), 10);
     
  2. Offline

    timtower Moderator Moderator

    @6zero Just use the player there, not the name.
     
  3. Offline

    6zero

    ok thank you, but i have next problem
    [22:48:57 ERROR]: [Money] [Money] - Disabled due to no Vault dependency found!

    This is my plugin.yml
    Code:
    name: Money
    version: 1.0.0
    author: EDSEL
    main: Economy.Main
    depend: [Vault]
    
    commands:
      kit:
        description: Po
     
  4. Offline

    timtower Moderator Moderator

    @6zero Do you have an economy plugin installed?
     
  5. Offline

    6zero

    Yes
    Code:
    WARN]: [Vault] Stable Version: 1.7.2 is out! You are still running version: 1.5.6
     
  6. Offline

    timtower Moderator Moderator

    @6zero Vault is not an economy plugin
     
  7. Offline

    6zero

    "Vault is a Economy/Permission plugin for hooking into the various Economy and Permission plugins."
     
  8. Offline

    timtower Moderator Moderator

    It is an API, it gives the ability to connect both sides without knowing which one is which.
     
  9. Offline

    6zero

    ohh ok, what plugin do you recommend for Economy ?
     
  10. Offline

    CraftCreeper6

    @6zero
    Essentials/EssentialsX
     
    6zero likes this.
  11. Offline

    timtower Moderator Moderator

    @6zero That is a personal preference and I haven't used one for a really long time.
    Something you need to look for yourself.
     
    6zero likes this.
  12. Offline

    6zero

    @CraftCreeper6 Is there another plugin without sethome or something, claer Economy Plugin ?
     
  13. Offline

    timtower Moderator Moderator

    Any besides Essentials.
     

Share This Page