mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-26 20:16:02 +01:00
Small optimization for armor searching
This commit is contained in:
parent
615128eba2
commit
9b6a9fca3d
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user