I need to implement vault. I used the tutorial that was provided, but I have an error. Here is my code: Code: package com.github.KeybordPiano459.vaulttest; import java.util.logging.Level; import java.util.logging.Logger; import net.milkbowl.vault.Vault; import net.milkbowl.vault.chat.Chat; import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.EconomyResponse; import net.milkbowl.vault.permission.Permission; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; public class vaulttest extends JavaPlugin { private static final Logger log = Logger.getLogger("Minecraft"); public static Economy econ = null; public static Permission perms = null; public static Chat chat = null; @Override public void onDisable() { log.info(String.format("[%s] Disabled Version %s", getDescription().getName(), getDescription().getVersion())); } @Override public void onEnable() { if (!setupEconomy() ) { log.info(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName())); getServer().getPluginManager().disablePlugin(this); return; } setupPermissions(); setupChat(); } 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; } private boolean setupChat() { RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class); chat = rsp.getProvider(); return chat != null; } private boolean setupPermissions() { RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class); perms = rsp.getProvider(); return perms != null; } public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { if(!(sender instanceof Player)) { log.info("Only players are supported for this Example Plugin, but you should not do this!!!"); return true; } Player player = (Player) sender; if(command.getLabel().equals("test-economy")) { // Lets give the player 1.05 currency (note that SOME economic plugins require rounding! sender.sendMessage(String.format("You have %s", econ.format(econ.getBalance(player.getName()).amount))); EconomyResponse r = econ.depositPlayer(player.getName(), 1.05); if(r.transactionSuccess()) { sender.sendMessage(String.format("You were given %s and now have %s", econ.format(r.amount), econ.format(r.balance))); } else { sender.sendMessage(String.format("An error occured: %s", r.errorMessage)); } return true; } else if(command.getLabel().equals("test-permission")) { // Lets test if user has the node "example.plugin.awesome" to determine if they are awesome or just suck if(perms.has(player, "example.plugin.awesome")) { sender.sendMessage("You are awesome!"); } else { sender.sendMessage("You suck!"); } return true; } else { return false; } } } My error is under if (command.getLabel().equals("test-economy")) {, where it says (player.getName()).amount))); two lines below what I said above. Can someone help me out, I really need to hook vault into one of my plugins.
Sorry, the error is 'amount cannot be resolved or is not a field'. Also, if this helps, I'm running Eclipse Juno on a Mac 64-Bit.
You're asking the code for the "amount" variable, which it couldn't find, I belive you wanted to use amount() which is a method.
The econ.getBalance(player.getName()) returns a double, you don't need to use other methods on it since it's already a value you can use. But I notice th exact code in that tutorial, it should be edited beacuse it's invalid :}
Just remove the .amount ... If you're planing on making plugins, you should really read on basic Java
I'm taking a class =/ and this is only my second day. Give me time! You've already made three plugins.
Just out of curiosity, is there a page somewhere on the internet that shows me how to make a command cost vault money to use?
http://mythcraft.dyndns.org/javadoc/vault - it's linked from the overview page of Vault. I realize there may be issues on the github help page, as it was updated, and hasn't had a full code check, but if you take a couple seconds to actually look at what your IDE tells you about the Economy class you should be able to deduce what is going on with little effort.
I don't think that helped much. I just want to make it so that when a person enters a command (/example) they get charged money on their iconomy, essentialseco, or whatever other economy account they have.
You realize that http://mythcraft.dyndns.org/javadoc/vault/ is THE javadoc for vault and contains all the information you could possibly ever want on the vault api. If you don't want to take the time just to look for what you need, then yes, you are spamming these forums.
Im pretty sure that the function I would use is 'bankWithdraw'. Only because I'm a java noob and not too sure how to use these functions, I'm just going to ask you, how do I use this function?
Same way you use any method. You really need to learn some basic java before coming to bukkit, otherwise the best you can do is copy off of someone else's code.
bankWithdraw is only for banks. not player accounts. and sorry, it's a lower-case v for vault. Forgot that currently it's case-sensitive cause I haven't aliased it in my apache configs.
I don't think he was being rude at all. It's great that you're learning Java, and I wish you every success with that, but you need to understand: this forum is for discussing development of Bukkit plugins in Java. It's not a forum to teach you about Java basics - for that, you have your class, you have web tutorials, you have books, and you have the source of many existing plugins to refer to. Like it or not, a certain amount of Java knowledge needs to be assumed before you start writing Bukkit plugins.
Does anyone know why this isn't working? Code: if(cmd.getName().equalsIgnoreCase("test")) { sender.sendMessage(getConfig().getString("test")); EconomyResponse r = econ.withdrawPlayer(player.getName(), 0.50); if(r.transactionSuccess()) { sender.sendMessage("$0.50 has been withdrawn from your account."); } else { sender.sendMessage("An error occured: %s"); } return true; } else { return false; }
When I use this I get an error (The method withdrawPlayer(String, double) in the type Economy is not applicable for the arguments (String, String)). Does anyone know why and how to fix it? Code: Player player = (Player) sender; if(cmd.getName().equalsIgnoreCase("test")) { sender.sendMessage(getConfig().getString("test")); EconomyResponse r = econ.withdrawPlayer(player.getName(), getConfig().getString("cost")); if(r.transactionSuccess()) { sender.sendMessage("$1 has been withdrawn from your account."); } else { sender.sendMessage("An error occured: %s"); } return true; } else { return false; }