Updated extensions to use new constructor

This commit is contained in:
Auxilor
2020-12-12 11:43:14 +00:00
parent 7ab1a35686
commit ae3ffd2954
22 changed files with 60 additions and 56 deletions

View File

@@ -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);
}
private static final FixedMetadataValue TRUE = new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true);

View File

@@ -1,3 +1,3 @@
name: Alchemy
main: com.willfp.ecoenchants.alchemy.AlchemyMain
version: 1.1.0
version: 2.0.0

View File

@@ -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, prerequisites);
}
public abstract boolean isValid(Biome biome);

View File

@@ -1,3 +1,3 @@
name: Biomes
main: com.willfp.ecoenchants.biomes.BiomesMain
version: 1.1.0
version: 2.0.0

View File

@@ -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, prerequisites);
}
public abstract PotionEffectType getPotionEffect();

View File

@@ -1,3 +1,3 @@
name: Effects
main: com.willfp.ecoenchants.effects.EffectsMain
version: 1.1.0
version: 2.0.0

View File

@@ -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);
}
@EventHandler(priority = EventPriority.LOW)

View File

@@ -1,3 +1,3 @@
name: Endershot
main: com.willfp.ecoenchants.endershot.EndershotMain
version: 1.1.0
version: 2.0.0

View File

@@ -14,7 +14,7 @@ import org.bukkit.metadata.FixedMetadataValue;
public class Firewand extends Spell {
public Firewand() {
super("firewand", FirewandMain.class);
super("firewand");
}
@Override

View File

@@ -1,3 +1,3 @@
name: Firewand
main: com.willfp.ecoenchants.firewand.FirewandMain
version: 1.1.0
version: 2.0.0

View File

@@ -1,13 +1,12 @@
package com.willfp.ecoenchants.mmo.structure;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.mmo.MMOMain;
import com.willfp.ecoenchants.mmo.MMOPrerequisites;
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.getInstance(), MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE));
super(key, type, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE));
MMOEnchant.REGISTRY.add(this);
}

View File

@@ -1,14 +1,12 @@
package com.willfp.ecoenchants.mmo.structure
;
package com.willfp.ecoenchants.mmo.structure;
import com.willfp.ecoenchants.enchantments.itemtypes.Spell;
import com.willfp.ecoenchants.mmo.MMOMain;
import com.willfp.ecoenchants.mmo.MMOPrerequisites;
import com.willfp.ecoenchants.util.optional.Prerequisite;
public abstract class MMOSpell extends Spell implements MMOEnchant {
protected MMOSpell(String key, Prerequisite... prerequisites) {
super(key, MMOMain.getInstance(), MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE));
super(key, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE));
MMOEnchant.REGISTRY.add(this);
}

View File

@@ -1,3 +1,3 @@
name: MMO
main: com.willfp.ecoenchants.mmo.MMOMain
version: 1.1.0
version: 2.0.0

View File

@@ -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
);
}

View File

@@ -1,3 +1,3 @@
name: Precision
main: com.willfp.ecoenchants.precision.PrecisionMain
version: 1.1.0
version: 2.0.0

View File

@@ -1,3 +1,3 @@
name: Sprint Artifacts
main: com.willfp.ecoenchants.sprintartifacts.SprintArtifactsMain
version: 1.1.0
version: 2.0.0

View File

@@ -28,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, prerequisites);
this.summoningType = summoningType;
}

View File

@@ -1,3 +1,3 @@
name: Summoning
main: com.willfp.ecoenchants.summoning.SummoningMain
version: 1.1.0
version: 2.0.0

View File

