Changes to skin handling

This commit is contained in:
fullwall 2014-07-18 21:05:21 -07:00
parent 69bdc83f99
commit 8902579c69

View File

@ -22,8 +22,8 @@ import net.minecraft.util.com.mojang.authlib.minecraft.MinecraftSessionService;
import net.minecraft.util.com.mojang.authlib.properties.Property; import net.minecraft.util.com.mojang.authlib.properties.Property;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.CraftServer; import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -77,8 +77,10 @@ public class HumanController extends AbstractEntityController {
if (skinUUID == null) { if (skinUUID == null) {
skinUUID = npc.getName(); skinUUID = npc.getName();
} }
if (npc.data().has(CACHED_SKIN_UUID_METADATA) && npc.data().has(CACHED_SKIN_UUID_NAME_METADATA) if (npc.data().has(CACHED_SKIN_UUID_METADATA)
&& ChatColor.stripColor(skinUUID).equalsIgnoreCase(ChatColor.stripColor(npc.data().<String> get(CACHED_SKIN_UUID_NAME_METADATA)))) { && npc.data().has(CACHED_SKIN_UUID_NAME_METADATA)
&& ChatColor.stripColor(skinUUID).equalsIgnoreCase(
ChatColor.stripColor(npc.data().<String> get(CACHED_SKIN_UUID_NAME_METADATA)))) {
skinUUID = npc.data().get(CACHED_SKIN_UUID_METADATA); skinUUID = npc.data().get(CACHED_SKIN_UUID_METADATA);
} }
if (UUID_CACHE.containsKey(skinUUID)) { if (UUID_CACHE.containsKey(skinUUID)) {
@ -89,7 +91,8 @@ public class HumanController extends AbstractEntityController {
profile.getProperties().put("textures", cached); profile.getProperties().put("textures", cached);
} else { } else {
Bukkit.getScheduler().runTaskAsynchronously(CitizensAPI.getPlugin(), Bukkit.getScheduler().runTaskAsynchronously(CitizensAPI.getPlugin(),
new SkinFetcher(new UUIDFetcher(skinUUID, npc), nmsWorld.getMinecraftServer().av(), npc)); new SkinFetcher(new UUIDFetcher(skinUUID, npc), nmsWorld.getMinecraftServer().av(), npc),
Math.ceil(Math.min(0, 40 * Math.random())));
} }
} }
@ -152,7 +155,8 @@ public class HumanController extends AbstractEntityController {
} }
final GameProfileRepository repo = ((CraftServer) Bukkit.getServer()).getServer() final GameProfileRepository repo = ((CraftServer) Bukkit.getServer()).getServer()
.getGameProfileRepository(); .getGameProfileRepository();
repo.findProfilesByNames(new String[] { ChatColor.stripColor(reportedUUID) }, Agent.MINECRAFT, new ProfileLookupCallback() { repo.findProfilesByNames(new String[] { ChatColor.stripColor(reportedUUID) }, Agent.MINECRAFT,
new ProfileLookupCallback() {
@Override @Override
public void onProfileLookupFailed(GameProfile arg0, Exception arg1) { public void onProfileLookupFailed(GameProfile arg0, Exception arg1) {
throw new RuntimeException(arg1); throw new RuntimeException(arg1);
@ -165,7 +169,7 @@ public class HumanController extends AbstractEntityController {
npc.data().setPersistent(CACHED_SKIN_UUID_NAME_METADATA, profile.getName()); npc.data().setPersistent(CACHED_SKIN_UUID_NAME_METADATA, profile.getName());
} }
}); });
return npc.data().get(CACHED_SKIN_UUID_METADATA); return npc.data().get(CACHED_SKIN_UUID_METADATA, reportedUUID);
} }
} }