Advertisement
Guest User

BalanceCommand

a guest
Jul 29th, 2015
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. package com.sosoh.essentials.commands.economy;
  2.  
  3. import org.spongepowered.api.entity.player.Player;
  4. import org.spongepowered.api.text.Texts;
  5. import org.spongepowered.api.text.format.TextColors;
  6. import org.spongepowered.api.util.command.CommandException;
  7. import org.spongepowered.api.util.command.CommandResult;
  8. import org.spongepowered.api.util.command.CommandSource;
  9. import org.spongepowered.api.util.command.args.CommandContext;
  10. import org.spongepowered.api.util.command.spec.CommandExecutor;
  11.  
  12. import com.sosoh.essentials.Main;
  13. import com.sosoh.essentials.services.EconomyService;
  14.  
  15. public class BalanceCommand implements CommandExecutor {
  16.  
  17. public EconomyService economy = Main.access.economy;
  18.  
  19. @Override
  20. public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
  21. if(src instanceof Player){
  22. Player player = (Player)src;
  23. int balance = economy.getBalance(player);
  24. player.sendMessage(Texts.builder("Your current balance is " + balance + economy.getSymbol()
  25. + " (" + economy.getName() + ")").build());
  26. }else{
  27. src.sendMessage(Texts.builder("This command can only be performed by a player.").color(TextColors.RED).build());
  28. }
  29. return CommandResult.success();
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement