2013-11-22 21:10:20 +01:00
|
|
|
package me.libraryaddict.disguise.utilities;
|
2013-11-22 20:52:15 +01:00
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
2014-01-31 10:56:05 +01:00
|
|
|
import java.lang.reflect.InvocationTargetException;
|
2013-11-22 20:52:15 +01:00
|
|
|
import java.lang.reflect.Method;
|
2013-12-05 09:05:58 +01:00
|
|
|
import java.util.ArrayList;
|
2014-04-14 16:26:31 +02:00
|
|
|
import java.util.Arrays;
|
2013-11-22 20:52:15 +01:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashSet;
|
2013-11-22 21:04:31 +01:00
|
|
|
import java.util.Iterator;
|
2013-12-05 09:05:58 +01:00
|
|
|
import java.util.List;
|
2014-04-02 14:49:48 +02:00
|
|
|
import java.util.UUID;
|
2013-11-22 20:52:15 +01:00
|
|
|
|
2013-12-01 16:37:07 +01:00
|
|
|
import me.libraryaddict.disguise.DisguiseAPI;
|
2013-11-22 21:04:31 +01:00
|
|
|
import me.libraryaddict.disguise.LibsDisguises;
|
2013-11-22 20:52:15 +01:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
2013-12-22 01:03:47 +01:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
2013-12-01 16:37:07 +01:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
2013-12-22 01:03:47 +01:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
|
|
|
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
2013-12-01 16:37:07 +01:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
|
2013-11-22 20:52:15 +01:00
|
|
|
|
2013-11-22 21:04:31 +01:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Material;
|
2013-12-22 01:03:47 +01:00
|
|
|
import org.bukkit.entity.Ageable;
|
2013-11-22 20:52:15 +01:00
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.Player;
|
2013-12-22 01:03:47 +01:00
|
|
|
import org.bukkit.entity.Zombie;
|
2013-11-22 21:04:31 +01:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import org.bukkit.potion.PotionEffect;
|
|
|
|
import org.bukkit.util.Vector;
|
2013-11-22 20:52:15 +01:00
|
|
|
|
2013-12-07 15:30:30 +01:00
|
|
|
import com.comphenix.protocol.PacketType;
|
2013-11-22 20:52:15 +01:00
|
|
|
import com.comphenix.protocol.ProtocolLibrary;
|
2013-11-22 21:04:31 +01:00
|
|
|
import com.comphenix.protocol.ProtocolManager;
|
2013-11-22 20:52:15 +01:00
|
|
|
import com.comphenix.protocol.events.PacketContainer;
|
|
|
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|
|
|
|
|
|
|
public class DisguiseUtilities {
|
2014-04-02 15:39:52 +02:00
|
|
|
private static HashMap<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<Integer, HashSet<TargetedDisguise>>();
|
2014-04-14 16:26:31 +02:00
|
|
|
private static HashMap<String, Object> gameProfiles = new HashMap<String, Object>();
|
2013-11-22 21:04:31 +01:00
|
|
|
private static LibsDisguises libsDisguises;
|
2013-11-22 20:52:15 +01:00
|
|
|
// A internal storage of fake entity ID's I can use.
|
|
|
|
// Realistically I could probably use a ID like "4" for everyone, seeing as no one shares the ID
|
2014-04-02 14:49:48 +02:00
|
|
|
private static HashMap<UUID, Integer> selfDisguisesIds = new HashMap<UUID, Integer>();
|
2013-12-01 17:10:38 +01:00
|
|
|
// Store the entity IDs instead of entitys because then I can disguise entitys even before they exist
|
2014-04-02 14:54:36 +02:00
|
|
|
private static HashMap<UUID, HashSet<TargetedDisguise>> targetedDisguises = new HashMap<UUID, HashSet<TargetedDisguise>>();
|
2013-12-01 17:10:38 +01:00
|
|
|
|
2014-04-02 14:54:36 +02:00
|
|
|
public static void addDisguise(UUID entityId, TargetedDisguise disguise) {
|
2013-12-01 17:10:38 +01:00
|
|
|
if (!getDisguises().containsKey(entityId)) {
|
|
|
|
getDisguises().put(entityId, new HashSet<TargetedDisguise>());
|
|
|
|
}
|
|
|
|
getDisguises().get(entityId).add(disguise);
|
|
|
|
checkConflicts(disguise, null);
|
2013-12-22 01:03:47 +01:00
|
|
|
if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS && disguise.isModifyBoundingBox()) {
|
|
|
|
doBoundingBox(disguise);
|
|
|
|
}
|
2013-12-01 17:10:38 +01:00
|
|
|
}
|
|
|
|
|
2014-04-02 15:39:52 +02:00
|
|
|
public static void addFutureDisguise(int entityId, TargetedDisguise disguise) {
|
|
|
|
if (!futureDisguises.containsKey(entityId)) {
|
|
|
|
futureDisguises.put(entityId, new HashSet<TargetedDisguise>());
|
|
|
|
}
|
|
|
|
futureDisguises.get(entityId).add(disguise);
|
|
|
|
}
|
|
|
|
|
2013-12-01 17:10:38 +01:00
|
|
|
/**
|
|
|
|
* If name isn't null. Make sure that the name doesn't see any other disguise. Else if name is null. Make sure that the
|
|
|
|
* observers in the disguise don't see any other disguise.
|
|
|
|
*/
|
|
|
|
public static void checkConflicts(TargetedDisguise disguise, String name) {
|
2013-12-03 19:38:10 +01:00
|
|
|
// If the disguise is being used.. Else we may accidentally undisguise something else
|
2013-12-01 17:10:38 +01:00
|
|
|
if (DisguiseAPI.isDisguiseInUse(disguise)) {
|
2014-04-02 14:54:36 +02:00
|
|
|
Iterator<TargetedDisguise> disguiseItel = getDisguises().get(disguise.getEntity().getUniqueId()).iterator();
|
2013-12-03 19:38:10 +01:00
|
|
|
// Iterate through the disguises
|
2013-12-01 17:10:38 +01:00
|
|
|
while (disguiseItel.hasNext()) {
|
|
|
|
TargetedDisguise d = disguiseItel.next();
|
2013-12-03 19:38:10 +01:00
|
|
|
// Make sure the disguise isn't the same thing
|
2013-12-01 17:10:38 +01:00
|
|
|
if (d != disguise) {
|
2013-12-03 19:38:10 +01:00
|
|
|
// If the loop'd disguise is hiding the disguise to everyone in its list
|
|
|
|
if (d.getDisguiseTarget() == TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS) {
|
2013-12-01 17:10:38 +01:00
|
|
|
// If player is a observer in the loop
|
2013-12-03 19:38:10 +01:00
|
|
|
if (disguise.getDisguiseTarget() == TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS) {
|
2013-12-01 17:10:38 +01:00
|
|
|
// If player is a observer in the disguise
|
|
|
|
// Remove them from the loop
|
|
|
|
if (name != null) {
|
2013-12-03 19:38:10 +01:00
|
|
|
d.removePlayer(name);
|
2013-12-01 17:10:38 +01:00
|
|
|
} else {
|
|
|
|
for (String playername : disguise.getObservers()) {
|
2013-12-03 19:38:10 +01:00
|
|
|
d.silentlyRemovePlayer(playername);
|
2013-12-01 17:10:38 +01:00
|
|
|
}
|
|
|
|
}
|
2013-12-03 19:38:10 +01:00
|
|
|
} else if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) {
|
2013-12-01 17:10:38 +01:00
|
|
|
// If player is not a observer in the loop
|
|
|
|
if (name != null) {
|
|
|
|
if (!disguise.getObservers().contains(name)) {
|
2013-12-03 19:38:10 +01:00
|
|
|
d.removePlayer(name);
|
2013-12-01 17:10:38 +01:00
|
|
|
}
|
|
|
|
} else {
|
2014-01-15 10:40:33 +01:00
|
|
|
for (String playername : new ArrayList<String>(d.getObservers())) {
|
2013-12-01 17:10:38 +01:00
|
|
|
if (!disguise.getObservers().contains(playername)) {
|
2013-12-03 19:38:10 +01:00
|
|
|
d.silentlyRemovePlayer(playername);
|
2013-12-01 17:10:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-03 19:38:10 +01:00
|
|
|
} else if (d.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) {
|
2013-12-01 17:10:38 +01:00
|
|
|
// Here you add it to the loop if they see the disguise
|
2013-12-03 19:38:10 +01:00
|
|
|
if (disguise.getDisguiseTarget() == TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS) {
|
2013-12-01 17:10:38 +01:00
|
|
|
// Everyone who is in the disguise needs to be added to the loop
|
|
|
|
if (name != null) {
|
2013-12-03 19:38:10 +01:00
|
|
|
d.addPlayer(name);
|
2013-12-01 17:10:38 +01:00
|
|
|
} else {
|
|
|
|
for (String playername : disguise.getObservers()) {
|
2013-12-03 19:38:10 +01:00
|
|
|
d.silentlyAddPlayer(playername);
|
2013-12-01 17:10:38 +01:00
|
|
|
}
|
|
|
|
}
|
2013-12-03 19:38:10 +01:00
|
|
|
} else if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) {
|
2013-12-01 17:10:38 +01:00
|
|
|
// This here is a paradox.
|
|
|
|
// If fed a name. I can do this.
|
|
|
|
// But the rest of the time.. Its going to conflict.
|
2013-12-03 19:38:10 +01:00
|
|
|
// The below is debug output. Most people wouldn't care for it.
|
2013-12-05 09:05:58 +01:00
|
|
|
|
|
|
|
// System.out.print("Cannot set more than one " + TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS
|
|
|
|
// + " on a entity. Removed the old disguise.");
|
|
|
|
|
2013-12-01 17:10:38 +01:00
|
|
|
disguiseItel.remove();
|
|
|
|
/* if (name != null) {
|
|
|
|
if (!disguise.getObservers().contains(name)) {
|
|
|
|
d.setViewDisguise(name);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (String playername : d.getObservers()) {
|
|
|
|
if (!disguise.getObservers().contains(playername)) {
|
|
|
|
d.setViewDisguise(playername);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-04 07:54:40 +02:00
|
|
|
/**
|
|
|
|
* @param Sends
|
|
|
|
* entity removal packets, as this disguise was removed
|
|
|
|
*/
|
|
|
|
public static void destroyEntity(TargetedDisguise disguise) {
|
|
|
|
try {
|
|
|
|
Object world = ReflectionManager.getWorld(disguise.getEntity().getWorld());
|
|
|
|
Object tracker = world.getClass().getField("tracker").get(world);
|
|
|
|
Object trackedEntities = tracker.getClass().getField("trackedEntities").get(tracker);
|
|
|
|
Object entityTrackerEntry = trackedEntities.getClass().getMethod("get", int.class)
|
|
|
|
.invoke(trackedEntities, disguise.getEntity().getEntityId());
|
|
|
|
if (entityTrackerEntry != null) {
|
|
|
|
HashSet trackedPlayers = (HashSet) entityTrackerEntry.getClass().getField("trackedPlayers")
|
|
|
|
.get(entityTrackerEntry);
|
|
|
|
HashSet cloned = (HashSet) trackedPlayers.clone();
|
|
|
|
PacketContainer destroyPacket = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
|
|
|
|
destroyPacket.getIntegerArrays().write(0, new int[] { disguise.getEntity().getEntityId() });
|
|
|
|
for (Object p : cloned) {
|
|
|
|
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
|
|
|
if (disguise.canSee(player.getName())) {
|
|
|
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-22 01:03:47 +01:00
|
|
|
public static void doBoundingBox(TargetedDisguise disguise) {
|
|
|
|
// TODO Slimes
|
|
|
|
Entity entity = disguise.getEntity();
|
|
|
|
if (entity != null) {
|
2013-12-22 02:30:15 +01:00
|
|
|
if (isDisguiseInUse(disguise)) {
|
2013-12-31 08:08:14 +01:00
|
|
|
DisguiseValues disguiseValues = DisguiseValues.getDisguiseValues(disguise.getType());
|
|
|
|
FakeBoundingBox disguiseBox = disguiseValues.getAdultBox();
|
|
|
|
if (disguiseValues.getBabyBox() != null) {
|
|
|
|
if ((disguise.getWatcher() instanceof AgeableWatcher && ((AgeableWatcher) disguise.getWatcher()).isBaby())
|
|
|
|
|| (disguise.getWatcher() instanceof ZombieWatcher && ((ZombieWatcher) disguise.getWatcher())
|
|
|
|
.isBaby())) {
|
|
|
|
disguiseBox = disguiseValues.getBabyBox();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ReflectionManager.setBoundingBox(entity, disguiseBox, disguiseValues.getEntitySize());
|
2013-12-22 02:30:15 +01:00
|
|
|
} else {
|
2013-12-31 08:08:14 +01:00
|
|
|
DisguiseValues entityValues = DisguiseValues.getDisguiseValues(DisguiseType.getType(entity.getType()));
|
|
|
|
FakeBoundingBox entityBox = entityValues.getAdultBox();
|
|
|
|
if (entityValues.getBabyBox() != null) {
|
|
|
|
if ((entity instanceof Ageable && !((Ageable) entity).isAdult())
|
|
|
|
|| (entity instanceof Zombie && ((Zombie) entity).isBaby())) {
|
|
|
|
entityBox = entityValues.getBabyBox();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ReflectionManager.setBoundingBox(entity, entityBox, entityValues.getEntitySize());
|
2013-12-22 01:03:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-02 15:02:58 +02:00
|
|
|
public static TargetedDisguise getDisguise(Player observer, Entity entity) {
|
|
|
|
UUID entityId = entity.getUniqueId();
|
|
|
|
if (futureDisguises.containsKey(entity.getEntityId())) {
|
|
|
|
for (TargetedDisguise disguise : futureDisguises.remove(entity.getEntityId())) {
|
|
|
|
addDisguise(entityId, disguise);
|
|
|
|
}
|
|
|
|
}
|
2013-12-01 17:10:38 +01:00
|
|
|
if (getDisguises().containsKey(entityId)) {
|
|
|
|
for (TargetedDisguise disguise : getDisguises().get(entityId)) {
|
|
|
|
if (disguise.canSee(observer)) {
|
|
|
|
return disguise;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2013-11-22 20:52:15 +01:00
|
|
|
|
2014-04-02 14:54:36 +02:00
|
|
|
public static HashMap<UUID, HashSet<TargetedDisguise>> getDisguises() {
|
2013-12-01 13:32:38 +01:00
|
|
|
return targetedDisguises;
|
2013-11-22 20:52:15 +01:00
|
|
|
}
|
|
|
|
|
2014-04-02 14:54:36 +02:00
|
|
|
public static TargetedDisguise[] getDisguises(UUID entityId) {
|
2013-12-01 17:10:38 +01:00
|
|
|
if (getDisguises().containsKey(entityId)) {
|
|
|
|
return getDisguises().get(entityId).toArray(new TargetedDisguise[getDisguises().get(entityId).size()]);
|
|
|
|
}
|
|
|
|
return new TargetedDisguise[0];
|
|
|
|
}
|
|
|
|
|
2014-04-02 14:54:36 +02:00
|
|
|
public static TargetedDisguise getMainDisguise(UUID entityId) {
|
2014-01-21 02:05:32 +01:00
|
|
|
TargetedDisguise toReturn = null;
|
|
|
|
if (getDisguises().containsKey(entityId)) {
|
|
|
|
for (TargetedDisguise disguise : getDisguises().get(entityId)) {
|
|
|
|
if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) {
|
|
|
|
return disguise;
|
|
|
|
}
|
|
|
|
toReturn = disguise;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return toReturn;
|
|
|
|
}
|
|
|
|
|
2013-12-24 05:30:39 +01:00
|
|
|
/**
|
|
|
|
* Get all EntityPlayers who have this entity in their Entity Tracker And they are in the targetted disguise.
|
|
|
|
*/
|
|
|
|
public static ArrayList<Player> getPerverts(Disguise disguise) {
|
|
|
|
ArrayList<Player> players = new ArrayList<Player>();
|
|
|
|
try {
|
|
|
|
Object world = ReflectionManager.getWorld(disguise.getEntity().getWorld());
|
|
|
|
Object tracker = world.getClass().getField("tracker").get(world);
|
|
|
|
Object trackedEntities = tracker.getClass().getField("trackedEntities").get(tracker);
|
|
|
|
Object entityTrackerEntry = trackedEntities.getClass().getMethod("get", int.class)
|
|
|
|
.invoke(trackedEntities, disguise.getEntity().getEntityId());
|
|
|
|
if (entityTrackerEntry != null) {
|
|
|
|
HashSet trackedPlayers = (HashSet) entityTrackerEntry.getClass().getField("trackedPlayers")
|
|
|
|
.get(entityTrackerEntry);
|
|
|
|
for (Object p : trackedPlayers) {
|
|
|
|
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
|
|
|
if (((TargetedDisguise) disguise).canSee(player)) {
|
|
|
|
players.add(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
return players;
|
|
|
|
}
|
|
|
|
|
2014-04-14 16:26:31 +02:00
|
|
|
public static Object getProfile(final Disguise disguise, final String playerName) {
|
|
|
|
Player player = null;
|
|
|
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
|
|
|
if (p.getName().equalsIgnoreCase(playerName)) {
|
|
|
|
player = p;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (player != null) {
|
|
|
|
return ReflectionManager.getGameProfile(player);
|
|
|
|
} else if (disguise != null) {
|
|
|
|
if (gameProfiles.containsKey(playerName)) {
|
|
|
|
if (gameProfiles.get(playerName) != null) {
|
|
|
|
return gameProfiles.get(playerName);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Add null so that if this is called again. I already know I'm doing something about it
|
|
|
|
gameProfiles.put(playerName, null);
|
|
|
|
Bukkit.getScheduler().scheduleAsyncDelayedTask(libsDisguises, new Runnable() {
|
|
|
|
public void run() {
|
|
|
|
try {
|
|
|
|
UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(playerName));
|
|
|
|
HashMap<String, UUID> map = fetcher.call();
|
|
|
|
if (map.containsKey(playerName)) {
|
|
|
|
Object gameprofile = ReflectionManager.getGameProfile(map.get(playerName), playerName);
|
|
|
|
final Object gameProfile = ReflectionManager.grabSkullBlob(gameprofile);
|
|
|
|
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
|
|
|
public void run() {
|
|
|
|
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
|
|
|
|
gameProfiles.put(playerName, gameProfile);
|
|
|
|
}
|
|
|
|
if (DisguiseUtilities.isDisguiseInUse(disguise)) {
|
|
|
|
DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise);
|
|
|
|
if (disguise.getEntity() instanceof Player && disguise.isSelfDisguiseVisible()) {
|
|
|
|
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
|
|
|
|
gameProfiles.remove(playerName);
|
|
|
|
}
|
|
|
|
System.out.print("[LibsDisguises] Error when fetching " + playerName + "'s uuid from mojang: "
|
|
|
|
+ e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ReflectionManager.getGameProfile(null, playerName);
|
|
|
|
}
|
|
|
|
|
2013-12-05 09:05:58 +01:00
|
|
|
public static List<TargetedDisguise> getSeenDisguises(String viewer) {
|
|
|
|
List<TargetedDisguise> dis = new ArrayList<TargetedDisguise>();
|
|
|
|
for (HashSet<TargetedDisguise> disguises : getDisguises().values()) {
|
|
|
|
for (TargetedDisguise disguise : disguises) {
|
|
|
|
if (disguise.getDisguiseTarget() == TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS) {
|
|
|
|
if (disguise.canSee(viewer)) {
|
2013-12-05 09:06:52 +01:00
|
|
|
boolean add = true;
|
2013-12-05 09:05:58 +01:00
|
|
|
for (String observer : disguise.getObservers()) {
|
|
|
|
if (!observer.equals(viewer) && Bukkit.getPlayerExact(observer) != null) {
|
2013-12-05 09:06:52 +01:00
|
|
|
add = false;
|
2013-12-05 09:05:58 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-12-05 17:01:08 +01:00
|
|
|
if (add) {
|
2013-12-05 09:05:58 +01:00
|
|
|
dis.add(disguise);
|
2013-12-05 17:01:08 +01:00
|
|
|
}
|
2013-12-05 09:05:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-05 17:01:08 +01:00
|
|
|
}
|
|
|
|
return dis;
|
2013-12-05 09:05:58 +01:00
|
|
|
}
|
|
|
|
|
2014-04-02 14:49:48 +02:00
|
|
|
public static HashMap<UUID, Integer> getSelfDisguisesIds() {
|
2013-11-22 20:52:15 +01:00
|
|
|
return selfDisguisesIds;
|
|
|
|
}
|
|
|
|
|
2013-11-22 21:04:31 +01:00
|
|
|
public static void init(LibsDisguises disguises) {
|
|
|
|
libsDisguises = disguises;
|
|
|
|
}
|
|
|
|
|
2013-12-01 14:36:42 +01:00
|
|
|
public static boolean isDisguiseInUse(Disguise disguise) {
|
2014-04-02 14:54:36 +02:00
|
|
|
if (disguise.getEntity() != null && getDisguises().containsKey(disguise.getEntity().getUniqueId())
|
|
|
|
&& getDisguises().get(disguise.getEntity().getUniqueId()).contains(disguise)) {
|
2013-12-01 14:36:42 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-12-01 17:10:38 +01:00
|
|
|
/**
|
|
|
|
* @param Resends
|
|
|
|
* the entity to all the watching players, which is where the magic begins
|
|
|
|
*/
|
|
|
|
public static void refreshTracker(TargetedDisguise disguise, String player) {
|
|
|
|
try {
|
|
|
|
Object world = ReflectionManager.getWorld(disguise.getEntity().getWorld());
|
|
|
|
Object tracker = world.getClass().getField("tracker").get(world);
|
|
|
|
Object trackedEntities = tracker.getClass().getField("trackedEntities").get(tracker);
|
|
|
|
Object entityTrackerEntry = trackedEntities.getClass().getMethod("get", int.class)
|
|
|
|
.invoke(trackedEntities, disguise.getEntity().getEntityId());
|
|
|
|
if (entityTrackerEntry != null) {
|
|
|
|
HashSet trackedPlayers = (HashSet) entityTrackerEntry.getClass().getField("trackedPlayers")
|
|
|
|
.get(entityTrackerEntry);
|
|
|
|
Method clear = entityTrackerEntry.getClass().getMethod("clear", ReflectionManager.getNmsClass("EntityPlayer"));
|
|
|
|
Method updatePlayer = entityTrackerEntry.getClass().getMethod("updatePlayer",
|
|
|
|
ReflectionManager.getNmsClass("EntityPlayer"));
|
|
|
|
HashSet cloned = (HashSet) trackedPlayers.clone();
|
|
|
|
for (Object p : cloned) {
|
|
|
|
if (player.equals(((Player) ReflectionManager.getBukkitEntity(p)).getName())) {
|
|
|
|
clear.invoke(entityTrackerEntry, p);
|
|
|
|
updatePlayer.invoke(entityTrackerEntry, p);
|
2013-12-07 19:51:37 +01:00
|
|
|
break;
|
2013-12-01 17:10:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-27 22:59:22 +01:00
|
|
|
/**
|
2014-03-23 13:45:02 +01:00
|
|
|
* @param A
|
|
|
|
* convidence method for me to refresh trackers in other plugins
|
2014-02-27 22:59:22 +01:00
|
|
|
*/
|
|
|
|
public static void refreshTrackers(Entity entity) {
|
|
|
|
try {
|
|
|
|
Object world = ReflectionManager.getWorld(entity.getWorld());
|
|
|
|
Object tracker = world.getClass().getField("tracker").get(world);
|
|
|
|
Object trackedEntities = tracker.getClass().getField("trackedEntities").get(tracker);
|
|
|
|
Object entityTrackerEntry = trackedEntities.getClass().getMethod("get", int.class)
|
|
|
|
.invoke(trackedEntities, entity.getEntityId());
|
|
|
|
if (entityTrackerEntry != null) {
|
|
|
|
HashSet trackedPlayers = (HashSet) entityTrackerEntry.getClass().getField("trackedPlayers")
|
|
|
|
.get(entityTrackerEntry);
|
|
|
|
Method clear = entityTrackerEntry.getClass().getMethod("clear", ReflectionManager.getNmsClass("EntityPlayer"));
|
|
|
|
Method updatePlayer = entityTrackerEntry.getClass().getMethod("updatePlayer",
|
|
|
|
ReflectionManager.getNmsClass("EntityPlayer"));
|
|
|
|
HashSet cloned = (HashSet) trackedPlayers.clone();
|
|
|
|
for (Object p : cloned) {
|
|
|
|
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
|
|
|
// if (entity instanceof Player && !((Player) ReflectionManager.getBukkitEntity(player)).canSee((Player)
|
|
|
|
// entity))
|
|
|
|
// continue;
|
|
|
|
if (!(entity instanceof Player) || player.canSee((Player) entity)) {
|
|
|
|
clear.invoke(entityTrackerEntry, p);
|
|
|
|
updatePlayer.invoke(entityTrackerEntry, p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-22 20:52:15 +01:00
|
|
|
/**
|
|
|
|
* @param Resends
|
|
|
|
* the entity to all the watching players, which is where the magic begins
|
|
|
|
*/
|
2013-12-01 16:37:07 +01:00
|
|
|
public static void refreshTrackers(TargetedDisguise disguise) {
|
2013-11-22 20:52:15 +01:00
|
|
|
try {
|
2013-12-01 16:37:07 +01:00
|
|
|
Object world = ReflectionManager.getWorld(disguise.getEntity().getWorld());
|
2013-11-22 20:52:15 +01:00
|
|
|
Object tracker = world.getClass().getField("tracker").get(world);
|
|
|
|
Object trackedEntities = tracker.getClass().getField("trackedEntities").get(tracker);
|
|
|
|
Object entityTrackerEntry = trackedEntities.getClass().getMethod("get", int.class)
|
2013-12-01 16:37:07 +01:00
|
|
|
.invoke(trackedEntities, disguise.getEntity().getEntityId());
|
2013-11-22 20:52:15 +01:00
|
|
|
if (entityTrackerEntry != null) {
|
|
|
|
HashSet trackedPlayers = (HashSet) entityTrackerEntry.getClass().getField("trackedPlayers")
|
|
|
|
.get(entityTrackerEntry);
|
|
|
|
Method clear = entityTrackerEntry.getClass().getMethod("clear", ReflectionManager.getNmsClass("EntityPlayer"));
|
|
|
|
Method updatePlayer = entityTrackerEntry.getClass().getMethod("updatePlayer",
|
|
|
|
ReflectionManager.getNmsClass("EntityPlayer"));
|
|
|
|
HashSet cloned = (HashSet) trackedPlayers.clone();
|
2013-12-01 16:37:07 +01:00
|
|
|
for (Object p : cloned) {
|
|
|
|
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
|
|
|
// if (entity instanceof Player && !((Player) ReflectionManager.getBukkitEntity(player)).canSee((Player)
|
|
|
|
// entity))
|
|
|
|
// continue;
|
|
|
|
if (disguise.canSee(player.getName())) {
|
|
|
|
clear.invoke(entityTrackerEntry, p);
|
|
|
|
updatePlayer.invoke(entityTrackerEntry, p);
|
|
|
|
}
|
2013-11-22 20:52:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-01 17:10:38 +01:00
|
|
|
public static boolean removeDisguise(TargetedDisguise disguise) {
|
2014-04-02 14:54:36 +02:00
|
|
|
UUID entityId = disguise.getEntity().getUniqueId();
|
2013-12-01 17:10:38 +01:00
|
|
|
if (getDisguises().containsKey(entityId) && getDisguises().get(entityId).remove(disguise)) {
|
|
|
|
if (getDisguises().get(entityId).isEmpty()) {
|
|
|
|
getDisguises().remove(entityId);
|
|
|
|
}
|
2013-12-22 01:03:47 +01:00
|
|
|
if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS && disguise.isModifyBoundingBox()) {
|
|
|
|
doBoundingBox(disguise);
|
|
|
|
}
|
2013-12-01 17:10:38 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-22 20:52:15 +01:00
|
|
|
public static void removeSelfDisguise(Player player) {
|
2014-04-02 14:49:48 +02:00
|
|
|
if (selfDisguisesIds.containsKey(player.getUniqueId())) {
|
2013-11-22 20:52:15 +01:00
|
|
|
// Send a packet to destroy the fake entity
|
2013-12-07 15:30:30 +01:00
|
|
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
|
2014-04-02 14:49:48 +02:00
|
|
|
packet.getModifier().write(0, new int[] { selfDisguisesIds.get(player.getUniqueId()) });
|
2013-11-22 20:52:15 +01:00
|
|
|
try {
|
|
|
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
// Remove the fake entity ID from the disguise bin
|
2014-04-02 14:49:48 +02:00
|
|
|
selfDisguisesIds.remove(player.getUniqueId());
|
2013-11-22 20:52:15 +01:00
|
|
|
// Get the entity tracker
|
|
|
|
try {
|
|
|
|
Object world = ReflectionManager.getWorld(player.getWorld());
|
|
|
|
Object tracker = world.getClass().getField("tracker").get(world);
|
|
|
|
Object trackedEntities = tracker.getClass().getField("trackedEntities").get(tracker);
|
|
|
|
Object entityTrackerEntry = trackedEntities.getClass().getMethod("get", int.class)
|
|
|
|
.invoke(trackedEntities, player.getEntityId());
|
|
|
|
if (entityTrackerEntry != null) {
|
|
|
|
HashSet trackedPlayers = (HashSet) entityTrackerEntry.getClass().getField("trackedPlayers")
|
|
|
|
.get(entityTrackerEntry);
|
|
|
|
// If the tracker exists. Remove himself from his tracker
|
|
|
|
trackedPlayers.remove(ReflectionManager.getNmsEntity(player));
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
2013-11-22 21:04:31 +01:00
|
|
|
}
|
|
|
|
// Resend entity metadata else he will be invisible to himself until its resent
|
2013-11-22 20:52:15 +01:00
|
|
|
try {
|
2013-11-22 21:04:31 +01:00
|
|
|
ProtocolLibrary.getProtocolManager().sendServerPacket(
|
|
|
|
player,
|
2013-11-23 03:50:10 +01:00
|
|
|
ProtocolLibrary
|
|
|
|
.getProtocolManager()
|
2013-12-07 15:30:30 +01:00
|
|
|
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(),
|
2013-11-23 03:50:10 +01:00
|
|
|
WrappedDataWatcher.getEntityWatcher(player), true)
|
|
|
|
.createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true));
|
2013-11-22 20:52:15 +01:00
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
player.updateInventory();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-22 21:04:31 +01:00
|
|
|
/**
|
|
|
|
* Sends the self disguise to the player
|
|
|
|
*/
|
2014-04-13 03:15:04 +02:00
|
|
|
public static void sendSelfDisguise(final Player player, final Disguise disguise) {
|
2013-11-22 21:04:31 +01:00
|
|
|
try {
|
2014-04-13 03:15:04 +02:00
|
|
|
if (!player.isValid() || !player.isOnline()) {
|
2013-11-23 03:21:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2013-11-22 21:04:31 +01:00
|
|
|
Object world = ReflectionManager.getWorld(player.getWorld());
|
|
|
|
Object tracker = world.getClass().getField("tracker").get(world);
|
|
|
|
Object trackedEntities = tracker.getClass().getField("trackedEntities").get(tracker);
|
|
|
|
Object entityTrackerEntry = trackedEntities.getClass().getMethod("get", int.class)
|
|
|
|
.invoke(trackedEntities, player.getEntityId());
|
|
|
|
if (entityTrackerEntry == null) {
|
|
|
|
// A check incase the tracker is null.
|
|
|
|
// If it is, then this method will be run again in one tick. Which is when it should be constructed.
|
|
|
|
// Else its going to run in a infinite loop hue hue hue..
|
2014-04-13 03:15:04 +02:00
|
|
|
// At least until this disguise is discarded
|
2013-11-22 21:04:31 +01:00
|
|
|
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
|
|
|
public void run() {
|
2014-04-13 03:15:04 +02:00
|
|
|
if (DisguiseAPI.getDisguise(player, player) == disguise) {
|
|
|
|
sendSelfDisguise(player, disguise);
|
|
|
|
}
|
2013-11-22 21:04:31 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
2014-04-02 14:49:48 +02:00
|
|
|
int fakeId = selfDisguisesIds.get(player.getUniqueId());
|
2013-11-22 21:04:31 +01:00
|
|
|
// Add himself to his own entity tracker
|
|
|
|
((HashSet) entityTrackerEntry.getClass().getField("trackedPlayers").get(entityTrackerEntry)).add(ReflectionManager
|
|
|
|
.getNmsEntity(player));
|
|
|
|
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
|
|
|
// Send the player a packet with himself being spawned
|
2014-01-31 11:00:24 +01:00
|
|
|
manager.sendServerPacket(player, manager.createPacketConstructor(PacketType.Play.Server.NAMED_ENTITY_SPAWN, player)
|
|
|
|
.createPacket(player));
|
|
|
|
sendSelfPacket(
|
2013-11-22 21:04:31 +01:00
|
|
|
player,
|
2014-01-31 10:56:05 +01:00
|
|
|
manager.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(),
|
|
|
|
WrappedDataWatcher.getEntityWatcher(player), true).createPacket(player.getEntityId(),
|
2014-01-31 11:00:24 +01:00
|
|
|
WrappedDataWatcher.getEntityWatcher(player), true), fakeId);
|
2013-11-22 21:04:31 +01:00
|
|
|
|
|
|
|
boolean isMoving = false;
|
|
|
|
try {
|
|
|
|
Field field = ReflectionManager.getNmsClass("EntityTrackerEntry").getDeclaredField("isMoving");
|
|
|
|
field.setAccessible(true);
|
|
|
|
isMoving = field.getBoolean(entityTrackerEntry);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
// Send the velocity packets
|
|
|
|
if (isMoving) {
|
|
|
|
Vector velocity = player.getVelocity();
|
2014-01-31 10:56:05 +01:00
|
|
|
sendSelfPacket(
|
2013-11-22 21:04:31 +01:00
|
|
|
player,
|
2014-01-31 10:56:05 +01:00
|
|
|
manager.createPacketConstructor(PacketType.Play.Server.ENTITY_VELOCITY, player.getEntityId(),
|
|
|
|
velocity.getX(), velocity.getY(), velocity.getZ()).createPacket(player.getEntityId(),
|
|
|
|
velocity.getX(), velocity.getY(), velocity.getZ()), fakeId);
|
2013-11-22 21:04:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Why the hell would he even need this. Meh.
|
|
|
|
if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) {
|
2014-01-31 10:56:05 +01:00
|
|
|
sendSelfPacket(player,
|
2013-12-07 15:30:30 +01:00
|
|
|
manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player, player.getVehicle())
|
2014-01-31 10:56:05 +01:00
|
|
|
.createPacket(0, player, player.getVehicle()), fakeId);
|
2013-11-22 21:04:31 +01:00
|
|
|
} else if (player.getPassenger() != null && player.getEntityId() > player.getPassenger().getEntityId()) {
|
2014-01-31 10:56:05 +01:00
|
|
|
sendSelfPacket(player,
|
2013-12-07 15:30:30 +01:00
|
|
|
manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player.getPassenger(), player)
|
2014-01-31 10:56:05 +01:00
|
|
|
.createPacket(0, player.getPassenger(), player), fakeId);
|
2013-11-22 21:04:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Resend the armor
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
|
ItemStack item;
|
|
|
|
if (i == 0) {
|
|
|
|
item = player.getItemInHand();
|
|
|
|
} else {
|
|
|
|
item = player.getInventory().getArmorContents()[i - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item != null && item.getType() != Material.AIR) {
|
2014-01-31 10:56:05 +01:00
|
|
|
sendSelfPacket(
|
|
|
|
player,
|
|
|
|
manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EQUIPMENT, player.getEntityId(), i,
|
|
|
|
item).createPacket(player.getEntityId(), i, item), fakeId);
|
2013-11-22 21:04:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Location loc = player.getLocation();
|
|
|
|
// If the disguised is sleeping for w/e reason
|
|
|
|
if (player.isSleeping()) {
|
2014-01-31 10:56:05 +01:00
|
|
|
sendSelfPacket(
|
2013-11-22 21:04:31 +01:00
|
|
|
player,
|
2014-01-04 23:05:19 +01:00
|
|
|
manager.createPacketConstructor(PacketType.Play.Server.BED, player, loc.getBlockX(), loc.getBlockY(),
|
2014-01-31 10:56:05 +01:00
|
|
|
loc.getBlockZ()).createPacket(player, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), fakeId);
|
2013-11-22 21:04:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Resend any active potion effects
|
|
|
|
Iterator iterator = player.getActivePotionEffects().iterator();
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
PotionEffect potionEffect = (PotionEffect) iterator.next();
|
2014-01-31 10:56:05 +01:00
|
|
|
sendSelfPacket(player,
|
|
|
|
manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EFFECT, player.getEntityId(), potionEffect)
|
|
|
|
.createPacket(player.getEntityId(), potionEffect), fakeId);
|
2013-11-22 21:04:31 +01:00
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-27 22:59:22 +01:00
|
|
|
/**
|
|
|
|
* Method to send a packet to the self disguise, translate his entity ID to the fake id.
|
|
|
|
*/
|
|
|
|
private static void sendSelfPacket(Player player, PacketContainer packet, int fakeId) {
|
|
|
|
PacketContainer[] packets = PacketsManager.transformPacket(packet, player, player);
|
|
|
|
try {
|
2014-03-23 13:45:02 +01:00
|
|
|
if (packets == null) {
|
|
|
|
packets = new PacketContainer[] { packet };
|
|
|
|
}
|
2014-02-27 22:59:22 +01:00
|
|
|
for (PacketContainer p : packets) {
|
|
|
|
p = p.deepClone();
|
|
|
|
p.getIntegers().write(0, fakeId);
|
|
|
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, p, false);
|
|
|
|
}
|
|
|
|
} catch (InvocationTargetException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-22 20:52:15 +01:00
|
|
|
/**
|
|
|
|
* Setup it so he can see himself when disguised
|
|
|
|
*/
|
|
|
|
public static void setupFakeDisguise(final Disguise disguise) {
|
2013-12-01 13:32:38 +01:00
|
|
|
Entity e = disguise.getEntity();
|
2013-11-22 20:52:15 +01:00
|
|
|
// If the disguises entity is null, or the disguised entity isn't a player return
|
2014-04-02 14:54:36 +02:00
|
|
|
if (e == null || !(e instanceof Player) || !getDisguises().containsKey(e.getUniqueId())
|
|
|
|
|| !getDisguises().get(e.getUniqueId()).contains(disguise)) {
|
2013-11-22 20:52:15 +01:00
|
|
|
return;
|
2013-12-01 17:10:38 +01:00
|
|
|
}
|
2013-12-01 13:32:38 +01:00
|
|
|
Player player = (Player) e;
|
2013-12-01 17:10:38 +01:00
|
|
|
// Check if he can even see this..
|
|
|
|
if (!((TargetedDisguise) disguise).canSee(player)) {
|
|
|
|
return;
|
|
|
|
}
|
2013-11-22 20:52:15 +01:00
|
|
|
// Remove the old disguise, else we have weird disguises around the place
|
|
|
|
DisguiseUtilities.removeSelfDisguise(player);
|
|
|
|
// If the disguised player can't see himself. Return
|
2013-12-01 17:10:38 +01:00
|
|
|
if (!disguise.isSelfDisguiseVisible() || !PacketsManager.isViewDisguisesListenerEnabled() || player.getVehicle() != null) {
|
2013-11-22 20:52:15 +01:00
|
|
|
return;
|
2013-12-01 17:10:38 +01:00
|
|
|
}
|
2013-11-22 20:52:15 +01:00
|
|
|
try {
|
|
|
|
// Grab the entity ID the fake disguise will use
|
|
|
|
Field field = ReflectionManager.getNmsClass("Entity").getDeclaredField("entityCount");
|
|
|
|
field.setAccessible(true);
|
|
|
|
int id = field.getInt(null);
|
|
|
|
// Set the entitycount plus one so we don't have the id being reused
|
|
|
|
field.set(null, id + 1);
|
2014-04-02 14:49:48 +02:00
|
|
|
selfDisguisesIds.put(player.getUniqueId(), id);
|
2013-11-22 20:52:15 +01:00
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
2014-04-13 03:15:04 +02:00
|
|
|
sendSelfDisguise(player, disguise);
|
2013-11-22 20:52:15 +01:00
|
|
|
if (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf()) {
|
|
|
|
if (PacketsManager.isInventoryListenerEnabled()) {
|
|
|
|
player.updateInventory();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|