Player names are now restricted to prevent security issues
This commit is contained in:
2 files changed
+15
-3
No files matched your search
@@ -136,7 +136,7 @@ public class PlayerCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Collection<String> getPlayerSuggestions(CommandSourceStack source) {
|
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());
|
players.addAll(source.getOnlinePlayerNames());
|
||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
@@ -185,6 +185,13 @@ public class PlayerCommand {
|
|||||||
Messenger.m(context.getSource(), "r Player ", "rb " + playerName, "r is already logged on");
|
Messenger.m(context.getSource(), "r Player ", "rb " + playerName, "r is already logged on");
|
||||||
return true;
|
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);
|
GameProfile profile = server.getProfileCache().get(playerName).orElse(null);
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
if (!CarpetSettings.allowSpawningOfflinePlayers) {
|
if (!CarpetSettings.allowSpawningOfflinePlayers) {
|
||||||
|
|||||||
@@ -51,9 +51,11 @@ public class EntityPlayerMPFake extends ServerPlayer
|
|||||||
//prolly half of that crap is not necessary, but it works
|
//prolly half of that crap is not necessary, but it works
|
||||||
ServerLevel worldIn = server.getLevel(dimensionId);
|
ServerLevel worldIn = server.getLevel(dimensionId);
|
||||||
GameProfileCache.setUsesAuthentication(false);
|
GameProfileCache.setUsesAuthentication(false);
|
||||||
GameProfile gameprofile;
|
GameProfile gameprofile = null;
|
||||||
try {
|
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 {
|
finally {
|
||||||
GameProfileCache.setUsesAuthentication(server.isDedicatedServer() && server.usesAuthentication());
|
GameProfileCache.setUsesAuthentication(server.isDedicatedServer() && server.usesAuthentication());
|
||||||
@@ -92,6 +94,9 @@ public class EntityPlayerMPFake extends ServerPlayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static CompletableFuture<Optional<GameProfile>> fetchGameProfile(final String name) {
|
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);
|
return SkullBlockEntity.fetchGameProfile(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user