mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 11:03:43 +01:00 
			
		
		
		
	Remove metadata, validation checks.
This commit is contained in:
		@@ -12,13 +12,20 @@ public class MobHealthDisplayUpdaterTask extends BukkitRunnable {
 | 
			
		||||
 | 
			
		||||
    public MobHealthDisplayUpdaterTask(LivingEntity target) {
 | 
			
		||||
        this.target = target;
 | 
			
		||||
        this.oldName = target.getMetadata(mcMMO.customNameKey).get(0).asString();
 | 
			
		||||
        this.oldNameVisible = target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean();
 | 
			
		||||
 | 
			
		||||
        if (target.isValid()) {
 | 
			
		||||
            this.oldName = target.getMetadata(mcMMO.customNameKey).get(0).asString();
 | 
			
		||||
            this.oldNameVisible = target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void run() {
 | 
			
		||||
        target.setCustomNameVisible(oldNameVisible);
 | 
			
		||||
        target.setCustomName(oldName);
 | 
			
		||||
        if (target.isValid()) {
 | 
			
		||||
            target.setCustomNameVisible(oldNameVisible);
 | 
			
		||||
            target.setCustomName(oldName);
 | 
			
		||||
            target.removeMetadata(mcMMO.customNameKey, mcMMO.p);
 | 
			
		||||
            target.removeMetadata(mcMMO.customVisibleKey, mcMMO.p);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -313,9 +313,7 @@ public final class CombatUtils {
 | 
			
		||||
                        target.setMetadata(mcMMO.customVisibleKey, new FixedMetadataValue(mcMMO.p, oldNameVisible));
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    if (target.isValid()) {
 | 
			
		||||
                        new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, displayTime * 20); // Clear health display after 3 seconds
 | 
			
		||||
                    }
 | 
			
		||||
                    new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, displayTime * 20); // Clear health display after 3 seconds
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user