mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-23 18:45:39 +01:00
Fixed realistic weapon damage on 1.13-
This commit is contained in:
parent
a7cd1e6ffc
commit
61e120c3ca
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "UltimateStacker"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "1.10.6"
|
||||
version: "1.10.7"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
@ -115,20 +115,18 @@ public class DeathListeners implements Listener {
|
||||
if (Settings.KILL_WHOLE_STACK_ON_DEATH.getBoolean() && Settings.REALISTIC_DAMAGE.getBoolean()) {
|
||||
Player player = (Player) event.getDamager();
|
||||
ItemStack tool = player.getInventory().getItemInHand();
|
||||
if (tool.getType().getMaxDurability() < 1 || (tool.getItemMeta() != null && (tool.getItemMeta().isUnbreakable()
|
||||
if (tool.getType().getMaxDurability() < 1 || (tool.getItemMeta() != null && (tool.getItemMeta().spigot().isUnbreakable()
|
||||
|| (ServerProject.isServer(ServerProject.SPIGOT, ServerProject.PAPER) && tool.getItemMeta().spigot().isUnbreakable()))))
|
||||
return;
|
||||
|
||||
int unbreakingLevel = tool.getEnchantmentLevel(Enchantment.DURABILITY);
|
||||
Damageable damageable = (Damageable) tool.getItemMeta();
|
||||
|
||||
int actualDamage = 0;
|
||||
for (int i = 0; i < stack.getAmount(); i++)
|
||||
if (checkUnbreakingChance(unbreakingLevel))
|
||||
actualDamage++;
|
||||
|
||||
damageable.setDamage(damageable.getDamage() + actualDamage-1);
|
||||
tool.setItemMeta((ItemMeta) damageable);
|
||||
tool.setDurability((short)(tool.getDurability() + actualDamage));
|
||||
|
||||
if (!this.hasEnoughDurability(tool, 1))
|
||||
player.getInventory().setItemInHand(null);
|
||||
@ -137,12 +135,9 @@ public class DeathListeners implements Listener {
|
||||
}
|
||||
|
||||
public boolean hasEnoughDurability(ItemStack tool, int requiredAmount) {
|
||||
if (!tool.hasItemMeta() || !(tool.getItemMeta() instanceof Damageable) || tool.getType().getMaxDurability() < 1)
|
||||
if (tool.getType().getMaxDurability() <= 1)
|
||||
return true;
|
||||
|
||||
Damageable damageable = (Damageable) tool.getItemMeta();
|
||||
int durabilityRemaining = tool.getType().getMaxDurability() - damageable.getDamage();
|
||||
return durabilityRemaining > requiredAmount;
|
||||
return tool.getDurability() + requiredAmount <= tool.getType().getMaxDurability();
|
||||
}
|
||||
|
||||
public boolean checkUnbreakingChance(int level) {
|
||||
|
Loading…
Reference in New Issue
Block a user