Improved the cloning of flagwatcher, and now saves backups as a backup value
This commit is contained in:
		@@ -464,12 +464,12 @@ public class Disguise {
 | 
			
		||||
                continue;
 | 
			
		||||
            // If the disguise has this, but not the entity. Then better set it!
 | 
			
		||||
            if (!entityValues.containsKey(dataNo) && disguiseValues.containsKey(dataNo)) {
 | 
			
		||||
                getWatcher().setValue(dataNo, disguiseValues.get(dataNo));
 | 
			
		||||
                getWatcher().setBackupValue(dataNo, disguiseValues.get(dataNo));
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            // Else if the disguise doesn't have it. But the entity does. Better remove it!
 | 
			
		||||
            if (entityValues.containsKey(dataNo) && !disguiseValues.containsKey(dataNo)) {
 | 
			
		||||
                getWatcher().setValue(dataNo, null);
 | 
			
		||||
                getWatcher().setBackupValue(dataNo, null);
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            // Since they both share it. Time to check if its from something they extend.
 | 
			
		||||
@@ -512,7 +512,7 @@ public class Disguise {
 | 
			
		||||
                continue;
 | 
			
		||||
            // Well I can't find a reason I should leave it alone. They will probably conflict.
 | 
			
		||||
            // Time to set the value to the disguises value so no conflicts!
 | 
			
		||||
            getWatcher().setValue(dataNo, disguiseValues.get(dataNo));
 | 
			
		||||
            getWatcher().setBackupValue(dataNo, disguiseValues.get(dataNo));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -51,6 +51,10 @@ public class FlagWatcher {
 | 
			
		||||
    }
 | 
			
		||||
    private Disguise disguise;
 | 
			
		||||
    private HashMap<Integer, Object> entityValues = new HashMap<Integer, Object>();
 | 
			
		||||
    /**
 | 
			
		||||
     * This is the entity values I need to add else it could crash them..
 | 
			
		||||
     */
 | 
			
		||||
    private HashMap<Integer, Object> backupEntityValues = new HashMap<Integer, Object>();
 | 
			
		||||
    private boolean hasDied;
 | 
			
		||||
    private org.bukkit.inventory.ItemStack[] items = new org.bukkit.inventory.ItemStack[5];
 | 
			
		||||
 | 
			
		||||
@@ -78,10 +82,17 @@ public class FlagWatcher {
 | 
			
		||||
            // I send my custom values if I see this!
 | 
			
		||||
            if (dataType == 1)
 | 
			
		||||
                sendAllCustom = true;
 | 
			
		||||
            Object value = null;
 | 
			
		||||
            if (entityValues.containsKey(dataType)) {
 | 
			
		||||
                if (entityValues.get(dataType) == null)
 | 
			
		||||
                    continue;
 | 
			
		||||
                Object value = entityValues.get(dataType);
 | 
			
		||||
                value = entityValues.get(dataType);
 | 
			
		||||
            } else if (backupEntityValues.containsKey(dataType)) {
 | 
			
		||||
                if (backupEntityValues.get(dataType) == null)
 | 
			
		||||
                    continue;
 | 
			
		||||
                value = backupEntityValues.get(dataType);
 | 
			
		||||
            }
 | 
			
		||||
            if (value != null) {
 | 
			
		||||
                boolean doD = watch.d();
 | 
			
		||||
                watch = new WatchableObject(classTypes.get(value.getClass()), dataType, value);
 | 
			
		||||
                if (!doD)
 | 
			
		||||
@@ -307,4 +318,8 @@ public class FlagWatcher {
 | 
			
		||||
        entityValues.put(no, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void setBackupValue(int no, Object value) {
 | 
			
		||||
        backupEntityValues.put(no, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user