Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 09:00:09 +01:00
Merge pull request #247 from HugoDaBosss/apiv2
Small optimization for armor searching
Dieser Commit ist enthalten in:
Commit
ed766eb656
@ -1,7 +1,10 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -35,11 +38,17 @@ public enum ArmorType {
|
|||||||
private final int id;
|
private final int id;
|
||||||
private final Material type;
|
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) {
|
public static ArmorType findByType(Material type) {
|
||||||
for (ArmorType a : ArmorType.values())
|
ArmorType t = armor.get(type);
|
||||||
if (a.getType() == type)
|
return t == null ? ArmorType.NONE : t;
|
||||||
return a;
|
|
||||||
return ArmorType.NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int calculateArmorPoints(ItemStack[] armor) {
|
public static int calculateArmorPoints(ItemStack[] armor) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren