refactor code
This commit is contained in:
+14
-14
@@ -38,9 +38,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 +145,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 +157,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 +175,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 +193,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 +218,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 +230,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 +248,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 +266,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(BlockXArg::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -282,14 +282,14 @@ public class ProfilerCommand extends RootNode {
|
|||||||
private final class BlockXArg extends ArgumentNode<Integer> {
|
private final class BlockXArg extends ArgumentNode<Integer> {
|
||||||
private BlockXArg() {
|
private BlockXArg() {
|
||||||
super("blockX", IntegerArgumentType.integer());
|
super("blockX", IntegerArgumentType.integer());
|
||||||
children(new BlockZArg());
|
children(BlockZArg::new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class BlockZArg extends ArgumentNode<Integer> {
|
private final class BlockZArg extends ArgumentNode<Integer> {
|
||||||
private BlockZArg() {
|
private BlockZArg() {
|
||||||
super("blockZ", IntegerArgumentType.integer());
|
super("blockZ", IntegerArgumentType.integer());
|
||||||
children(new CoordinateSecondsArg());
|
children(CoordinateSecondsArg::new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +337,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
|
||||||
|
|||||||
+3
-2
@@ -7,7 +7,7 @@ import org.jspecify.annotations.NonNull;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* note: 1.a single instance should be called single threadedly(except method "toggle")
|
* note: 1.a single instance should be called single threadedly(except method "toggle")
|
||||||
* 2.tickEnd, tickBegin, taskEnd, taskBegin are called serially not concurrently, if not, exception or unexpected behavior would be
|
* 2.tickEnd, tickBegin, taskEnd, taskBegin are called serially not concurrently, if not, exception or unexpected behavior would be
|
||||||
* surely happened
|
* surely happened
|
||||||
*/
|
*/
|
||||||
public class RegionScheduleProfiler {
|
public class RegionScheduleProfiler {
|
||||||
@@ -91,7 +91,8 @@ 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