diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbook.java b/Essentials/src/com/earth2me/essentials/commands/Commandbook.java index 9e8dfc38d..ea2934716 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbook.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbook.java @@ -2,6 +2,7 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.User; import com.earth2me.essentials.craftbukkit.InventoryWorkaround; +import com.earth2me.essentials.utils.EnumUtil; import com.google.common.collect.Lists; import org.bukkit.Material; import org.bukkit.Server; @@ -15,6 +16,9 @@ import static com.earth2me.essentials.I18n.tl; public class Commandbook extends EssentialsCommand { + + private static final Material WRITABLE_BOOK = EnumUtil.getMaterial("WRITABLE_BOOK", "BOOK_AND_QUILL"); + public Commandbook() { super("book"); } @@ -44,7 +48,7 @@ public class Commandbook extends EssentialsCommand { } } else { if (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others")) { - ItemStack newItem = new ItemStack(Material.WRITABLE_BOOK, item.getAmount()); + ItemStack newItem = new ItemStack(WRITABLE_BOOK, item.getAmount()); newItem.setItemMeta(bmeta); InventoryWorkaround.setItemInMainHand(user.getBase(), newItem); user.sendMessage(tl("editBookContents")); @@ -52,7 +56,7 @@ public class Commandbook extends EssentialsCommand { throw new Exception(tl("denyBookEdit")); } } - } else if (item.getType() == Material.WRITABLE_BOOK) { + } else if (item.getType() == WRITABLE_BOOK) { BookMeta bmeta = (BookMeta) item.getItemMeta(); if (!user.isAuthorized("essentials.book.author")) { bmeta.setAuthor(player); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfirework.java b/Essentials/src/com/earth2me/essentials/commands/Commandfirework.java index 344c5db77..c2860e052 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandfirework.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandfirework.java @@ -2,6 +2,7 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.MetaItemStack; import com.earth2me.essentials.User; +import com.earth2me.essentials.utils.MaterialUtil; import com.earth2me.essentials.utils.NumberUtil; import com.google.common.collect.Lists; import org.bukkit.DyeColor; @@ -44,7 +45,7 @@ public class Commandfirework extends EssentialsCommand { @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { final ItemStack stack = user.getBase().getInventory().getItemInMainHand(); - if (stack.getType() == Material.FIREWORK_ROCKET || stack.getType() == Material.FIREWORK_STAR) { + if (MaterialUtil.isFirework(stack.getType())) { if (args.length > 0) { if (args[0].equalsIgnoreCase("clear")) { FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java b/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java index 4be7af7a6..f0d4ec805 100755 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java @@ -2,6 +2,7 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.User; +import com.earth2me.essentials.utils.EnumUtil; import com.earth2me.essentials.utils.NumberUtil; import com.earth2me.essentials.utils.VersionUtil; import org.bukkit.Material; @@ -20,6 +21,11 @@ import net.ess3.nms.refl.ReflUtil; public class Commandrecipe extends EssentialsCommand { + + private static final Material FIREWORK_ROCKET = EnumUtil.getMaterial("FIREWORK_ROCKET", "FIREWORK"); + private static final Material FIREWORK_STAR = EnumUtil.getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE"); + private static final Material GUNPOWDER = EnumUtil.getMaterial("GUNPOWDER", "SULPHUR"); + public Commandrecipe() { super("recipe"); } @@ -67,11 +73,11 @@ public class Commandrecipe extends EssentialsCommand { } else if (selectedRecipe instanceof ShapedRecipe) { shapedRecipe(sender, (ShapedRecipe) selectedRecipe, sender.isPlayer()); } else if (selectedRecipe instanceof ShapelessRecipe) { - if (recipesOfType.size() == 1 && (itemType.getType() == Material.FIREWORK_ROCKET || itemType.getType() == Material.FIREWORK_STAR)) { + if (recipesOfType.size() == 1 && (itemType.getType() == FIREWORK_ROCKET)) { ShapelessRecipe shapelessRecipe = new ShapelessRecipe(itemType); - shapelessRecipe.addIngredient(Material.LEGACY_SULPHUR); + shapelessRecipe.addIngredient(GUNPOWDER); shapelessRecipe.addIngredient(Material.PAPER); - shapelessRecipe.addIngredient(Material.FIREWORK_ROCKET); + shapelessRecipe.addIngredient(FIREWORK_STAR); shapelessRecipe(sender, shapelessRecipe, sender.isPlayer()); } else { shapelessRecipe(sender, (ShapelessRecipe) selectedRecipe, sender.isPlayer()); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandskull.java b/Essentials/src/com/earth2me/essentials/commands/Commandskull.java index e37e00468..e0be7058b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandskull.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandskull.java @@ -2,6 +2,8 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.User; import com.earth2me.essentials.craftbukkit.InventoryWorkaround; +import com.earth2me.essentials.utils.EnumUtil; +import com.earth2me.essentials.utils.MaterialUtil; import com.google.common.collect.Lists; import org.bukkit.Material; import org.bukkit.Server; @@ -14,6 +16,9 @@ import java.util.List; import static com.earth2me.essentials.I18n.tl; public class Commandskull extends EssentialsCommand { + + private static final Material SKULL_ITEM = EnumUtil.getMaterial("PLAYER_HEAD", "SKULL_ITEM"); + public Commandskull() { super("skull"); } @@ -35,10 +40,10 @@ public class Commandskull extends EssentialsCommand { SkullMeta metaSkull = null; boolean spawn = false; - if (itemSkull != null && itemSkull.getType() == Material.LEGACY_SKULL_ITEM && itemSkull.getDurability() == 3) { + if (itemSkull != null && MaterialUtil.isPlayerHead(itemSkull.getType(), itemSkull.getDurability())) { metaSkull = (SkullMeta) itemSkull.getItemMeta(); } else if (user.isAuthorized("essentials.skull.spawn")) { - itemSkull = new ItemStack(Material.LEGACY_SKULL_ITEM, 1, (byte) 3); + itemSkull = new ItemStack(SKULL_ITEM, 1, (byte) 3); metaSkull = (SkullMeta) itemSkull.getItemMeta(); spawn = true; } else { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index 0515d12e5..35eb6dc56 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -17,13 +17,12 @@ import static com.earth2me.essentials.I18n.tl; public class Commandwhois extends EssentialsCommand { - private final Statistic playOneTick; + // For some reason, in 1.13 PLAY_ONE_MINUTE = ticks played = what used to be PLAY_ONE_TICK + // https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/b848d8ce633871b52115247b089029749c02f579 + private static final Statistic PLAY_ONE_TICK = EnumUtil.getStatistic("PLAY_ONE_MINUTE", "PLAY_ONE_TICK"); public Commandwhois() { super("whois"); - // For some reason, in 1.13 PLAY_ONE_MINUTE = ticks played - // https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/b848d8ce633871b52115247b089029749c02f579 - playOneTick = EnumUtil.getStatistic("PLAY_ONE_MINUTE", "PLAY_ONE_TICK"); } @Override @@ -42,7 +41,7 @@ public class Commandwhois extends EssentialsCommand { sender.sendMessage(tl("whoisHunger", user.getBase().getFoodLevel(), user.getBase().getSaturation())); sender.sendMessage(tl("whoisExp", SetExpFix.getTotalExperience(user.getBase()), user.getBase().getLevel())); sender.sendMessage(tl("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ())); - long playtimeMs = System.currentTimeMillis() - (user.getBase().getStatistic(playOneTick) * 50); + long playtimeMs = System.currentTimeMillis() - (user.getBase().getStatistic(PLAY_ONE_TICK) * 50); sender.sendMessage(tl("whoisPlaytime", DateUtil.formatDateDiff(playtimeMs))); if (!ess.getSettings().isEcoDisabled()) { sender.sendMessage(tl("whoisMoney", NumberUtil.displayCurrency(user.getMoney(), ess)));