diff --git a/src/main/java/carpet/commands/PlayerCommand.java b/src/main/java/carpet/commands/PlayerCommand.java index 95ad6a94..fd5ddf00 100644 --- a/src/main/java/carpet/commands/PlayerCommand.java +++ b/src/main/java/carpet/commands/PlayerCommand.java @@ -136,7 +136,7 @@ public class PlayerCommand { } private static Collection getPlayerSuggestions(CommandSourceStack source) { - Set players = new LinkedHashSet<>(List.of("Steve", "Alex")); + Set players = new LinkedHashSet<>(List.of("Steve.bot", "Alex.bot")); players.addAll(source.getOnlinePlayerNames()); return players; } @@ -185,6 +185,13 @@ public class PlayerCommand { Messenger.m(context.getSource(), "r Player ", "rb " + playerName, "r is already logged on"); return true; } + var sender = context.getSource().getPlayer(); + if(!playerName.endsWith(".bot") && sender != null && !Permissions.check(sender,"carpet.command.player.name",sender.hasPermissions(4))){ + Messenger.m(sender,"r You can't spawn a player whose name isn't ends with `.bot` suffix."); + Messenger.m(sender,"r Try this: /player "+playerName+".bot spawn ..."); + return true; + } + GameProfile profile = server.getProfileCache().get(playerName).orElse(null); if (profile == null) { if (!CarpetSettings.allowSpawningOfflinePlayers) { diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index b3d5d0cc..981e46bf 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -51,9 +51,11 @@ public class EntityPlayerMPFake extends ServerPlayer //prolly half of that crap is not necessary, but it works ServerLevel worldIn = server.getLevel(dimensionId); GameProfileCache.setUsesAuthentication(false); - GameProfile gameprofile; + GameProfile gameprofile = null; try { - gameprofile = server.getProfileCache().get(username).orElse(null); //findByName .orElse(null) + if(!username.endsWith(".bot")){ + gameprofile = server.getProfileCache().get(username).orElse(null); //findByName .orElse(null) + } } finally { GameProfileCache.setUsesAuthentication(server.isDedicatedServer() && server.usesAuthentication()); @@ -92,6 +94,9 @@ public class EntityPlayerMPFake extends ServerPlayer } private static CompletableFuture> fetchGameProfile(final String name) { + if(name.endsWith(".bot")){ + return CompletableFuture.completedFuture(Optional.of(new GameProfile(UUIDUtil.createOfflinePlayerUUID(name), name))); + } return SkullBlockEntity.fetchGameProfile(name); }