mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Created CounterEffects extensions
This commit is contained in:
parent
9540d8fbb1
commit
925b852130
7
eco-extensions/countereffects/build.gradle
Normal file
7
eco-extensions/countereffects/build.gradle
Normal file
@ -0,0 +1,7 @@
|
||||
group 'com.willfp'
|
||||
version '1.0.0'
|
||||
description = 'CounterEffects Extension'
|
||||
|
||||
shadowJar {
|
||||
archiveFileName = project.getDescription() + " v" + project.version + ".jar"
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
@ -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
|
||||
};
|
||||
}
|
||||
}
|
@ -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
|
||||
};
|
||||
}
|
||||
}
|
@ -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
|
||||
};
|
||||
}
|
||||
}
|
@ -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
|
||||
};
|
||||
}
|
||||
}
|
@ -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
|
||||
};
|
||||
}
|
||||
}
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -0,0 +1,4 @@
|
||||
name: CounterEffects
|
||||
main: com.willfp.ecoenchants.countereffects.CounterEffectsMain
|
||||
version: ${projectVersion}
|
||||
author: Auxilor
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user