Skip to content

Commit

Permalink
Fix cured villagers not having custom name removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Archy-X committed Jul 20, 2024
1 parent 5f3a203 commit 8238bd6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/main/java/dev/aurelium/auramobs/AuraMobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.*;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

Expand Down Expand Up @@ -194,6 +193,12 @@ public boolean isAuraMob(LivingEntity m) {
return m.getPersistentDataContainer().has(mobKey, PersistentDataType.INTEGER);
}

public boolean isInvalidEntity(Entity entity) {
if (entity instanceof Boss || !(entity instanceof LivingEntity)) return true; // Types to exclude
if (entity instanceof Hoglin || entity instanceof Slime) return false; // Types to include
return !(entity instanceof Monster);
}

public Formatter getFormatter() {
return formatter;
}
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/dev/aurelium/auramobs/listeners/MobSpawn.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void onSpawn(CreatureSpawnEvent e) {
}
if (!f) return;

if (isInvalidEntity(e.getEntity())) {
if (plugin.isInvalidEntity(e.getEntity())) {
return;
}
LivingEntity entity = e.getEntity();
Expand Down Expand Up @@ -62,11 +62,6 @@ public void onSpawn(CreatureSpawnEvent e) {
}
}

private boolean isInvalidEntity(Entity entity) {
if (entity instanceof Boss || !(entity instanceof LivingEntity)) return true; // Types to exclude
if (entity instanceof Hoglin || entity instanceof Slime) return false; // Types to include
return !(entity instanceof Monster);
}

public boolean passWorld(World world) {
if (plugin.isWorldWhitelist()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void onMutate(EntityTransformEvent event) {
return;
}

if (!(event.getTransformedEntity() instanceof LivingEntity)) {
if (plugin.isInvalidEntity(entity)) {
event.getTransformedEntity().getPersistentDataContainer().remove(plugin.getMobKey());
event.getTransformedEntity().setCustomNameVisible(false);
event.getTransformedEntity().setCustomName(null);
Expand Down

0 comments on commit 8238bd6

Please sign in to comment.