mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-12-28 11:59:21 +01:00
Add debug command to clear caches
This commit is contained in:
parent
7405520713
commit
3fd22e5b45
@ -100,13 +100,19 @@ public void init() {
|
||||
LiteralCommandNode<S> debugCommand =
|
||||
literal("debug")
|
||||
.requires(requirements("bluemap.debug"))
|
||||
.executes(this::debugCommand)
|
||||
|
||||
.then(argument("world", StringArgumentType.string()).suggests(new WorldSuggestionProvider<>(plugin))
|
||||
.then(argument("x", DoubleArgumentType.doubleArg())
|
||||
.then(argument("y", DoubleArgumentType.doubleArg())
|
||||
.then(argument("z", DoubleArgumentType.doubleArg())
|
||||
.executes(this::debugCommand)))))
|
||||
|
||||
.then(literal("block")
|
||||
.executes(this::debugBlockCommand)
|
||||
|
||||
.then(argument("world", StringArgumentType.string()).suggests(new WorldSuggestionProvider<>(plugin))
|
||||
.then(argument("x", DoubleArgumentType.doubleArg())
|
||||
.then(argument("y", DoubleArgumentType.doubleArg())
|
||||
.then(argument("z", DoubleArgumentType.doubleArg())
|
||||
.executes(this::debugBlockCommand))))))
|
||||
|
||||
.then(literal("cache")
|
||||
.executes(this::debugClearCacheCommand))
|
||||
|
||||
.build();
|
||||
|
||||
LiteralCommandNode<S> pauseCommand =
|
||||
@ -310,7 +316,18 @@ public int reloadCommand(CommandContext<S> context) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int debugCommand(CommandContext<S> context) throws CommandSyntaxException {
|
||||
public int debugClearCacheCommand(CommandContext<S> context) throws CommandSyntaxException {
|
||||
CommandSource source = commandSourceInterface.apply(context.getSource());
|
||||
|
||||
for (World world : plugin.getWorlds()) {
|
||||
world.invalidateChunkCache();
|
||||
}
|
||||
|
||||
source.sendMessage(Text.of(TextColor.GREEN, "All caches cleared!"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int debugBlockCommand(CommandContext<S> context) throws CommandSyntaxException {
|
||||
final CommandSource source = commandSourceInterface.apply(context.getSource());
|
||||
|
||||
// parse arguments
|
||||
@ -358,6 +375,7 @@ public int debugCommand(CommandContext<S> context) throws CommandSyntaxException
|
||||
}
|
||||
|
||||
source.sendMessages(Lists.newArrayList(
|
||||
Text.of(TextColor.GOLD, "Is generated: ", TextColor.WHITE, world.isChunkGenerated(world.blockPosToChunkPos(blockPos))),
|
||||
Text.of(TextColor.GOLD, "Block at you: ", TextColor.WHITE, block, TextColor.GRAY, blockIdMeta),
|
||||
Text.of(TextColor.GOLD, "Block below you: ", TextColor.WHITE, blockBelow, TextColor.GRAY, blockBelowIdMeta)
|
||||
));
|
||||
|
Loading…
Reference in New Issue
Block a user