You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
3.6 KiB
Java
119 lines
3.6 KiB
Java
package net.minecraft.nbt;
|
|
|
|
import com.mojang.authlib.GameProfile;
|
|
import com.mojang.authlib.properties.Property;
|
|
import java.util.Iterator;
|
|
import java.util.UUID;
|
|
import net.minecraft.util.StringUtils;
|
|
|
|
public final class NBTUtil
|
|
{
|
|
private static final String __OBFID = "CL_00001901";
|
|
|
|
public static GameProfile func_152459_a(NBTTagCompound compound)
|
|
{
|
|
String s = null;
|
|
String s1 = null;
|
|
|
|
if (compound.hasKey("Name", 8))
|
|
{
|
|
s = compound.getString("Name");
|
|
}
|
|
|
|
if (compound.hasKey("Id", 8))
|
|
{
|
|
s1 = compound.getString("Id");
|
|
}
|
|
|
|
if (StringUtils.isNullOrEmpty(s) && StringUtils.isNullOrEmpty(s1))
|
|
{
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
UUID uuid;
|
|
|
|
try
|
|
{
|
|
uuid = UUID.fromString(s1);
|
|
}
|
|
catch (Throwable throwable)
|
|
{
|
|
uuid = null;
|
|
}
|
|
|
|
GameProfile gameprofile = new GameProfile(uuid, s);
|
|
|
|
if (compound.hasKey("Properties", 10))
|
|
{
|
|
NBTTagCompound nbttagcompound1 = compound.getCompoundTag("Properties");
|
|
Iterator iterator = nbttagcompound1.func_150296_c().iterator();
|
|
|
|
while (iterator.hasNext())
|
|
{
|
|
String s2 = (String)iterator.next();
|
|
NBTTagList nbttaglist = nbttagcompound1.getTagList(s2, 10);
|
|
|
|
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
|
{
|
|
NBTTagCompound nbttagcompound2 = nbttaglist.getCompoundTagAt(i);
|
|
String s3 = nbttagcompound2.getString("Value");
|
|
|
|
if (nbttagcompound2.hasKey("Signature", 8))
|
|
{
|
|
gameprofile.getProperties().put(s2, new Property(s2, s3, nbttagcompound2.getString("Signature")));
|
|
}
|
|
else
|
|
{
|
|
gameprofile.getProperties().put(s2, new Property(s2, s3));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return gameprofile;
|
|
}
|
|
}
|
|
|
|
public static void func_152460_a(NBTTagCompound compound, GameProfile profile)
|
|
{
|
|
if (!StringUtils.isNullOrEmpty(profile.getName()))
|
|
{
|
|
compound.setString("Name", profile.getName());
|
|
}
|
|
|
|
if (profile.getId() != null)
|
|
{
|
|
compound.setString("Id", profile.getId().toString());
|
|
}
|
|
|
|
if (!profile.getProperties().isEmpty())
|
|
{
|
|
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
|
Iterator iterator = profile.getProperties().keySet().iterator();
|
|
|
|
while (iterator.hasNext())
|
|
{
|
|
String s = (String)iterator.next();
|
|
NBTTagList nbttaglist = new NBTTagList();
|
|
NBTTagCompound nbttagcompound2;
|
|
|
|
for (Iterator iterator1 = profile.getProperties().get(s).iterator(); iterator1.hasNext(); nbttaglist.appendTag(nbttagcompound2))
|
|
{
|
|
Property property = (Property)iterator1.next();
|
|
nbttagcompound2 = new NBTTagCompound();
|
|
nbttagcompound2.setString("Value", property.getValue());
|
|
|
|
if (property.hasSignature())
|
|
{
|
|
nbttagcompound2.setString("Signature", property.getSignature());
|
|
}
|
|
}
|
|
|
|
nbttagcompound1.setTag(s, nbttaglist);
|
|
}
|
|
|
|
compound.setTag("Properties", nbttagcompound1);
|
|
}
|
|
}
|
|
} |