mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-26 15:45:12 +01:00
Refactored Artifacts
Signed-off-by: BuildTools <unconfigured@null.spigotmc.org>
This commit is contained in:
parent
f4463c6244
commit
54d7f3d4df
@ -44,6 +44,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
|
||||
private final Set<Material> target = new HashSet<>();
|
||||
|
||||
private boolean enabled;
|
||||
private boolean registered = false;
|
||||
|
||||
/**
|
||||
* Create new EcoEnchant matching builder and prerequisites
|
||||
@ -130,6 +131,8 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
|
||||
f.setAccessible(false);
|
||||
|
||||
Enchantment.registerEnchantment(this);
|
||||
|
||||
this.registered = true;
|
||||
} catch (NoSuchFieldException | IllegalAccessException ignored) {}
|
||||
}
|
||||
|
||||
@ -171,6 +174,14 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if enchantment is registered
|
||||
* @return If registered
|
||||
*/
|
||||
public boolean isRegistered() {
|
||||
return this.registered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get permission name of enchantment
|
||||
* @return The permission name
|
||||
|
@ -9,8 +9,12 @@ public final class AshArtifact extends Artifact {
|
||||
super(
|
||||
"ash_artifact",
|
||||
5.0,
|
||||
Particle.WHITE_ASH,
|
||||
new Prerequisite[]{Prerequisite.MinVer1_16}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.WHITE_ASH;
|
||||
}
|
||||
}
|
@ -7,9 +7,17 @@ public final class CloudsArtifact extends Artifact {
|
||||
public CloudsArtifact() {
|
||||
super(
|
||||
"clouds_artifact",
|
||||
5.0,
|
||||
Particle.REDSTONE,
|
||||
new Particle.DustOptions(Color.AQUA, 1.0f)
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.REDSTONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle.DustOptions getDustOptions() {
|
||||
return new Particle.DustOptions(Color.AQUA, 1.0f);
|
||||
}
|
||||
}
|
@ -9,8 +9,12 @@ public final class CrimsonArtifact extends Artifact {
|
||||
super(
|
||||
"crimson_artifact",
|
||||
5.0,
|
||||
Particle.CRIMSON_SPORE,
|
||||
new Prerequisite[]{Prerequisite.MinVer1_16}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.CRIMSON_SPORE;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class DamageArtifact extends Artifact {
|
||||
public DamageArtifact() {
|
||||
super(
|
||||
"damage_artifact",
|
||||
5.0,
|
||||
Particle.DAMAGE_INDICATOR
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.DAMAGE_INDICATOR;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class DragonArtifact extends Artifact {
|
||||
public DragonArtifact() {
|
||||
super(
|
||||
"dragon_artifact",
|
||||
5.0,
|
||||
Particle.DRAGON_BREATH
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.DRAGON_BREATH;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class DustArtifact extends Artifact {
|
||||
public DustArtifact() {
|
||||
super(
|
||||
"dust_artifact",
|
||||
5.0,
|
||||
Particle.CRIT
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.CRIT;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class EmeraldArtifact extends Artifact {
|
||||
public EmeraldArtifact() {
|
||||
super(
|
||||
"emerald_artifact",
|
||||
5.0,
|
||||
Particle.COMPOSTER
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.COMPOSTER;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class EnchantmentArtifact extends Artifact {
|
||||
public EnchantmentArtifact() {
|
||||
super(
|
||||
"enchantment_artifact",
|
||||
5.0,
|
||||
Particle.ENCHANTMENT_TABLE
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.ENCHANTMENT_TABLE;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class EndArtifact extends Artifact {
|
||||
public EndArtifact() {
|
||||
super(
|
||||
"end_artifact",
|
||||
5.0,
|
||||
Particle.END_ROD
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.END_ROD;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class FireArtifact extends Artifact {
|
||||
public FireArtifact() {
|
||||
super(
|
||||
"fire_artifact",
|
||||
5.0,
|
||||
Particle.FLAME
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.FLAME;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class HeartArtifact extends Artifact {
|
||||
public HeartArtifact() {
|
||||
super(
|
||||
"heart_artifact",
|
||||
5.0,
|
||||
Particle.HEART
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.HEART;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class HoneyArtifact extends Artifact {
|
||||
public HoneyArtifact() {
|
||||
super(
|
||||
"honey_artifact",
|
||||
5.0,
|
||||
Particle.FALLING_HONEY
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.FALLING_HONEY;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class InkArtifact extends Artifact {
|
||||
public InkArtifact() {
|
||||
super(
|
||||
"ink_artifact",
|
||||
5.0,
|
||||
Particle.SQUID_INK
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.SQUID_INK;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class LavaArtifact extends Artifact {
|
||||
public LavaArtifact() {
|
||||
super(
|
||||
"lava_artifact",
|
||||
5.0,
|
||||
Particle.DRIP_LAVA
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.DRIP_LAVA;
|
||||
}
|
||||
}
|
@ -8,9 +8,17 @@ public final class LimeArtifact extends Artifact {
|
||||
public LimeArtifact() {
|
||||
super(
|
||||
"lime_artifact",
|
||||
5.0,
|
||||
Particle.REDSTONE,
|
||||
new Particle.DustOptions(Color.fromRGB(3, 252, 140), 1.0f)
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.REDSTONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle.DustOptions getDustOptions() {
|
||||
return new Particle.DustOptions(Color.fromRGB(3, 252, 140), 1.0f);
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class MagicArtifact extends Artifact {
|
||||
public MagicArtifact() {
|
||||
super(
|
||||
"magic_artifact",
|
||||
5.0,
|
||||
Particle.CRIT_MAGIC
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.CRIT_MAGIC;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class MagmaArtifact extends Artifact {
|
||||
public MagmaArtifact() {
|
||||
super(
|
||||
"magma_artifact",
|
||||
5.0,
|
||||
Particle.LAVA
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.LAVA;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class MusicArtifact extends Artifact {
|
||||
public MusicArtifact() {
|
||||
super(
|
||||
"music_artifact",
|
||||
5.0,
|
||||
Particle.NOTE
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.NOTE;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class NetherArtifact extends Artifact {
|
||||
public NetherArtifact() {
|
||||
super(
|
||||
"nether_artifact",
|
||||
5.0,
|
||||
Particle.PORTAL
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.PORTAL;
|
||||
}
|
||||
}
|
@ -7,9 +7,17 @@ public final class RedstoneArtifact extends Artifact {
|
||||
public RedstoneArtifact() {
|
||||
super(
|
||||
"redstone_artifact",
|
||||
5.0,
|
||||
Particle.REDSTONE,
|
||||
new Particle.DustOptions(Color.RED, 1.0f)
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.REDSTONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle.DustOptions getDustOptions() {
|
||||
return new Particle.DustOptions(Color.RED, 1.0f);
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class SmokeArtifact extends Artifact {
|
||||
public SmokeArtifact() {
|
||||
super(
|
||||
"smoke_artifact",
|
||||
5.0,
|
||||
Particle.CAMPFIRE_COSY_SMOKE
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.CAMPFIRE_COSY_SMOKE;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class SnowArtifact extends Artifact {
|
||||
public SnowArtifact() {
|
||||
super(
|
||||
"snow_artifact",
|
||||
5.0,
|
||||
Particle.SNOWBALL
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.SNOWBALL;
|
||||
}
|
||||
}
|
@ -9,8 +9,12 @@ public final class SoulArtifact extends Artifact {
|
||||
super(
|
||||
"soul_artifact",
|
||||
5.0,
|
||||
Particle.SOUL,
|
||||
new Prerequisite[]{Prerequisite.MinVer1_16}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.SOUL;
|
||||
}
|
||||
}
|
@ -9,8 +9,12 @@ public final class SoulFireArtifact extends Artifact {
|
||||
super(
|
||||
"soul_fire_artifact",
|
||||
5.0,
|
||||
Particle.SOUL_FIRE_FLAME,
|
||||
new Prerequisite[]{Prerequisite.MinVer1_16}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.SOUL_FIRE_FLAME;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class SparkleArtifact extends Artifact {
|
||||
public SparkleArtifact() {
|
||||
super(
|
||||
"sparkle_artifact",
|
||||
5.0,
|
||||
Particle.FIREWORKS_SPARK
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.FIREWORKS_SPARK;
|
||||
}
|
||||
}
|
@ -9,8 +9,12 @@ public final class TearArtifact extends Artifact {
|
||||
super(
|
||||
"tear_artifact",
|
||||
5.0,
|
||||
Particle.DRIPPING_OBSIDIAN_TEAR,
|
||||
new Prerequisite[]{Prerequisite.MinVer1_16}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.DRIPPING_OBSIDIAN_TEAR;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class TotemArtifact extends Artifact {
|
||||
public TotemArtifact() {
|
||||
super(
|
||||
"totem_artifact",
|
||||
5.0,
|
||||
Particle.TOTEM
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.TOTEM;
|
||||
}
|
||||
}
|
@ -9,8 +9,12 @@ public final class WarpedArtifact extends Artifact {
|
||||
super(
|
||||
"warped_artifact",
|
||||
5.0,
|
||||
Particle.WARPED_SPORE,
|
||||
new Prerequisite[]{Prerequisite.MinVer1_16}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.WARPED_SPORE;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class WaterArtifact extends Artifact {
|
||||
public WaterArtifact() {
|
||||
super(
|
||||
"water_artifact",
|
||||
5.0,
|
||||
Particle.DRIP_WATER
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.DRIP_WATER;
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ public final class WitchArtifact extends Artifact {
|
||||
public WitchArtifact() {
|
||||
super(
|
||||
"witch_artifact",
|
||||
5.0,
|
||||
Particle.SPELL_WITCH
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.SPELL_WITCH;
|
||||
}
|
||||
}
|
@ -7,9 +7,17 @@ public final class ZapArtifact extends Artifact {
|
||||
public ZapArtifact() {
|
||||
super(
|
||||
"zap_artifact",
|
||||
5.0,
|
||||
Particle.REDSTONE,
|
||||
new Particle.DustOptions(Color.YELLOW, 1.0f)
|
||||
5.0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle getParticle() {
|
||||
return Particle.REDSTONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Particle.DustOptions getDustOptions() {
|
||||
return new Particle.DustOptions(Color.YELLOW, 1.0f);
|
||||
}
|
||||
}
|
@ -30,27 +30,27 @@ import org.bukkit.util.Vector;
|
||||
* in order to reduce copying existing code between artifacts.
|
||||
*/
|
||||
public abstract class Artifact extends EcoEnchant {
|
||||
private final Particle particle;
|
||||
private final Particle.DustOptions extra;
|
||||
private Particle particle;
|
||||
private Particle.DustOptions extra;
|
||||
|
||||
protected Artifact(String key, double version, Particle particle) {
|
||||
this(key, version, particle, null, new Prerequisite[]{} );
|
||||
protected Artifact(String key, double version) {
|
||||
this(key, version, new Prerequisite[]{});
|
||||
}
|
||||
|
||||
protected Artifact(String key, double version, Particle particle, Particle.DustOptions extra) {
|
||||
this(key, version, particle, extra, new Prerequisite[]{});
|
||||
}
|
||||
|
||||
protected Artifact(String key, double version, Particle particle, Prerequisite[] prerequisites) {
|
||||
this(key, version, particle, null, prerequisites);
|
||||
}
|
||||
|
||||
protected Artifact(String key, double version, Particle particle, Particle.DustOptions extra, Prerequisite[] prerequisites) {
|
||||
protected Artifact(String key, double version, Prerequisite[] prerequisites) {
|
||||
super(new EcoEnchantBuilder(key, EnchantmentType.ARTIFACT, version), prerequisites);
|
||||
this.particle = particle;
|
||||
this.extra = extra;
|
||||
if(!this.isRegistered()) return;
|
||||
|
||||
this.particle = this.getParticle();
|
||||
this.extra = this.getDustOptions();
|
||||
}
|
||||
|
||||
protected abstract Particle getParticle();
|
||||
|
||||
protected Particle.DustOptions getDustOptions() {
|
||||
return null;
|
||||
};
|
||||
|
||||
@EventHandler
|
||||
public void onBreak(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
Loading…
Reference in New Issue
Block a user