mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 19:24:44 +02:00
Another dupe fix + 1.16 support part 4
This commit is contained in:
@ -2,6 +2,7 @@ package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
|
||||
@ -53,6 +54,8 @@ public class MaterialMapStore {
|
||||
|
||||
private HashSet<String> ores;
|
||||
|
||||
private HashMap<String, Integer> tierValue;
|
||||
|
||||
|
||||
public MaterialMapStore()
|
||||
{
|
||||
@ -96,7 +99,9 @@ public class MaterialMapStore {
|
||||
|
||||
ores = new HashSet<>();
|
||||
|
||||
fillHardcodedHashSets();
|
||||
tierValue = new HashMap<>();
|
||||
|
||||
fillVanillaMaterialRegisters();
|
||||
}
|
||||
|
||||
public boolean isMultiBlockPlant(Material material)
|
||||
@ -139,7 +144,7 @@ public class MaterialMapStore {
|
||||
return canMakeShroomyWhiteList.contains(material.getKey().getKey());
|
||||
}
|
||||
|
||||
private void fillHardcodedHashSets()
|
||||
private void fillVanillaMaterialRegisters()
|
||||
{
|
||||
fillAbilityBlackList();
|
||||
fillToolBlackList();
|
||||
@ -155,6 +160,34 @@ public class MaterialMapStore {
|
||||
fillTools();
|
||||
fillEnchantables();
|
||||
fillOres();
|
||||
|
||||
fillTierMap();
|
||||
}
|
||||
|
||||
private void fillTierMap() {
|
||||
for(String id : leatherArmor) {
|
||||
tierValue.put(id, 1);
|
||||
}
|
||||
|
||||
for(String id : ironArmor) {
|
||||
tierValue.put(id, 2);
|
||||
}
|
||||
|
||||
for(String id : goldArmor) {
|
||||
tierValue.put(id, 3);
|
||||
}
|
||||
|
||||
for(String id : chainmailArmor) {
|
||||
tierValue.put(id, 3);
|
||||
}
|
||||
|
||||
for(String id : diamondArmor) {
|
||||
tierValue.put(id, 6);
|
||||
}
|
||||
|
||||
for(String id : netherriteArmor) {
|
||||
tierValue.put(id, 12);
|
||||
}
|
||||
}
|
||||
|
||||
private void fillOres() {
|
||||
@ -1040,6 +1073,14 @@ public class MaterialMapStore {
|
||||
toolBlackList.add("stonecutter");
|
||||
}
|
||||
|
||||
public int getTier(Material material) {
|
||||
return getTier(material.getKey().getKey());
|
||||
}
|
||||
|
||||
public int getTier(String id) {
|
||||
return tierValue.getOrDefault(id, 1); //1 for unknown items
|
||||
}
|
||||
|
||||
private void addToHashSet(String string, HashSet<String> stringHashSet)
|
||||
{
|
||||
stringHashSet.add(string.toLowerCase(Locale.ENGLISH));
|
||||
|
@ -411,12 +411,9 @@ public final class CombatUtils {
|
||||
if(metadataValue.size() <= 0)
|
||||
return;
|
||||
|
||||
if(metadataValue != null)
|
||||
{
|
||||
OldName oldName = (OldName) metadataValue.get(0);
|
||||
entity.setCustomName(oldName.asString());
|
||||
entity.setCustomNameVisible(false);
|
||||
}
|
||||
OldName oldName = (OldName) metadataValue.get(0);
|
||||
entity.setCustomName(oldName.asString());
|
||||
entity.setCustomNameVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -480,33 +477,7 @@ public final class CombatUtils {
|
||||
* @return the armor quality of a specific Item Stack
|
||||
*/
|
||||
private static int getArmorQuality(ItemStack itemStack) {
|
||||
int quality = 0;
|
||||
|
||||
switch(itemStack.getType()) {
|
||||
case LEATHER_HELMET:
|
||||
case LEATHER_BOOTS:
|
||||
case LEATHER_CHESTPLATE:
|
||||
case LEATHER_LEGGINGS:
|
||||
return 1;
|
||||
case IRON_HELMET:
|
||||
case IRON_BOOTS:
|
||||
case IRON_CHESTPLATE:
|
||||
case IRON_LEGGINGS:
|
||||
return 2;
|
||||
case GOLDEN_HELMET:
|
||||
case GOLDEN_BOOTS:
|
||||
case GOLDEN_CHESTPLATE:
|
||||
case GOLDEN_LEGGINGS:
|
||||
return 3;
|
||||
case DIAMOND_HELMET:
|
||||
case DIAMOND_BOOTS:
|
||||
case DIAMOND_CHESTPLATE:
|
||||
case DIAMOND_LEGGINGS:
|
||||
return 6;
|
||||
default:
|
||||
return 1;
|
||||
|
||||
}
|
||||
return mcMMO.getMaterialMapStore().getTier(itemStack.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user