9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-29 20:09:23 +00:00

Update Paper

This commit is contained in:
violetc
2025-03-18 15:08:19 +08:00
parent 4795c85163
commit cfcfb4e521
8 changed files with 223 additions and 17 deletions

View File

@@ -78,7 +78,7 @@ public class ServerBot extends ServerPlayer {
public UUID createPlayer;
private final int tracingRange;
private final ServerStatsCounter stats;
private final BotStatsCounter stats;
private final BotInventoryContainer container;
public int notSleepTicks;

View File

@@ -13,7 +13,7 @@ import java.util.List;
public class TickTypeConfig extends AbstractBotConfig<ServerBot.TickType> {
private static final String NAME = "tick_type";
private static final CommandArgumentType<ServerBot.TickType> TICK_TYPE_ARGUMENT = CommandArgumentType.of(ServerBot.TickType.class, (string -> ServerBot.TickType.valueOf(string.toUpperCase())));
private static final CommandArgumentType<ServerBot.TickType> TICK_TYPE_ARGUMENT = CommandArgumentType.ofEnum(ServerBot.TickType.class);
private ServerBot.TickType value;

View File

@@ -7,10 +7,10 @@ import java.util.function.Function;
public abstract class CommandArgumentType<E> {
public static final CommandArgumentType<String> STRING = CommandArgumentType.string();
public static final CommandArgumentType<Integer> INTEGER = CommandArgumentType.of(Integer.class, Integer::parseInt);
public static final CommandArgumentType<Double> DOUBLE = CommandArgumentType.of(Double.class, Double::parseDouble);
public static final CommandArgumentType<Float> FLOAT = CommandArgumentType.of(Float.class, Float::parseFloat);
public static final CommandArgumentType<String> STRING = CommandArgumentType.of(String.class, (arg) -> arg);
public static final CommandArgumentType<Boolean> BOOLEAN = CommandArgumentType.of(Boolean.class, Boolean::parseBoolean);
private final Class<E> type;
@@ -34,6 +34,23 @@ public abstract class CommandArgumentType<E> {
};
}
@NotNull
@Contract(value = "_ -> new", pure = true)
public static <E extends Enum<E>> CommandArgumentType<E> ofEnum(Class<E> type) {
return of(type, (string -> Enum.valueOf(type, string.toUpperCase())));
}
@NotNull
@Contract(value = " -> new", pure = true)
private static CommandArgumentType<String> string() {
return new CommandArgumentType<>(String.class) {
@Override
public String parse(@NotNull String arg) {
return arg;
}
};
}
public Class<E> getType() {
return type;
}