fix bug where armor stand could be renamed to heart symbols

This commit is contained in:
nossr50
2025-10-05 13:30:24 -07:00
parent c79b3fe024
commit 00c0b2e5ec
3 changed files with 14 additions and 6 deletions

View File

@@ -9,6 +9,7 @@ Version 2.2.043
Added Copper_Golem to experience.yml for Combat XP Added Copper_Golem to experience.yml for Combat XP
Fixed ExploitFix.PreventArmorStandInteraction in experience.yml not being respected Fixed ExploitFix.PreventArmorStandInteraction in experience.yml not being respected
Added ExploitFix.PreventMannequinInteraction to experience.yml to prevent mannequins from granting XP or other effects Added ExploitFix.PreventMannequinInteraction to experience.yml to prevent mannequins from granting XP or other effects
Fixed bug where Armor Stands would get renamed to heart symbols upon breaking them
NOTES: NOTES:
You don't need to update your experience.yml, that one updates automatically when you run mcMMO after an update. You don't need to update your experience.yml, that one updates automatically when you run mcMMO after an update.

View File

@@ -1203,11 +1203,11 @@ public class EntityListener implements Listener {
} }
} }
private static boolean isMannequinEntity(Entity attacker) { public static boolean isMannequinEntity(Entity attacker) {
return MANNEQUIN.contains(attacker.getType().toString()); return MANNEQUIN.contains(attacker.getType().toString());
} }
private static boolean isArmorStandEntity(Entity attacker) { public static boolean isArmorStandEntity(Entity attacker) {
return ARMOR_STAND.contains(attacker.getType().toString()); return ARMOR_STAND.contains(attacker.getType().toString());
} }
} }

View File

@@ -1,5 +1,8 @@
package com.gmail.nossr50.util; package com.gmail.nossr50.util;
import static com.gmail.nossr50.listeners.EntityListener.isArmorStandEntity;
import static com.gmail.nossr50.listeners.EntityListener.isMannequinEntity;
import com.gmail.nossr50.datatypes.MobHealthbarType; import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.meta.OldName; import com.gmail.nossr50.datatypes.meta.OldName;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
@@ -40,8 +43,12 @@ public final class MobHealthbarUtils {
* @param damage damage done by the attack triggering this * @param damage damage done by the attack triggering this
*/ */
public static void handleMobHealthbars(LivingEntity target, double damage, mcMMO plugin) { public static void handleMobHealthbars(LivingEntity target, double damage, mcMMO plugin) {
if (mcMMO.isHealthBarPluginEnabled() || !mcMMO.p.getGeneralConfig() if (isArmorStandEntity(target) || isMannequinEntity(target)) {
.getMobHealthbarEnabled()) { return;
}
if (mcMMO.isHealthBarPluginEnabled()
|| !mcMMO.p.getGeneralConfig().getMobHealthbarEnabled()) {
return; return;
} }
@@ -54,13 +61,13 @@ public final class MobHealthbarUtils {
return; return;
} }
String originalName = target.getName(); final String originalName = target.getName();
String oldName = target.getCustomName(); String oldName = target.getCustomName();
/* /*
* Store the name in metadata * Store the name in metadata
*/ */
if (target.getMetadata(MetadataConstants.METADATA_KEY_OLD_NAME_KEY).size() <= 0) { if (target.getMetadata(MetadataConstants.METADATA_KEY_OLD_NAME_KEY).isEmpty()) {
target.setMetadata(MetadataConstants.METADATA_KEY_OLD_NAME_KEY, target.setMetadata(MetadataConstants.METADATA_KEY_OLD_NAME_KEY,
new OldName(originalName, plugin)); new OldName(originalName, plugin));
} }