Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //begin vault
- public Economy econ;
- //end vault
- public void onEnable() {
- //begin vault
- setupEconomy();
- //end vault
- }
- public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
- if(label.equalsIgnoreCase("yourcommand")) {
- if(cs.hasPermission("your.permission.node")) {
- //You can change the amout of money being deducted
- EconomyResponse er = econ.withdrawPlayer(cs.getName(), 1.0);
- if(er.transactionSuccess()) {
- //The player has enough money and no errors occured
- //Do your command here
- return true;
- }
- else {
- cs.sendMessage(ChatColor.RED + "Insufficent funds!");
- return true;
- }
- }
- else {
- cs.sendMessage(ChatColor.RED + "You do not have permission!");
- return true;
- }
- }
- return false;
- }
- //Some parts of this code are copied from Vault. You will know by the code starting with "begin vault". At the end there should be a "end vault".
- //begin vault
- 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;
- }
- //end vault
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement