package com.crossge.necessities.Commands.Economy;

import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class Cmdl2m extends EconomyCmd {
    public boolean commandUse(CommandSender sender, String[] args) {
        if (sender instanceof Player) {
            Player p = (Player) sender;

            if (args.length == 0) {
                p.sendMessage(ChatColor.AQUA + "/l2m <level_amount> - Convert levels to $$");
                return true;
            }

            int level;
            try {
                level = Integer.parseInt(args[0]);
            } catch (Throwable t) {
                p.sendMessage(ChatColor.AQUA + "/l2m <level_amount> - Convert levels to $$");
                return true;
            }

            if (p.getLevel() < level) {
                p.sendMessage("" + ChatColor.RED + ChatColor.BOLD + "You don't have that many levels!");
                return true;
            }

            double money = calculateMoney(level);
            p.setLevel(p.getLevel() - level);
            balc.removeMoney(p.getUniqueId(), money);
            //PShop.econ.depositPlayer(Bukkit.getOfflinePlayer(p.getUniqueId()), money);

            p.sendMessage("" + ChatColor.BOLD + ChatColor.GREEN + "+" + ChatColor.RESET + " Converted " + ChatColor.BOLD + level + ChatColor.RESET + " levels to " + ChatColor.BOLD + "$" + money + ChatColor.RESET + "!");
        }

        return true;
    }

    public double calculateMoney(int level) {
        if (level <= 0)
            return 0.0;

        if (level <= 16) {
            //At level 1, you get 100
            //At level 16, you get 1,600
            return 100.0 * level;
        }

        if (level > 16 && level < 32) {
            //At level 17, you get 4,335
            //At level 31, you get 14,415
            return 15.0 * (level * level);
        }

        if (level >= 32) {
            //At level 32, you get 15,768
            //At level 40, you get 47,000
            return (level * level * level) - 17000.0;
        }

        //Case would never happen
        return level;
    }
}

@@ -984,45 +984,102 @@
     
-double money = calculateMoney(level);
+int exp = levelToExp(p.getLevel(), p.getLevel() - level);%0A            double money = 2 * exp;%0A
 %0A   
@@ -1488,32 +1488,32 @@
 !%22);%0A        %7D%0A%0A
-
         return t
@@ -1520,24 +1520,492 @@
 rue;%0A    %7D%0A%0A
+    public int levelToExp(int currentLevel, int destination) %7B%0A        int exp = 0;%0A%0A        for (; currentLevel %3E destination; currentLevel--) %7B%0A            if (currentLevel %3C= 16) %7B%0A                exp += (2 * currentLevel) + 7;%0A            %7D else if (currentLevel %3E= 17 && currentLevel %3C= 31) %7B%0A                exp += (5 * currentLevel) - 38;%0A            %7D else %7B%0A                exp += (9 * currentLevel) - 158;%0A            %7D%0A        %7D%0A%0A        return exp;%0A    %7D%0A%0A
     public d

Convert xp required instead of direct levels