Solved Milliseconds formatter not working

Discussion in 'Spigot Plugin Development' started by DocDrewskii, Jun 1, 2018.

  1. I'm trying to send the player a message of the time it took to reload the config when they run the command /UpgradableSpawners reload, But When I insert my code, It shows the little yellow lightbulb in the side at line sender.sendMessage(("RELOAD-COMPLETE") + ("%ms%", formatter.format(l2))); Specifically the formatter.format(l2))); part
    Code (Text):
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
                if (cmd.getName().equalsIgnoreCase("UpgradableSpawners")) {
                    if (args.length == 0) {
                        sender.sendMessage(ChatColor.RED + "Please use /UpgradableSpawners Help for more options");
                    } else {
                    if (args[0].equalsIgnoreCase("Reload")) {
                        long l1 = System.currentTimeMillis();
                        long l2 = System.currentTimeMillis() - l1;
                        DecimalFormat formatter = new DecimalFormat("###.#");
                        sender.sendMessage(("RELOAD-COMPLETE") + ("%ms%", formatter.format(l2)));
            return false;
  2. Code (Java):
    sender.sendMessage(("RELOAD-COMPLETE").replace("%ms%", formatter.format(l2)));
    • Agree Agree x 1
    • Useful Useful x 1
  3. Yep, That worked, probelmo solved