Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8554d3b962 | ||
|
|
8331d07690 |
@@ -1,5 +1,6 @@
|
||||
package io.nanachiyo0721.shiroha.commands;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.nanachiyo0721.shiroha.commands.bar.BarCommand;
|
||||
import io.nanachiyo0721.shiroha.commands.profiler.ProfilerCommand;
|
||||
import io.nanachiyo0721.shiroha.config.modules.function.ProfilerConfig;
|
||||
@@ -14,9 +15,12 @@ public class CommandRegister {
|
||||
public static void register() {
|
||||
new BarCommand().register();
|
||||
if (ProfilerConfig.enabled) {
|
||||
try {
|
||||
TickRegions.getScheduleProfilerManager().init();
|
||||
|
||||
new ProfilerCommand(TickRegions.getScheduleProfilerManager()).register();
|
||||
} catch (UnsupportedOperationException e) {
|
||||
LogUtils.getLogger().warn("Profiler command registration failed: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+22
-25
@@ -12,6 +12,9 @@ import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.papermc.paper.threadedregions.RegionizedServer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.minecraft.commands.arguments.coordinates.ColumnPosArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.Coordinates;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -38,9 +41,9 @@ public class ProfilerCommand extends RootNode {
|
||||
super("sprofiler", PERM_BASE);
|
||||
this.profilerManager = profilerManager;
|
||||
children(
|
||||
new StartCommand(),
|
||||
new StartAtCommand(),
|
||||
new StopCommand()
|
||||
StartCommand::new,
|
||||
StartAtCommand::new,
|
||||
StopCommand::new
|
||||
);
|
||||
}
|
||||
|
||||
@@ -145,7 +148,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class StartCommand extends LiteralNode {
|
||||
private StartCommand() {
|
||||
super("start");
|
||||
children(new TypeArg());
|
||||
children(TypeArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,7 +160,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class TypeArg extends ArgumentNode<String> {
|
||||
private TypeArg() {
|
||||
super("type", StringArgumentType.word());
|
||||
children(new CategoryArg());
|
||||
children(CategoryArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -175,7 +178,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class CategoryArg extends ArgumentNode<String> {
|
||||
private CategoryArg() {
|
||||
super("category", StringArgumentType.word());
|
||||
children(new RegionArg());
|
||||
children(RegionArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,7 +196,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class RegionArg extends ArgumentNode<Long> {
|
||||
private RegionArg() {
|
||||
super("regionId", LongArgumentType.longArg(0L));
|
||||
children(new SecondsArg());
|
||||
children(SecondsArg::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +221,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class StartAtCommand extends LiteralNode {
|
||||
private StartAtCommand() {
|
||||
super("start-at");
|
||||
children(new CoordinateTypeArg());
|
||||
children(CoordinateTypeArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -230,7 +233,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class CoordinateTypeArg extends ArgumentNode<String> {
|
||||
private CoordinateTypeArg() {
|
||||
super("coordinateType", StringArgumentType.word());
|
||||
children(new CoordinateCategoryArg());
|
||||
children(CoordinateCategoryArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -248,7 +251,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class CoordinateCategoryArg extends ArgumentNode<String> {
|
||||
private CoordinateCategoryArg() {
|
||||
super("coordinateCategory", StringArgumentType.word());
|
||||
children(new WorldArg());
|
||||
children(WorldArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -266,7 +269,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class WorldArg extends ArgumentNode<String> {
|
||||
private WorldArg() {
|
||||
super("world", StringArgumentType.word());
|
||||
children(new BlockXArg());
|
||||
children(BlockArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -279,17 +282,10 @@ public class ProfilerCommand extends RootNode {
|
||||
}
|
||||
}
|
||||
|
||||
private final class BlockXArg extends ArgumentNode<Integer> {
|
||||
private BlockXArg() {
|
||||
super("blockX", IntegerArgumentType.integer());
|
||||
children(new BlockZArg());
|
||||
}
|
||||
}
|
||||
|
||||
private final class BlockZArg extends ArgumentNode<Integer> {
|
||||
private BlockZArg() {
|
||||
super("blockZ", IntegerArgumentType.integer());
|
||||
children(new CoordinateSecondsArg());
|
||||
private final class BlockArg extends ArgumentNode<Coordinates> {
|
||||
private BlockArg() {
|
||||
super("blockPos", ColumnPosArgument.columnPos());
|
||||
children(CoordinateSecondsArg::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,8 +298,9 @@ public class ProfilerCommand extends RootNode {
|
||||
protected boolean execute(@NotNull CommandContext context) {
|
||||
final CommandSender sender = context.getSender();
|
||||
final String worldName = context.getArgument(WorldArg.class);
|
||||
final int blockX = context.getArgument(BlockXArg.class);
|
||||
final int blockZ = context.getArgument(BlockZArg.class);
|
||||
final BlockPos blockPos = context.getArgument(BlockArg.class).getBlockPos((net.minecraft.commands.CommandSourceStack) context.getMojangContext().getSource());
|
||||
final int blockX = blockPos.getX();
|
||||
final int blockZ = blockPos.getZ();
|
||||
final World world = Bukkit.getWorld(worldName);
|
||||
|
||||
if (world == null) {
|
||||
@@ -337,7 +334,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class StopCommand extends LiteralNode {
|
||||
private StopCommand() {
|
||||
super("stop");
|
||||
children(new SessionArg());
|
||||
children(SessionArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
@@ -92,6 +92,7 @@ public class RegionScheduleProfiler {
|
||||
|
||||
/**
|
||||
* Gets the execution time of last operation
|
||||
*
|
||||
* @return -1 -> no execution history yet, otherwise the execution time of last operation
|
||||
*/
|
||||
public long lastExecutionTime() {
|
||||
|
||||
+1
-5
@@ -17,11 +17,7 @@ import java.nio.file.FileAlreadyExistsException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
Reference in New Issue
Block a user