mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-25 15:35:11 +01:00
Added Lucky Catch enchantment
This commit is contained in:
parent
a2151fbc06
commit
70b7765bc3
@ -128,6 +128,7 @@ import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Leeching;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Lesion;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Levitate;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.LiquidShot;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.LuckyCatch;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Lumberjack;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.MagmaWalker;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Magnetic;
|
||||
@ -470,6 +471,7 @@ public class EcoEnchants {
|
||||
public static final EcoEnchant CHARGE = new Charge();
|
||||
public static final EcoEnchant ASCEND = new Ascend();
|
||||
public static final EcoEnchant ARBORIST = new Arborist();
|
||||
public static final EcoEnchant LUCKY_CATCH = new LuckyCatch();
|
||||
|
||||
/**
|
||||
* Get all registered {@link EcoEnchant}s.
|
||||
|
@ -0,0 +1,51 @@
|
||||
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
|
||||
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.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LuckyCatch extends EcoEnchant {
|
||||
public LuckyCatch() {
|
||||
super(
|
||||
"lucky_catch", EnchantmentType.NORMAL
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFish(@NotNull final PlayerFishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
|
||||
if (!EnchantChecks.item(item, this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int level = EnchantChecks.getItemLevel(item, this);
|
||||
|
||||
if (this.getDisabledWorlds().contains(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity caught = event.getCaught();
|
||||
|
||||
if (!(caught instanceof Item)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EnchantmentUtils.passedChance(this, level)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Item caughtItem = (Item) caught;
|
||||
|
||||
caughtItem.getItemStack().setAmount(caughtItem.getItemStack().getAmount() * 2);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
#
|
||||
# Lucky Catch EcoEnchant
|
||||
#
|
||||
|
||||
name: "Lucky Catch"
|
||||
description: Chance to double fishing drops.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: legendary
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- rod
|
||||
grindstoneable: true
|
||||
disabled-in-worlds: []
|
||||
conflicts: []
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
chance-per-level: 15
|
Loading…
Reference in New Issue
Block a user