Minimal diffs! Move methods for the new list-name away from nms

This commit is contained in:
Dinnerbone
2011-10-03 00:34:51 +01:00
parent bf09121354
commit 80c2bc266a
3 changed files with 52 additions and 53 deletions

View File

@@ -876,4 +876,26 @@ public final class CraftServer implements Server {
public ConsoleCommandSender getConsoleSender() {
return console.console;
}
public void detectListNameConflict(EntityPlayer entityPlayer) {
// Collisions will make for invisible people
for (int i = 0; i < getHandle().players.size(); ++i) {
EntityPlayer testEntityPlayer = (EntityPlayer)getHandle().players.get(i);
// We have a problem!
if (testEntityPlayer != entityPlayer && testEntityPlayer.listName.equals(entityPlayer.listName)) {
String oldName = entityPlayer.listName;
int spaceLeft = 16 - oldName.length();
if (spaceLeft <= 1) { // We also hit the list name length limit!
entityPlayer.listName = oldName.subSequence(0, oldName.length() - 2 - spaceLeft)
+ String.valueOf(System.currentTimeMillis() % 99);
} else {
entityPlayer.listName = oldName + String.valueOf(System.currentTimeMillis() % 99);
}
return;
}
}
}
}