mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-28 07:36:01 +00:00
Add util method to get Username from UUID, without nulls
This commit is contained in:
1 parent
5f2501693f
commit
a5e816dddc
6 files changed
+27
-6
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package mekanism.common.util;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import ic2.api.energy.EnergyNet;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -12,6 +13,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import mekanism.api.Chunk3D;
|
||||
import mekanism.api.Coord4D;
|
||||
@@ -85,17 +87,21 @@ import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.UsernameCache;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import cofh.api.item.IToolHammer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Utilities used by Mekanism. All miscellaneous methods are located here.
|
||||
* @author AidanBrady
|
||||
@@ -1503,6 +1509,19 @@ public final class MekanismUtils
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String getLastKnownUsername(UUID uuid)
|
||||
{
|
||||
String ret = UsernameCache.getLastKnownUsername(uuid);
|
||||
if (ret == null && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ // see if MC/Yggdrasil knows about it?!
|
||||
GameProfile gp = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getProfileByUUID(uuid);
|
||||
if (gp != null){
|
||||
ret = gp.getName();
|
||||
}
|
||||
}
|
||||
return ret != null ? ret : "<???>";
|
||||
}
|
||||
|
||||
public static enum ResourceType
|
||||
{
|
||||
GUI("gui"),
|
||||
|
||||
Reference in new issue
Block a user