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