Compile against 1.13 preview.

Still a lot of work to do. One thing to note is that I used LEGACY materials in a few spots where I didn't know what the new ones are as I'm not very familiar with the 1.13 update and what it changes.
This commit is contained in:
Trent Hensler 2018-01-18 17:52:44 -08:00
parent 1a820ad9b7
commit ace361af60
29 changed files with 159 additions and 258 deletions

View file

@ -29,8 +29,9 @@ import static com.earth2me.essentials.I18n.tl;
public class MetaItemStack {
private static final Map<String, DyeColor> colorMap = new HashMap<String, DyeColor>();
private static final Map<String, FireworkEffect.Type> fireworkShape = new HashMap<String, FireworkEffect.Type>();
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()) {
@ -39,6 +40,11 @@ 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("[:+',;.]");
@ -181,7 +187,7 @@ public class MetaItemStack {
} else if (split[0].equalsIgnoreCase("unbreakable") && hasMetaPermission(sender, "unbreakable", false, true, ess)) {
boolean value = split.length > 1 ? Boolean.valueOf(split[1]) : true;
setUnbreakable(stack, value);
} else if (split.length > 1 && (split[0].equalsIgnoreCase("player") || split[0].equalsIgnoreCase("owner")) && stack.getType() == Material.SKULL_ITEM && hasMetaPermission(sender, "head", false, true, ess)) {
} else if (split.length > 1 && (split[0].equalsIgnoreCase("player") || split[0].equalsIgnoreCase("owner")) && (stack.getType() == Material.SKELETON_SKULL || stack.getType() == Material.WITHER_SKELETON_SKULL) && hasMetaPermission(sender, "head", false, true, ess)) {
if (stack.getDurability() == 3) {
final String owner = split[1];
final SkullMeta meta = (SkullMeta) stack.getItemMeta();
@ -208,12 +214,12 @@ public class MetaItemStack {
final BookMeta meta = (BookMeta) stack.getItemMeta();
meta.setTitle(title);
stack.setItemMeta(meta);
} else if (split.length > 1 && split[0].equalsIgnoreCase("power") && stack.getType() == Material.FIREWORK && hasMetaPermission(sender, "firework-power", false, true, ess)) {
} else if (split.length > 1 && split[0].equalsIgnoreCase("power") && (stack.getType() == Material.FIREWORK_ROCKET || stack.getType() == Material.FIREWORK_STAR)&& hasMetaPermission(sender, "firework-power", false, true, ess)) {
final int power = NumberUtil.isInt(split[1]) ? Integer.parseInt(split[1]) : 0;
final FireworkMeta meta = (FireworkMeta) stack.getItemMeta();
meta.setPower(power > 3 ? 4 : power);
stack.setItemMeta(meta);
} else if (stack.getType() == Material.FIREWORK) {//WARNING - Meta for fireworks will be ignored after this point.
} else if (stack.getType() == Material.FIREWORK_ROCKET || stack.getType() == Material.FIREWORK_STAR) {//WARNING - Meta for fireworks will be ignored after this point.
addFireworkMeta(sender, false, string, ess);
} else if (isPotion(stack.getType())) { //WARNING - Meta for potions will be ignored after this point.
addPotionMeta(sender, false, string, ess);
@ -251,7 +257,7 @@ public class MetaItemStack {
}
public void addFireworkMeta(final CommandSource sender, final boolean allowShortName, final String string, final IEssentials ess) throws Exception {
if (stack.getType() == Material.FIREWORK) {
if (stack.getType() == Material.FIREWORK_ROCKET || stack.getType() == Material.FIREWORK_STAR) {
final String[] split = splitPattern.split(string, 2);
if (split.length < 2) {
return;
@ -444,7 +450,7 @@ public class MetaItemStack {
}
public void addBannerMeta(final CommandSource sender, final boolean allowShortName, final String string, final IEssentials ess) throws Exception {
if (stack.getType() == Material.BANNER && string != null) {
if (banners.contains(stack.getType()) && string != null) {
final String[] split = splitPattern.split(string, 2);
if (split.length < 2) {