Config money is less then

Discussion in 'Plugin Development' started by ChucknorisSR, Jun 23, 2015.

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

    ChucknorisSR

    So I am creating a kitpvp server. I have it when a player does /levelup it will give them a level. As you can see I want it to cancel the command if the money is less then 50 000. I don't know how to do this.

    Code:
    Code:
    package skits.commands;
    
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    import skits.main.sKitmain;
    import skits.util.CurrencyAPI;
    import skits.util.LevelAPI;
    
    public class LevelCommand implements CommandExecutor {
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(!(sender instanceof Player)) {
                return false;
            }  
       
            Player player = (Player)sender;
                String nameMoney = player.getName();
                String money = sKitmain.config.getString(nameMoney + ".Money");
                if (money.isEmpty() || money.(<50000) || money.equals(null));
                player.sendMessage(ChatColor.BLUE + "KitPVP> " + ChatColor.GRAY + "You don't have enough money!");   
                return false;
                        LevelAPI.giveLevel(player, 1);
                        CurrencyAPI.takeMoney(player, 50000); 
                return true;
           
                }  
        }
     
  2. Offline

    JaydenKieran

    1. Your if statements are ending with a semi-colon instead of an opening and closing bracket, which will cause issues.
    2. You can't check if a String is less than an Integer.
    Code:
    String money = sKitmain.config.getString(nameMoney + ".Money");
    Get an Integer from your configuration file, and then create the variable as an Integer. Then, something like "money < 5000" would work. You also would not need to the other checks you've got in that if statement, because the if statement will run for anything under 5000.
     
Thread Status:
Not open for further replies.

Share This Page