Added clone() for the disguises, clones it auto. Fixes potential bug
This commit is contained in:
		@@ -55,6 +55,8 @@ public class DisguiseAPI {
 | 
			
		||||
    public static void disguiseToAll(Entity entity, Disguise disguise) {
 | 
			
		||||
        if (disguise == null)
 | 
			
		||||
            return;
 | 
			
		||||
        if (disguise.getWatcher() != null)
 | 
			
		||||
            disguise = disguise.clone();
 | 
			
		||||
        put(entity instanceof Player ? ((Player) entity).getName() : entity.getUniqueId(), disguise);
 | 
			
		||||
        disguise.constructWatcher(entity.getType(), entity.getEntityId());
 | 
			
		||||
        refresh(entity);
 | 
			
		||||
 
 | 
			
		||||
@@ -44,6 +44,11 @@ public class Disguise {
 | 
			
		||||
        replaceSounds = doSounds;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Disguise clone() {
 | 
			
		||||
        Disguise disguise = new Disguise(getType(), replaceSounds());
 | 
			
		||||
        return disguise;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public PacketContainer[] constructPacket(org.bukkit.entity.Entity e) {
 | 
			
		||||
        PacketContainer[] spawnPackets = new PacketContainer[2];
 | 
			
		||||
        ProtocolManager manager = ProtocolLibrary.getProtocolManager();
 | 
			
		||||
@@ -260,11 +265,11 @@ public class Disguise {
 | 
			
		||||
            else
 | 
			
		||||
                tempWatcher = new FlagWatcher(entityId);
 | 
			
		||||
        }
 | 
			
		||||
        if (this instanceof MobDisguise) {
 | 
			
		||||
        if (this instanceof MobDisguise && !((MobDisguise) this).isAdult()) {
 | 
			
		||||
            if (tempWatcher instanceof AgeableWatcher)
 | 
			
		||||
                tempWatcher.setValue(12, ((MobDisguise) this).isAdult() ? 0 : -24000);
 | 
			
		||||
                tempWatcher.setValue(12, -24000);
 | 
			
		||||
            else if (tempWatcher instanceof ZombieWatcher)
 | 
			
		||||
                tempWatcher.setValue(12, (byte) (((MobDisguise) this).isAdult() ? 0 : 1));
 | 
			
		||||
                tempWatcher.setValue(12, (byte) 1);
 | 
			
		||||
        }
 | 
			
		||||
        HashMap<Integer, Object> disguiseValues = Values.getMetaValues(getType());
 | 
			
		||||
        HashMap<Integer, Object> entityValues = Values.getMetaValues(DisguiseType.getType(type));
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,11 @@ public class MiscDisguise extends Disguise {
 | 
			
		||||
        this(disguiseType, true, id, data);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public MiscDisguise clone() {
 | 
			
		||||
        MiscDisguise disguise = new MiscDisguise(getType(), replaceSounds(), getId(), getData());
 | 
			
		||||
        return disguise;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getData() {
 | 
			
		||||
        return data;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,11 @@ public class PlayerDisguise extends Disguise {
 | 
			
		||||
        playerName = name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public PlayerDisguise clone() {
 | 
			
		||||
        PlayerDisguise disguise = new PlayerDisguise(getName(), replaceSounds());
 | 
			
		||||
        return disguise;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return playerName;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user