1
0
forked from xjboss/KCauldronX
KCauldronX/patches/net/minecraftforge/common/util/FakePlayerFactory.java.patch
2015-03-22 20:38:04 +03:00

32 lines
1.3 KiB
Diff

--- ../src-base/minecraft/net/minecraftforge/common/util/FakePlayerFactory.java
+++ ../src-work/minecraft/net/minecraftforge/common/util/FakePlayerFactory.java
@@ -35,12 +35,24 @@
*/
public static FakePlayer get(WorldServer world, GameProfile username)
{
- if (!fakePlayers.containsKey(username))
+ // Cauldron start - Refactored below to avoid a hashCode check with a null GameProfile ID
+ if (username == null || username.getName() == null) return null;
+
+ for (Map.Entry<GameProfile, FakePlayer> mapEntry : fakePlayers.entrySet())
{
- FakePlayer fakePlayer = new FakePlayer(world, username);
- fakePlayers.put(username, fakePlayer);
+ GameProfile gameprofile = mapEntry.getKey();
+ if (gameprofile.getName().equals(username.getName()))
+ {
+ return mapEntry.getValue();
+ }
}
-
+ FakePlayer fakePlayer = new FakePlayer(world, username);
+ if (username.getId() == null) // GameProfile hashCode check will fail with a null ID
+ {
+ username = new GameProfile(UUID.randomUUID(), username.getName()); // Create new GameProfile with random UUID
+ }
+ // Cauldron end
+ fakePlayers.put(username, fakePlayer);
return fakePlayers.get(username);
}