Implement minimum food level option for capitator functionality
This commit is contained in:
parent
353f97a5e8
commit
8acef93d7d
@ -10,4 +10,5 @@ search:
|
|||||||
searchRadiusZ: 8
|
searchRadiusZ: 8
|
||||||
ghostClick: true
|
ghostClick: true
|
||||||
capitator: true
|
capitator: true
|
||||||
capitatorHungerPerBlock: 0.03125
|
capitatorHungerPerBlock: 0.03125
|
||||||
|
capitatorMinHunger: 3
|
@ -123,7 +123,8 @@ public final class InvTweaksPlugin extends JavaPlugin {
|
|||||||
pluginManager.registerEvents(new TabCompletionListener(), this);
|
pluginManager.registerEvents(new TabCompletionListener(), this);
|
||||||
pluginManager.registerEvents(new TreeCapitatorListener(
|
pluginManager.registerEvents(new TreeCapitatorListener(
|
||||||
activateCapitator ? capitatorEnchantment.getEnchantment() : null,
|
activateCapitator ? capitatorEnchantment.getEnchantment() : null,
|
||||||
getConfig().getDouble("capitatorHungerPerBlock")
|
getConfig().getDouble("capitatorHungerPerBlock"),
|
||||||
|
getConfig().getInt("capitatorMinHunger")
|
||||||
), this);
|
), this);
|
||||||
pluginManager.registerEvents(new PlayerMoveRenderListener(chestManager), this);
|
pluginManager.registerEvents(new PlayerMoveRenderListener(chestManager), this);
|
||||||
pluginManager.registerEvents(new ChestBreakListener(chestManager), this);
|
pluginManager.registerEvents(new ChestBreakListener(chestManager), this);
|
||||||
|
@ -15,6 +15,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static dev.w1zzrd.spigot.wizcompat.command.CommandUtils.errorMessage;
|
||||||
import static org.bukkit.Material.*;
|
import static org.bukkit.Material.*;
|
||||||
|
|
||||||
public class TreeCapitatorListener implements Listener {
|
public class TreeCapitatorListener implements Listener {
|
||||||
@ -47,10 +48,12 @@ public class TreeCapitatorListener implements Listener {
|
|||||||
|
|
||||||
private final Enchantment capitatorEnchantment;
|
private final Enchantment capitatorEnchantment;
|
||||||
private final double hungerPerBlock;
|
private final double hungerPerBlock;
|
||||||
|
private final int minHunger;
|
||||||
|
|
||||||
public TreeCapitatorListener(final Enchantment capitatorEnchantment, final double hungerPerBlock) {
|
public TreeCapitatorListener(final Enchantment capitatorEnchantment, final double hungerPerBlock, final int minHunger) {
|
||||||
this.capitatorEnchantment = capitatorEnchantment;
|
this.capitatorEnchantment = capitatorEnchantment;
|
||||||
this.hungerPerBlock = hungerPerBlock;
|
this.hungerPerBlock = hungerPerBlock;
|
||||||
|
this.minHunger = minHunger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -59,6 +62,12 @@ public class TreeCapitatorListener implements Listener {
|
|||||||
if (event.isCancelled() || !handTool.containsEnchantment(capitatorEnchantment))
|
if (event.isCancelled() || !handTool.containsEnchantment(capitatorEnchantment))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Check if capitator functionality is prevented by hunger
|
||||||
|
if (event.getPlayer().getFoodLevel() < minHunger) {
|
||||||
|
event.getPlayer().spigot().sendMessage(errorMessage("You are too tired to fell the tree"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (handTool.getItemMeta() instanceof final Damageable tool) {
|
if (handTool.getItemMeta() instanceof final Damageable tool) {
|
||||||
if (!leaves.contains(event.getBlock().getType()) && targetMaterials.contains(event.getBlock().getType())) {
|
if (!leaves.contains(event.getBlock().getType()) && targetMaterials.contains(event.getBlock().getType())) {
|
||||||
int logBreakCount = 0;
|
int logBreakCount = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user