|
@@ -1,6 +1,7 @@
|
|
|
package com.gmail.nossr50.listeners;
|
|
|
|
|
|
import com.gmail.nossr50.config.AdvancedConfig;
|
|
|
+import com.gmail.nossr50.datatypes.meta.OldName;
|
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
|
|
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
|
|
@@ -36,10 +37,13 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
import org.bukkit.inventory.meta.PotionMeta;
|
|
|
import org.bukkit.metadata.FixedMetadataValue;
|
|
|
+import org.bukkit.metadata.MetadataValue;
|
|
|
import org.bukkit.potion.PotionEffect;
|
|
|
import org.bukkit.potion.PotionEffectType;
|
|
|
import org.bukkit.projectiles.ProjectileSource;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
public class EntityListener implements Listener {
|
|
|
private final mcMMO plugin;
|
|
|
|
|
@@ -223,7 +227,28 @@ public class EntityListener implements Listener {
|
|
|
}
|
|
|
|
|
|
CombatUtils.processCombatAttack(event, attacker, target);
|
|
|
- CombatUtils.handleHealthbars(attacker, target, event.getFinalDamage());
|
|
|
+ CombatUtils.handleHealthbars(attacker, target, event.getFinalDamage(), plugin);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * This sets entity names back to whatever they are supposed to be
|
|
|
+ */
|
|
|
+ if(!(attacker instanceof Player) && defender instanceof Player)
|
|
|
+ {
|
|
|
+ if(event.getFinalDamage() >= ((LivingEntity) defender).getHealth())
|
|
|
+ {
|
|
|
+ List<MetadataValue> metadataValue = attacker.getMetadata("mcMMO_oldName");
|
|
|
+
|
|
|
+ if(metadataValue.size() <= 0)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if(metadataValue != null)
|
|
|
+ {
|
|
|
+ OldName oldName = (OldName) metadataValue.get(0);
|
|
|
+ attacker.setCustomName(oldName.asString());
|
|
|
+ attacker.setCustomNameVisible(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -294,6 +319,7 @@ public class EntityListener implements Listener {
|
|
|
if (event.getFinalDamage() >= 1) {
|
|
|
mcMMOPlayer.actualizeRecentlyHurt();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
else if (livingEntity instanceof Tameable) {
|