Let's try to convert to minutes from milliseconds.

This commit is contained in:
graywolf336 2013-12-19 11:32:04 -06:00
parent 17ac609a0f
commit 7376326288

View File

@ -40,16 +40,26 @@ public class JailCommand implements Command {
return true; return true;
} }
Long time = Long.parseLong(params.time()); Long time = 10L;
try {
Long.parseLong(params.time());
}catch(NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "Number format is incorrect.");
return true;
}
Player p = jm.getPlugin().getServer().getPlayer(params.player()); Player p = jm.getPlugin().getServer().getPlayer(params.player());
Prisoner pris = new Prisoner(params.player(), params.muted(), TimeUnit.MILLISECONDS.convert(time, TimeUnit.MINUTES)); Prisoner pris = new Prisoner(params.player(), params.muted(), TimeUnit.MILLISECONDS.convert(time, TimeUnit.MINUTES));
//Player is not online //Player is not online
if(p == null) { if(p == null) {
sender.sendMessage(pris.getName() + " is offline and will be jailed for " + pris.getRemainingTime() + " milliseconds in the jail " + params.jail() + "in the cell " + params.cell() + " and will be muted: " + pris.isMuted() + "."); sender.sendMessage(pris.getName() + " is offline and will be jailed for " + pris.getRemainingTime() + " milliseconds in the jail " + params.jail() + "in the cell " + params.cell() + " and will be muted: " + pris.isMuted() + ".");
sender.sendMessage(pris.getName() + " will be jailed for " + TimeUnit.MINUTES.convert(pris.getRemainingTime(), TimeUnit.MILLISECONDS) + " minutes.");
}else { }else {
//Player *is* online //Player *is* online
sender.sendMessage(pris.getName() + " is online and will be jailed for " + pris.getRemainingTime() + " milliseconds in the jail " + params.jail() + "in the cell " + params.cell() + " and will be muted: " + pris.isMuted() + "."); sender.sendMessage(pris.getName() + " is online and will be jailed for " + pris.getRemainingTime() + " milliseconds in the jail " + params.jail() + "in the cell " + params.cell() + " and will be muted: " + pris.isMuted() + ".");
sender.sendMessage(pris.getName() + " will be jailed for " + TimeUnit.MINUTES.convert(pris.getRemainingTime(), TimeUnit.MILLISECONDS) + " minutes.");
} }
return true; return true;