2013-02-28 11:53:42 +00:00
|
|
|
package net.minecraftforge.common;
|
|
|
|
|
2013-12-10 05:59:12 +00:00
|
|
|
import java.util.Map;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
import com.mojang.authlib.GameProfile;
|
|
|
|
|
2013-02-28 11:53:42 +00:00
|
|
|
import net.minecraft.world.World;
|
2013-12-10 05:59:12 +00:00
|
|
|
import net.minecraft.world.WorldServer;
|
2013-02-28 11:53:42 +00:00
|
|
|
|
|
|
|
//To be expanded for generic Mod fake players?
|
|
|
|
public class FakePlayerFactory
|
|
|
|
{
|
2013-12-10 05:59:12 +00:00
|
|
|
private static GameProfile MINECRAFT = new GameProfile("41C82C87-7AfB-4024-BA57-13D2C99CAE77", "[Minecraft]");
|
2013-10-03 06:46:17 +00:00
|
|
|
// Map of all active fake player usernames to their entities
|
2013-12-10 05:59:12 +00:00
|
|
|
private static Map<GameProfile, FakePlayer> fakePlayers = Maps.newHashMap();
|
2013-02-28 11:53:42 +00:00
|
|
|
private static FakePlayer MINECRAFT_PLAYER = null;
|
|
|
|
|
2013-12-10 05:59:12 +00:00
|
|
|
public static FakePlayer getMinecraft(WorldServer world)
|
2013-02-28 11:53:42 +00:00
|
|
|
{
|
|
|
|
if (MINECRAFT_PLAYER == null)
|
|
|
|
{
|
2013-12-10 05:59:12 +00:00
|
|
|
MINECRAFT_PLAYER = FakePlayerFactory.get(world, MINECRAFT);
|
2013-02-28 11:53:42 +00:00
|
|
|
}
|
|
|
|
return MINECRAFT_PLAYER;
|
|
|
|
}
|
2013-10-03 06:46:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a fake player with a given username
|
|
|
|
*/
|
2013-12-10 05:59:12 +00:00
|
|
|
public static FakePlayer get(WorldServer world, GameProfile username)
|
2013-10-10 17:45:56 +00:00
|
|
|
{
|
2013-10-03 06:46:17 +00:00
|
|
|
if (!fakePlayers.containsKey(username))
|
|
|
|
{
|
|
|
|
FakePlayer fakePlayer = new FakePlayer(world, username);
|
|
|
|
fakePlayers.put(username, fakePlayer);
|
|
|
|
}
|
2013-10-10 22:15:38 +00:00
|
|
|
|
2013-10-03 06:46:17 +00:00
|
|
|
return fakePlayers.get(username);
|
2013-10-10 17:45:56 +00:00
|
|
|
}
|
2013-02-28 11:53:42 +00:00
|
|
|
}
|