Return a self constructed gameprofile if profile lookup failed.
This commit is contained in:
parent
8f2c5d6e54
commit
8410904f94
@ -358,7 +358,7 @@ public class DisguiseUtilities {
|
|||||||
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
|
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WrappedGameProfile getProfileFromMojang(String origName, final Object runnable) {
|
private static WrappedGameProfile getProfileFromMojang(final String origName, final Object runnable) {
|
||||||
final String playerName = origName.toLowerCase();
|
final String playerName = origName.toLowerCase();
|
||||||
if (gameProfiles.containsKey(playerName)) {
|
if (gameProfiles.containsKey(playerName)) {
|
||||||
if (gameProfiles.get(playerName) != null) {
|
if (gameProfiles.get(playerName) != null) {
|
||||||
@ -379,7 +379,7 @@ public class DisguiseUtilities {
|
|||||||
Bukkit.getScheduler().runTaskAsynchronously(libsDisguises, new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(libsDisguises, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
final WrappedGameProfile gameProfile = lookupGameProfile(playerName);
|
final WrappedGameProfile gameProfile = lookupGameProfile(origName);
|
||||||
Bukkit.getScheduler().runTask(libsDisguises, new Runnable() {
|
Bukkit.getScheduler().runTask(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) {
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
|
||||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||||
@ -17,14 +14,6 @@ public class LibsProfileLookupCaller implements ProfileLookupCallback {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProfileLookupFailed(GameProfile gameProfile, Exception arg1) {
|
public void onProfileLookupFailed(GameProfile gameProfile, Exception arg1) {
|
||||||
try {
|
|
||||||
Field field = GameProfile.class.getDeclaredField("id");
|
|
||||||
field.setAccessible(true);
|
|
||||||
field.set(gameProfile, UUID.randomUUID());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
this.onProfileLookupSucceeded(gameProfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -530,8 +530,11 @@ public class ReflectionManager {
|
|||||||
.getMethod("findProfilesByNames", String[].class, agent.getClass(),
|
.getMethod("findProfilesByNames", String[].class, agent.getClass(),
|
||||||
Class.forName("net.minecraft.util.com.mojang.authlib.ProfileLookupCallback"))
|
Class.forName("net.minecraft.util.com.mojang.authlib.ProfileLookupCallback"))
|
||||||
.invoke(profileRepo, new String[] { playername }, agent, callback);
|
.invoke(profileRepo, new String[] { playername }, agent, callback);
|
||||||
|
if (callback.getGameProfile() != null) {
|
||||||
return callback.getGameProfile();
|
return callback.getGameProfile();
|
||||||
}
|
}
|
||||||
|
return getGameProfile(null, playername);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user