Created CounterEffects extensions

This commit is contained in:
Auxilor 2021-08-04 17:38:30 +01:00
parent 9540d8fbb1
commit 925b852130
15 changed files with 325 additions and 0 deletions

View File

@ -0,0 +1,7 @@
group 'com.willfp'
version '1.0.0'
description = 'CounterEffects Extension'
shadowJar {
archiveFileName = project.getDescription() + " v" + project.version + ".jar"
}

View File

@ -0,0 +1,49 @@
package com.willfp.ecoenchants.countereffects;
import com.willfp.eco.core.Prerequisite;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
public abstract class CounterEffectsEnchantment extends EcoEnchant {
protected CounterEffectsEnchantment(@NotNull final String key,
@NotNull final EnchantmentType type,
@NotNull final Prerequisite... prerequisites) {
super(key, type, prerequisites);
}
public abstract PotionEffectType[] getPotionEffects();
@EventHandler
public void onEffect(@NotNull final EntityPotionEffectEvent event) {
if (event.isCancelled()) {
return;
}
if (!(event.getEntity() instanceof LivingEntity livingEntity)) {
return;
}
if (event.getNewEffect() == null) {
return;
}
int level = EnchantChecks.getArmorPoints(livingEntity, this);
if (!EnchantmentUtils.passedChance(this, level)) {
return;
}
if (Arrays.asList(this.getPotionEffects()).contains(event.getNewEffect().getType())) {
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,33 @@
package com.willfp.ecoenchants.countereffects;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.extensions.Extension;
import com.willfp.ecoenchants.countereffects.enchants.Abundance;
import com.willfp.ecoenchants.countereffects.enchants.Apothecary;
import com.willfp.ecoenchants.countereffects.enchants.Resolve;
import com.willfp.ecoenchants.countereffects.enchants.Vigor;
import com.willfp.ecoenchants.countereffects.enchants.Vivacity;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import org.jetbrains.annotations.NotNull;
public class CounterEffectsMain extends Extension {
public static final EcoEnchant APOTHECARY = new Apothecary();
public static final EcoEnchant ABUNDANCE = new Abundance();
public static final EcoEnchant VIGOR = new Vigor();
public static final EcoEnchant VIVACITY = new Vivacity();
public static final EcoEnchant RESOLVE = new Resolve();
public CounterEffectsMain(@NotNull final EcoPlugin plugin) {
super(plugin);
}
@Override
public void onEnable() {
// Handled by super
}
@Override
public void onDisable() {
// Handled by super
}
}

View File

@ -0,0 +1,18 @@
package com.willfp.ecoenchants.countereffects.enchants;
import com.willfp.ecoenchants.countereffects.CounterEffectsEnchantment;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.potion.PotionEffectType;
public class Abundance extends CounterEffectsEnchantment {
public Abundance() {
super("abundance", EnchantmentType.NORMAL);
}
@Override
public PotionEffectType[] getPotionEffects() {
return new PotionEffectType[]{
PotionEffectType.HUNGER
};
}
}

View File

@ -0,0 +1,19 @@
package com.willfp.ecoenchants.countereffects.enchants;
import com.willfp.ecoenchants.countereffects.CounterEffectsEnchantment;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.potion.PotionEffectType;
public class Apothecary extends CounterEffectsEnchantment {
public Apothecary() {
super("apothecary", EnchantmentType.NORMAL);
}
@Override
public PotionEffectType[] getPotionEffects() {
return new PotionEffectType[]{
PotionEffectType.WITHER,
PotionEffectType.POISON
};
}
}

View File

@ -0,0 +1,18 @@
package com.willfp.ecoenchants.countereffects.enchants;
import com.willfp.ecoenchants.countereffects.CounterEffectsEnchantment;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.potion.PotionEffectType;
public class Resolve extends CounterEffectsEnchantment {
public Resolve() {
super("resolve", EnchantmentType.NORMAL);
}
@Override
public PotionEffectType[] getPotionEffects() {
return new PotionEffectType[]{
PotionEffectType.WEAKNESS
};
}
}

View File

@ -0,0 +1,18 @@
package com.willfp.ecoenchants.countereffects.enchants;
import com.willfp.ecoenchants.countereffects.CounterEffectsEnchantment;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.potion.PotionEffectType;
public class Vigor extends CounterEffectsEnchantment {
public Vigor() {
super("vigor", EnchantmentType.NORMAL);
}
@Override
public PotionEffectType[] getPotionEffects() {
return new PotionEffectType[]{
PotionEffectType.CONFUSION
};
}
}

View File

@ -0,0 +1,18 @@
package com.willfp.ecoenchants.countereffects.enchants;
import com.willfp.ecoenchants.countereffects.CounterEffectsEnchantment;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.potion.PotionEffectType;
public class Vivacity extends CounterEffectsEnchantment {
public Vivacity() {
super("vivacity", EnchantmentType.NORMAL);
}
@Override
public PotionEffectType[] getPotionEffects() {
return new PotionEffectType[]{
PotionEffectType.SLOW_DIGGING
};
}
}

View File

@ -0,0 +1,28 @@
#
# Abundance EcoEnchant
#
name: "Abundance"
description: Chance to not get affected by hunger.
enabled: true
obtaining:
table: true
villager: true
loot: true
rarity: epic
general-config:
flags: []
targets:
- helmet
- chestplate
- leggings
- boots
grindstoneable: true
disabled-in-worlds: [ ]
conflicts: []
maximum-level: 2
config:
chance-per-level: 12.5

View File

@ -0,0 +1,28 @@
#
# Apothecary EcoEnchant
#
name: "Apothecary"
description: Chance to not get affected by posion or wither.
enabled: true
obtaining:
table: true
villager: true
loot: true
rarity: epic
general-config:
flags: []
targets:
- helmet
- chestplate
- leggings
- boots
grindstoneable: true
disabled-in-worlds: [ ]
conflicts: []
maximum-level: 2
config:
chance-per-level: 12.5

View File

@ -0,0 +1,28 @@
#
# Resolve EcoEnchant
#
name: "Resolve"
description: Chance to not get affected by weakness.
enabled: true
obtaining:
table: true
villager: true
loot: true
rarity: epic
general-config:
flags: []
targets:
- helmet
- chestplate
- leggings
- boots
grindstoneable: true
disabled-in-worlds: [ ]
conflicts: []
maximum-level: 2
config:
chance-per-level: 12.5

View File

@ -0,0 +1,28 @@
#
# Vigor EcoEnchant
#
name: "Vigor"
description: Chance to not get affected by nausea.
enabled: true
obtaining:
table: true
villager: true
loot: true
rarity: epic
general-config:
flags: []
targets:
- helmet
- chestplate
- leggings
- boots
grindstoneable: true
disabled-in-worlds: [ ]
conflicts: []
maximum-level: 2
config:
chance-per-level: 12.5

View File

@ -0,0 +1,28 @@
#
# Vivacity EcoEnchant
#
name: "Vivacity"
description: Chance to not get affected by mining fatigue.
enabled: true
obtaining:
table: true
villager: true
loot: true
rarity: epic
general-config:
flags: []
targets:
- helmet
- chestplate
- leggings
- boots
grindstoneable: true
disabled-in-worlds: [ ]
conflicts: []
maximum-level: 2
config:
chance-per-level: 12.5

View File

@ -0,0 +1,4 @@
name: CounterEffects
main: com.willfp.ecoenchants.countereffects.CounterEffectsMain
version: ${projectVersion}
author: Auxilor

View File

@ -13,6 +13,7 @@ include ':eco-extensions'
include ':eco-extensions:alchemy'
include ':eco-extensions:biomes'
include ':eco-extensions:citizen'
include ':eco-extensions:countereffects'
include ':eco-extensions:effects'
include ':eco-extensions:endershot'
include ':eco-extensions:firewand'