After setting/cancelling TBR also check main menu state after cancel.

This commit is contained in:
Johannes Mockenhaupt 2017-08-12 15:11:19 +02:00
parent 49aa63bd31
commit d75a04c985
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -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) {