Make /wg profile text more clear.

This patch dedicated to @phoenix616.
This commit is contained in:
wizjany 2019-07-16 18:42:16 -04:00
parent 1f362bef59
commit 79f6635b8a
2 changed files with 13 additions and 9 deletions

View File

@ -720,7 +720,9 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
? player.getInventory().getItemInOffHand() : player.getInventory().getItemInMainHand();
Entity entity = event.getRightClicked();
Events.fireToCancel(event, new UseItemEvent(event, create(player), world, item));
if (Events.fireToCancel(event, new UseItemEvent(event, create(player), world, item))) {
return;
}
final UseEntityEvent useEntityEvent = new UseEntityEvent(event, create(player), entity);
Material matchingItem = Materials.getRelatedMaterial(entity.getType());
if (matchingItem != null && hasInteractBypass(world, matchingItem)) {

View File

@ -57,7 +57,7 @@
import java.io.File;
import java.io.IOException;
import java.lang.management.ThreadInfo;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
@ -134,7 +134,7 @@ public void report(CommandContext args, final Actor sender) throws CommandExcept
try {
File dest = new File(worldGuard.getPlatform().getConfigDir().toFile(), "report.txt");
Files.write(result, dest, Charset.forName("UTF-8"));
Files.write(result, dest, StandardCharsets.UTF_8);
sender.print("WorldGuard report written to " + dest.getAbsolutePath());
} catch (IOException e) {
throw new CommandException("Failed to write report: " + e.getMessage());
@ -196,7 +196,7 @@ public void profile(final CommandContext args, final Actor sender) throws Comman
synchronized (this) {
if (activeSampler != null) {
throw new CommandException("A profile is currently in progress! Please use /wg stopprofile to stop the current profile.");
throw new CommandException("A profile is currently in progress! Please use /wg stopprofile to cancel the current profile.");
}
SamplerBuilder builder = new SamplerBuilder();
@ -206,10 +206,12 @@ public void profile(final CommandContext args, final Actor sender) throws Comman
sampler = activeSampler = builder.start();
}
sender.print(TextComponent.of("Starting CPU profiling. Use ", TextColor.LIGHT_PURPLE)
sender.print(TextComponent.of("Starting CPU profiling. Results will be available in " + minutes + " minutes.", TextColor.LIGHT_PURPLE)
.append(TextComponent.newline())
.append(TextComponent.of("Use ", TextColor.GRAY))
.append(TextComponent.of("/wg stopprofile", TextColor.AQUA)
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/wg stopprofile")))
.append(TextComponent.of(" to stop profiling.", TextColor.LIGHT_PURPLE)));
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/wg stopprofile")))
.append(TextComponent.of(" at any time to cancel CPU profiling.", TextColor.GRAY)));
worldGuard.getSupervisor().monitor(FutureForwardingTask.create(
sampler.getFuture(), "CPU profiling for " + minutes + " minutes", sender));
@ -227,7 +229,7 @@ public void onSuccess(Sampler result) {
try {
File dest = new File(worldGuard.getPlatform().getConfigDir().toFile(), "profile.txt");
Files.write(output, dest, Charset.forName("UTF-8"));
Files.write(output, dest, StandardCharsets.UTF_8);
sender.print("CPU profiling data written to " + dest.getAbsolutePath());
} catch (IOException e) {
sender.printError("Failed to write CPU profiling data: " + e.getMessage());
@ -256,7 +258,7 @@ public void stopProfile(CommandContext args, final Actor sender) throws CommandE
activeSampler = null;
}
sender.print("The running CPU profile has been stopped.");
sender.print("The running CPU profile has been cancelled.");
}
@Command(aliases = {"flushstates", "clearstates"},