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

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
CraftBukkit/Spigot
2011-10-03 00:34:51 +01:00
parent feed511869
commit 49395291c2
2 changed files with 51 additions and 3 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;
}
}
}
}