Move SHIELD to from MetaItemStack to MaterialUtil

This commit is contained in:
md678685 2018-12-09 13:47:52 +00:00
parent 814e5a643e
commit 5922b85290
2 changed files with 3 additions and 12 deletions

View File

@ -37,7 +37,6 @@ import static com.earth2me.essentials.I18n.tl;
public class MetaItemStack {
private static final Map<String, DyeColor> colorMap = new HashMap<>();
private static final Map<String, FireworkEffect.Type> fireworkShape = new HashMap<>();
private static final Set<Material> banners = new HashSet<>();
static {
for (DyeColor color : DyeColor.values()) {
@ -46,11 +45,6 @@ public class MetaItemStack {
for (FireworkEffect.Type type : FireworkEffect.Type.values()) {
fireworkShape.put(type.name(), type);
}
for (Material mat : Material.values()) {
if (mat.name().contains("BANNER")) {
banners.add(mat);
}
}
}
private final transient Pattern splitPattern = Pattern.compile("[:+',;.]");
@ -163,7 +157,6 @@ public class MetaItemStack {
}
Material WRITTEN_BOOK = EnumUtil.getMaterial("WRITTEN_BOOK");
Material SHIELD = EnumUtil.getMaterial("SHIELD"); // 1.9
if (split.length > 1 && split[0].equalsIgnoreCase("name") && hasMetaPermission(sender, "name", false, true, ess)) {
final String displayName = FormatUtil.replaceFormat(split[1].replace('_', ' '));
@ -222,8 +215,6 @@ public class MetaItemStack {
} else if (MaterialUtil.isBanner(stack.getType())) {
//WARNING - Meta for banners will be ignored after this point.
addBannerMeta(sender, false, string, ess);
} else if (SHIELD != null && stack.getType() == SHIELD) { //WARNING - Meta for shields will be ignored after this point.
addBannerMeta(sender, false, string, ess);
} else if (split.length > 1 && (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour")) && MaterialUtil.isLeatherArmor(stack.getType())) {
final String[] color = split[1].split("(\\||,)");
if (color.length == 1 && (NumberUtil.isInt(color[0]) || color[0].startsWith("#"))) {
@ -480,7 +471,7 @@ public class MetaItemStack {
}
public void addBannerMeta(final CommandSource sender, final boolean allowShortName, final String string, final IEssentials ess) throws Exception {
if (banners.contains(stack.getType()) && string != null) {
if (MaterialUtil.isBanner(stack.getType()) && !stack.getType().toString().equals("SHIELD") && string != null) {
final String[] split = splitPattern.split(string, 2);
if (split.length < 2) {
@ -504,7 +495,7 @@ public class MetaItemStack {
}
stack.setItemMeta(meta);
} else if (stack.getType() == Material.SHIELD && string != null) {
} else if (stack.getType().toString().equals("SHIELD") && string != null) {
final String[] split = splitPattern.split(string, 2);
if (split.length < 2) {

View File

@ -30,7 +30,7 @@ public class MaterialUtil {
BANNERS = EnumUtil.getAllMatching(Material.class, "BANNER", "WHITE_BANNER",
"ORANGE_BANNER", "MAGENTA_BANNER", "LIGHT_BLUE_BANNER", "YELLOW_BANNER", "LIME_BANNER",
"PINK_BANNER","GRAY_BANNER","LIGHT_GRAY_BANNER", "CYAN_BANNER", "PURPLE_BANNER",
"BLUE_BANNER", "BROWN_BANNER", "GREEN_BANNER", "RED_BANNER", "BLACK_BANNER");
"BLUE_BANNER", "BROWN_BANNER", "GREEN_BANNER", "RED_BANNER", "BLACK_BANNER", "SHIELD");
FIREWORKS = EnumUtil.getAllMatching(Material.class, "FIREWORK", "FIREWORK_ROCKET",
"FIREWORK_CHARGE", "FIREWORK_STAR");