Player names are now restricted to prevent security issues
This commit is contained in:
2 files changed
+14
-2
No files matched your search
@@ -136,7 +136,7 @@ public class PlayerCommand {
|
||||
}
|
||||
|
||||
private static Collection<String> getPlayerSuggestions(CommandSourceStack source) {
|
||||
Set<String> players = new LinkedHashSet<>(List.of("Steve", "Alex"));
|
||||
Set<String> 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) {
|
||||
|
||||
@@ -51,10 +51,12 @@ 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 {
|
||||
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<Optional<GameProfile>> fetchGameProfile(final String name) {
|
||||
if(name.endsWith(".bot")){
|
||||
return CompletableFuture.completedFuture(Optional.of(new GameProfile(UUIDUtil.createOfflinePlayerUUID(name), name)));
|
||||
}
|
||||
return SkullBlockEntity.fetchGameProfile(name);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user