Made intimidation enchantment

This commit is contained in:
Auxilor 2021-08-04 17:07:53 +01:00
parent 02477778f4
commit 0637bdf1c1
6 changed files with 108 additions and 0 deletions

View File

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

View File

@ -0,0 +1,47 @@
package com.willfp.ecoenchants.intimidation;
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.Monster;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Intimidation extends EcoEnchant {
public Intimidation() {
super(
"intimidation", EnchantmentType.NORMAL
);
}
@EventHandler
public void onSwitchTarget(@NotNull final EntityTargetLivingEntityEvent event) {
if (!(event.getEntity() instanceof Monster attacker)) {
return;
}
if (event.getTarget() == null) {
return;
}
if (!EnchantChecks.mainhand(event.getTarget(), this)) {
return;
}
if (event.isCancelled()) {
return;
}
if (this.getDisabledWorlds().contains(event.getTarget().getWorld())) {
return;
}
int level = EnchantChecks.getArmorPoints(event.getTarget(), this);
if (EnchantmentUtils.passedChance(this, level)) {
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,24 @@
package com.willfp.ecoenchants.intimidation;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.extensions.Extension;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import org.jetbrains.annotations.NotNull;
public class IntimidationMain extends Extension {
public static final EcoEnchant INTIMIDATION = new Intimidation();
public IntimidationMain(@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,25 @@
#
# Intimidation EcoEnchant
#
name: "Intimidation"
description: Decrease the chance of hostile mobs being aggravated at you.
enabled: true
obtaining:
table: true
villager: true
loot: true
rarity: legendary
general-config:
flags: []
targets:
- helmet
grindstoneable: true
disabled-in-worlds: [ ]
conflicts: []
maximum-level: 4
config:
chance-per-level: 20

View File

@ -0,0 +1,4 @@
name: Intimidation
main: com.willfp.ecoenchants.intimidation.IntimidationMain
version: ${projectVersion}
author: Auxilor

View File

@ -15,6 +15,7 @@ include ':eco-extensions:biomes'
include ':eco-extensions:effects' include ':eco-extensions:effects'
include ':eco-extensions:endershot' include ':eco-extensions:endershot'
include ':eco-extensions:firewand' include ':eco-extensions:firewand'
include ':eco-extensions:intimidation'
//include ':eco-extensions:mmo' //include ':eco-extensions:mmo'
include ':eco-extensions:precision' include ':eco-extensions:precision'
include ':eco-extensions:rainbow' include ':eco-extensions:rainbow'