From 05bd8f31bef87d5293ab84e74a9b8a5d5bcf96bc Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 11 Dec 2020 19:02:51 +0000 Subject: [PATCH] Updated all extensions and kept legacy registration - will be removed in next version --- .../willfp/ecoenchants/alchemy/Alchemy.java | 2 +- .../Alchemy/src/main/resources/extension.yml | 2 +- .../ecoenchants/biomes/BiomesEnchantment.java | 2 +- .../Biomes/src/main/resources/extension.yml | 2 +- .../effects/EffectsEnchantment.java | 2 +- .../Effects/src/main/resources/extension.yml | 2 +- .../ecoenchants/endershot/Endershot.java | 2 +- .../src/main/resources/extension.yml | 2 +- .../willfp/ecoenchants/firewand/Firewand.java | 2 +- .../Firewand/src/main/resources/extension.yml | 2 +- .../mmo/structure/MMOEnchantment.java | 2 +- .../ecoenchants/mmo/structure/MMOSpell.java | 2 +- .../MMO/src/main/resources/extension.yml | 2 +- .../ecoenchants/precision/Precision.java | 2 +- .../src/main/resources/extension.yml | 2 +- .../src/main/resources/extension.yml | 2 +- .../summoning/SummoningEnchantment.java | 9 +++- .../src/main/resources/extension.yml | 2 +- .../config/EnchantmentYamlConfig.java | 44 ++++++++++++++++++- .../config/configs/EnchantmentConfig.java | 6 +++ .../ecoenchants/enchantments/EcoEnchant.java | 43 +++++++++++++++++- .../enchantments/itemtypes/Artifact.java | 21 +++++++-- .../enchantments/itemtypes/Spell.java | 14 ++++-- .../ecoenchants/extensions/Extension.java | 4 +- settings.gradle | 5 +-- 25 files changed, 146 insertions(+), 34 deletions(-) diff --git a/Extensions/Alchemy/src/main/java/com/willfp/ecoenchants/alchemy/Alchemy.java b/Extensions/Alchemy/src/main/java/com/willfp/ecoenchants/alchemy/Alchemy.java index ee46b8e6..81de0621 100644 --- a/Extensions/Alchemy/src/main/java/com/willfp/ecoenchants/alchemy/Alchemy.java +++ b/Extensions/Alchemy/src/main/java/com/willfp/ecoenchants/alchemy/Alchemy.java @@ -13,7 +13,7 @@ import org.bukkit.potion.PotionEffect; public class Alchemy extends EcoEnchant { public Alchemy() { - super("alchemy", EnchantmentType.NORMAL, AlchemyMain.class); + super("alchemy", EnchantmentType.NORMAL, AlchemyMain.getInstance()); } private static final FixedMetadataValue TRUE = new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true); diff --git a/Extensions/Alchemy/src/main/resources/extension.yml b/Extensions/Alchemy/src/main/resources/extension.yml index fe5dccb7..d297b24c 100644 --- a/Extensions/Alchemy/src/main/resources/extension.yml +++ b/Extensions/Alchemy/src/main/resources/extension.yml @@ -1,3 +1,3 @@ name: Alchemy main: com.willfp.ecoenchants.alchemy.AlchemyMain -version: 1.0.1 \ No newline at end of file +version: 1.1.0 \ No newline at end of file diff --git a/Extensions/Biomes/src/main/java/com/willfp/ecoenchants/biomes/BiomesEnchantment.java b/Extensions/Biomes/src/main/java/com/willfp/ecoenchants/biomes/BiomesEnchantment.java index cad118cf..515f1aa7 100644 --- a/Extensions/Biomes/src/main/java/com/willfp/ecoenchants/biomes/BiomesEnchantment.java +++ b/Extensions/Biomes/src/main/java/com/willfp/ecoenchants/biomes/BiomesEnchantment.java @@ -12,7 +12,7 @@ import org.bukkit.event.entity.EntityDamageEvent; public abstract class BiomesEnchantment extends EcoEnchant { protected BiomesEnchantment(String key, EnchantmentType type, Prerequisite... prerequisites) { - super(key, type, BiomesMain.class, prerequisites); + super(key, type, BiomesMain.getInstance(), prerequisites); } public abstract boolean isValid(Biome biome); diff --git a/Extensions/Biomes/src/main/resources/extension.yml b/Extensions/Biomes/src/main/resources/extension.yml index b23e4c6c..ba310aab 100644 --- a/Extensions/Biomes/src/main/resources/extension.yml +++ b/Extensions/Biomes/src/main/resources/extension.yml @@ -1,3 +1,3 @@ name: Biomes main: com.willfp.ecoenchants.biomes.BiomesMain -version: 1.0.1 \ No newline at end of file +version: 1.1.0 \ No newline at end of file diff --git a/Extensions/Effects/src/main/java/com/willfp/ecoenchants/effects/EffectsEnchantment.java b/Extensions/Effects/src/main/java/com/willfp/ecoenchants/effects/EffectsEnchantment.java index 6c418c85..7ed21b0a 100644 --- a/Extensions/Effects/src/main/java/com/willfp/ecoenchants/effects/EffectsEnchantment.java +++ b/Extensions/Effects/src/main/java/com/willfp/ecoenchants/effects/EffectsEnchantment.java @@ -13,7 +13,7 @@ import org.bukkit.potion.PotionEffectType; public abstract class EffectsEnchantment extends EcoEnchant { protected EffectsEnchantment(String key, EnchantmentType type, Prerequisite... prerequisites) { - super(key, type, EffectsMain.class, prerequisites); + super(key, type, EffectsMain.getInstance(), prerequisites); } public abstract PotionEffectType getPotionEffect(); diff --git a/Extensions/Effects/src/main/resources/extension.yml b/Extensions/Effects/src/main/resources/extension.yml index c34280c8..5705fbaf 100644 --- a/Extensions/Effects/src/main/resources/extension.yml +++ b/Extensions/Effects/src/main/resources/extension.yml @@ -1,3 +1,3 @@ name: Effects main: com.willfp.ecoenchants.effects.EffectsMain -version: 1.0.2 \ No newline at end of file +version: 1.1.0 \ No newline at end of file diff --git a/Extensions/Endershot/src/main/java/com/willfp/ecoenchants/endershot/Endershot.java b/Extensions/Endershot/src/main/java/com/willfp/ecoenchants/endershot/Endershot.java index 109fea5c..e7b30cf6 100644 --- a/Extensions/Endershot/src/main/java/com/willfp/ecoenchants/endershot/Endershot.java +++ b/Extensions/Endershot/src/main/java/com/willfp/ecoenchants/endershot/Endershot.java @@ -18,7 +18,7 @@ import org.bukkit.inventory.ItemStack; public class Endershot extends EcoEnchant { public Endershot() { - super("endershot", EnchantmentType.NORMAL, EndershotMain.class); + super("endershot", EnchantmentType.NORMAL, EndershotMain.getInstance()); } @EventHandler(priority = EventPriority.LOW) diff --git a/Extensions/Endershot/src/main/resources/extension.yml b/Extensions/Endershot/src/main/resources/extension.yml index def9482b..12f67061 100644 --- a/Extensions/Endershot/src/main/resources/extension.yml +++ b/Extensions/Endershot/src/main/resources/extension.yml @@ -1,3 +1,3 @@ name: Endershot main: com.willfp.ecoenchants.endershot.EndershotMain -version: 1.0.1 +version: 1.1.0 diff --git a/Extensions/Firewand/src/main/java/com/willfp/ecoenchants/firewand/Firewand.java b/Extensions/Firewand/src/main/java/com/willfp/ecoenchants/firewand/Firewand.java index 518dca1b..02def3d0 100644 --- a/Extensions/Firewand/src/main/java/com/willfp/ecoenchants/firewand/Firewand.java +++ b/Extensions/Firewand/src/main/java/com/willfp/ecoenchants/firewand/Firewand.java @@ -14,7 +14,7 @@ import org.bukkit.metadata.FixedMetadataValue; public class Firewand extends Spell { public Firewand() { - super("firewand", FirewandMain.class); + super("firewand", FirewandMain.getInstance()); } @Override diff --git a/Extensions/Firewand/src/main/resources/extension.yml b/Extensions/Firewand/src/main/resources/extension.yml index 960eeb84..9905e4bf 100644 --- a/Extensions/Firewand/src/main/resources/extension.yml +++ b/Extensions/Firewand/src/main/resources/extension.yml @@ -1,3 +1,3 @@ name: Firewand main: com.willfp.ecoenchants.firewand.FirewandMain -version: 1.0.4 \ No newline at end of file +version: 1.1.0 \ No newline at end of file diff --git a/Extensions/MMO/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOEnchantment.java b/Extensions/MMO/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOEnchantment.java index 4806dc75..9deabdf2 100644 --- a/Extensions/MMO/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOEnchantment.java +++ b/Extensions/MMO/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOEnchantment.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.util.optional.Prerequisite; public abstract class MMOEnchantment extends EcoEnchant implements MMOEnchant { protected MMOEnchantment(String key, EnchantmentType type, Prerequisite... prerequisites) { - super(key, type, MMOMain.class, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE)); + super(key, type, MMOMain.getInstance(), MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE)); MMOEnchant.REGISTRY.add(this); } diff --git a/Extensions/MMO/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOSpell.java b/Extensions/MMO/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOSpell.java index 02fd6615..d33ca7f0 100644 --- a/Extensions/MMO/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOSpell.java +++ b/Extensions/MMO/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOSpell.java @@ -8,7 +8,7 @@ import com.willfp.ecoenchants.util.optional.Prerequisite; public abstract class MMOSpell extends Spell implements MMOEnchant { protected MMOSpell(String key, Prerequisite... prerequisites) { - super(key, MMOMain.class, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE)); + super(key, MMOMain.getInstance(), MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE)); MMOEnchant.REGISTRY.add(this); } diff --git a/Extensions/MMO/src/main/resources/extension.yml b/Extensions/MMO/src/main/resources/extension.yml index f2bbce8e..01586fd0 100644 --- a/Extensions/MMO/src/main/resources/extension.yml +++ b/Extensions/MMO/src/main/resources/extension.yml @@ -1,3 +1,3 @@ name: MMO main: com.willfp.ecoenchants.mmo.MMOMain -version: 1.0.0 \ No newline at end of file +version: 1.1.0 \ No newline at end of file diff --git a/Extensions/Precision/src/main/java/com/willfp/ecoenchants/precision/Precision.java b/Extensions/Precision/src/main/java/com/willfp/ecoenchants/precision/Precision.java index 661b3373..08389ead 100644 --- a/Extensions/Precision/src/main/java/com/willfp/ecoenchants/precision/Precision.java +++ b/Extensions/Precision/src/main/java/com/willfp/ecoenchants/precision/Precision.java @@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger; public class Precision extends EcoEnchant { public Precision() { super( - "precision", EnchantmentType.SPECIAL, PrecisionMain.class + "precision", EnchantmentType.SPECIAL, PrecisionMain.getInstance() ); } diff --git a/Extensions/Precision/src/main/resources/extension.yml b/Extensions/Precision/src/main/resources/extension.yml index a6f56445..82976efa 100644 --- a/Extensions/Precision/src/main/resources/extension.yml +++ b/Extensions/Precision/src/main/resources/extension.yml @@ -1,3 +1,3 @@ name: Precision main: com.willfp.ecoenchants.precision.PrecisionMain -version: 1.0.4 \ No newline at end of file +version: 1.1.0 \ No newline at end of file diff --git a/Extensions/SprintArtifacts/src/main/resources/extension.yml b/Extensions/SprintArtifacts/src/main/resources/extension.yml index 8425b85c..eb8f8c16 100644 --- a/Extensions/SprintArtifacts/src/main/resources/extension.yml +++ b/Extensions/SprintArtifacts/src/main/resources/extension.yml @@ -1,3 +1,3 @@ name: Sprint Artifacts main: com.willfp.ecoenchants.sprintartifacts.SprintArtifactsMain -version: 1.0.1 \ No newline at end of file +version: 1.1.0 \ No newline at end of file diff --git a/Extensions/Summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningEnchantment.java b/Extensions/Summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningEnchantment.java index 453c284b..99517e1e 100644 --- a/Extensions/Summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningEnchantment.java +++ b/Extensions/Summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningEnchantment.java @@ -11,7 +11,12 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.attribute.Attribute; -import org.bukkit.entity.*; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Mob; +import org.bukkit.entity.Player; +import org.bukkit.entity.Trident; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -23,7 +28,7 @@ public abstract class SummoningEnchantment extends EcoEnchant { private final SummoningType summoningType; protected SummoningEnchantment(String key, EnchantmentType type, SummoningType summoningType, Prerequisite... prerequisites) { - super(key, type, SummoningMain.class, prerequisites); + super(key, type, SummoningMain.getInstance(), prerequisites); this.summoningType = summoningType; } diff --git a/Extensions/Summoning/src/main/resources/extension.yml b/Extensions/Summoning/src/main/resources/extension.yml index d092c54c..4a809e83 100644 --- a/Extensions/Summoning/src/main/resources/extension.yml +++ b/Extensions/Summoning/src/main/resources/extension.yml @@ -1,3 +1,3 @@ name: Summoning main: com.willfp.ecoenchants.summoning.SummoningMain -version: 1.0.3 \ No newline at end of file +version: 1.1.0 \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java index 0cee2294..647815a7 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java @@ -3,6 +3,7 @@ package com.willfp.ecoenchants.config; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.util.EnchantmentRegisterer; +import com.willfp.ecoenchants.util.internal.Logger; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; @@ -27,6 +28,9 @@ public abstract class EnchantmentYamlConfig { private final EnchantmentRegisterer registerer; private final EcoEnchant.EnchantmentType type; + private final boolean legacy; + private Class legacyRegisterer; + /** * Create new config yml * @@ -38,6 +42,30 @@ public abstract class EnchantmentYamlConfig { this.name = name; this.registerer = registerer; this.type = type; + legacy = false; + + File basedir = new File(EcoEnchantsPlugin.getInstance().getDataFolder(), "enchants/"); + if (!basedir.exists()) basedir.mkdirs(); + + File dir = new File(basedir, type.getName() + "/"); + if (!dir.exists()) { + dir.mkdirs(); + } + this.directory = dir; + + init(); + } + + @Deprecated + public EnchantmentYamlConfig(String name, Class registerer, EcoEnchant.EnchantmentType type) { + this.name = name; + this.legacyRegisterer = registerer; + this.registerer = null; + this.type = type; + legacy = true; + + Logger.warn("Config " + name + " was created in legacy mode!"); + Logger.warn("Update your extensions"); File basedir = new File(EcoEnchantsPlugin.getInstance().getDataFolder(), "enchants/"); if (!basedir.exists()) basedir.mkdirs(); @@ -65,7 +93,12 @@ public abstract class EnchantmentYamlConfig { private void saveResource() { String resourcePath = "/enchants/" + type.getName() + "/" + name + ".yml"; - InputStream in = registerer.getResourceAsStream(resourcePath); + InputStream in; + if(legacy) { + in = legacyRegisterer.getResourceAsStream(resourcePath); + } else { + in = registerer.getResourceAsStream(resourcePath); + } File outFile = new File(EcoEnchantsPlugin.getInstance().getDataFolder(), resourcePath); int lastIndex = resourcePath.lastIndexOf('/'); @@ -99,7 +132,14 @@ public abstract class EnchantmentYamlConfig { config.load(configFile); String resourcePath = "/enchants/" + type.getName() + "/" + name + ".yml"; - InputStream newIn = registerer.getResourceAsStream(resourcePath); + + InputStream newIn; + + if(legacy) { + newIn = legacyRegisterer.getResourceAsStream(resourcePath); + } else { + newIn = registerer.getResourceAsStream(resourcePath); + } BufferedReader reader = new BufferedReader(new InputStreamReader(newIn, StandardCharsets.UTF_8)); YamlConfiguration newConfig = new YamlConfiguration(); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java index 4fd8bc5e..a2a7a82c 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java @@ -28,6 +28,12 @@ public class EnchantmentConfig extends EnchantmentYamlConfig { this.name = name; } + @Deprecated + public EnchantmentConfig(String name, Class registerer, EcoEnchant.EnchantmentType type) { + super(name, registerer, type); + this.name = name; + } + public String getName() { return name; } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java index 337f97b9..cd8928e1 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java @@ -10,6 +10,7 @@ import com.willfp.ecoenchants.enchantments.util.Watcher; import com.willfp.ecoenchants.util.StringUtils; import com.willfp.ecoenchants.util.interfaces.ObjectCallable; import com.willfp.ecoenchants.util.interfaces.Registerable; +import com.willfp.ecoenchants.util.internal.Logger; import com.willfp.ecoenchants.util.optional.Prerequisite; import org.apache.commons.lang.WordUtils; import org.bukkit.Bukkit; @@ -70,12 +71,52 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist this(key, type, EcoEnchantsPlugin.getInstance(), prerequisites); } + /** + * Create a new EcoEnchant that exists within an extension or external plugin + * + * @param key The key name of the enchantment + * @param type The type of the enchantment + * @param registererClass The Main class of the {@link org.bukkit.plugin.Plugin} or {@link com.willfp.ecoenchants.extensions.Extension} that the enchantment was created by + * @param prerequisites Optional {@link Prerequisite}s that must be met + * + * @deprecated Class-based enchantment registration was deprecated in 5.6.0. Base your extensions off of {@link EnchantmentRegisterer} + */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.7.0") + protected EcoEnchant(String key, EcoEnchant.EnchantmentType type, Class registererClass, Prerequisite... prerequisites) { + super(NamespacedKey.minecraft(key)); + + Logger.warn("Enchantment " + key + " was created in legacy mode!"); + Logger.warn("Update your extensions"); + + this.type = type; + this.permissionName = key.replaceAll("_", ""); + ConfigManager.addEnchantmentConfig(new EnchantmentConfig(this.permissionName, registererClass, this.type)); + this.config = ConfigManager.getEnchantmentConfig(this.permissionName); + + if (Bukkit.getPluginManager().getPermission("ecoenchants.fromtable." + permissionName) == null) { + Permission permission = new Permission( + "ecoenchants.fromtable." + permissionName, + "Allows getting " + permissionName + " from an Enchanting Table", + PermissionDefault.TRUE + ); + permission.addParent(Objects.requireNonNull(Bukkit.getPluginManager().getPermission("ecoenchants.fromtable.*")), true); + Bukkit.getPluginManager().addPermission(permission); + } + + if (!Prerequisite.areMet(prerequisites)) + return; + + this.update(); + EcoEnchants.addNewEcoEnchant(this); + } + /** * Create a new EcoEnchant that exists within an extension or external plugin * * @param key The key name of the enchantment * @param type The type of the enchantment - * @param registerer The Main class of the {@link org.bukkit.plugin.Plugin} or {@link com.willfp.ecoenchants.extensions.Extension} that the enchantment was created by + * @param registerer Instance of the main class of the {@link com.willfp.ecoenchants.extensions.Extension} or {@link EnchantmentRegisterer} that the enchantment was created by * @param prerequisites Optional {@link Prerequisite}s that must be met */ protected EcoEnchant(String key, EcoEnchant.EnchantmentType type, EnchantmentRegisterer registerer, Prerequisite... prerequisites) { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java index acb2f74b..818384ed 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java @@ -5,6 +5,7 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.EnchantmentRegisterer; import com.willfp.ecoenchants.nms.TridentStack; import com.willfp.ecoenchants.util.NumberUtils; import com.willfp.ecoenchants.util.optional.Prerequisite; @@ -24,6 +25,7 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; /** * Wrapper for Artifact enchantments @@ -34,11 +36,11 @@ public abstract class Artifact extends EcoEnchant { private Particle.DustOptions extra; protected Artifact(String key, Prerequisite... prerequisites) { - this(key, EcoEnchantsPlugin.class, prerequisites); + this(key, EcoEnchantsPlugin.getInstance(), prerequisites); } - protected Artifact(String key, Class plugin, Prerequisite... prerequisites) { - super(key, EnchantmentType.ARTIFACT, plugin, prerequisites); + protected Artifact(String key, EnchantmentRegisterer registerer, Prerequisite... prerequisites) { + super(key, EnchantmentType.ARTIFACT, registerer, prerequisites); if(!Prerequisite.areMet(prerequisites)) { HandlerList.unregisterAll(this); // Prevent events firing @@ -47,7 +49,20 @@ public abstract class Artifact extends EcoEnchant { this.particle = this.getParticle(); this.extra = this.getDustOptions(); + } + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.7.0") + protected Artifact(String key, Class registerer, Prerequisite... prerequisites) { + super(key, EnchantmentType.ARTIFACT, registerer, prerequisites); + + if(!Prerequisite.areMet(prerequisites)) { + HandlerList.unregisterAll(this); // Prevent events firing + return; + } + + this.particle = this.getParticle(); + this.extra = this.getDustOptions(); } public abstract Particle getParticle(); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java index 4873ceb5..d1448ace 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java @@ -6,6 +6,7 @@ import com.willfp.ecoenchants.display.EnchantmentCache; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.EnchantmentRegisterer; import com.willfp.ecoenchants.enchantments.util.SpellRunnable; import com.willfp.ecoenchants.util.optional.Prerequisite; import org.bukkit.Bukkit; @@ -16,6 +17,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; +import org.jetbrains.annotations.ApiStatus; import java.util.Arrays; import java.util.HashMap; @@ -36,11 +38,17 @@ public abstract class Spell extends EcoEnchant { ); protected Spell(String key, Prerequisite... prerequisites) { - this(key, EcoEnchantsPlugin.class, prerequisites); + this(key, EcoEnchantsPlugin.getInstance(), prerequisites); } - protected Spell(String key, Class plugin, Prerequisite... prerequisites) { - super(key, EnchantmentType.SPELL, plugin, prerequisites); + protected Spell(String key, EnchantmentRegisterer registerer, Prerequisite... prerequisites) { + super(key, EnchantmentType.SPELL, registerer, prerequisites); + } + + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "5.7.0") + protected Spell(String key, Class registerer, Prerequisite... prerequisites) { + super(key, EnchantmentType.SPELL, registerer, prerequisites); } public int getCooldownTime() { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/extensions/Extension.java b/Plugin/src/main/java/com/willfp/ecoenchants/extensions/Extension.java index 6554dcb5..eac5462d 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/extensions/Extension.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/extensions/Extension.java @@ -18,7 +18,7 @@ public abstract class Extension implements EnchantmentRegisterer { /** * Instance of the extension */ - private Extension instance; + private static Extension instance; /** * Method to validate metadata and enable extension @@ -50,7 +50,7 @@ public abstract class Extension implements EnchantmentRegisterer { * Get instance of the extension * @return The instance */ - public final Extension getInstance() { + public static Extension getInstance() { return instance; } diff --git a/settings.gradle b/settings.gradle index 797907b4..ea76b967 100644 --- a/settings.gradle +++ b/settings.gradle @@ -38,8 +38,5 @@ findProject(':SprintArtifacts').projectDir = file('Extensions/SprintArtifacts') include('Alchemy') findProject(':Alchemy').projectDir = file('Extensions/Alchemy') -/* -Excluded for extended build times include('MMO') -findProject(':MMO').projectDir = file('Extensions/MMO') - */ \ No newline at end of file +findProject(':MMO').projectDir = file('Extensions/MMO') \ No newline at end of file