mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Added Marking
This commit is contained in:
parent
b694eb4d0b
commit
aae45e98d5
@ -191,6 +191,7 @@ public class EcoEnchants {
|
||||
public static final EcoEnchant FORCE = new Force();
|
||||
public static final EcoEnchant END_INFUSION = new EndInfusion();
|
||||
public static final EcoEnchant DIURNAL = new Diurnal();
|
||||
public static final EcoEnchant MARKING = new Marking();
|
||||
|
||||
/**
|
||||
* Get all registered {@link EcoEnchant}s
|
||||
|
@ -0,0 +1,67 @@
|
||||
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
|
||||
import com.willfp.ecoenchants.nms.Target;
|
||||
import com.willfp.ecoenchants.util.HasEnchant;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class Marking extends EcoEnchant {
|
||||
public Marking() {
|
||||
super(
|
||||
new EcoEnchantBuilder("marking", EnchantmentType.NORMAL, new Target.Applicable[]{Target.Applicable.CROSSBOW, Target.Applicable.BOW}, 4.0)
|
||||
);
|
||||
}
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
Set<LivingEntity> weakened = new HashSet<>();
|
||||
|
||||
@EventHandler
|
||||
public void onHit(EntityDamageByEntityEvent event) {
|
||||
if (!(event.getDamager() instanceof Arrow))
|
||||
return;
|
||||
|
||||
if(!(((Arrow) event.getDamager()).getShooter() instanceof Player))
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof LivingEntity))
|
||||
return;
|
||||
|
||||
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
|
||||
if(weakened.contains(victim)) {
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier-while-weak");
|
||||
|
||||
event.setDamage(event.getDamage() * multiplier);
|
||||
}
|
||||
|
||||
if(!AntigriefManager.canInjure(player, victim)) return;
|
||||
|
||||
if (!HasEnchant.playerHeld(player, this)) return;
|
||||
|
||||
int level = HasEnchant.getPlayerLevel(player, this);
|
||||
|
||||
int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level");
|
||||
int ticks = ticksPerLevel * level;
|
||||
|
||||
weakened.add(victim);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> {
|
||||
weakened.remove(victim);
|
||||
}, ticks);
|
||||
}
|
||||
}
|
24
Plugin/src/main/resources/enchants/normal/marking.yml
Normal file
24
Plugin/src/main/resources/enchants/normal/marking.yml
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# Marking EcoEnchant
|
||||
#
|
||||
|
||||
config-version: 4.0 # Don't edit this.
|
||||
|
||||
name: "Marking"
|
||||
|
||||
description: Increases subsequent damage dealt to opponent.
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: legendary
|
||||
|
||||
general-config:
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 4
|
||||
|
||||
config:
|
||||
ticks-per-level: 15 # Ticks to weaken player for per level
|
||||
multiplier-while-weak: 1.3 # Times more damage to deal while weakened
|
@ -210,6 +210,7 @@ permissions:
|
||||
ecoenchants.fromtable.force: true
|
||||
ecoenchants.fromtable.endinfusion: true
|
||||
ecoenchants.fromtable.diurnal: true
|
||||
ecoenchants.fromtable.marking: true
|
||||
|
||||
ecoenchants.updateannounce:
|
||||
description: Informs admins of a new update
|
||||
@ -712,4 +713,7 @@ permissions:
|
||||
default: true
|
||||
ecoenchants.fromtable.diurnal:
|
||||
description: Allows getting diurnal from an enchanting table
|
||||
default: true
|
||||
ecoenchants.fromtable.marking:
|
||||
description: Allows getting marking from an enchanting table
|
||||
default: true
|
Loading…
Reference in New Issue
Block a user