Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.server.v1_7_R3.NetworkManager;
import net.minecraft.server.v1_7_R3.PacketPlayOutNamedEntitySpawn;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.util.com.mojang.authlib.properties.Property;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.kitteh.tag.api.PacketHandlerException;
Expand Down Expand Up @@ -49,7 +50,12 @@ public void handlePacket(Object packet, Player destination) throws NoSuchFieldEx
final TagInfo newName = this.handler.getNameForPacket20(oldID, this.entityIDField.getInt(p), oldName, destination);
if (newName != null && !newName.getName().equals(oldName)) {
int i = this.tastySnack++;
this.gameProfileField.set(p, new GameProfile(UUID.nameUUIDFromBytes(new byte[]{(byte) (i >> 24), (byte) (i >> 16), (byte) (i >> 8), (byte) i}), newName.getName()));
GameProfile newProfile = new GameProfile(newName.getUUID(), newName.getName());
PropertiesResult.Properties properties = PropertiesResult.getProperties(newName.getUUID().toString().replaceAll("-", ""), false);
Property property = new Property(properties.name, properties.value, properties.signature);
//newProfile.getProperties().clear();
newProfile.getProperties().put(property.getName(), property);
this.gameProfileField.set(p, newProfile);
}
}
}
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/org/kitteh/tag/compat/v1_7_R3/PropertiesResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.kitteh.tag.compat.v1_7_R3;

import com.google.common.base.Charsets;
import net.minecraft.util.com.google.gson.Gson;
import net.minecraft.util.org.apache.commons.io.IOUtils;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.List;

public class PropertiesResult {

private static HashMap<String, Properties> savedProperties = new HashMap<String, Properties>();

private String id;
private String name;
public List<Properties> properties;

public static class Properties {
public String name;
public String value;
public String signature;
}

private static String skullbloburl = "https://sessionserver.mojang.com/session/minecraft/profile/";
public static Properties getProperties(String id, boolean force) {
if(!savedProperties.containsKey(id) ||force){
try {
URL url = new URL(skullbloburl+id);
InputStream is = url.openStream();
String result = IOUtils.toString(is, Charsets.UTF_8);
Gson gson = new Gson();
PropertiesResult propr = gson.fromJson(result, PropertiesResult.class);
if (!propr.properties.isEmpty()) {
savedProperties.put(id, propr.properties.get(0));
return propr.properties.get(0);
}
} catch (IOException e) {
}
}
return savedProperties.get(id);
}

}