diff --git a/Essentials/src/main/java/com/earth2me/essentials/Enchantments.java b/Essentials/src/main/java/com/earth2me/essentials/Enchantments.java index 542dca311..c75fc6aa3 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Enchantments.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Enchantments.java @@ -1,5 +1,6 @@ package com.earth2me.essentials; +import com.earth2me.essentials.utils.RegistryUtil; import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; @@ -15,33 +16,43 @@ public final class Enchantments { private static boolean isFlat; static { - ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL); - ALIASENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL); - ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL); - ALIASENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL); - ALIASENCHANTMENTS.put("dal", Enchantment.DAMAGE_ALL); + final Enchantment SHARPNESS = RegistryUtil.valueOf(Enchantment.class, "DAMAGE_ALL", "SHARPNESS"); + + ENCHANTMENTS.put("alldamage", SHARPNESS); + ALIASENCHANTMENTS.put("alldmg", SHARPNESS); + ENCHANTMENTS.put("sharpness", SHARPNESS); + ALIASENCHANTMENTS.put("sharp", SHARPNESS); + ALIASENCHANTMENTS.put("dal", SHARPNESS); + + final Enchantment BANE_OF_ARTHROPODS = RegistryUtil.valueOf(Enchantment.class, "DAMAGE_ARTHROPODS", "BANE_OF_ARTHROPODS"); - ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS); - ENCHANTMENTS.put("baneofarthropods", Enchantment.DAMAGE_ARTHROPODS); - ALIASENCHANTMENTS.put("baneofarthropod", Enchantment.DAMAGE_ARTHROPODS); - ALIASENCHANTMENTS.put("arthropod", Enchantment.DAMAGE_ARTHROPODS); - ALIASENCHANTMENTS.put("dar", Enchantment.DAMAGE_ARTHROPODS); + ENCHANTMENTS.put("ardmg", BANE_OF_ARTHROPODS); + ENCHANTMENTS.put("baneofarthropods", BANE_OF_ARTHROPODS); + ALIASENCHANTMENTS.put("baneofarthropod", BANE_OF_ARTHROPODS); + ALIASENCHANTMENTS.put("arthropod", BANE_OF_ARTHROPODS); + ALIASENCHANTMENTS.put("dar", BANE_OF_ARTHROPODS); + + final Enchantment SMITE = RegistryUtil.valueOf(Enchantment.class, "DAMAGE_UNDEAD", "SMITE"); - ENCHANTMENTS.put("undeaddamage", Enchantment.DAMAGE_UNDEAD); - ENCHANTMENTS.put("smite", Enchantment.DAMAGE_UNDEAD); - ALIASENCHANTMENTS.put("du", Enchantment.DAMAGE_UNDEAD); + ENCHANTMENTS.put("undeaddamage", SMITE); + ENCHANTMENTS.put("smite", SMITE); + ALIASENCHANTMENTS.put("du", SMITE); + + final Enchantment EFFICIENCY = RegistryUtil.valueOf(Enchantment.class, "DIG_SPEED", "EFFICIENCY"); - ENCHANTMENTS.put("digspeed", Enchantment.DIG_SPEED); - ENCHANTMENTS.put("efficiency", Enchantment.DIG_SPEED); - ALIASENCHANTMENTS.put("minespeed", Enchantment.DIG_SPEED); - ALIASENCHANTMENTS.put("cutspeed", Enchantment.DIG_SPEED); - ALIASENCHANTMENTS.put("ds", Enchantment.DIG_SPEED); - ALIASENCHANTMENTS.put("eff", Enchantment.DIG_SPEED); + ENCHANTMENTS.put("digspeed", EFFICIENCY); + ENCHANTMENTS.put("efficiency", EFFICIENCY); + ALIASENCHANTMENTS.put("minespeed", EFFICIENCY); + ALIASENCHANTMENTS.put("cutspeed", EFFICIENCY); + ALIASENCHANTMENTS.put("ds", EFFICIENCY); + ALIASENCHANTMENTS.put("eff", EFFICIENCY); + + final Enchantment UNBREAKING = RegistryUtil.valueOf(Enchantment.class, "DURABILITY", "UNBREAKING"); - ENCHANTMENTS.put("durability", Enchantment.DURABILITY); - ALIASENCHANTMENTS.put("dura", Enchantment.DURABILITY); - ENCHANTMENTS.put("unbreaking", Enchantment.DURABILITY); - ALIASENCHANTMENTS.put("d", Enchantment.DURABILITY); + ENCHANTMENTS.put("durability", UNBREAKING); + ALIASENCHANTMENTS.put("dura", UNBREAKING); + ENCHANTMENTS.put("unbreaking", UNBREAKING); + ALIASENCHANTMENTS.put("d", UNBREAKING); ENCHANTMENTS.put("thorns", Enchantment.THORNS); ENCHANTMENTS.put("highcrit", Enchantment.THORNS); @@ -59,106 +70,127 @@ public final class Enchantments { ALIASENCHANTMENTS.put("kback", Enchantment.KNOCKBACK); ALIASENCHANTMENTS.put("kb", Enchantment.KNOCKBACK); ALIASENCHANTMENTS.put("k", Enchantment.KNOCKBACK); + + final Enchantment FORTUNE = RegistryUtil.valueOf(Enchantment.class, "LOOT_BONUS_BLOCKS", "FORTUNE"); - ALIASENCHANTMENTS.put("blockslootbonus", Enchantment.LOOT_BONUS_BLOCKS); - ENCHANTMENTS.put("fortune", Enchantment.LOOT_BONUS_BLOCKS); - ALIASENCHANTMENTS.put("fort", Enchantment.LOOT_BONUS_BLOCKS); - ALIASENCHANTMENTS.put("lbb", Enchantment.LOOT_BONUS_BLOCKS); + ALIASENCHANTMENTS.put("blockslootbonus", FORTUNE); + ENCHANTMENTS.put("fortune", FORTUNE); + ALIASENCHANTMENTS.put("fort", FORTUNE); + ALIASENCHANTMENTS.put("lbb", FORTUNE); + + final Enchantment LOOTING = RegistryUtil.valueOf(Enchantment.class, "LOOT_BONUS_MOBS", "LOOTING"); - ALIASENCHANTMENTS.put("mobslootbonus", Enchantment.LOOT_BONUS_MOBS); - ENCHANTMENTS.put("mobloot", Enchantment.LOOT_BONUS_MOBS); - ENCHANTMENTS.put("looting", Enchantment.LOOT_BONUS_MOBS); - ALIASENCHANTMENTS.put("lbm", Enchantment.LOOT_BONUS_MOBS); + ALIASENCHANTMENTS.put("mobslootbonus", LOOTING); + ENCHANTMENTS.put("mobloot", LOOTING); + ENCHANTMENTS.put("looting", LOOTING); + ALIASENCHANTMENTS.put("lbm", LOOTING); + + final Enchantment RESPIRATION = RegistryUtil.valueOf(Enchantment.class, "OXYGEN", "RESPIRATION"); - ALIASENCHANTMENTS.put("oxygen", Enchantment.OXYGEN); - ENCHANTMENTS.put("respiration", Enchantment.OXYGEN); - ALIASENCHANTMENTS.put("breathing", Enchantment.OXYGEN); - ENCHANTMENTS.put("breath", Enchantment.OXYGEN); - ALIASENCHANTMENTS.put("o", Enchantment.OXYGEN); + ALIASENCHANTMENTS.put("oxygen", RESPIRATION); + ENCHANTMENTS.put("respiration", RESPIRATION); + ALIASENCHANTMENTS.put("breathing", RESPIRATION); + ENCHANTMENTS.put("breath", RESPIRATION); + ALIASENCHANTMENTS.put("o", RESPIRATION); + + final Enchantment PROTECTION = RegistryUtil.valueOf(Enchantment.class, "PROTECTION_ENVIRONMENTAL", "PROTECTION"); - ENCHANTMENTS.put("protection", Enchantment.PROTECTION_ENVIRONMENTAL); - ALIASENCHANTMENTS.put("prot", Enchantment.PROTECTION_ENVIRONMENTAL); - ENCHANTMENTS.put("protect", Enchantment.PROTECTION_ENVIRONMENTAL); - ALIASENCHANTMENTS.put("p", Enchantment.PROTECTION_ENVIRONMENTAL); + ENCHANTMENTS.put("protection", PROTECTION); + ALIASENCHANTMENTS.put("prot", PROTECTION); + ENCHANTMENTS.put("protect", PROTECTION); + ALIASENCHANTMENTS.put("p", PROTECTION); + + final Enchantment BLAST_PROTECTION = RegistryUtil.valueOf(Enchantment.class, "PROTECTION_EXPLOSIONS", "BLAST_PROTECTION"); - ALIASENCHANTMENTS.put("explosionsprotection", Enchantment.PROTECTION_EXPLOSIONS); - ALIASENCHANTMENTS.put("explosionprotection", Enchantment.PROTECTION_EXPLOSIONS); - ALIASENCHANTMENTS.put("expprot", Enchantment.PROTECTION_EXPLOSIONS); - ALIASENCHANTMENTS.put("blastprotection", Enchantment.PROTECTION_EXPLOSIONS); - ALIASENCHANTMENTS.put("bprotection", Enchantment.PROTECTION_EXPLOSIONS); - ALIASENCHANTMENTS.put("bprotect", Enchantment.PROTECTION_EXPLOSIONS); - ENCHANTMENTS.put("blastprotect", Enchantment.PROTECTION_EXPLOSIONS); - ALIASENCHANTMENTS.put("pe", Enchantment.PROTECTION_EXPLOSIONS); + ALIASENCHANTMENTS.put("explosionsprotection", BLAST_PROTECTION); + ALIASENCHANTMENTS.put("explosionprotection", BLAST_PROTECTION); + ALIASENCHANTMENTS.put("expprot", BLAST_PROTECTION); + ALIASENCHANTMENTS.put("blastprotection", BLAST_PROTECTION); + ALIASENCHANTMENTS.put("bprotection", BLAST_PROTECTION); + ALIASENCHANTMENTS.put("bprotect", BLAST_PROTECTION); + ENCHANTMENTS.put("blastprotect", BLAST_PROTECTION); + ALIASENCHANTMENTS.put("pe", BLAST_PROTECTION); + + final Enchantment FEATHER_FALLING = RegistryUtil.valueOf(Enchantment.class, "PROTECTION_FALL", "FEATHER_FALLING"); - ALIASENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL); - ENCHANTMENTS.put("fallprot", Enchantment.PROTECTION_FALL); - ENCHANTMENTS.put("featherfall", Enchantment.PROTECTION_FALL); - ALIASENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL); - ALIASENCHANTMENTS.put("pfa", Enchantment.PROTECTION_FALL); + ALIASENCHANTMENTS.put("fallprotection", FEATHER_FALLING); + ENCHANTMENTS.put("fallprot", FEATHER_FALLING); + ENCHANTMENTS.put("featherfall", FEATHER_FALLING); + ALIASENCHANTMENTS.put("featherfalling", FEATHER_FALLING); + ALIASENCHANTMENTS.put("pfa", FEATHER_FALLING); + + final Enchantment FIRE_PROTECTION = RegistryUtil.valueOf(Enchantment.class, "PROTECTION_FIRE", "FIRE_PROTECTION"); - ALIASENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE); - ALIASENCHANTMENTS.put("flameprotection", Enchantment.PROTECTION_FIRE); - ENCHANTMENTS.put("fireprotect", Enchantment.PROTECTION_FIRE); - ALIASENCHANTMENTS.put("flameprotect", Enchantment.PROTECTION_FIRE); - ENCHANTMENTS.put("fireprot", Enchantment.PROTECTION_FIRE); - ALIASENCHANTMENTS.put("flameprot", Enchantment.PROTECTION_FIRE); - ALIASENCHANTMENTS.put("pf", Enchantment.PROTECTION_FIRE); + ALIASENCHANTMENTS.put("fireprotection", FIRE_PROTECTION); + ALIASENCHANTMENTS.put("flameprotection", FIRE_PROTECTION); + ENCHANTMENTS.put("fireprotect", FIRE_PROTECTION); + ALIASENCHANTMENTS.put("flameprotect", FIRE_PROTECTION); + ENCHANTMENTS.put("fireprot", FIRE_PROTECTION); + ALIASENCHANTMENTS.put("flameprot", FIRE_PROTECTION); + ALIASENCHANTMENTS.put("pf", FIRE_PROTECTION); + + final Enchantment PROJECTILE_PROTECTION = RegistryUtil.valueOf(Enchantment.class, "PROTECTION_PROJECTILE", "PROJECTILE_PROTECTION"); - ENCHANTMENTS.put("projectileprotection", Enchantment.PROTECTION_PROJECTILE); - ENCHANTMENTS.put("projprot", Enchantment.PROTECTION_PROJECTILE); - ALIASENCHANTMENTS.put("pp", Enchantment.PROTECTION_PROJECTILE); + ENCHANTMENTS.put("projectileprotection", PROJECTILE_PROTECTION); + ENCHANTMENTS.put("projprot", PROJECTILE_PROTECTION); + ALIASENCHANTMENTS.put("pp", PROJECTILE_PROTECTION); ENCHANTMENTS.put("silktouch", Enchantment.SILK_TOUCH); ALIASENCHANTMENTS.put("softtouch", Enchantment.SILK_TOUCH); ALIASENCHANTMENTS.put("st", Enchantment.SILK_TOUCH); + + final Enchantment AQUA_AFFINITY = RegistryUtil.valueOf(Enchantment.class, "WATER_WORKER", "AQUA_AFFINITY"); - ENCHANTMENTS.put("waterworker", Enchantment.WATER_WORKER); - ENCHANTMENTS.put("aquaaffinity", Enchantment.WATER_WORKER); - ALIASENCHANTMENTS.put("watermine", Enchantment.WATER_WORKER); - ALIASENCHANTMENTS.put("ww", Enchantment.WATER_WORKER); + ENCHANTMENTS.put("waterworker", AQUA_AFFINITY); + ENCHANTMENTS.put("aquaaffinity", AQUA_AFFINITY); + ALIASENCHANTMENTS.put("watermine", AQUA_AFFINITY); + ALIASENCHANTMENTS.put("ww", AQUA_AFFINITY); + + final Enchantment FLAME = RegistryUtil.valueOf(Enchantment.class, "ARROW_FIRE", "FLAME"); - ALIASENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE); - ENCHANTMENTS.put("flame", Enchantment.ARROW_FIRE); - ENCHANTMENTS.put("flamearrow", Enchantment.ARROW_FIRE); - ALIASENCHANTMENTS.put("af", Enchantment.ARROW_FIRE); + ALIASENCHANTMENTS.put("firearrow", FLAME); + ENCHANTMENTS.put("flame", FLAME); + ENCHANTMENTS.put("flamearrow", FLAME); + ALIASENCHANTMENTS.put("af", FLAME); + + final Enchantment POWER = RegistryUtil.valueOf(Enchantment.class, "ARROW_DAMAGE", "POWER"); - ENCHANTMENTS.put("arrowdamage", Enchantment.ARROW_DAMAGE); - ENCHANTMENTS.put("power", Enchantment.ARROW_DAMAGE); - ALIASENCHANTMENTS.put("arrowpower", Enchantment.ARROW_DAMAGE); - ALIASENCHANTMENTS.put("ad", Enchantment.ARROW_DAMAGE); + ENCHANTMENTS.put("arrowdamage", POWER); + ENCHANTMENTS.put("power", POWER); + ALIASENCHANTMENTS.put("arrowpower", POWER); + ALIASENCHANTMENTS.put("ad", POWER); + + final Enchantment PUNCH = RegistryUtil.valueOf(Enchantment.class, "ARROW_KNOCKBACK", "PUNCH"); - ENCHANTMENTS.put("arrowknockback", Enchantment.ARROW_KNOCKBACK); - ALIASENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK); - ENCHANTMENTS.put("punch", Enchantment.ARROW_KNOCKBACK); - ALIASENCHANTMENTS.put("arrowpunch", Enchantment.ARROW_KNOCKBACK); - ALIASENCHANTMENTS.put("ak", Enchantment.ARROW_KNOCKBACK); + ENCHANTMENTS.put("arrowknockback", PUNCH); + ALIASENCHANTMENTS.put("arrowkb", PUNCH); + ENCHANTMENTS.put("punch", PUNCH); + ALIASENCHANTMENTS.put("arrowpunch", PUNCH); + ALIASENCHANTMENTS.put("ak", PUNCH); + + final Enchantment INFINITY = RegistryUtil.valueOf(Enchantment.class, "ARROW_INFINITE", "INFINITY"); - ALIASENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE); - ENCHANTMENTS.put("infarrows", Enchantment.ARROW_INFINITE); - ENCHANTMENTS.put("infinity", Enchantment.ARROW_INFINITE); - ALIASENCHANTMENTS.put("infinite", Enchantment.ARROW_INFINITE); - ALIASENCHANTMENTS.put("unlimited", Enchantment.ARROW_INFINITE); - ALIASENCHANTMENTS.put("unlimitedarrows", Enchantment.ARROW_INFINITE); - ALIASENCHANTMENTS.put("ai", Enchantment.ARROW_INFINITE); + ALIASENCHANTMENTS.put("infinitearrows", INFINITY); + ENCHANTMENTS.put("infarrows", INFINITY); + ENCHANTMENTS.put("infinity", INFINITY); + ALIASENCHANTMENTS.put("infinite", INFINITY); + ALIASENCHANTMENTS.put("unlimited", INFINITY); + ALIASENCHANTMENTS.put("unlimitedarrows", INFINITY); + ALIASENCHANTMENTS.put("ai", INFINITY); + + final Enchantment LUCK_OF_THE_SEA = RegistryUtil.valueOf(Enchantment.class, "LUCK", "LUCK_OF_THE_SEA"); - ENCHANTMENTS.put("luck", Enchantment.LUCK); - ALIASENCHANTMENTS.put("luckofsea", Enchantment.LUCK); - ALIASENCHANTMENTS.put("luckofseas", Enchantment.LUCK); - ALIASENCHANTMENTS.put("rodluck", Enchantment.LUCK); + ENCHANTMENTS.put("luck", LUCK_OF_THE_SEA); + ALIASENCHANTMENTS.put("luckofsea", LUCK_OF_THE_SEA); + ALIASENCHANTMENTS.put("luckofseas", LUCK_OF_THE_SEA); + ALIASENCHANTMENTS.put("rodluck", LUCK_OF_THE_SEA); ENCHANTMENTS.put("lure", Enchantment.LURE); ALIASENCHANTMENTS.put("rodlure", Enchantment.LURE); - // 1.8 - try { - final Enchantment depthStrider = Enchantment.getByName("DEPTH_STRIDER"); - if (depthStrider != null) { - ENCHANTMENTS.put("depthstrider", depthStrider); - ALIASENCHANTMENTS.put("depth", depthStrider); - ALIASENCHANTMENTS.put("strider", depthStrider); - } - } catch (final IllegalArgumentException ignored) { - } + ENCHANTMENTS.put("depthstrider", Enchantment.DEPTH_STRIDER); + ALIASENCHANTMENTS.put("depth", Enchantment.DEPTH_STRIDER); + ALIASENCHANTMENTS.put("strider", Enchantment.DEPTH_STRIDER); // 1.9 try { diff --git a/Essentials/src/main/java/com/earth2me/essentials/Essentials.java b/Essentials/src/main/java/com/earth2me/essentials/Essentials.java index a095ba8aa..9933f4523 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Essentials.java @@ -59,6 +59,7 @@ import net.ess3.nms.refl.providers.ReflServerStateProvider; import net.ess3.nms.refl.providers.ReflSpawnEggProvider; import net.ess3.nms.refl.providers.ReflSpawnerBlockProvider; import net.ess3.nms.refl.providers.ReflSyncCommandsProvider; +import net.ess3.provider.BannerDataProvider; import net.ess3.provider.BiomeKeyProvider; import net.ess3.provider.ContainerProvider; import net.ess3.provider.DamageEventProvider; @@ -78,8 +79,10 @@ import net.ess3.provider.SpawnerBlockProvider; import net.ess3.provider.SpawnerItemProvider; import net.ess3.provider.SyncCommandsProvider; import net.ess3.provider.WorldInfoProvider; +import net.ess3.provider.providers.BaseBannerDataProvider; import net.ess3.provider.providers.BaseLoggerProvider; -import net.ess3.provider.providers.BasePotionDataProvider; +import net.ess3.provider.providers.LegacyBannerDataProvider; +import net.ess3.provider.providers.LegacyPotionMetaProvider; import net.ess3.provider.providers.BlockMetaSpawnerItemProvider; import net.ess3.provider.providers.BukkitMaterialTagProvider; import net.ess3.provider.providers.BukkitSpawnerBlockProvider; @@ -88,7 +91,8 @@ import net.ess3.provider.providers.FlatSpawnEggProvider; import net.ess3.provider.providers.LegacyDamageEventProvider; import net.ess3.provider.providers.LegacyItemUnbreakableProvider; import net.ess3.provider.providers.LegacyPlayerLocaleProvider; -import net.ess3.provider.providers.LegacyPotionMetaProvider; +import net.ess3.provider.providers.ModernPotionMetaProvider; +import net.ess3.provider.providers.PrehistoricPotionMetaProvider; import net.ess3.provider.providers.LegacySpawnEggProvider; import net.ess3.provider.providers.ModernDamageEventProvider; import net.ess3.provider.providers.ModernDataWorldInfoProvider; @@ -184,6 +188,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { private transient SpawnerBlockProvider spawnerBlockProvider; private transient SpawnEggProvider spawnEggProvider; private transient PotionMetaProvider potionMetaProvider; + private transient BannerDataProvider bannerDataProvider; private transient ServerStateProvider serverStateProvider; private transient ContainerProvider containerProvider; private transient SerializationProvider serializationProvider; @@ -403,10 +408,19 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { } //Potion Meta Provider - if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_9_R01)) { - potionMetaProvider = new LegacyPotionMetaProvider(); + if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_20_6_R01)) { + potionMetaProvider = new ModernPotionMetaProvider(); + } else if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_9_R01)) { + potionMetaProvider = new PrehistoricPotionMetaProvider(); } else { - potionMetaProvider = new BasePotionDataProvider(); + potionMetaProvider = new LegacyPotionMetaProvider(); + } + + //Banner Meta Provider + if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_20_6_R01)) { + bannerDataProvider = new BaseBannerDataProvider(); + } else { + bannerDataProvider = new LegacyBannerDataProvider(); } //Server State Provider @@ -1364,6 +1378,11 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { return potionMetaProvider; } + @Override + public BannerDataProvider getBannerDataProvider() { + return bannerDataProvider; + } + @Override public CustomItemResolver getCustomItemResolver() { return customItemResolver; diff --git a/Essentials/src/main/java/com/earth2me/essentials/IEssentials.java b/Essentials/src/main/java/com/earth2me/essentials/IEssentials.java index 3b41f1c30..5fbb1bf87 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/IEssentials.java +++ b/Essentials/src/main/java/com/earth2me/essentials/IEssentials.java @@ -9,6 +9,7 @@ import com.earth2me.essentials.perm.PermissionsHandler; import com.earth2me.essentials.updatecheck.UpdateChecker; import com.earth2me.essentials.userstorage.IUserMap; import net.ess3.nms.refl.providers.ReflOnlineModeProvider; +import net.ess3.provider.BannerDataProvider; import net.ess3.provider.BiomeKeyProvider; import net.ess3.provider.ContainerProvider; import net.ess3.provider.DamageEventProvider; @@ -189,5 +190,7 @@ public interface IEssentials extends Plugin { BiomeKeyProvider getBiomeKeyProvider(); + BannerDataProvider getBannerDataProvider(); + PluginCommand getPluginCommand(String cmd); } diff --git a/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java b/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java index 136209887..58c980b74 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java +++ b/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java @@ -30,7 +30,6 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.meta.SkullMeta; -import org.bukkit.potion.Potion; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -251,7 +250,7 @@ public class MetaItemStack { meta.setTitle(title); stack.setItemMeta(meta); } else if (split.length > 1 && split[0].startsWith("page") && split[0].length() > 4 && MaterialUtil.isEditableBook(stack.getType()) && hasMetaPermission(sender, "page", false, true, ess)) { - final int page = NumberUtil.isInt(split[0].substring(4)) ? (Integer.parseInt(split[0].substring(4)) - 1) : 0; + final int page = NumberUtil.isInt(split[0].substring(4)) ? Integer.parseInt(split[0].substring(4)) - 1 : 0; final BookMeta meta = (BookMeta) stack.getItemMeta(); final List pages = meta.hasPages() ? new ArrayList<>(meta.getPages()) : new ArrayList<>(); final List lines = new ArrayList<>(); @@ -354,7 +353,7 @@ public class MetaItemStack { return; } - if (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour") || (allowShortName && split[0].equalsIgnoreCase("c"))) { + if (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour") || allowShortName && split[0].equalsIgnoreCase("c")) { final List primaryColors = new ArrayList<>(); final String[] colors = split[1].split(","); for (final String color : colors) { @@ -369,7 +368,7 @@ public class MetaItemStack { } } builder.withColor(primaryColors); - } else if (split[0].equalsIgnoreCase("shape") || split[0].equalsIgnoreCase("type") || (allowShortName && (split[0].equalsIgnoreCase("s") || split[0].equalsIgnoreCase("t")))) { + } else if (split[0].equalsIgnoreCase("shape") || split[0].equalsIgnoreCase("type") || allowShortName && (split[0].equalsIgnoreCase("s") || split[0].equalsIgnoreCase("t"))) { FireworkEffect.Type finalEffect = null; split[1] = split[1].equalsIgnoreCase("large") ? "BALL_LARGE" : split[1]; if (fireworkShape.containsKey(split[1].toUpperCase())) { @@ -380,7 +379,7 @@ public class MetaItemStack { if (finalEffect != null) { builder.with(finalEffect); } - } else if (split[0].equalsIgnoreCase("fade") || (allowShortName && split[0].equalsIgnoreCase("f"))) { + } else if (split[0].equalsIgnoreCase("fade") || allowShortName && split[0].equalsIgnoreCase("f")) { final List fadeColors = new ArrayList<>(); final String[] colors = split[1].split(","); for (final String color : colors) { @@ -395,7 +394,7 @@ public class MetaItemStack { if (!fadeColors.isEmpty()) { builder.withFade(fadeColors); } - } else if (split[0].equalsIgnoreCase("effect") || (allowShortName && split[0].equalsIgnoreCase("e"))) { + } else if (split[0].equalsIgnoreCase("effect") || allowShortName && split[0].equalsIgnoreCase("e")) { final String[] effects = split[1].split(","); for (final String effect : effects) { if (effect.equalsIgnoreCase("twinkle")) { @@ -416,7 +415,7 @@ public class MetaItemStack { return; } - if (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour") || (allowShortName && split[0].equalsIgnoreCase("c"))) { + if (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour") || allowShortName && split[0].equalsIgnoreCase("c")) { if (validFirework) { if (!hasMetaPermission(sender, "firework", true, true, ess)) { throw new TranslatableException("noMetaFirework"); @@ -445,7 +444,7 @@ public class MetaItemStack { } } builder.withColor(primaryColors); - } else if (split[0].equalsIgnoreCase("shape") || split[0].equalsIgnoreCase("type") || (allowShortName && (split[0].equalsIgnoreCase("s") || split[0].equalsIgnoreCase("t")))) { + } else if (split[0].equalsIgnoreCase("shape") || split[0].equalsIgnoreCase("type") || allowShortName && (split[0].equalsIgnoreCase("s") || split[0].equalsIgnoreCase("t"))) { FireworkEffect.Type finalEffect = null; split[1] = split[1].equalsIgnoreCase("large") ? "BALL_LARGE" : split[1]; if (fireworkShape.containsKey(split[1].toUpperCase())) { @@ -456,7 +455,7 @@ public class MetaItemStack { if (finalEffect != null) { builder.with(finalEffect); } - } else if (split[0].equalsIgnoreCase("fade") || (allowShortName && split[0].equalsIgnoreCase("f"))) { + } else if (split[0].equalsIgnoreCase("fade") || allowShortName && split[0].equalsIgnoreCase("f")) { final List fadeColors = new ArrayList<>(); final String[] colors = split[1].split(","); for (final String color : colors) { @@ -471,7 +470,7 @@ public class MetaItemStack { if (!fadeColors.isEmpty()) { builder.withFade(fadeColors); } - } else if (split[0].equalsIgnoreCase("effect") || (allowShortName && split[0].equalsIgnoreCase("e"))) { + } else if (split[0].equalsIgnoreCase("effect") || allowShortName && split[0].equalsIgnoreCase("e")) { final String[] effects = split[1].split(","); for (final String effect : effects) { if (effect.equalsIgnoreCase("twinkle")) { @@ -494,7 +493,7 @@ public class MetaItemStack { return; } - if (split[0].equalsIgnoreCase("effect") || (allowShortName && split[0].equalsIgnoreCase("e"))) { + if (split[0].equalsIgnoreCase("effect") || allowShortName && split[0].equalsIgnoreCase("e")) { pEffectType = Potions.getByName(split[1]); if (pEffectType != null && pEffectType.getName() != null) { if (hasMetaPermission(sender, "potions." + pEffectType.getName().toLowerCase(Locale.ENGLISH), true, false, ess)) { @@ -505,7 +504,7 @@ public class MetaItemStack { } else { throw new TranslatableException("invalidPotionMeta", split[1]); } - } else if (split[0].equalsIgnoreCase("power") || (allowShortName && split[0].equalsIgnoreCase("p"))) { + } else if (split[0].equalsIgnoreCase("power") || allowShortName && split[0].equalsIgnoreCase("p")) { if (NumberUtil.isInt(split[1])) { validPotionPower = true; power = Integer.parseInt(split[1]); @@ -515,21 +514,21 @@ public class MetaItemStack { } else { throw new TranslatableException("invalidPotionMeta", split[1]); } - } else if (split[0].equalsIgnoreCase("amplifier") || (allowShortName && split[0].equalsIgnoreCase("a"))) { + } else if (split[0].equalsIgnoreCase("amplifier") || allowShortName && split[0].equalsIgnoreCase("a")) { if (NumberUtil.isInt(split[1])) { validPotionPower = true; power = Integer.parseInt(split[1]); } else { throw new TranslatableException("invalidPotionMeta", split[1]); } - } else if (split[0].equalsIgnoreCase("duration") || (allowShortName && split[0].equalsIgnoreCase("d"))) { + } else if (split[0].equalsIgnoreCase("duration") || allowShortName && split[0].equalsIgnoreCase("d")) { if (NumberUtil.isInt(split[1])) { validPotionDuration = true; duration = Integer.parseInt(split[1]) * 20; //Duration is in ticks by default, converted to seconds } else { throw new TranslatableException("invalidPotionMeta", split[1]); } - } else if (split[0].equalsIgnoreCase("splash") || (allowShortName && split[0].equalsIgnoreCase("s"))) { + } else if (split[0].equalsIgnoreCase("splash") || allowShortName && split[0].equalsIgnoreCase("s")) { isSplashPotion = Boolean.parseBoolean(split[1]); } @@ -541,17 +540,7 @@ public class MetaItemStack { } pmeta.addCustomEffect(pEffect, true); stack.setItemMeta(pmeta); - if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_9_R01)) { - if (isSplashPotion && stack.getType() == Material.POTION) { - stack.setType(Material.SPLASH_POTION); - } else if (!isSplashPotion && stack.getType() == Material.SPLASH_POTION) { - stack.setType(Material.POTION); - } - } else { - final Potion potion = Potion.fromDamage(stack.getDurability()); - potion.setSplash(isSplashPotion); - potion.apply(stack); - } + ess.getPotionMetaProvider().setSplashPotion(stack, isSplashPotion); resetPotionMeta(); } } @@ -572,7 +561,7 @@ public class MetaItemStack { } } - if (level < 0 || (!allowUnsafe && level > enchantment.getMaxLevel())) { + if (level < 0 || !allowUnsafe && level > enchantment.getMaxLevel()) { level = enchantment.getMaxLevel(); } addEnchantment(sender, allowUnsafe, enchantment, level); @@ -633,6 +622,7 @@ public class MetaItemStack { PatternType patternType = null; try { + //noinspection removal patternType = PatternType.getByIdentifier(split[0]); } catch (final Exception ignored) { } @@ -640,8 +630,9 @@ public class MetaItemStack { final BannerMeta meta = (BannerMeta) stack.getItemMeta(); if (split[0].equalsIgnoreCase("basecolor")) { final Color color = Color.fromRGB(Integer.parseInt(split[1])); - meta.setBaseColor(DyeColor.getByColor(color)); + ess.getBannerDataProvider().setBaseColor(stack, DyeColor.getByColor(color)); } else if (patternType != null) { + //noinspection removal final PatternType type = PatternType.getByIdentifier(split[0]); final DyeColor color = DyeColor.getByColor(Color.fromRGB(Integer.parseInt(split[1]))); final org.bukkit.block.banner.Pattern pattern = new org.bukkit.block.banner.Pattern(color, type); @@ -658,6 +649,7 @@ public class MetaItemStack { PatternType patternType = null; try { + //noinspection removal patternType = PatternType.getByIdentifier(split[0]); } catch (final Exception ignored) { } diff --git a/Essentials/src/main/java/com/earth2me/essentials/Mob.java b/Essentials/src/main/java/com/earth2me/essentials/Mob.java index 249746c0f..735b18a99 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Mob.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Mob.java @@ -42,9 +42,9 @@ public enum Mob { ENDERDRAGON("EnderDragon", Enemies.ENEMY, EntityType.ENDER_DRAGON), VILLAGER("Villager", Enemies.FRIENDLY, EntityType.VILLAGER), BLAZE("Blaze", Enemies.ENEMY, EntityType.BLAZE), - MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, EntityType.MUSHROOM_COW), + MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, MobCompat.MOOSHROOM), MAGMACUBE("MagmaCube", Enemies.ENEMY, EntityType.MAGMA_CUBE), - SNOWMAN("Snowman", Enemies.FRIENDLY, "", EntityType.SNOWMAN), + SNOWMAN("Snowman", Enemies.FRIENDLY, "", MobCompat.SNOW_GOLEM), OCELOT("Ocelot", Enemies.NEUTRAL, EntityType.OCELOT), IRONGOLEM("IronGolem", Enemies.NEUTRAL, EntityType.IRON_GOLEM), WITHER("Wither", Enemies.ENEMY, EntityType.WITHER), @@ -52,12 +52,12 @@ public enum Mob { WITCH("Witch", Enemies.ENEMY, EntityType.WITCH), BOAT("Boat", Enemies.NEUTRAL, EntityType.BOAT), MINECART("Minecart", Enemies.NEUTRAL, EntityType.MINECART), - MINECART_CHEST("ChestMinecart", Enemies.NEUTRAL, EntityType.MINECART_CHEST), - MINECART_FURNACE("FurnaceMinecart", Enemies.NEUTRAL, EntityType.MINECART_FURNACE), - MINECART_TNT("TNTMinecart", Enemies.NEUTRAL, EntityType.MINECART_TNT), - MINECART_HOPPER("HopperMinecart", Enemies.NEUTRAL, EntityType.MINECART_HOPPER), - MINECART_MOB_SPAWNER("SpawnerMinecart", Enemies.NEUTRAL, EntityType.MINECART_MOB_SPAWNER), - ENDERCRYSTAL("EnderCrystal", Enemies.NEUTRAL, EntityType.ENDER_CRYSTAL), + MINECART_CHEST("ChestMinecart", Enemies.NEUTRAL, MobCompat.CHEST_MINECART), + MINECART_FURNACE("FurnaceMinecart", Enemies.NEUTRAL, MobCompat.FURNACE_MINECART), + MINECART_TNT("TNTMinecart", Enemies.NEUTRAL, MobCompat.TNT_MINECART), + MINECART_HOPPER("HopperMinecart", Enemies.NEUTRAL, MobCompat.HOPPER_MINECART), + MINECART_MOB_SPAWNER("SpawnerMinecart", Enemies.NEUTRAL, MobCompat.SPAWNER_MINECART), + ENDERCRYSTAL("EnderCrystal", Enemies.NEUTRAL, MobCompat.END_CRYSTAL), EXPERIENCEORB("ExperienceOrb", Enemies.NEUTRAL, "EXPERIENCE_ORB"), ARMOR_STAND("ArmorStand", Enemies.NEUTRAL, "ARMOR_STAND"), ENDERMITE("Endermite", Enemies.ENEMY, "ENDERMITE"), @@ -112,6 +112,7 @@ public enum Mob { CHEST_BOAT("ChestBoat", Enemies.NEUTRAL, "CHEST_BOAT"), CAMEL("Camel", Enemies.FRIENDLY, "CAMEL"), SNIFFER("Sniffer", Enemies.FRIENDLY, "SNIFFER"), + ARMADILLO("Armadillo", Enemies.FRIENDLY, "ARMADILLO"), ; private static final Map hashMap = new HashMap<>(); diff --git a/Essentials/src/main/java/com/earth2me/essentials/MobCompat.java b/Essentials/src/main/java/com/earth2me/essentials/MobCompat.java index e4992f547..092e8d775 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/MobCompat.java +++ b/Essentials/src/main/java/com/earth2me/essentials/MobCompat.java @@ -1,6 +1,7 @@ package com.earth2me.essentials; import com.earth2me.essentials.utils.EnumUtil; +import com.earth2me.essentials.utils.RegistryUtil; import com.earth2me.essentials.utils.VersionUtil; import net.ess3.nms.refl.ReflUtil; import org.bukkit.Material; @@ -20,6 +21,7 @@ import org.bukkit.entity.Parrot; import org.bukkit.entity.Player; import org.bukkit.entity.TropicalFish; import org.bukkit.entity.Villager; +import org.bukkit.entity.Wolf; import org.bukkit.inventory.ItemStack; import java.lang.reflect.Method; @@ -50,6 +52,15 @@ public final class MobCompat { // Constants for mobs that have changed since earlier versions public static final EntityType CAT = getEntityType("CAT", "OCELOT"); public static final EntityType ZOMBIFIED_PIGLIN = getEntityType("ZOMBIFIED_PIGLIN", "PIG_ZOMBIE"); + public static final EntityType MOOSHROOM = getEntityType("MOOSHROOM", "MUSHROOM_COW"); + public static final EntityType SNOW_GOLEM = getEntityType("SNOW_GOLEM", "SNOWMAN"); + public static final EntityType CHEST_MINECART = getEntityType("CHEST_MINECART", "MINECART_CHEST"); + public static final EntityType FURNACE_MINECART = getEntityType("FURNACE_MINECART", "MINECART_FURNACE"); + public static final EntityType TNT_MINECART = getEntityType("TNT_MINECART", "MINECART_TNT"); + public static final EntityType HOPPER_MINECART = getEntityType("HOPPER_MINECART", "MINECART_HOPPER"); + public static final EntityType SPAWNER_MINECART = getEntityType("SPAWNER_MINECART", "MINECART_MOB_SPAWNER"); + public static final EntityType END_CRYSTAL = getEntityType("END_CRYSTAL", "ENDER_CRYSTAL"); + public static final EntityType FIREWORK_ROCKET = getEntityType("FIREWORK_ROCKET", "FIREWORK"); private MobCompat() { } @@ -213,6 +224,18 @@ public final class MobCompat { } } + public static void setWolfVariant(final Entity entity, final String variant) { + if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_20_6_R01)) { + return; + } + + if (entity instanceof Wolf) { + final Wolf wolf = (Wolf) entity; + //noinspection DataFlowIssue + wolf.setVariant(RegistryUtil.valueOf(Wolf.Variant.class, variant)); + } + } + public enum CatType { // These are (loosely) Mojang names for the cats SIAMESE("SIAMESE", "SIAMESE_CAT"), diff --git a/Essentials/src/main/java/com/earth2me/essentials/MobData.java b/Essentials/src/main/java/com/earth2me/essentials/MobData.java index 581713d82..90c8e42c5 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/MobData.java +++ b/Essentials/src/main/java/com/earth2me/essentials/MobData.java @@ -157,8 +157,8 @@ public enum MobData { BLOCKFISH_TROPICAL_FISH("blockfish", MobCompat.TROPICAL_FISH, "tropicalfish:BLOCKFISH", true), BETTY_TROPICAL_FISH("betty", MobCompat.TROPICAL_FISH, "tropicalfish:BETTY", true), CLAYFISH_TROPICAL_FISH("clayfish", MobCompat.TROPICAL_FISH, "tropicalfish:CLAYFISH", true), - BROWN_MUSHROOM_COW("brown", EntityType.MUSHROOM_COW, "mooshroom:BROWN", true), - RED_MUSHROOM_COW("red", EntityType.MUSHROOM_COW, "mooshroom:RED", true), + BROWN_MUSHROOM_COW("brown", MobCompat.MOOSHROOM, "mooshroom:BROWN", true), + RED_MUSHROOM_COW("red", MobCompat.MOOSHROOM, "mooshroom:RED", true), AGGRESSIVE_PANDA_MAIN("aggressive", MobCompat.PANDA, "pandamain:AGGRESSIVE", true), LAZY_PANDA_MAIN("lazy", MobCompat.PANDA, "pandamain:LAZY", true), WORRIED_PANDA_MAIN("worried", MobCompat.PANDA, "pandamain:WORRIED", true), @@ -209,6 +209,15 @@ public enum MobData { OAK_BOAT("oak", Boat.class, MobCompat.BoatVariant.OAK, true), SPRUCE_BOAT("spruce", Boat.class, MobCompat.BoatVariant.SPRUCE, true), SADDLE_CAMEL("saddle", MobCompat.CAMEL, Data.CAMELSADDLE, true), + PALE_WOLF("pale", EntityType.WOLF, "wolf:PALE", true), + SPOTTED_WOLF("spotted", EntityType.WOLF, "wolf:PALE", true), + SNOWY_WOLF("snowy", EntityType.WOLF, "wolf:PALE", true), + BLACK_WOLF("black", EntityType.WOLF, "wolf:BLACK", true), + ASHEN_WOLF("ashen", EntityType.WOLF, "wolf:ASHEN", true), + RUSTY_WOLF("rusty", EntityType.WOLF, "wolf:RUSTY", true), + WOODS_WOLF("woods", EntityType.WOLF, "wolf:WOODS", true), + CHESTNUT_WOLF("chestnut", EntityType.WOLF, "wolf:CHESTNUT", true), + STRIPED_WOLF("striped", EntityType.WOLF, "wolf:STRIPED", true), ; final private String nickname; @@ -424,6 +433,9 @@ public enum MobData { case "frog": MobCompat.setFrogVariant(spawned, split[1]); break; + case "wolf": + MobCompat.setWolfVariant(spawned, split[1]); + break; } } else { Essentials.getWrappedLogger().warning("Unknown mob data type: " + this.toString()); diff --git a/Essentials/src/main/java/com/earth2me/essentials/Potions.java b/Essentials/src/main/java/com/earth2me/essentials/Potions.java index b174a03c1..21eb45ff4 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Potions.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Potions.java @@ -1,6 +1,7 @@ package com.earth2me.essentials; import com.earth2me.essentials.utils.NumberUtil; +import com.earth2me.essentials.utils.RegistryUtil; import org.bukkit.potion.PotionEffectType; import java.util.HashMap; @@ -21,50 +22,68 @@ public final class Potions { ALIASPOTIONS.put("sprint", PotionEffectType.SPEED); ALIASPOTIONS.put("swift", PotionEffectType.SPEED); - POTIONS.put("slowness", PotionEffectType.SLOW); - ALIASPOTIONS.put("slow", PotionEffectType.SLOW); - ALIASPOTIONS.put("sluggish", PotionEffectType.SLOW); + final PotionEffectType SLOWNESS = RegistryUtil.valueOf(PotionEffectType.class, "SLOW", "SLOWNESS"); - POTIONS.put("haste", PotionEffectType.FAST_DIGGING); - ALIASPOTIONS.put("superpick", PotionEffectType.FAST_DIGGING); - ALIASPOTIONS.put("quickmine", PotionEffectType.FAST_DIGGING); - ALIASPOTIONS.put("digspeed", PotionEffectType.FAST_DIGGING); - ALIASPOTIONS.put("digfast", PotionEffectType.FAST_DIGGING); - ALIASPOTIONS.put("sharp", PotionEffectType.FAST_DIGGING); + POTIONS.put("slowness", SLOWNESS); + ALIASPOTIONS.put("slow", SLOWNESS); + ALIASPOTIONS.put("sluggish", SLOWNESS); - POTIONS.put("fatigue", PotionEffectType.SLOW_DIGGING); - ALIASPOTIONS.put("slow", PotionEffectType.SLOW_DIGGING); - ALIASPOTIONS.put("dull", PotionEffectType.SLOW_DIGGING); + final PotionEffectType HASTE = RegistryUtil.valueOf(PotionEffectType.class, "FAST_DIGGING", "HASTE"); - POTIONS.put("strength", PotionEffectType.INCREASE_DAMAGE); - ALIASPOTIONS.put("strong", PotionEffectType.INCREASE_DAMAGE); - ALIASPOTIONS.put("bull", PotionEffectType.INCREASE_DAMAGE); - ALIASPOTIONS.put("attack", PotionEffectType.INCREASE_DAMAGE); + POTIONS.put("haste", HASTE); + ALIASPOTIONS.put("superpick", HASTE); + ALIASPOTIONS.put("quickmine", HASTE); + ALIASPOTIONS.put("digspeed", HASTE); + ALIASPOTIONS.put("digfast", HASTE); + ALIASPOTIONS.put("sharp", HASTE); - POTIONS.put("heal", PotionEffectType.HEAL); - ALIASPOTIONS.put("healthy", PotionEffectType.HEAL); - ALIASPOTIONS.put("instaheal", PotionEffectType.HEAL); + final PotionEffectType MINING_FATIGUE = RegistryUtil.valueOf(PotionEffectType.class, "SLOW_DIGGING", "MINING_FATIGUE"); - POTIONS.put("harm", PotionEffectType.HARM); - ALIASPOTIONS.put("harming", PotionEffectType.HARM); - ALIASPOTIONS.put("injure", PotionEffectType.HARM); - ALIASPOTIONS.put("damage", PotionEffectType.HARM); - ALIASPOTIONS.put("inflict", PotionEffectType.HARM); + POTIONS.put("fatigue", MINING_FATIGUE); + ALIASPOTIONS.put("slow", MINING_FATIGUE); + ALIASPOTIONS.put("dull", MINING_FATIGUE); - POTIONS.put("jump", PotionEffectType.JUMP); - ALIASPOTIONS.put("leap", PotionEffectType.JUMP); + final PotionEffectType STRENGTH = RegistryUtil.valueOf(PotionEffectType.class, "INCREASE_DAMAGE", "STRENGTH"); - POTIONS.put("nausea", PotionEffectType.CONFUSION); - ALIASPOTIONS.put("sick", PotionEffectType.CONFUSION); - ALIASPOTIONS.put("sickness", PotionEffectType.CONFUSION); - ALIASPOTIONS.put("confusion", PotionEffectType.CONFUSION); + POTIONS.put("strength", STRENGTH); + ALIASPOTIONS.put("strong", STRENGTH); + ALIASPOTIONS.put("bull", STRENGTH); + ALIASPOTIONS.put("attack", STRENGTH); + + final PotionEffectType INSTANT_HEALTH = RegistryUtil.valueOf(PotionEffectType.class, "HEAL", "INSTANT_HEALTH"); + + POTIONS.put("heal", INSTANT_HEALTH); + ALIASPOTIONS.put("healthy", INSTANT_HEALTH); + ALIASPOTIONS.put("instaheal", INSTANT_HEALTH); + + final PotionEffectType INSTANT_DAMAGE = RegistryUtil.valueOf(PotionEffectType.class, "HARM", "INSTANT_DAMAGE"); + + POTIONS.put("harm", INSTANT_DAMAGE); + ALIASPOTIONS.put("harming", INSTANT_DAMAGE); + ALIASPOTIONS.put("injure", INSTANT_DAMAGE); + ALIASPOTIONS.put("damage", INSTANT_DAMAGE); + ALIASPOTIONS.put("inflict", INSTANT_DAMAGE); + + final PotionEffectType JUMP_BOOST = RegistryUtil.valueOf(PotionEffectType.class, "JUMP", "JUMP_BOOST"); + + POTIONS.put("jump", JUMP_BOOST); + ALIASPOTIONS.put("leap", JUMP_BOOST); + + final PotionEffectType NAUSEA = RegistryUtil.valueOf(PotionEffectType.class, "CONFUSION", "NAUSEA"); + + POTIONS.put("nausea", NAUSEA); + ALIASPOTIONS.put("sick", NAUSEA); + ALIASPOTIONS.put("sickness", NAUSEA); + ALIASPOTIONS.put("confusion", NAUSEA); POTIONS.put("regeneration", PotionEffectType.REGENERATION); ALIASPOTIONS.put("regen", PotionEffectType.REGENERATION); - POTIONS.put("resistance", PotionEffectType.DAMAGE_RESISTANCE); - ALIASPOTIONS.put("dmgresist", PotionEffectType.DAMAGE_RESISTANCE); - ALIASPOTIONS.put("armor", PotionEffectType.DAMAGE_RESISTANCE); + final PotionEffectType RESISTANCE = RegistryUtil.valueOf(PotionEffectType.class, "DAMAGE_RESISTANCE", "RESISTANCE"); + + POTIONS.put("resistance", RESISTANCE); + ALIASPOTIONS.put("dmgresist", RESISTANCE); + ALIASPOTIONS.put("armor", RESISTANCE); POTIONS.put("fireresist", PotionEffectType.FIRE_RESISTANCE); ALIASPOTIONS.put("fireresistance", PotionEffectType.FIRE_RESISTANCE); diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandfirework.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandfirework.java index 53238793a..0caddc7c2 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandfirework.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandfirework.java @@ -1,6 +1,7 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.MetaItemStack; +import com.earth2me.essentials.MobCompat; import com.earth2me.essentials.User; import com.earth2me.essentials.utils.MaterialUtil; import com.earth2me.essentials.utils.NumberUtil; @@ -9,7 +10,6 @@ import net.ess3.api.TranslatableException; import org.bukkit.DyeColor; import org.bukkit.FireworkEffect; import org.bukkit.Server; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.FireworkMeta; @@ -81,7 +81,7 @@ public class Commandfirework extends EssentialsCommand { } } for (int i = 0; i < amount; i++) { - final Firework firework = (Firework) user.getWorld().spawnEntity(user.getLocation(), EntityType.FIREWORK); + final Firework firework = (Firework) user.getWorld().spawnEntity(user.getLocation(), MobCompat.FIREWORK_ROCKET); final FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta(); if (direction) { final Vector vector = user.getBase().getEyeLocation().getDirection().multiply(0.070); diff --git a/Essentials/src/main/java/com/earth2me/essentials/items/AbstractItemDb.java b/Essentials/src/main/java/com/earth2me/essentials/items/AbstractItemDb.java index 19178c904..9b9b72656 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/items/AbstractItemDb.java +++ b/Essentials/src/main/java/com/earth2me/essentials/items/AbstractItemDb.java @@ -24,10 +24,8 @@ import org.bukkit.inventory.meta.FireworkEffectMeta; import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.Plugin; -import org.bukkit.potion.Potion; import org.bukkit.potion.PotionEffect; import java.util.ArrayList; @@ -285,16 +283,8 @@ public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb { serializeEffectMeta(sb, fireworkEffectMeta.getEffect()); } } else if (MaterialUtil.isPotion(material)) { - final boolean splash; - final Collection effects; - if (VersionUtil.PRE_FLATTENING) { - final Potion potion = Potion.fromDamage(is.getDurability()); - splash = potion.isSplash(); - effects = potion.getEffects(); - } else { - splash = is.getType() == Material.SPLASH_POTION; - effects = ((PotionMeta) is.getItemMeta()).getCustomEffects(); - } + final boolean splash = ess.getPotionMetaProvider().isSplashPotion(is); + final Collection effects = ess.getPotionMetaProvider().getCustomEffects(is); for (final PotionEffect e : effects) { // long but needs to be effect:speed power:2 duration:120 in that order. @@ -317,6 +307,7 @@ public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb { sb.append("basecolor:").append(basecolor).append(" "); } for (final org.bukkit.block.banner.Pattern p : shieldBannerMeta.getPatterns()) { + //noinspection removal final String type = p.getPattern().getIdentifier(); final int color = p.getColor().getColor().asRGB(); sb.append(type).append(",").append(color).append(" "); @@ -324,7 +315,7 @@ public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb { } else { final BannerMeta bannerMeta = (BannerMeta) is.getItemMeta(); if (bannerMeta != null) { - DyeColor baseDyeColor = bannerMeta.getBaseColor(); + DyeColor baseDyeColor = ess.getBannerDataProvider().getBaseColor(is); if (baseDyeColor == null) { baseDyeColor = MaterialUtil.getColorOf(material); } @@ -335,6 +326,7 @@ public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb { sb.append("basecolor:").append(basecolor).append(" "); } for (final org.bukkit.block.banner.Pattern p : bannerMeta.getPatterns()) { + //noinspection removal final String type = p.getPattern().getIdentifier(); final int color = p.getColor().getColor().asRGB(); sb.append(type).append(",").append(color).append(" "); diff --git a/Essentials/src/main/java/com/earth2me/essentials/items/FlatItemDb.java b/Essentials/src/main/java/com/earth2me/essentials/items/FlatItemDb.java index bcb4a9bea..992a89d8d 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/items/FlatItemDb.java +++ b/Essentials/src/main/java/com/earth2me/essentials/items/FlatItemDb.java @@ -9,13 +9,14 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import net.ess3.api.IEssentials; import net.ess3.api.TranslatableException; +import net.ess3.provider.PotionMetaProvider; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.PotionData; +import org.bukkit.potion.PotionType; import java.util.ArrayList; import java.util.Collection; @@ -23,6 +24,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -127,14 +129,14 @@ public class FlatItemDb extends AbstractItemDb { final ItemStack stack = new ItemStack(material); stack.setAmount(material.getMaxStackSize()); - final PotionData potionData = data.getPotionData(); - final ItemMeta meta = stack.getItemMeta(); + final ItemData.EssentialPotionData potionData = data.getPotionData(); - if (potionData != null && meta instanceof PotionMeta) { - final PotionMeta potionMeta = (PotionMeta) meta; - potionMeta.setBasePotionData(potionData); + if (potionData != null && stack.getItemMeta() instanceof PotionMeta) { + ess.getPotionMetaProvider().setBasePotionType(stack, potionData.getType(), potionData.isExtended(), potionData.isUpgraded()); } + final ItemMeta meta = stack.getItemMeta(); + // For some reason, Damageable doesn't extend ItemMeta but CB implements them in the same // class. As to why, your guess is as good as mine. if (split.length > 1 && meta instanceof Damageable) { @@ -200,14 +202,14 @@ public class FlatItemDb extends AbstractItemDb { throw new UnsupportedOperationException("Legacy IDs aren't supported on this version."); } - private ItemData lookup(final ItemStack item) { - final Material type = item.getType(); + private ItemData lookup(final ItemStack is) { + final Material type = is.getType(); - if (MaterialUtil.isPotion(type) && item.getItemMeta() instanceof PotionMeta) { - final PotionData potion = ((PotionMeta) item.getItemMeta()).getBasePotionData(); - return new ItemData(type, potion); + if (MaterialUtil.isPotion(type) && is.getItemMeta() instanceof PotionMeta) { + final PotionMetaProvider provider = ess.getPotionMetaProvider(); + return new ItemData(type, new ItemData.EssentialPotionData(provider.getBasePotionType(is), provider.isUpgraded(is), provider.isExtended(is))); } else if (type.toString().contains("SPAWNER")) { - final EntityType entity = ess.getSpawnerItemProvider().getEntityType(item); + final EntityType entity = ess.getSpawnerItemProvider().getEntityType(is); return new ItemData(type, entity); } else { return new ItemData(type); @@ -224,14 +226,14 @@ public class FlatItemDb extends AbstractItemDb { public static class ItemData { private Material material; private String[] fallbacks = null; - private PotionData potionData = null; + private EssentialPotionData potionData = null; private EntityType entity = null; ItemData(final Material material) { this.material = material; } - ItemData(final Material material, final PotionData potionData) { + ItemData(final Material material, final EssentialPotionData potionData) { this.material = material; this.potionData = potionData; } @@ -267,7 +269,7 @@ public class FlatItemDb extends AbstractItemDb { return material; } - public PotionData getPotionData() { + public EssentialPotionData getPotionData() { return this.potionData; } @@ -294,5 +296,50 @@ public class FlatItemDb extends AbstractItemDb { return false; } } + + public static class EssentialPotionData { + private PotionType type; + private String fallbackType; + private final boolean upgraded; + private final boolean extended; + + EssentialPotionData(PotionType type, boolean upgraded, boolean extended) { + this.type = type; + this.upgraded = upgraded; + this.extended = extended; + } + + public PotionType getType() { + if (type == null && fallbackType != null) { + type = EnumUtil.valueOf(PotionType.class, fallbackType); + fallbackType = null; // If fallback fails, don't keep trying to look up fallbacks + } + + return type; + } + + public boolean isUpgraded() { + return upgraded; + } + + public boolean isExtended() { + return extended; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final EssentialPotionData that = (EssentialPotionData) o; + return upgraded == that.upgraded && + extended == that.extended && + type == that.type; + } + + @Override + public int hashCode() { + return Objects.hash(type, upgraded, extended); + } + } } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/utils/RegistryUtil.java b/Essentials/src/main/java/com/earth2me/essentials/utils/RegistryUtil.java new file mode 100644 index 000000000..dcf35dd0a --- /dev/null +++ b/Essentials/src/main/java/com/earth2me/essentials/utils/RegistryUtil.java @@ -0,0 +1,32 @@ +package com.earth2me.essentials.utils; + +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Table; + +public final class RegistryUtil { + private static final Table, String, Object> registryCache = HashBasedTable.create(); + + private RegistryUtil() { + } + + public static T valueOf(Class registry, String... names) { + for (final String name : names) { + //noinspection unchecked + T value = (T) registryCache.get(registry, name); + if (value != null) { + return value; + } + + try { + //noinspection unchecked + value = (T) registry.getDeclaredField(name).get(null); + if (value != null) { + registryCache.put(registry, name, value); + return value; + } + } catch (NoSuchFieldException | IllegalAccessException ignored) { + } + } + return null; + } +} diff --git a/Essentials/src/main/java/com/earth2me/essentials/utils/VersionUtil.java b/Essentials/src/main/java/com/earth2me/essentials/utils/VersionUtil.java index b3788d835..9eb937fb4 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/utils/VersionUtil.java +++ b/Essentials/src/main/java/com/earth2me/essentials/utils/VersionUtil.java @@ -39,8 +39,9 @@ public final class VersionUtil { public static final BukkitVersion v1_19_4_R01 = BukkitVersion.fromString("1.19.4-R0.1-SNAPSHOT"); public static final BukkitVersion v1_20_1_R01 = BukkitVersion.fromString("1.20.1-R0.1-SNAPSHOT"); public static final BukkitVersion v1_20_4_R01 = BukkitVersion.fromString("1.20.4-R0.1-SNAPSHOT"); + public static final BukkitVersion v1_20_6_R01 = BukkitVersion.fromString("1.20.6-R0.1-SNAPSHOT"); - private static final Set supportedVersions = ImmutableSet.of(v1_8_8_R01, v1_9_4_R01, v1_10_2_R01, v1_11_2_R01, v1_12_2_R01, v1_13_2_R01, v1_14_4_R01, v1_15_2_R01, v1_16_5_R01, v1_17_1_R01, v1_18_2_R01, v1_19_4_R01, v1_20_4_R01); + private static final Set supportedVersions = ImmutableSet.of(v1_8_8_R01, v1_9_4_R01, v1_10_2_R01, v1_11_2_R01, v1_12_2_R01, v1_13_2_R01, v1_14_4_R01, v1_15_2_R01, v1_16_5_R01, v1_17_1_R01, v1_18_2_R01, v1_19_4_R01, v1_20_6_R01); public static final boolean PRE_FLATTENING = VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_13_0_R01); diff --git a/Essentials/src/main/resources/items.json b/Essentials/src/main/resources/items.json index c8f74341c..ef9363e4b 100644 --- a/Essentials/src/main/resources/items.json +++ b/Essentials/src/main/resources/items.json @@ -492,6 +492,16 @@ "archerpotterysherd": "archer_pottery_sherd", "archersherd": "archer_pottery_sherd", "minecraft:archer_pottery_sherd": "archer_pottery_sherd", + "armadillo_scute": { + "material": "ARMADILLO_SCUTE" + }, + "armadilloscute": "armadillo_scute", + "minecraft:armadillo_scute": "armadillo_scute", + "armadillo_spawn_egg": { + "material": "ARMADILLO_SPAWN_EGG" + }, + "armadillospawnegg": "armadillo_spawn_egg", + "minecraft:armadillo_spawn_egg": "armadillo_spawn_egg", "armor_stand": { "material": "ARMOR_STAND" }, @@ -6325,67 +6335,6 @@ "oreemerald": "emerald_ore", "stoneemeraldore": "emerald_ore", "stoneeore": "emerald_ore", - "empty_lingering_potion": { - "potionData": { - "type": "UNCRAFTABLE", - "upgraded": false, - "extended": false - }, - "material": "LINGERING_POTION" - }, - "aoepotionuncraftable": "empty_lingering_potion", - "aoepotuncraftable": "empty_lingering_potion", - "areapotionuncraftable": "empty_lingering_potion", - "areapotuncraftable": "empty_lingering_potion", - "cloudpotionuncraftable": "empty_lingering_potion", - "cloudpotuncraftable": "empty_lingering_potion", - "lingerpotuncraftable": "empty_lingering_potion", - "uncraftableaoepoiont": "empty_lingering_potion", - "uncraftableaoepot": "empty_lingering_potion", - "uncraftableareapot": "empty_lingering_potion", - "uncraftableareapotion": "empty_lingering_potion", - "uncraftablecloudpot": "empty_lingering_potion", - "uncraftablecloudpotion": "empty_lingering_potion", - "uncraftablelingerpot": "empty_lingering_potion", - "empty_potion": { - "potionData": { - "type": "UNCRAFTABLE", - "upgraded": false, - "extended": false - }, - "material": "POTION" - }, - "potionofuncraftable": "empty_potion", - "potofuncraftable": "empty_potion", - "uncraftablepot": "empty_potion", - "uncraftablepotion": "empty_potion", - "empty_splash_potion": { - "potionData": { - "type": "UNCRAFTABLE", - "upgraded": false, - "extended": false - }, - "material": "SPLASH_POTION" - }, - "splashuncraftablepot": "empty_splash_potion", - "splashuncraftablepotion": "empty_splash_potion", - "spluncraftablepot": "empty_splash_potion", - "spluncraftablepotion": "empty_splash_potion", - "uncraftablesplashpot": "empty_splash_potion", - "uncraftablesplashpotion": "empty_splash_potion", - "empty_tipped_arrow": { - "potionData": { - "type": "UNCRAFTABLE", - "upgraded": false, - "extended": false - }, - "material": "TIPPED_ARROW" - }, - "arrowuncraftable": "empty_tipped_arrow", - "uncraftablearrow": "empty_tipped_arrow", - "uncraftabletarr": "empty_tipped_arrow", - "uncraftabletarrow": "empty_tipped_arrow", - "uncraftabletippedarrow": "empty_tipped_arrow", "enchanted_book": { "material": "ENCHANTED_BOOK" }, @@ -7156,6 +7105,11 @@ }, "flintandsteel": "flint_and_steel", "minecraft:flint_and_steel": "flint_and_steel", + "flow_banner_pattern": { + "material": "FLOW_BANNER_PATTERN" + }, + "flowbannerpattern": "flow_banner_pattern", + "minecraft:flow_banner_pattern": "flow_banner_pattern", "flower_banner_pattern": { "material": "FLOWER_BANNER_PATTERN" }, @@ -8530,6 +8484,11 @@ "material": "GUNPOWDER" }, "minecraft:gunpowder": "gunpowder", + "guster_banner_pattern": { + "material": "GUSTER_BANNER_PATTERN" + }, + "gusterbannerpattern": "guster_banner_pattern", + "minecraft:guster_banner_pattern": "guster_banner_pattern", "hanging_roots": { "material": "HANGING_ROOTS" }, @@ -8543,7 +8502,8 @@ "minecraft:hanging_roots": "hanging_roots", "harming_lingering_potion": { "potionData": { - "type": "INSTANT_DAMAGE", + "type": "HARMING", + "fallbackType": "INSTANT_DAMAGE", "upgraded": false, "extended": false }, @@ -8621,7 +8581,8 @@ "lingerpotinstantdamage": "harming_lingering_potion", "harming_potion": { "potionData": { - "type": "INSTANT_DAMAGE", + "type": "HARMING", + "fallbackType": "INSTANT_DAMAGE", "upgraded": false, "extended": false }, @@ -8649,7 +8610,8 @@ "potofinstantdamage": "harming_potion", "harming_splash_potion": { "potionData": { - "type": "INSTANT_DAMAGE", + "type": "HARMING", + "fallbackType": "INSTANT_DAMAGE", "upgraded": false, "extended": false }, @@ -8687,7 +8649,8 @@ "splinstantdamagepotion": "harming_splash_potion", "harming_tipped_arrow": { "potionData": { - "type": "INSTANT_DAMAGE", + "type": "HARMING", + "fallbackType": "INSTANT_DAMAGE", "upgraded": false, "extended": false }, @@ -8729,7 +8692,8 @@ "minecraft:hay_block": "hay_block", "healing_lingering_potion": { "potionData": { - "type": "INSTANT_HEAL", + "type": "HEALING", + "fallbackType": "INSTANT_HEAL", "upgraded": false, "extended": false }, @@ -8807,7 +8771,8 @@ "lingerpotlife": "healing_lingering_potion", "healing_potion": { "potionData": { - "type": "INSTANT_HEAL", + "type": "HEALING", + "fallbackType": "INSTANT_HEAL", "upgraded": false, "extended": false }, @@ -8835,7 +8800,8 @@ "potoflife": "healing_potion", "healing_splash_potion": { "potionData": { - "type": "INSTANT_HEAL", + "type": "HEALING", + "fallbackType": "INSTANT_HEAL", "upgraded": false, "extended": false }, @@ -8873,7 +8839,8 @@ "spllifepotion": "healing_splash_potion", "healing_tipped_arrow": { "potionData": { - "type": "INSTANT_HEAL", + "type": "HEALING", + "fallbackType": "INSTANT_HEAL", "upgraded": false, "extended": false }, @@ -10977,7 +10944,8 @@ "minecraft:lead": "lead", "leaping_lingering_potion": { "potionData": { - "type": "JUMP", + "type": "LEAPING", + "fallbackType": "JUMP", "upgraded": false, "extended": false }, @@ -11027,7 +10995,8 @@ "lingerpotleaping": "leaping_lingering_potion", "leaping_potion": { "potionData": { - "type": "JUMP", + "type": "LEAPING", + "fallbackType": "JUMP", "upgraded": false, "extended": false }, @@ -11047,7 +11016,8 @@ "potofleaping": "leaping_potion", "leaping_splash_potion": { "potionData": { - "type": "JUMP", + "type": "LEAPING", + "fallbackType": "JUMP", "upgraded": false, "extended": false }, @@ -11073,7 +11043,8 @@ "splleappotion": "leaping_splash_potion", "leaping_tipped_arrow": { "potionData": { - "type": "JUMP", + "type": "LEAPING", + "fallbackType": "JUMP", "upgraded": false, "extended": false }, @@ -13313,7 +13284,8 @@ "invlongtippedarrow": "long_invisibility_tipped_arrow", "long_leaping_lingering_potion": { "potionData": { - "type": "JUMP", + "type": "LEAPING", + "fallbackType": "JUMP", "upgraded": false, "extended": true }, @@ -13531,7 +13503,8 @@ "lingerpotleaplong": "long_leaping_lingering_potion", "long_leaping_potion": { "potionData": { - "type": "JUMP", + "type": "LEAPING", + "fallbackType": "JUMP", "upgraded": false, "extended": true }, @@ -13599,7 +13572,8 @@ "potofleaplong": "long_leaping_potion", "long_leaping_splash_potion": { "potionData": { - "type": "JUMP", + "type": "LEAPING", + "fallbackType": "JUMP", "upgraded": false, "extended": true }, @@ -13697,7 +13671,8 @@ "splleaplongpotion": "long_leaping_splash_potion", "long_leaping_tipped_arrow": { "potionData": { - "type": "JUMP", + "type": "LEAPING", + "fallbackType": "JUMP", "upgraded": false, "extended": true }, @@ -15294,7 +15269,8 @@ "poisonlongtippedarrow": "long_poison_tipped_arrow", "long_regeneration_lingering_potion": { "potionData": { - "type": "REGEN", + "type": "REGENERATION", + "fallbackType": "REGEN", "upgraded": false, "extended": true }, @@ -15512,7 +15488,8 @@ "regenlingerpotlong": "long_regeneration_lingering_potion", "long_regeneration_potion": { "potionData": { - "type": "REGEN", + "type": "REGENERATION", + "fallbackType": "REGEN", "upgraded": false, "extended": true }, @@ -15580,7 +15557,8 @@ "regenlongpotion": "long_regeneration_potion", "long_regeneration_splash_potion": { "potionData": { - "type": "REGEN", + "type": "REGENERATION", + "fallbackType": "REGEN", "upgraded": false, "extended": true }, @@ -15678,7 +15656,8 @@ "splregenlongpotion": "long_regeneration_splash_potion", "long_regeneration_tipped_arrow": { "potionData": { - "type": "REGEN", + "type": "REGENERATION", + "fallbackType": "REGEN", "upgraded": false, "extended": true }, @@ -17017,7 +16996,8 @@ "stronglongtippedarrow": "long_strength_tipped_arrow", "long_swiftness_lingering_potion": { "potionData": { - "type": "SPEED", + "type": "SWIFTNESS", + "fallbackType": "SPEED", "upgraded": false, "extended": true }, @@ -17235,7 +17215,8 @@ "swiftnesslingerpotlong": "long_swiftness_lingering_potion", "long_swiftness_potion": { "potionData": { - "type": "SPEED", + "type": "SWIFTNESS", + "fallbackType": "SPEED", "upgraded": false, "extended": true }, @@ -17303,7 +17284,8 @@ "swiftnesslongpotion": "long_swiftness_potion", "long_swiftness_splash_potion": { "potionData": { - "type": "SPEED", + "type": "SWIFTNESS", + "fallbackType": "SPEED", "upgraded": false, "extended": true }, @@ -17401,7 +17383,8 @@ "swiftnesslongsplashpotion": "long_swiftness_splash_potion", "long_swiftness_tipped_arrow": { "potionData": { - "type": "SPEED", + "type": "SWIFTNESS", + "fallbackType": "SPEED", "upgraded": false, "extended": true }, @@ -19935,6 +19918,43 @@ "spawnmushroom": "mooshroom_spawn_egg", "spawnmushroom_cow": "mooshroom_spawn_egg", "spawnmushroomcow": "mooshroom_spawn_egg", + "mooshroom_spawner": { + "entity": "MOOSHROOM", + "material": "SPAWNER" + }, + "mooshroomcage": "mooshroom_spawner", + "mooshroommcage": "mooshroom_spawner", + "mooshroommobcage": "mooshroom_spawner", + "mooshroommobspawner": "mooshroom_spawner", + "mooshroommonstercage": "mooshroom_spawner", + "mooshroommonsterspawner": "mooshroom_spawner", + "mooshroommspawner": "mooshroom_spawner", + "mooshroomspawner": "mooshroom_spawner", + "mushroom_cow_spawner": "mooshroom_spawner", + "mushroom_cowcage": "mooshroom_spawner", + "mushroom_cowmcage": "mooshroom_spawner", + "mushroom_cowmobcage": "mooshroom_spawner", + "mushroom_cowmobspawner": "mooshroom_spawner", + "mushroom_cowmonstercage": "mooshroom_spawner", + "mushroom_cowmonsterspawner": "mooshroom_spawner", + "mushroom_cowmspawner": "mooshroom_spawner", + "mushroom_cowspawner": "mooshroom_spawner", + "mushroomcage": "mooshroom_spawner", + "mushroomcowcage": "mooshroom_spawner", + "mushroomcowmcage": "mooshroom_spawner", + "mushroomcowmobcage": "mooshroom_spawner", + "mushroomcowmobspawner": "mooshroom_spawner", + "mushroomcowmonstercage": "mooshroom_spawner", + "mushroomcowmonsterspawner": "mooshroom_spawner", + "mushroomcowmspawner": "mooshroom_spawner", + "mushroomcowspawner": "mooshroom_spawner", + "mushroommcage": "mooshroom_spawner", + "mushroommobcage": "mooshroom_spawner", + "mushroommobspawner": "mooshroom_spawner", + "mushroommonstercage": "mooshroom_spawner", + "mushroommonsterspawner": "mooshroom_spawner", + "mushroommspawner": "mooshroom_spawner", + "mushroomspawner": "mooshroom_spawner", "moss_block": { "material": "MOSS_BLOCK" }, @@ -20319,42 +20339,6 @@ "mundanetarr": "mundane_tipped_arrow", "mundanetarrow": "mundane_tipped_arrow", "mundanetippedarrow": "mundane_tipped_arrow", - "mushroom_cow_spawner": { - "entity": "MUSHROOM_COW", - "material": "SPAWNER" - }, - "mooshroomcage": "mushroom_cow_spawner", - "mooshroommcage": "mushroom_cow_spawner", - "mooshroommobcage": "mushroom_cow_spawner", - "mooshroommobspawner": "mushroom_cow_spawner", - "mooshroommonstercage": "mushroom_cow_spawner", - "mooshroommonsterspawner": "mushroom_cow_spawner", - "mooshroommspawner": "mushroom_cow_spawner", - "mooshroomspawner": "mushroom_cow_spawner", - "mushroom_cowcage": "mushroom_cow_spawner", - "mushroom_cowmcage": "mushroom_cow_spawner", - "mushroom_cowmobcage": "mushroom_cow_spawner", - "mushroom_cowmobspawner": "mushroom_cow_spawner", - "mushroom_cowmonstercage": "mushroom_cow_spawner", - "mushroom_cowmonsterspawner": "mushroom_cow_spawner", - "mushroom_cowmspawner": "mushroom_cow_spawner", - "mushroom_cowspawner": "mushroom_cow_spawner", - "mushroomcage": "mushroom_cow_spawner", - "mushroomcowcage": "mushroom_cow_spawner", - "mushroomcowmcage": "mushroom_cow_spawner", - "mushroomcowmobcage": "mushroom_cow_spawner", - "mushroomcowmobspawner": "mushroom_cow_spawner", - "mushroomcowmonstercage": "mushroom_cow_spawner", - "mushroomcowmonsterspawner": "mushroom_cow_spawner", - "mushroomcowmspawner": "mushroom_cow_spawner", - "mushroomcowspawner": "mushroom_cow_spawner", - "mushroommcage": "mushroom_cow_spawner", - "mushroommobcage": "mushroom_cow_spawner", - "mushroommobspawner": "mushroom_cow_spawner", - "mushroommonstercage": "mushroom_cow_spawner", - "mushroommonsterspawner": "mushroom_cow_spawner", - "mushroommspawner": "mushroom_cow_spawner", - "mushroomspawner": "mushroom_cow_spawner", "mushroom_stem": { "material": "MUSHROOM_STEM" }, @@ -25337,7 +25321,8 @@ "rstorch": "redstone_torch", "regeneration_lingering_potion": { "potionData": { - "type": "REGEN", + "type": "REGENERATION", + "fallbackType": "REGEN", "upgraded": false, "extended": false }, @@ -25387,7 +25372,8 @@ "regenlingerpot": "regeneration_lingering_potion", "regeneration_potion": { "potionData": { - "type": "REGEN", + "type": "REGENERATION", + "fallbackType": "REGEN", "upgraded": false, "extended": false }, @@ -25407,7 +25393,8 @@ "regenpotion": "regeneration_potion", "regeneration_splash_potion": { "potionData": { - "type": "REGEN", + "type": "REGENERATION", + "fallbackType": "REGEN", "upgraded": false, "extended": false }, @@ -25433,7 +25420,8 @@ "splregenpotion": "regeneration_splash_potion", "regeneration_tipped_arrow": { "potionData": { - "type": "REGEN", + "type": "REGENERATION", + "fallbackType": "REGEN", "upgraded": false, "extended": false }, @@ -25689,10 +25677,6 @@ "minecraft:sculk_vein": "sculk_vein", "sculkvein": "sculk_vein", "scvein": "sculk_vein", - "scute": { - "material": "SCUTE" - }, - "minecraft:scute": "scute", "sea_lantern": { "material": "SEA_LANTERN" }, @@ -26594,40 +26578,80 @@ "snow_golem_spawn_egg": { "material": "SNOW_GOLEM_SPAWN_EGG" }, + "eggsgolem": "snow_golem_spawn_egg", + "eggsnow_golem": "snow_golem_spawn_egg", + "eggsnowgolem": "snow_golem_spawn_egg", + "eggsnowman": "snow_golem_spawn_egg", "minecraft:snow_golem_spawn_egg": "snow_golem_spawn_egg", + "seggsgolem": "snow_golem_spawn_egg", + "seggsnow_golem": "snow_golem_spawn_egg", + "seggsnowgolem": "snow_golem_spawn_egg", + "seggsnowman": "snow_golem_spawn_egg", + "sgolemegg": "snow_golem_spawn_egg", + "sgolemsegg": "snow_golem_spawn_egg", + "sgolemspawn": "snow_golem_spawn_egg", + "sgolemspawnegg": "snow_golem_spawn_egg", + "snow_golemegg": "snow_golem_spawn_egg", + "snow_golemsegg": "snow_golem_spawn_egg", + "snow_golemspawn": "snow_golem_spawn_egg", + "snow_golemspawnegg": "snow_golem_spawn_egg", + "snowgolemegg": "snow_golem_spawn_egg", + "snowgolemsegg": "snow_golem_spawn_egg", + "snowgolemspawn": "snow_golem_spawn_egg", "snowgolemspawnegg": "snow_golem_spawn_egg", + "snowmanegg": "snow_golem_spawn_egg", + "snowmansegg": "snow_golem_spawn_egg", + "snowmanspawn": "snow_golem_spawn_egg", + "snowmanspawnegg": "snow_golem_spawn_egg", + "spawneggsgolem": "snow_golem_spawn_egg", + "spawneggsnow_golem": "snow_golem_spawn_egg", + "spawneggsnowgolem": "snow_golem_spawn_egg", + "spawneggsnowman": "snow_golem_spawn_egg", + "spawnsgolem": "snow_golem_spawn_egg", + "spawnsnow_golem": "snow_golem_spawn_egg", + "spawnsnowgolem": "snow_golem_spawn_egg", + "spawnsnowman": "snow_golem_spawn_egg", + "snow_golem_spawner": { + "entity": "SNOW_GOLEM", + "material": "SPAWNER" + }, + "sgolemcage": "snow_golem_spawner", + "sgolemmcage": "snow_golem_spawner", + "sgolemmobcage": "snow_golem_spawner", + "sgolemmobspawner": "snow_golem_spawner", + "sgolemmonstercage": "snow_golem_spawner", + "sgolemmonsterspawner": "snow_golem_spawner", + "sgolemmspawner": "snow_golem_spawner", + "sgolemspawner": "snow_golem_spawner", + "snow_golemcage": "snow_golem_spawner", + "snow_golemmcage": "snow_golem_spawner", + "snow_golemmobcage": "snow_golem_spawner", + "snow_golemmobspawner": "snow_golem_spawner", + "snow_golemmonstercage": "snow_golem_spawner", + "snow_golemmonsterspawner": "snow_golem_spawner", + "snow_golemmspawner": "snow_golem_spawner", + "snow_golemspawner": "snow_golem_spawner", + "snowgolemcage": "snow_golem_spawner", + "snowgolemmcage": "snow_golem_spawner", + "snowgolemmobcage": "snow_golem_spawner", + "snowgolemmobspawner": "snow_golem_spawner", + "snowgolemmonstercage": "snow_golem_spawner", + "snowgolemmonsterspawner": "snow_golem_spawner", + "snowgolemmspawner": "snow_golem_spawner", + "snowgolemspawner": "snow_golem_spawner", + "snowman_spawner": "snow_golem_spawner", + "snowmancage": "snow_golem_spawner", + "snowmanmcage": "snow_golem_spawner", + "snowmanmobcage": "snow_golem_spawner", + "snowmanmobspawner": "snow_golem_spawner", + "snowmanmonstercage": "snow_golem_spawner", + "snowmanmonsterspawner": "snow_golem_spawner", + "snowmanmspawner": "snow_golem_spawner", + "snowmanspawner": "snow_golem_spawner", "snowball": { "material": "SNOWBALL" }, "minecraft:snowball": "snowball", - "snowman_spawner": { - "entity": "SNOWMAN", - "material": "SPAWNER" - }, - "sgolemcage": "snowman_spawner", - "sgolemmcage": "snowman_spawner", - "sgolemmobcage": "snowman_spawner", - "sgolemmobspawner": "snowman_spawner", - "sgolemmonstercage": "snowman_spawner", - "sgolemmonsterspawner": "snowman_spawner", - "sgolemmspawner": "snowman_spawner", - "sgolemspawner": "snowman_spawner", - "snowgolemcage": "snowman_spawner", - "snowgolemmcage": "snowman_spawner", - "snowgolemmobcage": "snowman_spawner", - "snowgolemmobspawner": "snowman_spawner", - "snowgolemmonstercage": "snowman_spawner", - "snowgolemmonsterspawner": "snowman_spawner", - "snowgolemmspawner": "snowman_spawner", - "snowgolemspawner": "snowman_spawner", - "snowmancage": "snowman_spawner", - "snowmanmcage": "snowman_spawner", - "snowmanmobcage": "snowman_spawner", - "snowmanmobspawner": "snowman_spawner", - "snowmanmonstercage": "snowman_spawner", - "snowmanmonsterspawner": "snowman_spawner", - "snowmanmspawner": "snowman_spawner", - "snowmanspawner": "snowman_spawner", "soul_campfire": { "material": "SOUL_CAMPFIRE" }, @@ -28408,7 +28432,8 @@ "warpstrippedlog": "stripped_warped_stem", "strong_harming_lingering_potion": { "potionData": { - "type": "INSTANT_DAMAGE", + "type": "HARMING", + "fallbackType": "INSTANT_DAMAGE", "upgraded": true, "extended": false }, @@ -28626,7 +28651,8 @@ "lingerpotinstantdamagestrong": "strong_harming_lingering_potion", "strong_harming_potion": { "potionData": { - "type": "INSTANT_DAMAGE", + "type": "HARMING", + "fallbackType": "INSTANT_DAMAGE", "upgraded": true, "extended": false }, @@ -28694,7 +28720,8 @@ "potofinstantdamagestrong": "strong_harming_potion", "strong_harming_splash_potion": { "potionData": { - "type": "INSTANT_DAMAGE", + "type": "HARMING", + "fallbackType": "INSTANT_DAMAGE", "upgraded": true, "extended": false }, @@ -28792,7 +28819,8 @@ "splinstantdamagestrongpotion": "strong_harming_splash_potion", "strong_harming_tipped_arrow": { "potionData": { - "type": "INSTANT_DAMAGE", + "type": "HARMING", + "fallbackType": "INSTANT_DAMAGE", "upgraded": true, "extended": false }, @@ -28875,7 +28903,8 @@ "instantdamagestrongtippedarrow": "strong_harming_tipped_arrow", "strong_healing_lingering_potion": { "potionData": { - "type": "INSTANT_HEAL", + "type": "HEALING", + "fallbackType": "INSTANT_HEAL", "upgraded": true, "extended": false }, @@ -29093,7 +29122,8 @@ "lingerpotlifestrong": "strong_healing_lingering_potion", "strong_healing_potion": { "potionData": { - "type": "INSTANT_HEAL", + "type": "HEALING", + "fallbackType": "INSTANT_HEAL", "upgraded": true, "extended": false }, @@ -29161,7 +29191,8 @@ "potoflifestrong": "strong_healing_potion", "strong_healing_splash_potion": { "potionData": { - "type": "INSTANT_HEAL", + "type": "HEALING", + "fallbackType": "INSTANT_HEAL", "upgraded": true, "extended": false }, @@ -29259,7 +29290,8 @@ "spllifestrongpotion": "strong_healing_splash_potion", "strong_healing_tipped_arrow": { "potionData": { - "type": "INSTANT_HEAL", + "type": "HEALING", + "fallbackType": "INSTANT_HEAL", "upgraded": true, "extended": false }, @@ -29342,7 +29374,8 @@ "lifestrongtippedarrow": "strong_healing_tipped_arrow", "strong_leaping_lingering_potion": { "potionData": { - "type": "JUMP", + "type": "LEAPING", + "fallbackType": "JUMP", "upgraded": true, "extended": false }, @@ -29476,7 +29509,8 @@ "lingerpotleapstrong": "strong_leaping_lingering_potion", "strong_leaping_potion": { "potionData": { - "type": "JUMP", + "type": "LEAPING", + "fallbackType": "JUMP", "upgraded": true, "extended": false }, @@ -29520,7 +29554,8 @@ "potofleapstrong": "strong_leaping_potion", "strong_leaping_splash_potion": { "potionData": { - "type": "JUMP", + "type": "LEAPING", + "fallbackType": "JUMP", "upgraded": true, "extended": false }, @@ -29582,7 +29617,8 @@ "splleapstrongpotion": "strong_leaping_splash_potion", "strong_leaping_tipped_arrow": { "potionData": { - "type": "JUMP", + "type": "LEAPING", + "fallbackType": "JUMP", "upgraded": true, "extended": false }, @@ -29928,7 +29964,8 @@ "pstrongtippedarrow": "strong_poison_tipped_arrow", "strong_regeneration_lingering_potion": { "potionData": { - "type": "REGEN", + "type": "REGENERATION", + "fallbackType": "REGEN", "upgraded": true, "extended": false }, @@ -30062,7 +30099,8 @@ "regenlingerpotstrong": "strong_regeneration_lingering_potion", "strong_regeneration_potion": { "potionData": { - "type": "REGEN", + "type": "REGENERATION", + "fallbackType": "REGEN", "upgraded": true, "extended": false }, @@ -30106,7 +30144,8 @@ "regenstrongpotion": "strong_regeneration_potion", "strong_regeneration_splash_potion": { "potionData": { - "type": "REGEN", + "type": "REGENERATION", + "fallbackType": "REGEN", "upgraded": true, "extended": false }, @@ -30168,7 +30207,8 @@ "splregenstrongpotion": "strong_regeneration_splash_potion", "strong_regeneration_tipped_arrow": { "potionData": { - "type": "REGEN", + "type": "REGENERATION", + "fallbackType": "REGEN", "upgraded": true, "extended": false }, @@ -30720,7 +30760,8 @@ "strstrongtippedarrow": "strong_strength_tipped_arrow", "strong_swiftness_lingering_potion": { "potionData": { - "type": "SPEED", + "type": "SWIFTNESS", + "fallbackType": "SPEED", "upgraded": true, "extended": false }, @@ -30854,7 +30895,8 @@ "swiftnesslingerpotstrong": "strong_swiftness_lingering_potion", "strong_swiftness_potion": { "potionData": { - "type": "SPEED", + "type": "SWIFTNESS", + "fallbackType": "SPEED", "upgraded": true, "extended": false }, @@ -30898,7 +30940,8 @@ "swiftstrongpotion": "strong_swiftness_potion", "strong_swiftness_splash_potion": { "potionData": { - "type": "SPEED", + "type": "SWIFTNESS", + "fallbackType": "SPEED", "upgraded": true, "extended": false }, @@ -30960,7 +31003,8 @@ "swiftstrongsplashpotion": "strong_swiftness_splash_potion", "strong_swiftness_tipped_arrow": { "potionData": { - "type": "SPEED", + "type": "SWIFTNESS", + "fallbackType": "SPEED", "upgraded": true, "extended": false }, @@ -31353,7 +31397,8 @@ "sweetberries": "sweet_berries", "swiftness_lingering_potion": { "potionData": { - "type": "SPEED", + "type": "SWIFTNESS", + "fallbackType": "SPEED", "upgraded": false, "extended": false }, @@ -31403,7 +31448,8 @@ "swiftnesslingerpot": "swiftness_lingering_potion", "swiftness_potion": { "potionData": { - "type": "SPEED", + "type": "SWIFTNESS", + "fallbackType": "SPEED", "upgraded": false, "extended": false }, @@ -31423,7 +31469,8 @@ "swiftpotion": "swiftness_potion", "swiftness_splash_potion": { "potionData": { - "type": "SPEED", + "type": "SWIFTNESS", + "fallbackType": "SPEED", "upgraded": false, "extended": false }, @@ -31449,7 +31496,8 @@ "swiftsplashpotion": "swiftness_splash_potion", "swiftness_tipped_arrow": { "potionData": { - "type": "SPEED", + "type": "SWIFTNESS", + "fallbackType": "SPEED", "upgraded": false, "extended": false }, @@ -31983,6 +32031,13 @@ "turtletarr": "turtle_master_tipped_arrow", "turtletarrow": "turtle_master_tipped_arrow", "turtletippedarrow": "turtle_master_tipped_arrow", + "turtle_scute": { + "material": "TURTLE_SCUTE" + }, + "minecraft:scute": "turtle_scute", + "minecraft:turtle_scute": "turtle_scute", + "scute": "turtle_scute", + "turtlescute": "turtle_scute", "turtle_spawn_egg": { "material": "TURTLE_SPAWN_EGG" }, @@ -42340,6 +42395,11 @@ "withermonsterspawner": "wither_spawner", "withermspawner": "wither_spawner", "witherspawner": "wither_spawner", + "wolf_armor": { + "material": "WOLF_ARMOR" + }, + "minecraft:wolf_armor": "wolf_armor", + "wolfarmor": "wolf_armor", "wolf_spawn_egg": { "material": "WOLF_SPAWN_EGG" }, diff --git a/README.md b/README.md index 6aef88946..76db8f564 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ however, have some new requirements: * **EssentialsX requires CraftBukkit, Spigot or Paper to run.** Other server software may work, but these are not tested by the team and we may not be able to help with any issues that occur. * **EssentialsX currently supports Minecraft versions 1.8.8, 1.9.4, 1.10.2, 1.11.2, 1.12.2, 1.13.2, 1.14.4, 1.15.2, - 1.16.5, 1.17.1, 1.18.2, 1.19.4, and 1.20.4.** + 1.16.5, 1.17.1, 1.18.2, 1.19.4, and 1.20.6.** * **EssentialsX currently requires Java 8 or higher.** We recommend using the latest Java version supported by your server software. * **EssentialsX requires [Vault](http://dev.bukkit.org/bukkit-plugins/vault/) to enable using chat prefix/suffixes and diff --git a/build-logic/src/main/kotlin/constants.kt b/build-logic/src/main/kotlin/constants.kt index f1398887f..60793a152 100644 --- a/build-logic/src/main/kotlin/constants.kt +++ b/build-logic/src/main/kotlin/constants.kt @@ -1 +1 @@ -const val RUN_PAPER_MINECRAFT_VERSION = "1.20.4" +const val RUN_PAPER_MINECRAFT_VERSION = "1.20.6" diff --git a/build-logic/src/main/kotlin/essentials.base-conventions.gradle.kts b/build-logic/src/main/kotlin/essentials.base-conventions.gradle.kts index 0a497fed8..f337b6fb0 100644 --- a/build-logic/src/main/kotlin/essentials.base-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/essentials.base-conventions.gradle.kts @@ -10,7 +10,7 @@ plugins { val baseExtension = extensions.create("essentials", project) val checkstyleVersion = "8.36.2" -val spigotVersion = "1.20.4-R0.1-SNAPSHOT" +val spigotVersion = "1.20.6-R0.1-SNAPSHOT" val junit5Version = "5.10.2" val mockitoVersion = "3.12.4" @@ -75,6 +75,9 @@ tasks { } withType { archiveVersion.set(rootProject.ext["FULL_VERSION"] as String) + manifest { + attributes("paperweight-mappings-namespace" to "mojang") + } } withType { onlyIf { project.hasProperty("forceSign") } diff --git a/providers/1_12Provider/build.gradle b/providers/1_12Provider/build.gradle index e04aa5426..438afeea5 100644 --- a/providers/1_12Provider/build.gradle +++ b/providers/1_12Provider/build.gradle @@ -3,6 +3,9 @@ plugins { } dependencies { + implementation(project(':providers:BaseProviders')) { + exclude group: "org.spigotmc", module: "spigot-api" + } api project(':providers:NMSReflectionProvider') } diff --git a/providers/1_12Provider/src/main/java/net/ess3/provider/providers/LegacyBannerDataProvider.java b/providers/1_12Provider/src/main/java/net/ess3/provider/providers/LegacyBannerDataProvider.java new file mode 100644 index 000000000..afd971ffd --- /dev/null +++ b/providers/1_12Provider/src/main/java/net/ess3/provider/providers/LegacyBannerDataProvider.java @@ -0,0 +1,26 @@ +package net.ess3.provider.providers; + +import net.ess3.provider.BannerDataProvider; +import org.bukkit.DyeColor; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; + +public class LegacyBannerDataProvider implements BannerDataProvider { + @Override + public DyeColor getBaseColor(ItemStack stack) { + final BannerMeta bannerMeta = (BannerMeta) stack.getItemMeta(); + return bannerMeta.getBaseColor(); + } + + @Override + public void setBaseColor(ItemStack stack, DyeColor color) { + final BannerMeta bannerMeta = (BannerMeta) stack.getItemMeta(); + bannerMeta.setBaseColor(color); + stack.setItemMeta(bannerMeta); + } + + @Override + public String getDescription() { + return "Legacy Banner Meta Provider"; + } +} diff --git a/providers/1_12Provider/src/main/java/net/ess3/provider/providers/LegacyPotionMetaProvider.java b/providers/1_12Provider/src/main/java/net/ess3/provider/providers/LegacyPotionMetaProvider.java new file mode 100644 index 000000000..c08307d46 --- /dev/null +++ b/providers/1_12Provider/src/main/java/net/ess3/provider/providers/LegacyPotionMetaProvider.java @@ -0,0 +1,134 @@ +package net.ess3.provider.providers; + +import com.google.common.collect.ImmutableMap; +import net.ess3.provider.PotionMetaProvider; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionData; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionType; + +import java.util.Collection; +import java.util.Map; + +public class LegacyPotionMetaProvider implements PotionMetaProvider { + private static final Map damageValueToType = ImmutableMap.builder() + .put(1, PotionType.REGEN) + .put(2, PotionType.SPEED) + .put(3, PotionType.FIRE_RESISTANCE) + .put(4, PotionType.POISON) + .put(5, PotionType.INSTANT_HEAL) + .put(6, PotionType.NIGHT_VISION) + // Skip 7 + .put(8, PotionType.WEAKNESS) + .put(9, PotionType.STRENGTH) + .put(10, PotionType.SLOWNESS) + .put(11, PotionType.JUMP) + .put(12, PotionType.INSTANT_DAMAGE) + .put(13, PotionType.WATER_BREATHING) + .put(14, PotionType.INVISIBILITY) + .build(); + + private static int getBit(final int n, final int k) { + return (n >> k) & 1; + } + + @Override + public ItemStack createPotionItem(final Material initial, final int effectId) { + ItemStack potion = new ItemStack(initial, 1); + + if (effectId == 0) { + return potion; + } + + final int damageValue = getBit(effectId, 0) + + 2 * getBit(effectId, 1) + + 4 * getBit(effectId, 2) + + 8 * getBit(effectId, 3); + + final PotionType type = damageValueToType.get(damageValue); + if (type == null) { + throw new IllegalArgumentException("Unable to process potion effect ID " + effectId + " with damage value " + damageValue); + } + + //getBit is splash here + if (getBit(effectId, 14) == 1 && initial == Material.POTION) { + potion = new ItemStack(Material.SPLASH_POTION, 1); + } + + final PotionMeta meta = (PotionMeta) potion.getItemMeta(); + //getBit(s) are extended and upgraded respectfully + final PotionData data = new PotionData(type, getBit(effectId, 6) == 1, getBit(effectId, 5) == 1); + meta.setBasePotionData(data); // this method is exclusive to recent 1.9+ + potion.setItemMeta(meta); + + return potion; + } + + @Override + public void setSplashPotion(final ItemStack stack, final boolean isSplash) { + if (stack == null) { + throw new IllegalArgumentException("ItemStack cannot be null"); + } + + if (isSplash && stack.getType() == Material.POTION) { + stack.setType(Material.SPLASH_POTION); + } else if (!isSplash && stack.getType() == Material.SPLASH_POTION) { + stack.setType(Material.POTION); + } + } + + @Override + public boolean isSplashPotion(final ItemStack stack) { + return stack != null && stack.getType() == Material.SPLASH_POTION; + } + + @Override + public Collection getCustomEffects(final ItemStack stack) { + final PotionMeta meta = (PotionMeta) stack.getItemMeta(); + return meta.getCustomEffects(); + } + + @Override + public boolean isExtended(final ItemStack stack) { + final PotionMeta meta = (PotionMeta) stack.getItemMeta(); + final PotionData data = meta.getBasePotionData(); + return data.isExtended(); + } + + @Override + public boolean isUpgraded(final ItemStack stack) { + final PotionMeta meta = (PotionMeta) stack.getItemMeta(); + final PotionData data = meta.getBasePotionData(); + return data.isUpgraded(); + } + + @Override + public PotionType getBasePotionType(final ItemStack stack) { + final PotionMeta meta = (PotionMeta) stack.getItemMeta(); + final PotionData data = meta.getBasePotionData(); + return data.getType(); + } + + @Override + public void setBasePotionType(final ItemStack stack, final PotionType type, final boolean extended, final boolean upgraded) { + if (stack == null) { + throw new IllegalArgumentException("ItemStack cannot be null"); + } + + if (extended && upgraded) { + throw new IllegalArgumentException("Potion cannot be both extended and upgraded"); + } + + final PotionData data = new PotionData(type, extended, upgraded); + final PotionMeta meta = (PotionMeta) stack.getItemMeta(); + meta.setBasePotionData(data); + stack.setItemMeta(meta); + } + + @Override + public String getDescription() { + return "1.9-1.20.4 Potion Meta Provider"; + } +} diff --git a/providers/1_8Provider/src/main/java/net/ess3/provider/providers/PrehistoricPotionMetaProvider.java b/providers/1_8Provider/src/main/java/net/ess3/provider/providers/PrehistoricPotionMetaProvider.java new file mode 100644 index 000000000..05dc7ce60 --- /dev/null +++ b/providers/1_8Provider/src/main/java/net/ess3/provider/providers/PrehistoricPotionMetaProvider.java @@ -0,0 +1,85 @@ +package net.ess3.provider.providers; + +import net.ess3.provider.PotionMetaProvider; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.Potion; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionType; + +import java.util.Collection; + +public class PrehistoricPotionMetaProvider implements PotionMetaProvider { + @Override + public ItemStack createPotionItem(final Material initial, final int effectId) { + final ItemStack potion = new ItemStack(initial, 1); + potion.setDurability((short) effectId); + return potion; + } + + @Override + public void setSplashPotion(final ItemStack stack, final boolean isSplash) { + if (stack == null) { + throw new IllegalArgumentException("ItemStack cannot be null"); + } + + final Potion potion = Potion.fromItemStack(stack); + potion.setSplash(isSplash); + potion.apply(stack); + } + + @Override + public boolean isSplashPotion(ItemStack stack) { + return Potion.fromItemStack(stack).isSplash(); + } + + @Override + public Collection getCustomEffects(ItemStack stack) { + return Potion.fromItemStack(stack).getEffects(); + } + + @Override + public boolean isExtended(final ItemStack stack) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isUpgraded(final ItemStack stack) { + throw new UnsupportedOperationException(); + } + + @Override + public PotionType getBasePotionType(final ItemStack stack) { + throw new UnsupportedOperationException(); + } + + @Override + public void setBasePotionType(final ItemStack stack, final PotionType type, final boolean extended, final boolean upgraded) { + if (stack == null) { + throw new IllegalArgumentException("ItemStack cannot be null"); + } + + if (extended && upgraded) { + throw new IllegalArgumentException("Potion cannot be both extended and upgraded"); + } + + final Potion potion = Potion.fromItemStack(stack); + + if (extended && !potion.getType().isInstant()) { + potion.setHasExtendedDuration(true); + potion.setLevel(Math.min(potion.getLevel(), 1)); + } + + if (upgraded && type.getMaxLevel() == 2) { + potion.setLevel(2); + potion.setHasExtendedDuration(false); + } + + potion.apply(stack); + } + + @Override + public String getDescription() { + return "Legacy 1.8 Potion Meta Provider"; + } +} diff --git a/providers/BaseProviders/src/main/java/net/ess3/provider/BannerDataProvider.java b/providers/BaseProviders/src/main/java/net/ess3/provider/BannerDataProvider.java new file mode 100644 index 000000000..eedf2e5f2 --- /dev/null +++ b/providers/BaseProviders/src/main/java/net/ess3/provider/BannerDataProvider.java @@ -0,0 +1,10 @@ +package net.ess3.provider; + +import org.bukkit.DyeColor; +import org.bukkit.inventory.ItemStack; + +public interface BannerDataProvider extends Provider { + DyeColor getBaseColor(ItemStack stack); + + void setBaseColor(ItemStack stack, DyeColor color); +} diff --git a/providers/BaseProviders/src/main/java/net/ess3/provider/PotionMetaProvider.java b/providers/BaseProviders/src/main/java/net/ess3/provider/PotionMetaProvider.java index 637a470a5..f2f35ba9f 100644 --- a/providers/BaseProviders/src/main/java/net/ess3/provider/PotionMetaProvider.java +++ b/providers/BaseProviders/src/main/java/net/ess3/provider/PotionMetaProvider.java @@ -2,7 +2,25 @@ package net.ess3.provider; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionType; + +import java.util.Collection; public interface PotionMetaProvider extends Provider { ItemStack createPotionItem(Material initial, int effectId); + + void setSplashPotion(ItemStack stack, boolean isSplash); + + boolean isSplashPotion(ItemStack stack); + + Collection getCustomEffects(ItemStack stack); + + boolean isExtended(ItemStack stack); + + boolean isUpgraded(ItemStack stack); + + PotionType getBasePotionType(ItemStack stack); + + void setBasePotionType(ItemStack stack, PotionType type, boolean extended, boolean upgraded); } diff --git a/providers/BaseProviders/src/main/java/net/ess3/provider/providers/BaseBannerDataProvider.java b/providers/BaseProviders/src/main/java/net/ess3/provider/providers/BaseBannerDataProvider.java new file mode 100644 index 000000000..e3a869ea8 --- /dev/null +++ b/providers/BaseProviders/src/main/java/net/ess3/provider/providers/BaseBannerDataProvider.java @@ -0,0 +1,161 @@ +package net.ess3.provider.providers; + +import net.ess3.provider.BannerDataProvider; +import org.bukkit.DyeColor; +import org.bukkit.inventory.ItemStack; + +public class BaseBannerDataProvider implements BannerDataProvider { + @Override + public DyeColor getBaseColor(ItemStack stack) { + final DyeColor base; + switch (stack.getType()) { + case WHITE_BANNER: { + base = DyeColor.WHITE; + break; + } + case LIGHT_GRAY_BANNER: { + base = DyeColor.LIGHT_GRAY; + break; + } + case GRAY_BANNER: { + base = DyeColor.GRAY; + break; + } + case BLACK_BANNER: { + base = DyeColor.BLACK; + break; + } + case RED_BANNER: { + base = DyeColor.RED; + break; + } + case ORANGE_BANNER: { + base = DyeColor.ORANGE; + break; + } + case YELLOW_BANNER: { + base = DyeColor.YELLOW; + break; + } + case LIME_BANNER: { + base = DyeColor.LIME; + break; + } + case GREEN_BANNER: { + base = DyeColor.GREEN; + break; + } + case CYAN_BANNER: { + base = DyeColor.CYAN; + break; + } + case LIGHT_BLUE_BANNER: { + base = DyeColor.LIGHT_BLUE; + break; + } + case BLUE_BANNER: { + base = DyeColor.BLUE; + break; + } + case PURPLE_BANNER: { + base = DyeColor.PURPLE; + break; + } + case MAGENTA_BANNER: { + base = DyeColor.MAGENTA; + break; + } + case PINK_BANNER: { + base = DyeColor.PINK; + break; + } + case BROWN_BANNER: { + base = DyeColor.BROWN; + break; + } + default: { + base = null; + break; + } + } + return base; + } + + @Override + public void setBaseColor(ItemStack stack, DyeColor color) { + switch (color) { + case WHITE: { + stack.setType(org.bukkit.Material.WHITE_BANNER); + break; + } + case LIGHT_GRAY: { + stack.setType(org.bukkit.Material.LIGHT_GRAY_BANNER); + break; + } + case GRAY: { + stack.setType(org.bukkit.Material.GRAY_BANNER); + break; + } + case BLACK: { + stack.setType(org.bukkit.Material.BLACK_BANNER); + break; + } + case RED: { + stack.setType(org.bukkit.Material.RED_BANNER); + break; + } + case ORANGE: { + stack.setType(org.bukkit.Material.ORANGE_BANNER); + break; + } + case YELLOW: { + stack.setType(org.bukkit.Material.YELLOW_BANNER); + break; + } + case LIME: { + stack.setType(org.bukkit.Material.LIME_BANNER); + break; + } + case GREEN: { + stack.setType(org.bukkit.Material.GREEN_BANNER); + break; + } + case CYAN: { + stack.setType(org.bukkit.Material.CYAN_BANNER); + break; + } + case LIGHT_BLUE: { + stack.setType(org.bukkit.Material.LIGHT_BLUE_BANNER); + break; + } + case BLUE: { + stack.setType(org.bukkit.Material.BLUE_BANNER); + break; + } + case PINK: { + stack.setType(org.bukkit.Material.PINK_BANNER); + break; + } + case BROWN: { + stack.setType(org.bukkit.Material.BROWN_BANNER); + break; + } + case PURPLE: { + stack.setType(org.bukkit.Material.PURPLE_BANNER); + break; + } + case MAGENTA: { + stack.setType(org.bukkit.Material.MAGENTA_BANNER); + break; + } + default: { + break; + } + } + } + + @Override + public String getDescription() { + return "1.20.5+ Banner Data Provider."; + } +} diff --git a/providers/BaseProviders/src/main/java/net/ess3/provider/providers/BasePotionDataProvider.java b/providers/BaseProviders/src/main/java/net/ess3/provider/providers/BasePotionDataProvider.java deleted file mode 100644 index 74b4592a5..000000000 --- a/providers/BaseProviders/src/main/java/net/ess3/provider/providers/BasePotionDataProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -package net.ess3.provider.providers; - -import com.google.common.collect.ImmutableMap; -import net.ess3.provider.PotionMetaProvider; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.PotionData; -import org.bukkit.potion.PotionType; - -import java.util.Map; - -public class BasePotionDataProvider implements PotionMetaProvider { - private static final Map damageValueToType = ImmutableMap.builder() - .put(1, PotionType.REGEN) - .put(2, PotionType.SPEED) - .put(3, PotionType.FIRE_RESISTANCE) - .put(4, PotionType.POISON) - .put(5, PotionType.INSTANT_HEAL) - .put(6, PotionType.NIGHT_VISION) - // Skip 7 - .put(8, PotionType.WEAKNESS) - .put(9, PotionType.STRENGTH) - .put(10, PotionType.SLOWNESS) - .put(11, PotionType.JUMP) - .put(12, PotionType.INSTANT_DAMAGE) - .put(13, PotionType.WATER_BREATHING) - .put(14, PotionType.INVISIBILITY) - .build(); - - private static int getBit(final int n, final int k) { - return (n >> k) & 1; - } - - @Override - public ItemStack createPotionItem(final Material initial, final int effectId) { - ItemStack potion = new ItemStack(initial, 1); - - if (effectId == 0) { - return potion; - } - - final int damageValue = getBit(effectId, 0) + - 2 * getBit(effectId, 1) + - 4 * getBit(effectId, 2) + - 8 * getBit(effectId, 3); - - final PotionType type = damageValueToType.get(damageValue); - if (type == null) { - throw new IllegalArgumentException("Unable to process potion effect ID " + effectId + " with damage value " + damageValue); - } - - //getBit is splash here - if (getBit(effectId, 14) == 1 && initial == Material.POTION) { - potion = new ItemStack(Material.SPLASH_POTION, 1); - } - - final PotionMeta meta = (PotionMeta) potion.getItemMeta(); - //getBit(s) are extended and upgraded respectfully - final PotionData data = new PotionData(type, getBit(effectId, 6) == 1, getBit(effectId, 5) == 1); - meta.setBasePotionData(data); // this method is exclusive to recent 1.9+ - potion.setItemMeta(meta); - - return potion; - } - - @Override - public String getDescription() { - return "1.9+ Potion Meta Provider"; - } -} diff --git a/providers/BaseProviders/src/main/java/net/ess3/provider/providers/LegacyPotionMetaProvider.java b/providers/BaseProviders/src/main/java/net/ess3/provider/providers/LegacyPotionMetaProvider.java deleted file mode 100644 index 2ab157895..000000000 --- a/providers/BaseProviders/src/main/java/net/ess3/provider/providers/LegacyPotionMetaProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.ess3.provider.providers; - -import net.ess3.provider.PotionMetaProvider; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -@SuppressWarnings("deprecation") -public class LegacyPotionMetaProvider implements PotionMetaProvider { - @Override - public ItemStack createPotionItem(final Material initial, final int effectId) { - final ItemStack potion = new ItemStack(initial, 1); - potion.setDurability((short) effectId); - return potion; - } - - @Override - public String getDescription() { - return "Legacy 1.8 Potion Meta Provider"; - } -} diff --git a/providers/BaseProviders/src/main/java/net/ess3/provider/providers/ModernPotionMetaProvider.java b/providers/BaseProviders/src/main/java/net/ess3/provider/providers/ModernPotionMetaProvider.java new file mode 100644 index 000000000..28c6d915b --- /dev/null +++ b/providers/BaseProviders/src/main/java/net/ess3/provider/providers/ModernPotionMetaProvider.java @@ -0,0 +1,99 @@ +package net.ess3.provider.providers; + +import net.ess3.provider.PotionMetaProvider; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionType; + +import java.util.Collection; + +public class ModernPotionMetaProvider implements PotionMetaProvider { + @Override + public ItemStack createPotionItem(Material initial, int effectId) { + throw new UnsupportedOperationException("This should never happen, if this happens please submit a bug report!"); + } + + @Override + public void setBasePotionType(final ItemStack stack, PotionType type, final boolean extended, final boolean upgraded) { + if (stack == null) { + throw new IllegalArgumentException("ItemStack cannot be null"); + } + + if (extended && upgraded) { + throw new IllegalArgumentException("Potion cannot be both extended and upgraded"); + } + + final String name = type.name(); + if (name.startsWith("LONG_")) { + type = PotionType.valueOf(name.substring(5)); + } else if (name.startsWith("STRONG_")) { + type = PotionType.valueOf(name.substring(7)); + } + + if (extended && type.isExtendable()) { + type = PotionType.valueOf("LONG_" + type.name()); + } + + if (upgraded && type.isUpgradeable()) { + type = PotionType.valueOf("STRONG_" + type.name()); + } + + final PotionMeta meta = (PotionMeta) stack.getItemMeta(); + //noinspection DataFlowIssue + meta.setBasePotionType(type); + stack.setItemMeta(meta); + } + + @Override + public Collection getCustomEffects(ItemStack stack) { + final PotionMeta meta = (PotionMeta) stack.getItemMeta(); + //noinspection DataFlowIssue + return meta.getCustomEffects(); + } + + @Override + public boolean isSplashPotion(ItemStack stack) { + return stack != null && stack.getType() == Material.SPLASH_POTION; + } + + @Override + public boolean isExtended(ItemStack stack) { + final PotionMeta meta = (PotionMeta) stack.getItemMeta(); + //noinspection DataFlowIssue + return meta.getBasePotionType().name().startsWith("LONG_"); + } + + @Override + public boolean isUpgraded(ItemStack stack) { + final PotionMeta meta = (PotionMeta) stack.getItemMeta(); + //noinspection DataFlowIssue + return meta.getBasePotionType().name().startsWith("STRONG_"); + } + + @Override + public PotionType getBasePotionType(ItemStack stack) { + final PotionMeta meta = (PotionMeta) stack.getItemMeta(); + //noinspection DataFlowIssue + return meta.getBasePotionType(); + } + + @Override + public void setSplashPotion(ItemStack stack, boolean isSplash) { + if (stack == null) { + throw new IllegalArgumentException("ItemStack cannot be null"); + } + + if (isSplash && stack.getType() == Material.POTION) { + stack.setType(Material.SPLASH_POTION); + } else if (!isSplash && stack.getType() == Material.SPLASH_POTION) { + stack.setType(Material.POTION); + } + } + + @Override + public String getDescription() { + return "1.20.5+ Potion Meta Provider"; + } +}