Don't permanantly store the game profile
This commit is contained in:
parent
5413b4f852
commit
62debf30c0
@ -430,6 +430,20 @@ public abstract class Disguise {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isPlayerDisguise()) {
|
||||
String name = ((PlayerDisguise) this).getName();
|
||||
if (!DisguiseUtilities.getAddedByPlugins().contains(name)) {
|
||||
for (HashSet<TargetedDisguise> disguise : disguises.values()) {
|
||||
for (Disguise d : disguise) {
|
||||
if (d.isPlayerDisguise() && ((PlayerDisguise) d).getName().equals(name)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
DisguiseUtilities.removeGameprofile(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
|
||||
public class DisguiseUtilities {
|
||||
private static HashSet<String> addedByPlugins = new HashSet<String>();
|
||||
private static HashMap<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<Integer, HashSet<TargetedDisguise>>();
|
||||
private static HashMap<String, Object> gameProfiles = new HashMap<String, Object>();
|
||||
private static LibsDisguises libsDisguises;
|
||||
@ -191,6 +192,10 @@ public class DisguiseUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
public static HashSet<String> getAddedByPlugins() {
|
||||
return addedByPlugins;
|
||||
}
|
||||
|
||||
public static TargetedDisguise getDisguise(Player observer, Entity entity) {
|
||||
UUID entityId = entity.getUniqueId();
|
||||
if (futureDisguises.containsKey(entity.getEntityId())) {
|
||||
@ -290,6 +295,7 @@ public class DisguiseUtilities {
|
||||
return gameProfiles.get(playerName);
|
||||
}
|
||||
} else {
|
||||
getAddedByPlugins().add(playerName);
|
||||
Player player = Bukkit.getPlayerExact(playerName);
|
||||
if (player != null) {
|
||||
Object gameProfile = ReflectionManager.getGameProfile(player);
|
||||
@ -317,6 +323,7 @@ public class DisguiseUtilities {
|
||||
} catch (Exception e) {
|
||||
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
|
||||
gameProfiles.remove(playerName);
|
||||
getAddedByPlugins().remove(playerName);
|
||||
}
|
||||
System.out.print("[LibsDisguises] Error when fetching " + playerName + "'s uuid from mojang: "
|
||||
+ e.getMessage());
|
||||
@ -497,6 +504,10 @@ public class DisguiseUtilities {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void removeGameprofile(String string) {
|
||||
gameProfiles.remove(string);
|
||||
}
|
||||
|
||||
public static void removeSelfDisguise(Player player) {
|
||||
if (selfDisguisesIds.containsKey(player.getUniqueId())) {
|
||||
// Send a packet to destroy the fake entity
|
||||
|
@ -201,7 +201,15 @@ public class PacketsManager {
|
||||
}
|
||||
} else {
|
||||
Object gameProfile = null;
|
||||
String name = ((PlayerDisguise) disguise).getName();
|
||||
boolean removeName = false;
|
||||
if (!DisguiseUtilities.hasGameProfile(name)) {
|
||||
removeName = !DisguiseUtilities.getAddedByPlugins().contains(name);
|
||||
}
|
||||
gameProfile = DisguiseUtilities.getProfileFromMojang(((PlayerDisguise) disguise).getName());
|
||||
if (removeName) {
|
||||
DisguiseUtilities.getAddedByPlugins().remove(name);
|
||||
}
|
||||
spawnPackets[0].getModifier().write(1, gameProfile);
|
||||
}
|
||||
StructureModifier<Integer> intMods = spawnPackets[0].getIntegers();
|
||||
|
@ -281,6 +281,22 @@ public class ReflectionManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Object getSkullBlob(Object gameProfile) {
|
||||
try {
|
||||
Object minecraftServer = getNmsClass("MinecraftServer").getMethod("getServer").invoke(null);
|
||||
for (Method method : getNmsClass("MinecraftServer").getMethods()) {
|
||||
if (method.getReturnType().getSimpleName().equals("MinecraftSessionService")) {
|
||||
Object session = method.invoke(minecraftServer);
|
||||
return session.getClass().getMethod("fillProfileProperties", gameProfile.getClass(), boolean.class)
|
||||
.invoke(session, gameProfile, true);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Float getSoundModifier(Object entity) {
|
||||
try {
|
||||
damageAndIdleSoundMethod.setAccessible(true);
|
||||
@ -321,22 +337,6 @@ public class ReflectionManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Object getSkullBlob(Object gameProfile) {
|
||||
try {
|
||||
Object minecraftServer = getNmsClass("MinecraftServer").getMethod("getServer").invoke(null);
|
||||
for (Method method : getNmsClass("MinecraftServer").getMethods()) {
|
||||
if (method.getReturnType().getSimpleName().equals("MinecraftSessionService")) {
|
||||
Object session = method.invoke(minecraftServer);
|
||||
return session.getClass().getMethod("fillProfileProperties", gameProfile.getClass(), boolean.class)
|
||||
.invoke(session, gameProfile, true);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasSkinBlob(Object gameprofile) {
|
||||
try {
|
||||
Field propField = gameprofile.getClass().getDeclaredField("properties");
|
||||
|
Loading…
Reference in New Issue
Block a user