Implement configurable hunger penalty for capitator axe
This commit is contained in:
parent
a3f0fcf5aa
commit
353f97a5e8
@ -9,4 +9,5 @@ search:
|
|||||||
searchRadiusY: 8
|
searchRadiusY: 8
|
||||||
searchRadiusZ: 8
|
searchRadiusZ: 8
|
||||||
ghostClick: true
|
ghostClick: true
|
||||||
capitator: true
|
capitator: true
|
||||||
|
capitatorHungerPerBlock: 0.03125
|
@ -121,7 +121,10 @@ public final class InvTweaksPlugin extends JavaPlugin {
|
|||||||
pluginManager.registerEvents(new SortListener(), this);
|
pluginManager.registerEvents(new SortListener(), this);
|
||||||
pluginManager.registerEvents(new MagnetismListener(magnetCommandExecutor), this);
|
pluginManager.registerEvents(new MagnetismListener(magnetCommandExecutor), this);
|
||||||
pluginManager.registerEvents(new TabCompletionListener(), this);
|
pluginManager.registerEvents(new TabCompletionListener(), this);
|
||||||
pluginManager.registerEvents(new TreeCapitatorListener(activateCapitator ? capitatorEnchantment.getEnchantment() : null), this);
|
pluginManager.registerEvents(new TreeCapitatorListener(
|
||||||
|
activateCapitator ? capitatorEnchantment.getEnchantment() : null,
|
||||||
|
getConfig().getDouble("capitatorHungerPerBlock")
|
||||||
|
), 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);
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,11 @@ public class TreeCapitatorListener implements Listener {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private final Enchantment capitatorEnchantment;
|
private final Enchantment capitatorEnchantment;
|
||||||
|
private final double hungerPerBlock;
|
||||||
|
|
||||||
public TreeCapitatorListener(final Enchantment capitatorEnchantment) {
|
public TreeCapitatorListener(final Enchantment capitatorEnchantment, final double hungerPerBlock) {
|
||||||
this.capitatorEnchantment = capitatorEnchantment;
|
this.capitatorEnchantment = capitatorEnchantment;
|
||||||
|
this.hungerPerBlock = hungerPerBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -76,6 +78,11 @@ public class TreeCapitatorListener implements Listener {
|
|||||||
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
|
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.getPlayer().getGameMode() == GameMode.ADVENTURE || event.getPlayer().getGameMode() == GameMode.SURVIVAL) {
|
||||||
|
final int hunger = (int) Math.round(hungerPerBlock * logBreakCount);
|
||||||
|
event.getPlayer().setFoodLevel(Math.max(0, event.getPlayer().getFoodLevel() - hunger));
|
||||||
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user