Created citizen extension

This commit is contained in:
Auxilor 2021-08-04 17:14:04 +01:00
parent 0637bdf1c1
commit 9540d8fbb1
6 changed files with 120 additions and 0 deletions

View File

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

View File

@ -0,0 +1,56 @@
package com.willfp.ecoenchants.citizen;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Trident;
import org.bukkit.entity.Villager;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Citizen extends EcoEnchant {
public Citizen() {
super(
"citizen", EnchantmentType.NORMAL
);
}
@Override
public void onMeleeAttack(@NotNull final LivingEntity attacker,
@NotNull final LivingEntity uncastVictim,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
if (!(uncastVictim instanceof Villager)) {
return;
}
event.setCancelled(true);
}
@Override
public void onArrowDamage(@NotNull final LivingEntity attacker,
@NotNull final LivingEntity victim,
@NotNull final Arrow arrow,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
if (!(victim instanceof Villager)) {
return;
}
event.setCancelled(true);
}
@Override
public void onTridentDamage(@NotNull final LivingEntity attacker,
@NotNull final LivingEntity victim,
@NotNull final Trident trident,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
if (!(victim instanceof Villager)) {
return;
}
event.setCancelled(true);
}
}

View File

@ -0,0 +1,24 @@
package com.willfp.ecoenchants.citizen;
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 CitizenMain extends Extension {
public static final EcoEnchant CITIZEN = new Citizen();
public CitizenMain(@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,28 @@
#
# Citizen EcoEnchant
#
name: "Citizen"
description: Prevent you from injuring villagers.
enabled: true
obtaining:
table: true
villager: true
loot: true
rarity: uncommon
general-config:
flags: []
targets:
- sword
- axe
- bow
- trident
grindstoneable: true
disabled-in-worlds: [ ]
conflicts: []
maximum-level: 1
config:
# No config is available for this enchantment

View File

@ -0,0 +1,4 @@
name: Citizen
main: com.willfp.ecoenchants.citizen.CitizenMain
version: ${projectVersion}
author: Auxilor

View File

@ -12,6 +12,7 @@ include ':eco-core:core-plugin'
include ':eco-extensions'
include ':eco-extensions:alchemy'
include ':eco-extensions:biomes'
include ':eco-extensions:citizen'
include ':eco-extensions:effects'
include ':eco-extensions:endershot'
include ':eco-extensions:firewand'