3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 00:50:13 +01:00

Merge pull request #247 from HugoDaBosss/apiv2

Small optimization for armor searching
Dieser Commit ist enthalten in:
Myles 2016-03-18 22:04:05 +00:00
Commit ed766eb656

Datei anzeigen

@ -1,7 +1,10 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8;
import java.util.HashMap;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@ -35,11 +38,17 @@ public enum ArmorType {
private final int id;
private final Material type;
private static HashMap<Material, ArmorType> armor;
static {
armor = new HashMap<Material, ArmorType>();
for(ArmorType a : ArmorType.values()) {
armor.put(a.getType(), a);
}
}
public static ArmorType findByType(Material type) {
for (ArmorType a : ArmorType.values())
if (a.getType() == type)
return a;
return ArmorType.NONE;
ArmorType t = armor.get(type);
return t == null ? ArmorType.NONE : t;
}
public static int calculateArmorPoints(ItemStack[] armor) {