Economy linking?

Discussion in 'Plugin Development' started by Sizableshrimp0, May 25, 2015.

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

    Sizableshrimp0

    I need help linking essentials and iconomy to my plugin. I also need to know how to charge players. Please help.
     
  2. Offline

    mythbusterma

  3. Offline

    Sizableshrimp0

  4. Offline

    567legodude

  5. Offline

    Zombie_Striker

  6. Offline

    Sizableshrimp0

    Right now I am setting it up. Thanks for the help! I'll let you know if its not working.

    I keep getting errors about vaults chat.
     
    Last edited by a moderator: May 25, 2015
  7. Offline

    Konato_K

  8. Offline

    Sizableshrimp0

    @Konato_K
    I removed the chat and permissions for vault. There is no errors anymore. I am trying to make it so when a player kills another player, they get $3. When I do it, the death message I created doesn't popup, and they don't get any money. I triple checked and there is no errors.
     
  9. Offline

    nverdier

    Please post code.
     
  10. Offline

    Sizableshrimp0

    Code:
    public class MyPlugin extends JavaPlugin {
    
        private static final Logger log = Logger.getLogger("Minecraft");
        public static Economy econ = null;
    
        public void onDisable() {
            log.info(String.format("[%s] Disabled Version %s", getDescription().getName(), getDescription().getVersion()));
        }
    
        public void onEnable() {
            if (!setupEconomy() ) {
                log.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;
        }
    
      
             @EventHandler
             public void onKill(PlayerDeathEvent e)
             {
             String killed = e.getEntity().getName();
             String killer = e.getEntity().getKiller().getName();
             EconomyResponse r = econ.depositPlayer(killer, 3.00);
             EconomyResponse d = econ.withdrawPlayer(killed, 3.00);
             if(r.transactionSuccess()){
                 if(d.transactionSuccess()){
                 }
                 {
                 e.getEntity().getKiller().sendMessage(ChatColor.DARK_PURPLE + "You have killed " + ChatColor.GRAY + e.getEntity().getName() + ChatColor.DARK_PURPLE + " , and have been given 3$!");
                 e.getEntity().sendMessage(ChatColor.GRAY + "You have been killed by " + ChatColor.DARK_PURPLE + e.getEntity().getName() + ChatColor.GRAY + ", and lost $3!");
                 return;
             }
           
    }
             }
    }
           
    
    
       
    
    
    
        
     
  11. Offline

    Konato_K

    nverdier likes this.
Thread Status:
Not open for further replies.

Share This Page