make sure player names do not cause players to get disconnected

This commit is contained in:
gnembon committed 2021-05-25 20:10:47 -03:00
1 parent 90c6af82d2
commit f2e759130a
1 file changed
+6 -1
@@ -272,7 +272,7 @@ public class PlayerCommand
} }
catch (CommandSyntaxException ignored) {} catch (CommandSyntaxException ignored) {}
String playerName = StringArgumentType.getString(context, "player"); String playerName = StringArgumentType.getString(context, "player");
if (playerName.length()>40) if (playerName.length()>maxPlayerLength(source.getMinecraftServer()))
{ {
Messenger.m(context.getSource(), "rb Player name: "+playerName+" is too long"); Messenger.m(context.getSource(), "rb Player name: "+playerName+" is too long");
return 0; return 0;
@@ -294,6 +294,11 @@ public class PlayerCommand
return 1; return 1;
} }
private static int maxPlayerLength(MinecraftServer server)
{
return server.getServerPort() >= 0 ? 16 : 40;
}
private static int stop(CommandContext<ServerCommandSource> context) private static int stop(CommandContext<ServerCommandSource> context)
{ {
if (cantManipulate(context)) return 0; if (cantManipulate(context)) return 0;