package protocolsupport.protocol.typeremapper.legacy;

import java.util.HashMap;
import java.util.Map;

import org.bukkit.NamespacedKey;

import protocolsupportbuildprocessor.Preload;

@Preload
public class LegacyEntityAttribute {

	protected static final Map<String, String> toLegacyId = new HashMap<>();

	protected static void register(String modernId, String legacyId) {
		toLegacyId.put(modernId, legacyId);
		toLegacyId.put(NamespacedKey.minecraft(modernId).toString(), legacyId);
	}

	static {
		register("generic.max_health", "generic.maxHealth");
		register("generic.follow_range", "generic.followRange");
		register("generic.knockback_resistance", "generic.knockbackResistance");
		register("generic.movement_speed", "generic.movementSpeed");
		register("generic.attack_damage", "generic.attackDamage");
		register("generic.attack_speed", "generic.attackSpeed");
		register("generic.flying_speed", "generic.flyingSpeed");
		register("generic.armor_toughness", "generic.armorToughness");
		register("generic.attack_knockback", "generic.attackKnockback");
		register("horse.jump_strength", "horse.jumpStrength");
		register("zombie.spawn_reinforcements", "zombie.spawnReinforcements");
	}

	public static String getLegacyId(String modernId) {
		return toLegacyId.getOrDefault(modernId, modernId);
	}

}

@@ -298,16 +298,90 @@
 Map%3C%3E();
+%0A%09protected static final Map%3CString, String%3E toModernId = new HashMap%3C%3E();
 %0A%0A%09prote
@@ -550,24 +550,62 @@
  legacyId);%0A
+%09%09toModernId.put(legacyId, modernId);%0A
 %09%7D%0A%0A%09static 
@@ -685,18 +685,19 @@
 ric.
-follow_ran
+attack_dama
 ge%22,
@@ -710,17 +710,18 @@
 ric.
-followRan
+attackDama
 ge%22)
@@ -746,28 +746,83 @@
 ric.
-knockback_resistance
+attack_speed%22, %22generic.attackSpeed%22);%0A%09%09register(%22generic.attack_knockback
 %22, %22
@@ -829,25 +829,31 @@
 generic.
-k
+attackK
 nockback
 Resistan
@@ -848,141 +848,193 @@
 back
-Resistance%22);%0A%09%09register(%22generic.movement_speed%22, %22generic.movementSpeed%22);%0A%09%09register(%22generic.attack_damage%22, %22generic.attackDamag
+%22);%0A%09%09register(%22generic.armor%22, %22generic.armor%22);%0A%09%09register(%22generic.armor_toughness%22, %22generic.armorToughness%22);%0A%09%09register(%22generic.knockback_resistance%22, %22generic.knockbackResistanc
 e%22);
@@ -1046,38 +1046,40 @@
 gister(%22generic.
-attack
+movement
 _speed%22, %22generi
@@ -1072,38 +1072,40 @@
 peed%22, %22generic.
-attack
+movement
 Speed%22);%0A%09%09regis
@@ -1180,49 +1180,43 @@
 ric.
-armor_toughness%22, %22generic.armorToughness
+follow_range%22, %22generic.followRange
 %22);%0A
@@ -1231,38 +1231,26 @@
 er(%22generic.
-attack_knockba
+lu
 ck%22, %22generi
@@ -1247,37 +1247,26 @@
 %22, %22generic.
-attackKnockba
+lu
 ck%22);%0A%09%09regi
@@ -1504,10 +1504,121 @@
 d);%0A%09%7D%0A%0A
+%09public static String getModernId(String legacyId) %7B%0A%09%09return toModernId.getOrDefault(legacyId, legacyId);%0A%09%7D%0A%0A
 %7D%0A

Add missing legacy entity attribute mappings