mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-09-29 23:27:28 +02:00
Make /wg profile text more clear.
This patch dedicated to @phoenix616.
This commit is contained in:
parent
1f362bef59
commit
79f6635b8a
@ -720,7 +720,9 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
|||||||
? player.getInventory().getItemInOffHand() : player.getInventory().getItemInMainHand();
|
? player.getInventory().getItemInOffHand() : player.getInventory().getItemInMainHand();
|
||||||
Entity entity = event.getRightClicked();
|
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);
|
final UseEntityEvent useEntityEvent = new UseEntityEvent(event, create(player), entity);
|
||||||
Material matchingItem = Materials.getRelatedMaterial(entity.getType());
|
Material matchingItem = Materials.getRelatedMaterial(entity.getType());
|
||||||
if (matchingItem != null && hasInteractBypass(world, matchingItem)) {
|
if (matchingItem != null && hasInteractBypass(world, matchingItem)) {
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.management.ThreadInfo;
|
import java.lang.management.ThreadInfo;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
@ -134,7 +134,7 @@ public void report(CommandContext args, final Actor sender) throws CommandExcept
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
File dest = new File(worldGuard.getPlatform().getConfigDir().toFile(), "report.txt");
|
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());
|
sender.print("WorldGuard report written to " + dest.getAbsolutePath());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new CommandException("Failed to write report: " + e.getMessage());
|
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) {
|
synchronized (this) {
|
||||||
if (activeSampler != null) {
|
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();
|
SamplerBuilder builder = new SamplerBuilder();
|
||||||
@ -206,10 +206,12 @@ public void profile(final CommandContext args, final Actor sender) throws Comman
|
|||||||
sampler = activeSampler = builder.start();
|
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)
|
.append(TextComponent.of("/wg stopprofile", TextColor.AQUA)
|
||||||
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/wg stopprofile")))
|
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/wg stopprofile")))
|
||||||
.append(TextComponent.of(" to stop profiling.", TextColor.LIGHT_PURPLE)));
|
.append(TextComponent.of(" at any time to cancel CPU profiling.", TextColor.GRAY)));
|
||||||
|
|
||||||
worldGuard.getSupervisor().monitor(FutureForwardingTask.create(
|
worldGuard.getSupervisor().monitor(FutureForwardingTask.create(
|
||||||
sampler.getFuture(), "CPU profiling for " + minutes + " minutes", sender));
|
sampler.getFuture(), "CPU profiling for " + minutes + " minutes", sender));
|
||||||
@ -227,7 +229,7 @@ public void onSuccess(Sampler result) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
File dest = new File(worldGuard.getPlatform().getConfigDir().toFile(), "profile.txt");
|
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());
|
sender.print("CPU profiling data written to " + dest.getAbsolutePath());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
sender.printError("Failed to write CPU profiling data: " + e.getMessage());
|
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;
|
activeSampler = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.print("The running CPU profile has been stopped.");
|
sender.print("The running CPU profile has been cancelled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"flushstates", "clearstates"},
|
@Command(aliases = {"flushstates", "clearstates"},
|
||||||
|
Loading…
Reference in New Issue
Block a user