After setting/cancelling TBR also check main menu state after cancel.
This commit is contained in:
parent
49aa63bd31
commit
d75a04c985
|
@ -243,15 +243,19 @@ public class SetTbrCommand implements Command {
|
|||
Object percentageObj = scripter.currentMenu.getAttribute(MenuAttribute.TBR);
|
||||
Object durationObj = scripter.currentMenu.getAttribute(MenuAttribute.RUNTIME);
|
||||
|
||||
if(percentage==100) {
|
||||
if (percentageObj != null || durationObj != null)
|
||||
throw new CommandException().message("TBR cancelled, but main menu shows a running TBR");
|
||||
|
||||
return new CommandResult().success(true).enacted(true).message("TBR was cancelled");
|
||||
}
|
||||
|
||||
if(percentageObj == null || !(percentageObj instanceof Double))
|
||||
throw new CommandException().message("not percentage");
|
||||
|
||||
if(((double)percentageObj)!=percentage)
|
||||
throw new CommandException().message("wrong percentage set!");
|
||||
|
||||
if(percentage==100)
|
||||
return new CommandResult().success(true).enacted(true).message("TBR was cancelled");
|
||||
|
||||
if(durationObj==null || !(durationObj instanceof MenuTime))
|
||||
throw new CommandException().message("not time");
|
||||
|
||||
|
@ -259,6 +263,7 @@ public class SetTbrCommand implements Command {
|
|||
if(t.getMinute()+(60*t.getHour())> duration || t.getMinute()+(60*t.getHour())< duration-5)
|
||||
throw new CommandException().message("wrong time set!");
|
||||
|
||||
|
||||
return new CommandResult().success(true).enacted(true).message(
|
||||
String.format(Locale.US, "TBR set to %d%% for %d min", percentage, duration));
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in a new issue