Added Fetching
This commit is contained in:
@@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments;
|
||||
|
||||
import com.willfp.ecoenchants.config.ConfigManager;
|
||||
import com.willfp.ecoenchants.config.configs.EnchantmentConfig;
|
||||
import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@@ -227,6 +227,7 @@ public class EcoEnchants {
|
||||
public static final EcoEnchant TRANSFUSE = new Transfuse();
|
||||
public static final EcoEnchant INACCURACY_CURSE = new InaccuracyCurse();
|
||||
public static final EcoEnchant RESPIRATOR = new Respirator();
|
||||
public static final EcoEnchant FETCHING = new Fetching();
|
||||
|
||||
/**
|
||||
* Get all registered {@link EcoEnchant}s
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks;
|
||||
import com.willfp.ecoenchants.events.entitydeathbyentity.EntityDeathByEntityEvent;
|
||||
import com.willfp.ecoenchants.nms.TridentStack;
|
||||
import com.willfp.ecoenchants.queue.DropQueue;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class Fetching extends EcoEnchant {
|
||||
public Fetching() {
|
||||
super(
|
||||
new EcoEnchantBuilder("fetching", EnchantmentType.NORMAL, 5.0)
|
||||
);
|
||||
}
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onWolfKill(EntityDeathByEntityEvent event) {
|
||||
LivingEntity entity = event.getVictim();
|
||||
|
||||
if(entity instanceof Player && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "not-on-players"))
|
||||
return;
|
||||
|
||||
if(!(event.getKiller() instanceof Wolf))
|
||||
return;
|
||||
|
||||
Wolf wolf = (Wolf) event.getKiller();
|
||||
|
||||
if(!wolf.isTamed() || wolf.getOwner() == null)
|
||||
return;
|
||||
|
||||
if(!(wolf.getOwner() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = (Player) wolf.getOwner();
|
||||
|
||||
if(!(EnchantChecks.helmet(player, this)))
|
||||
return;
|
||||
|
||||
int xp = event.getDroppedExp();
|
||||
Collection<ItemStack> drops = event.getDrops();
|
||||
|
||||
new DropQueue(player)
|
||||
.addItems(drops)
|
||||
.setLocation(entity.getLocation())
|
||||
.addXP(xp)
|
||||
.forceTelekinesis()
|
||||
.push();
|
||||
|
||||
event.getDeathEvent().setDroppedExp(0);
|
||||
event.getDeathEvent().getDrops().clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user