I can confirm this bug still exists in 1.5.2. How to reproduce:
(1) Start server (2) Try to whitelist a player by either (2a) using the server console (e.g. "whitelist add DMBuce") (2b) using command in-game (e.g. "/whitelist add DMBuce") (3) Note the logging message returned by the server: "You are not white-listed on this server!" (4) Next, whitelist the player but use all lowercase (e.g. "whitelist add dmbuce") (5) Note the successful logged in message.
I apologize in advance if it is wrong to do this but I looked over the (deobfuscated) source code via Minecraft Coder Pack (MCP). Having done so I can describe why users such as myself and Buce above are seeing this bug.
I'm going to use the MCP package/class names. These names probably don't align with the official Mojang source but hopefully it will be clear which part of the source tree is being referenced. Also, MCP decompiles the source into two directories: src/minecraft and src/minecraft_server. I'll be talking about files in the latter.
How the bug happens: (1) In net.minecraft.src.ServerConfigurationManager the method addToWhitelist() looks like this: public void addToWhiteList(String par1Str) { this.whiteListedPlayers.add(par1Str); }
(2) In net.minecraft.src.DedicatedPlayerList the method isAllowedToLogin() looks like this: public boolean isAllowedToLogin(String par1Str) { par1Str = par1Str.trim().toLowerCase(); return [snip] || [snip] || this.getWhiteListedPlayers().contains(par1Str); }
So when adding to the whitelist, the username string is added exactly. However, when checking the whitelist, the username string is first modified to its lowercase version. Hence the bug.
Workarounds: (1) Obviously, just enter the username in all lowercase. (2) Enter the username in mixed-case and either (a) reload the whitelist using the "reload" command, or (b) re-start the server.
Reloading or re-starting the server fixes the problem because in net.minecraft.src.DedicatedPlayerList the method readWhiteList() modifies the entries in white-list.txt to lowercase when it reads it in: private void readWhiteList() { try { this.getWhiteListedPlayers().clear(); BufferedReader var1 = new BufferedReader(new FileReader(this.whiteList)); String var2 = "";
while ((var2 = var1.readLine()) != null) { this.getWhiteListedPlayers().add(var2.trim().toLowerCase()); }
So in summary, isAllowedToLogin() and readWhiteList() both transform usernames to lowercase but addToWhiteList() does not. That's how the bug arises. It looks like the easiest way to fix it is to call toLowerCase() in addToWhiteList(). If that is actually implemented, care should be taken to call toLowerCase() in the method removeFromWhiteList() as well.
I can confirm this bug still exists in 1.5.2. How to reproduce:
(1) Start server
(2) Try to whitelist a player by either
(2a) using the server console (e.g. "whitelist add DMBuce")
(2b) using command in-game (e.g. "/whitelist add DMBuce")
(3) Note the logging message returned by the server: "You are not white-listed on this server!"
(4) Next, whitelist the player but use all lowercase (e.g. "whitelist add dmbuce")
(5) Note the successful logged in message.
I apologize in advance if it is wrong to do this but I looked over the (deobfuscated) source code via Minecraft Coder Pack (MCP). Having done so I can describe why users such as myself and Buce above are seeing this bug.
I'm going to use the MCP package/class names. These names probably don't align with the official Mojang source but hopefully it will be clear which part of the source tree is being referenced. Also, MCP decompiles the source into two directories: src/minecraft and src/minecraft_server. I'll be talking about files in the latter.
How the bug happens:
(1) In net.minecraft.src.ServerConfigurationManager the method addToWhitelist() looks like this:
public void addToWhiteList(String par1Str) {
this.whiteListedPlayers.add(par1Str);
}
(2) In net.minecraft.src.DedicatedPlayerList the method isAllowedToLogin() looks like this:
public boolean isAllowedToLogin(String par1Str) {
par1Str = par1Str.trim().toLowerCase();
return [snip] || [snip] || this.getWhiteListedPlayers().contains(par1Str);
}
So when adding to the whitelist, the username string is added exactly. However, when checking the whitelist, the username string is first modified to its lowercase version. Hence the bug.
Workarounds:
(1) Obviously, just enter the username in all lowercase.
(2) Enter the username in mixed-case and either (a) reload the whitelist using the "reload" command, or (b) re-start the server.
Reloading or re-starting the server fixes the problem because in net.minecraft.src.DedicatedPlayerList the method readWhiteList() modifies the entries in white-list.txt to lowercase when it reads it in:
private void readWhiteList() {
try
{
this.getWhiteListedPlayers().clear();
BufferedReader var1 = new BufferedReader(new FileReader(this.whiteList));
String var2 = "";
while ((var2 = var1.readLine()) != null)
{
this.getWhiteListedPlayers().add(var2.trim().toLowerCase());
}
var1.close();
}
catch (Exception var3)
{
[snip];
}
}
So in summary, isAllowedToLogin() and readWhiteList() both transform usernames to lowercase but addToWhiteList() does not. That's how the bug arises. It looks like the easiest way to fix it is to call toLowerCase() in addToWhiteList(). If that is actually implemented, care should be taken to call toLowerCase() in the method removeFromWhiteList() as well.