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

feat: fix some error

This commit is contained in:
MC_XiaoHei
2025-09-25 23:17:53 +08:00
parent b428557020
commit def2249b48
3 changed files with 63 additions and 18 deletions

View File

@@ -26,6 +26,7 @@ import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.entity.EntityRemoveEvent;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.leavesmc.leaves.LeavesConfig;
@@ -78,7 +79,7 @@ public class BotList {
Location location = event.getCreateLocation();
ServerLevel world = ((CraftWorld) location.getWorld()).getHandle();
CustomGameProfile profile = new CustomGameProfile(BotUtil.getBotUUID(state), state.name(), state.skin());
GameProfile profile = createBotProfile(BotUtil.getBotUUID(state), state.name(), state.skin());
ServerBot bot = new ServerBot(this.server, world, profile);
bot.createState = state;
if (event.getCreator() instanceof org.bukkit.entity.Player player) {
@@ -336,17 +337,13 @@ public class BotList {
return this.dataStorage.getSavedBotList();
}
public static class CustomGameProfile extends GameProfile {
public CustomGameProfile(UUID uuid, String name, String[] skin) {
super(uuid, name);
this.setSkin(skin);
}
public void setSkin(String[] skin) {
if (skin != null) {
this.properties().put("textures", new Property("textures", skin[0], skin[1]));
}
@Contract("_, _, _ -> new")
public static @NotNull GameProfile createBotProfile(UUID uuid, String name, String[] skin) {
GameProfile profile = new GameProfile(uuid, name);
profile.properties().put("is_bot", new Property("is_bot", "true"));
if (skin != null) {
profile.properties().put("textures", new Property("textures", skin[0], skin[1]));
}
return new GameProfile(uuid, name);
}
}

View File

@@ -424,7 +424,7 @@ public class ServerBot extends ServerPlayer {
createBuilder.createReason(BotCreateEvent.CreateReason.INTERNAL).creator(null);
this.createState = createBuilder.build();
this.gameProfile = new BotList.CustomGameProfile(this.getUUID(), this.createState.name(), this.createState.skin());
this.gameProfile = BotList.createBotProfile(this.getUUID(), this.createState.name(), this.createState.skin());
if (nbt.list("actions", CompoundTag.CODEC).isPresent()) {