2015-08-29 14:33:25 +02:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("FakePlayerUtil.java") is part of the Actually Additions mod for Minecraft.
|
2015-08-29 14:33:25 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-05-16 22:54:42 +02:00
|
|
|
* © 2015-2016 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.util;
|
2015-05-04 17:26:50 +02:00
|
|
|
|
|
|
|
import com.mojang.authlib.GameProfile;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraft.world.WorldServer;
|
|
|
|
import net.minecraftforge.common.util.FakePlayer;
|
2015-12-23 23:14:39 +01:00
|
|
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
2015-05-04 17:26:50 +02:00
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
public class FakePlayerUtil{
|
|
|
|
|
2016-05-17 11:34:50 +02:00
|
|
|
private static final String FAKE_NAME = ModUtil.MOD_ID+"fakeplayer";
|
2015-12-16 14:59:03 +01:00
|
|
|
private static final GameProfile FAKE_PROFILE = new GameProfile(UUID.nameUUIDFromBytes(FAKE_NAME.getBytes()), FAKE_NAME);
|
2015-07-06 23:41:10 +02:00
|
|
|
private static FakePlayer theFakePlayer;
|
2015-05-04 17:26:50 +02:00
|
|
|
|
2015-12-16 14:59:03 +01:00
|
|
|
public static void info(){
|
|
|
|
ModUtil.LOGGER.info(ModUtil.NAME+"' Fake Player: '"+FAKE_PROFILE.getName()+"', UUID: "+FAKE_PROFILE.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
public static FakePlayer getFakePlayer(World world){
|
2015-05-04 17:26:50 +02:00
|
|
|
if(world instanceof WorldServer){
|
2015-12-23 23:14:39 +01:00
|
|
|
if(theFakePlayer == null){
|
|
|
|
theFakePlayer = FakePlayerFactory.get((WorldServer)world, FAKE_PROFILE);
|
2015-07-06 23:41:10 +02:00
|
|
|
}
|
|
|
|
return theFakePlayer;
|
2015-05-04 17:26:50 +02:00
|
|
|
}
|
2015-10-02 16:48:01 +02:00
|
|
|
else{
|
|
|
|
return null;
|
|
|
|
}
|
2015-05-04 17:26:50 +02:00
|
|
|
}
|
2016-05-03 21:32:51 +02:00
|
|
|
|
|
|
|
public static void unloadFakePlayer(){
|
|
|
|
theFakePlayer = null;
|
|
|
|
}
|
2015-05-04 17:26:50 +02:00
|
|
|
}
|