@@ -1,6 +1,5 @@
package com.willfp.ecoenchants.enchantments;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.config.ConfigManager;
import com.willfp.ecoenchants.config.configs.EnchantmentConfig;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity;
@@ -9,6 +8,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;
@@ -25,14 +25,7 @@ import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
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.*;
import java.util.stream.Collectors;
@SuppressWarnings({"unchecked", "deprecation"})
@@ -59,31 +52,18 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
/**
* Create a new EcoEnchant that exists within the base plugin
* Create a new EcoEnchant
*
* @param key The key name of the enchantment
* @param type The type of the enchantment
* @param prerequisites Optional {@link Prerequisite}s that must be met
*/
@ApiStatus.Internal
protected EcoEnchant(String key, EcoEnchant.EnchantmentType type, Prerequisite... prerequisites) {
this(key, type, EcoEnchantsPlugin.class, 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 plugin 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
*/
protected EcoEnchant(String key, EcoEnchant.EnchantmentType type, Class<?> plugin, Prerequisite... prerequisites) {
super(NamespacedKey.minecraft(key));
this.type = type;
this.permissionName = key.replaceAll("_", "");
ConfigManager.addEnchantmentConfig(new EnchantmentConfig(this.permissionName, plugin, this.type));
ConfigManager.addEnchantmentConfig(new EnchantmentConfig(this.permissionName, this.getClass(), this.type));
this.config = ConfigManager.getEnchantmentConfig(this.permissionName);
if (Bukkit.getPluginManager().getPermission("ecoenchants.fromtable." + permissionName) == null) {
@@ -103,6 +83,25 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
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 plugin Unused value
* @param prerequisites Optional {@link Prerequisite}s that must be met
*
* @deprecated Specifying the source class is no longer needed
*/
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "5.8.0")
protected EcoEnchant(String key, EcoEnchant.EnchantmentType type, Class<?> plugin, Prerequisite... prerequisites) {
this(key, type, prerequisites);
Logger.warn("Enchantment " + key + " (Generated by " + plugin.getName() + ") is using a legacy constructor!");
Logger.warn("Update your extensions - support for legacy enchantments will be removed in subsequent versions.");
}
/**
* Update the enchantment based off config values
* This can be overriden but may lead to unexpected behavior
@@ -257,6 +256,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
* If enchantment conflicts with any enchantment in set
*
* @param enchantments The set to test against
*
* @return If there are any conflicts
*/
public boolean conflictsWithAny(Set<? extends Enchantment> enchantments) {
@@ -344,6 +344,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
* Only here for compatibility with {@link Enchantment}
*
* @return Returns {@link EnchantmentTarget#ALL}. Do not use.
*
* @deprecated {@link EnchantmentTarget} is not supported due to its lack of flexibility. Use {@link EcoEnchant#getTarget()} instead.
*/
@Override
@@ -354,6 +355,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
/**
* @return false
*
* @deprecated Treasure enchantments do not exist. Use {@link EcoEnchant#getType()} instead.
*/
@Override
@@ -364,6 +366,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
/**
* @return Returns if enchantment is cursed.
*
* @deprecated Use {@link EcoEnchant#getType()} instead.
*/
@Override
@@ -376,6 +379,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
* Get if enchantment conflicts with specified enchantment
*
* @param enchantment The enchantment to test against
*
* @return If conflicts
*/
@Override
@@ -387,6 +391,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
* If enchantment can be applied to item
*
* @param itemStack The {@link ItemStack} to test against
*
* @return If can be applied
*/
@Override

View File

@@ -35,11 +35,7 @@ public abstract class Artifact extends EcoEnchant {
private Particle.DustOptions extra;
protected Artifact(String key, Prerequisite... prerequisites) {
this(key, EcoEnchantsPlugin.class, prerequisites);
}
protected Artifact(String key, Class<?> plugin, Prerequisite... prerequisites) {
super(key, EnchantmentType.ARTIFACT, plugin, prerequisites);
super(key, EnchantmentType.ARTIFACT, prerequisites);
if(!Prerequisite.areMet(prerequisites)) {
HandlerList.unregisterAll(this); // Prevent events firing
@@ -50,6 +46,12 @@ public abstract class Artifact extends EcoEnchant {
this.extra = this.getDustOptions();
}
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "5.8.0")
protected Artifact(String key, Class<?> plugin, Prerequisite... prerequisites) {
this(key, prerequisites);
}
public abstract Particle getParticle();
public Particle.DustOptions getDustOptions() {

View File

@@ -37,11 +37,13 @@ public abstract class Spell extends EcoEnchant {
);
protected Spell(String key, Prerequisite... prerequisites) {
this(key, EcoEnchantsPlugin.class, prerequisites);
super(key, EnchantmentType.SPELL, prerequisites);
}
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "5.8.0")
protected Spell(String key, Class<?> plugin, Prerequisite... prerequisites) {
super(key, EnchantmentType.SPELL, plugin, prerequisites);
this(key, prerequisites);
}
public int getCooldownTime() {

View File

@@ -38,7 +38,5 @@ findProject(':SprintArtifacts').projectDir = file('Extensions/SprintArtifacts')
include('Alchemy')
findProject(':Alchemy').projectDir = file('Extensions/Alchemy')
/*
include('MMO')
findProject(':MMO').projectDir = file('Extensions/MMO')
*/
findProject(':MMO').projectDir = file('Extensions/MMO')