9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2026-01-04 15:41:31 +00:00

fix: fix bot errs

This commit is contained in:
MC_XiaoHei
2025-10-11 23:54:30 +08:00
parent 6967b50797
commit 96ffa72e7c
2 changed files with 5 additions and 2 deletions

View File

@@ -444,6 +444,7 @@ public class ServerBot extends ServerPlayer {
for (CompoundTag configTag : configNbt) {
AbstractBotConfig<?, ?> config = Configs.getConfig(configTag.getString("configName").orElseThrow());
if (config != null) {
config.setBot(this);
config.load(configTag);
}
}

View File

@@ -7,6 +7,8 @@ import org.leavesmc.leaves.bot.ServerBot;
import org.leavesmc.leaves.command.CommandContext;
import org.leavesmc.leaves.command.arguments.EnumArgumentType;
import java.util.Locale;
public class TickTypeConfig extends AbstractBotConfig<ServerBot.TickType, TickTypeConfig> {
private ServerBot.TickType value;
@@ -34,14 +36,14 @@ public class TickTypeConfig extends AbstractBotConfig<ServerBot.TickType, TickTy
@NotNull
public CompoundTag save(@NotNull CompoundTag nbt) {
super.save(nbt);
nbt.putString(getName(), this.getValue().toString());
nbt.putString(getName(), this.getValue().toString().toLowerCase(Locale.ROOT));
return nbt;
}
@Override
public void load(@NotNull CompoundTag nbt) {
String raw = nbt.getStringOr(getName(), LeavesConfig.modify.fakeplayer.inGame.tickType.name());
this.setValue(switch (raw) {
this.setValue(switch (raw.toLowerCase(Locale.ROOT)) {
case "network" -> ServerBot.TickType.NETWORK;
case "entity_list" -> ServerBot.TickType.ENTITY_LIST;
default -> throw new IllegalStateException("Unexpected bot tick type value: " + raw);