Fix activityHaltToggle in /stoplag

This commit is contained in:
TheMolkaPL 2019-05-05 16:25:21 +02:00
parent b27f18788c
commit 71df9c0011

View File

@ -115,31 +115,33 @@ public void stopLag(CommandContext args, Actor sender) throws CommandException {
sender.print("ALL intensive server activity is allowed."); sender.print("ALL intensive server activity is allowed.");
} }
} else { } else {
configManager.activityHaltToggle = !args.hasFlag('c'); boolean activityHaltToggle = !args.hasFlag('c');
if (configManager.activityHaltToggle) { if (activityHaltToggle && (args.argsLength() == 0 || !args.getString(0).equalsIgnoreCase("confirm"))) {
if (args.argsLength() == 0 || !args.getString(0).equalsIgnoreCase("confirm")) { String confirmCommand = "/" + args.getCommand() + " confirm";
String confirmCommand = "/" + args.getCommand() + " confirm";
TextComponent message = TextComponent.builder("") TextComponent message = TextComponent.builder("")
.append(ErrorFormat.wrap("This command will ")) .append(ErrorFormat.wrap("This command will "))
.append(ErrorFormat.wrap("PERMANENTLY") .append(ErrorFormat.wrap("PERMANENTLY")
.decoration(TextDecoration.BOLD, TextDecoration.State.TRUE)) .decoration(TextDecoration.BOLD, TextDecoration.State.TRUE))
.append(ErrorFormat.wrap(" erase ALL animals in ALL loaded chunks in ALL loaded worlds. ")) .append(ErrorFormat.wrap(" erase ALL animals in ALL loaded chunks in ALL loaded worlds. "))
.append(Component.newline()) .append(Component.newline())
.append(TextComponent.of("[Click]", TextColor.GREEN) .append(TextComponent.of("[Click]", TextColor.GREEN)
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, confirmCommand)) .clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, confirmCommand))
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to confirm /" + args.getCommand())))) .hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to confirm /" + args.getCommand()))))
.append(ErrorFormat.wrap(" or type ")) .append(ErrorFormat.wrap(" or type "))
.append(CodeFormat.wrap(confirmCommand) .append(CodeFormat.wrap(confirmCommand)
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, confirmCommand))) .clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, confirmCommand)))
.append(ErrorFormat.wrap(" to confirm.")) .append(ErrorFormat.wrap(" to confirm."))
.build(); .build();
sender.print(message); sender.print(message);
return; return;
} }
configManager.activityHaltToggle = activityHaltToggle;
if (activityHaltToggle) {
if (!(sender instanceof LocalPlayer)) { if (!(sender instanceof LocalPlayer)) {
sender.print("ALL intensive server activity halted."); sender.print("ALL intensive server activity halted.");
} }