HELP!

Discussion in 'Spigot Plugin Development' started by Creepermanthe3rd, Apr 17, 2017.

  1. Im working on a money note plugin and everything is working except if I do something like /withdraw 10.5 I get an internal error but ints work fine.
     
  2. Please post your code.
    EDIT: Your errors would be a good thing to post, too!
     
  3. It's probably because you are using Integer instead of Double
     
  4. We have nothing, and then we do nothing
     
  5. Code (Text):

    if(cmd.getName().equalsIgnoreCase("withdraw")) {
                if(args.length == 0) {
                    p.sendMessage(Main.Prefix + Main.color("&cCorrect Usage: /Withdraw (Amount)"));
                }else {
                if(args.length == 1) {
                    Pattern pattern = Pattern.compile("[a-zA-Z]");
                    Matcher m = pattern.matcher(args[0]);
                    if (m.find()) {
                       p.sendMessage(Main.color("&cError, Please only use numbers!!"));
                    }else {
                        int amount = Integer.parseInt(args[0]);
                       
                        double bal = Main.eco.getBalance(p);
                        if(amount == 0) {
                            p.sendMessage(Main.Prefix + Main.color("&4Invalid amount!"));
                        }
                        else    if(bal >= amount) {
                            ItemStack money = new ItemStack(Material.PAPER);
                            ItemMeta moneyM = money.getItemMeta();
                            moneyM.setDisplayName(Main.color("&2&l$" + amount + Main.color(" &7(Right Click)")));
                            moneyM.setLore(Arrays.asList(Main.color("&a&lWithdrawn By: &b") + p.getName(), Main.color("&a&lAmmount: &2$") + amount));
                            money.setItemMeta(moneyM);
                           
                            Main.eco.withdrawPlayer(p, amount);
                            p.sendMessage(Main.color("&c&l- &4&l$" + amount));
                            p.getInventory().addItem(money);
                        }              
                        else {
                            p.sendMessage(Main.Prefix + Main.color("&4You do not have enough money, your current balance is: &2$") + bal);
                        }
                    }
                }
                }
                }
     
  6. @DizMizzer Was right, use a double or float.