Added Fetching

This commit is contained in:
Auxilor 2020-09-17 07:38:15 +01:00
parent 3d0abbefd2
commit 850ce3d364
5 changed files with 95 additions and 0 deletions

View File

@ -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;

View File

@ -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

View File

@ -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();
}
}

View File

@ -0,0 +1,24 @@
#
# Fetching EcoEnchant
#
config-version: 5.0 # Don't edit this.
name: "Fetching"
description: Drops and xp from wolf kills go directly into your inventory.
enabled: true
obtaining:
table: true
villager: true
loot: true
rarity: rare
general-config:
targets:
- helmet
grindstoneable: true
conflicts: []
config:
not-on-players: false

View File

@ -246,6 +246,7 @@ permissions:
ecoenchants.fromtable.transfuse: true
ecoenchants.fromtable.inaccuracycurse: true
ecoenchants.fromtable.respirator: true
ecoenchants.fromtable.fetching: true
ecoenchants.updateannounce:
description: Informs admins of a new update
@ -856,4 +857,7 @@ permissions:
default: true
ecoenchants.fromtable.respirator:
description: Allows getting respirator from an enchanting table
default: true
ecoenchants.fromtable.fetching:
description: Allows getting fetching from an enchanting table
default: true