Instead of using Object's for gameprofiles. Use WrappedGameProfile
This commit is contained in:
parent
5ff1370ea0
commit
d23e518c1b
@ -2,6 +2,8 @@ package me.libraryaddict.disguise.disguisetypes;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsProfileLookup;
|
import me.libraryaddict.disguise.utilities.LibsProfileLookup;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
@ -9,7 +11,7 @@ import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
|
|||||||
|
|
||||||
public class PlayerDisguise extends TargetedDisguise {
|
public class PlayerDisguise extends TargetedDisguise {
|
||||||
private LibsProfileLookup currentLookup;
|
private LibsProfileLookup currentLookup;
|
||||||
private Object gameProfile;
|
private WrappedGameProfile gameProfile;
|
||||||
private String playerName;
|
private String playerName;
|
||||||
private String skinToUse;
|
private String skinToUse;
|
||||||
|
|
||||||
@ -53,7 +55,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Object getGameProfile() {
|
public WrappedGameProfile getGameProfile() {
|
||||||
if (getSkin() != null) {
|
if (getSkin() != null) {
|
||||||
if (gameProfile != null) {
|
if (gameProfile != null) {
|
||||||
return gameProfile;
|
return gameProfile;
|
||||||
@ -79,7 +81,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setGameProfile(Object gameProfile) {
|
public void setGameProfile(WrappedGameProfile gameProfile) {
|
||||||
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, getName(), gameProfile);
|
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, getName(), gameProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +99,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
currentLookup = new LibsProfileLookup() {
|
currentLookup = new LibsProfileLookup() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLookup(Object gameProfile) {
|
public void onLookup(WrappedGameProfile gameProfile) {
|
||||||
if (currentLookup == this && gameProfile != null) {
|
if (currentLookup == this && gameProfile != null) {
|
||||||
setGameProfile(gameProfile);
|
setGameProfile(gameProfile);
|
||||||
if (DisguiseUtilities.isDisguiseInUse(PlayerDisguise.this)) {
|
if (DisguiseUtilities.isDisguiseInUse(PlayerDisguise.this)) {
|
||||||
@ -109,7 +111,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Object obj = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup);
|
WrappedGameProfile obj = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup);
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
setGameProfile(obj);
|
setGameProfile(obj);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ import com.comphenix.protocol.ProtocolLibrary;
|
|||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
|
||||||
public class DisguiseUtilities {
|
public class DisguiseUtilities {
|
||||||
/**
|
/**
|
||||||
@ -58,7 +59,7 @@ public class DisguiseUtilities {
|
|||||||
/**
|
/**
|
||||||
* A hashmap storing the uuid and skin of a playername
|
* A hashmap storing the uuid and skin of a playername
|
||||||
*/
|
*/
|
||||||
private static HashMap<String, Object> gameProfiles = new HashMap<String, Object>();
|
private static HashMap<String, WrappedGameProfile> gameProfiles = new HashMap<String, WrappedGameProfile>();
|
||||||
private static LibsDisguises libsDisguises;
|
private static LibsDisguises libsDisguises;
|
||||||
private static HashMap<String, ArrayList<Object>> runnables = new HashMap<String, ArrayList<Object>>();
|
private static HashMap<String, ArrayList<Object>> runnables = new HashMap<String, ArrayList<Object>>();
|
||||||
/**
|
/**
|
||||||
@ -122,7 +123,7 @@ public class DisguiseUtilities {
|
|||||||
runnable.runTaskLater(libsDisguises, 20);
|
runnable.runTaskLater(libsDisguises, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addGameProfile(String string, Object gameProfile) {
|
public static void addGameProfile(String string, WrappedGameProfile gameProfile) {
|
||||||
getGameProfiles().put(string, gameProfile);
|
getGameProfiles().put(string, gameProfile);
|
||||||
addedByPlugins.add(string);
|
addedByPlugins.add(string);
|
||||||
}
|
}
|
||||||
@ -263,7 +264,7 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TargetedDisguise getDisguise(Player observer, Entity entity) {
|
public static TargetedDisguise getDisguise(Player observer, Entity entity) {
|
||||||
UUID entityId = entity.getUniqueId();
|
UUID entityId = entity.getUniqueId();
|
||||||
if (futureDisguises.containsKey(entity.getEntityId())) {
|
if (futureDisguises.containsKey(entity.getEntityId())) {
|
||||||
@ -297,11 +298,11 @@ public class DisguiseUtilities {
|
|||||||
return futureDisguises;
|
return futureDisguises;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getGameProfile(String playerName) {
|
public static WrappedGameProfile getGameProfile(String playerName) {
|
||||||
return gameProfiles.get(playerName);
|
return gameProfiles.get(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String, Object> getGameProfiles() {
|
public static HashMap<String, WrappedGameProfile> getGameProfiles() {
|
||||||
return gameProfiles;
|
return gameProfiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,11 +346,11 @@ public class DisguiseUtilities {
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getProfileFromMojang(final PlayerDisguise disguise) {
|
public static WrappedGameProfile getProfileFromMojang(final PlayerDisguise disguise) {
|
||||||
return getProfileFromMojang(disguise.getName(), new LibsProfileLookup() {
|
return getProfileFromMojang(disguise.getName(), new LibsProfileLookup() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLookup(Object gameProfile) {
|
public void onLookup(WrappedGameProfile gameProfile) {
|
||||||
getAddedByPlugins().remove(disguise.getName());
|
getAddedByPlugins().remove(disguise.getName());
|
||||||
if (DisguiseAPI.isDisguiseInUse(disguise)) {
|
if (DisguiseAPI.isDisguiseInUse(disguise)) {
|
||||||
DisguiseUtilities.refreshTrackers(disguise);
|
DisguiseUtilities.refreshTrackers(disguise);
|
||||||
@ -365,11 +366,11 @@ public class DisguiseUtilities {
|
|||||||
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
|
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
|
||||||
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||||
*/
|
*/
|
||||||
public static Object getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn) {
|
public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn) {
|
||||||
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
|
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object getProfileFromMojang(final String playerName, final Object runnable) {
|
private static WrappedGameProfile getProfileFromMojang(final String playerName, final Object runnable) {
|
||||||
if (gameProfiles.containsKey(playerName)) {
|
if (gameProfiles.containsKey(playerName)) {
|
||||||
if (gameProfiles.get(playerName) != null) {
|
if (gameProfiles.get(playerName) != null) {
|
||||||
return gameProfiles.get(playerName);
|
return gameProfiles.get(playerName);
|
||||||
@ -378,7 +379,7 @@ public class DisguiseUtilities {
|
|||||||
getAddedByPlugins().add(playerName);
|
getAddedByPlugins().add(playerName);
|
||||||
Player player = Bukkit.getPlayerExact(playerName);
|
Player player = Bukkit.getPlayerExact(playerName);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
Object gameProfile = ReflectionManager.getGameProfile(player);
|
WrappedGameProfile gameProfile = ReflectionManager.getGameProfile(player);
|
||||||
if (ReflectionManager.hasSkinBlob(gameProfile)) {
|
if (ReflectionManager.hasSkinBlob(gameProfile)) {
|
||||||
gameProfiles.put(playerName, gameProfile);
|
gameProfiles.put(playerName, gameProfile);
|
||||||
return gameProfile;
|
return gameProfile;
|
||||||
@ -389,7 +390,7 @@ public class DisguiseUtilities {
|
|||||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(libsDisguises, new Runnable() {
|
Bukkit.getScheduler().scheduleAsyncDelayedTask(libsDisguises, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
final Object gameProfile = lookupGameProfile(playerName);
|
final WrappedGameProfile gameProfile = lookupGameProfile(playerName);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
|
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
|
||||||
@ -430,7 +431,7 @@ public class DisguiseUtilities {
|
|||||||
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
|
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
|
||||||
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||||
*/
|
*/
|
||||||
public static Object getProfileFromMojang(String playerName, Runnable runnableIfCantReturn) {
|
public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn) {
|
||||||
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
|
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,8 +455,8 @@ public class DisguiseUtilities {
|
|||||||
/**
|
/**
|
||||||
* This is called on a thread as it is thread blocking
|
* This is called on a thread as it is thread blocking
|
||||||
*/
|
*/
|
||||||
public static Object lookupGameProfile(String playerName) {
|
public static WrappedGameProfile lookupGameProfile(String playerName) {
|
||||||
Object gameprofile = ReflectionManager.grabProfileAddUUID(playerName);
|
WrappedGameProfile gameprofile = ReflectionManager.grabProfileAddUUID(playerName);
|
||||||
return ReflectionManager.getSkullBlob(gameprofile);
|
return ReflectionManager.getSkullBlob(gameprofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
|
||||||
public interface LibsProfileLookup {
|
public interface LibsProfileLookup {
|
||||||
public void onLookup(Object gameProfile);
|
public void onLookup(WrappedGameProfile gameProfile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,15 @@ package me.libraryaddict.disguise.utilities;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
|
||||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.util.com.mojang.authlib.ProfileLookupCallback;
|
import net.minecraft.util.com.mojang.authlib.ProfileLookupCallback;
|
||||||
|
|
||||||
public class LibsProfileLookupCaller implements ProfileLookupCallback {
|
public class LibsProfileLookupCaller implements ProfileLookupCallback {
|
||||||
private GameProfile gameProfile;
|
private WrappedGameProfile gameProfile;
|
||||||
|
|
||||||
public GameProfile getGameProfile() {
|
public WrappedGameProfile getGameProfile() {
|
||||||
return gameProfile;
|
return gameProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +29,7 @@ public class LibsProfileLookupCaller implements ProfileLookupCallback {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProfileLookupSucceeded(GameProfile profile) {
|
public void onProfileLookupSucceeded(GameProfile profile) {
|
||||||
gameProfile = profile;
|
gameProfile = WrappedGameProfile.fromHandle(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ import com.comphenix.protocol.reflect.StructureModifier;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
||||||
import com.comphenix.protocol.wrappers.WrappedAttribute.Builder;
|
import com.comphenix.protocol.wrappers.WrappedAttribute.Builder;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
|
|
||||||
public class PacketsManager {
|
public class PacketsManager {
|
||||||
@ -196,7 +197,7 @@ public class PacketsManager {
|
|||||||
stringMods.write(i, ((PlayerDisguise) disguise).getName());
|
stringMods.write(i, ((PlayerDisguise) disguise).getName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Object gameProfile;
|
WrappedGameProfile gameProfile;
|
||||||
String name = ((PlayerDisguise) disguise).getName();
|
String name = ((PlayerDisguise) disguise).getName();
|
||||||
boolean removeName = false;
|
boolean removeName = false;
|
||||||
if (!DisguiseUtilities.hasGameProfile(name)) {
|
if (!DisguiseUtilities.hasGameProfile(name)) {
|
||||||
@ -206,7 +207,7 @@ public class PacketsManager {
|
|||||||
if (removeName) {
|
if (removeName) {
|
||||||
DisguiseUtilities.getAddedByPlugins().remove(name);
|
DisguiseUtilities.getAddedByPlugins().remove(name);
|
||||||
}
|
}
|
||||||
spawnPackets[0].getModifier().write(1, gameProfile);
|
spawnPackets[0].getGameProfiles().write(0, gameProfile);
|
||||||
}
|
}
|
||||||
StructureModifier<Integer> intMods = spawnPackets[0].getIntegers();
|
StructureModifier<Integer> intMods = spawnPackets[0].getIntegers();
|
||||||
intMods.write(0, disguisedEntity.getEntityId());
|
intMods.write(0, disguisedEntity.getEntityId());
|
||||||
|
@ -14,6 +14,8 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
|
||||||
public class ReflectionManager {
|
public class ReflectionManager {
|
||||||
public enum LibVersion {
|
public enum LibVersion {
|
||||||
V1_6, V1_7;
|
V1_6, V1_7;
|
||||||
@ -90,10 +92,10 @@ public class ReflectionManager {
|
|||||||
Object playerinteractmanager = getNmsClass("PlayerInteractManager").getConstructor(getNmsClass("World"))
|
Object playerinteractmanager = getNmsClass("PlayerInteractManager").getConstructor(getNmsClass("World"))
|
||||||
.newInstance(world);
|
.newInstance(world);
|
||||||
if (LibVersion.is1_7()) {
|
if (LibVersion.is1_7()) {
|
||||||
Object gameProfile = getGameProfile(null, "LibsDisguises");
|
WrappedGameProfile gameProfile = getGameProfile(null, "LibsDisguises");
|
||||||
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"),
|
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"),
|
||||||
gameProfile.getClass(), playerinteractmanager.getClass()).newInstance(minecraftServer, world,
|
gameProfile.getHandleType(), playerinteractmanager.getClass()).newInstance(minecraftServer, world,
|
||||||
gameProfile, playerinteractmanager);
|
gameProfile.getHandle(), playerinteractmanager);
|
||||||
} else {
|
} else {
|
||||||
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("World"), String.class,
|
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("World"), String.class,
|
||||||
playerinteractmanager.getClass()).newInstance(minecraftServer, world, "LibsDisguises",
|
playerinteractmanager.getClass()).newInstance(minecraftServer, world, "LibsDisguises",
|
||||||
@ -205,47 +207,26 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getGameProfile(Player player) {
|
public static WrappedGameProfile getGameProfile(Player player) {
|
||||||
if (LibVersion.is1_7()) {
|
if (LibVersion.is1_7()) {
|
||||||
try {
|
return WrappedGameProfile.fromPlayer(player);
|
||||||
return getNmsClass("EntityHuman").getMethod("getProfile").invoke(getNmsEntity(player));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getGameProfile(UUID uuid, String playerName) {
|
public static WrappedGameProfile getGameProfile(UUID uuid, String playerName) {
|
||||||
try {
|
try {
|
||||||
try {
|
return new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName);
|
||||||
return Class.forName("net.minecraft.util.com.mojang.authlib.GameProfile")
|
|
||||||
.getConstructor(UUID.class, String.class)
|
|
||||||
.newInstance(uuid != null ? uuid : UUID.randomUUID(), playerName);
|
|
||||||
} catch (NoSuchMethodException ex) {
|
|
||||||
return Class.forName("net.minecraft.util.com.mojang.authlib.GameProfile")
|
|
||||||
.getConstructor(String.class, String.class).newInstance(uuid != null ? uuid.toString() : "", playerName);
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getGameProfileWithThisSkin(UUID uuid, String playerName, Object profileWithSkin) {
|
public static WrappedGameProfile getGameProfileWithThisSkin(UUID uuid, String playerName, WrappedGameProfile profileWithSkin) {
|
||||||
try {
|
try {
|
||||||
Object gameProfile;
|
WrappedGameProfile gameProfile = new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName);
|
||||||
try {
|
gameProfile.getProperties().putAll(profileWithSkin.getProperties());
|
||||||
gameProfile = Class.forName("net.minecraft.util.com.mojang.authlib.GameProfile")
|
|
||||||
.getConstructor(UUID.class, String.class)
|
|
||||||
.newInstance(uuid != null ? uuid : UUID.randomUUID(), playerName);
|
|
||||||
} catch (NoSuchMethodException ex) {
|
|
||||||
gameProfile = Class.forName("net.minecraft.util.com.mojang.authlib.GameProfile")
|
|
||||||
.getConstructor(String.class, String.class).newInstance(uuid != null ? uuid.toString() : "", playerName);
|
|
||||||
}
|
|
||||||
Field properties = gameProfile.getClass().getDeclaredField("properties");
|
|
||||||
properties.setAccessible(true);
|
|
||||||
properties.set(gameProfile, properties.get(profileWithSkin));
|
|
||||||
return gameProfile;
|
return gameProfile;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -301,14 +282,15 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getSkullBlob(Object gameProfile) {
|
public static WrappedGameProfile getSkullBlob(WrappedGameProfile gameProfile) {
|
||||||
try {
|
try {
|
||||||
Object minecraftServer = getNmsClass("MinecraftServer").getMethod("getServer").invoke(null);
|
Object minecraftServer = getNmsClass("MinecraftServer").getMethod("getServer").invoke(null);
|
||||||
for (Method method : getNmsClass("MinecraftServer").getMethods()) {
|
for (Method method : getNmsClass("MinecraftServer").getMethods()) {
|
||||||
if (method.getReturnType().getSimpleName().equals("MinecraftSessionService")) {
|
if (method.getReturnType().getSimpleName().equals("MinecraftSessionService")) {
|
||||||
Object session = method.invoke(minecraftServer);
|
Object session = method.invoke(minecraftServer);
|
||||||
return session.getClass().getMethod("fillProfileProperties", gameProfile.getClass(), boolean.class)
|
return WrappedGameProfile.fromHandle(session.getClass()
|
||||||
.invoke(session, gameProfile, true);
|
.getMethod("fillProfileProperties", gameProfile.getHandleType(), boolean.class)
|
||||||
|
.invoke(session, gameProfile.getHandle(), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -335,7 +317,7 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object grabProfileAddUUID(String playername) {
|
public static WrappedGameProfile grabProfileAddUUID(String playername) {
|
||||||
try {
|
try {
|
||||||
Object minecraftServer = getNmsClass("MinecraftServer").getMethod("getServer").invoke(null);
|
Object minecraftServer = getNmsClass("MinecraftServer").getMethod("getServer").invoke(null);
|
||||||
for (Method method : getNmsClass("MinecraftServer").getMethods()) {
|
for (Method method : getNmsClass("MinecraftServer").getMethods()) {
|
||||||
@ -357,20 +339,8 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasSkinBlob(Object gameprofile) {
|
public static boolean hasSkinBlob(WrappedGameProfile gameProfile) {
|
||||||
try {
|
return !gameProfile.getProperties().isEmpty();
|
||||||
Field propField = gameprofile.getClass().getDeclaredField("properties");
|
|
||||||
propField.setAccessible(true);
|
|
||||||
Object propMap = propField.get(gameprofile);
|
|
||||||
propField = propMap.getClass().getDeclaredField("properties");
|
|
||||||
propField.setAccessible(true);
|
|
||||||
propMap = propField.get(propMap);
|
|
||||||
return !(Boolean) propMap.getClass().getMethod("isEmpty").invoke(propMap);
|
|
||||||
} catch (NoSuchFieldException ex) {
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setAllowSleep(Player player) {
|
public static void setAllowSleep(Player player) {
|
||||||
|
Loading…
Reference in New Issue
Block a user