Super Breaker & Giga Driller now use more durability

A configurable amount is added to the vanilla durability loss.

Use `Abilities.Tools.Durability_Loss` to disable (set to 0) or set it
to -1 for no durability loss while using abilities. Closes #1363
This commit is contained in:
TfT_02 2013-08-09 22:21:45 +02:00
parent 6330c4a69e
commit ead1398132
5 changed files with 24 additions and 5 deletions

View File

@ -22,6 +22,7 @@ Version 1.4.07-dev
! Improved profile saving
! Updated localization files
! Party item share category states are now saved when the server shuts down.
! When using Super Breaker or Giga Driller abilities extra tool durability is used (again)
- Removed Abilities.Tools.Durability_Loss_Enabled, set Abilities.Tools.Durability_Loss to 0 to disable instead.
Version 1.4.06

View File

@ -133,10 +133,6 @@ public class Config extends AutoUpdateConfigLoader {
reason.add("Commands.inspect.Max_Distance should be greater than 0!");
}
if (getAbilityToolDamage() < 0) {
reason.add("Abilities.Tools.Durability_Loss should be at least 0!");
}
if (getTreeFellerThreshold() <= 0) {
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.BlockState;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
@ -53,5 +54,7 @@ public class ExcavationManager extends SkillManager {
public void gigaDrillBreaker(BlockState blockState) {
excavationBlockCheck(blockState);
excavationBlockCheck(blockState);
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
}
}

View File

@ -66,6 +66,10 @@ public class MiningManager extends SkillManager {
Material material = blockState.getType();
if (mcMMOPlayer.getAbilityMode(skill.getAbility())) {
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
}
if (material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
return;
}

View File

@ -14,7 +14,6 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
@ -29,6 +28,7 @@ import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
import com.gmail.nossr50.runnables.skills.ToolLowerTask;
import com.gmail.nossr50.util.ItemUtils;
@ -445,6 +445,21 @@ public class SkillUtils {
return item;
}
/**
* Modify the durability of an ItemStack.
*
* @param itemStack The ItemStack which durability should be modified
* @return the itemStack with modified durability
*/
public static ItemStack handleDurabilityChange(ItemStack itemStack, int durabilityModifier) {
short finalDurability = (short) (itemStack.getDurability() + durabilityModifier);
short maxDurability = ModUtils.isCustomTool(itemStack) ? ModUtils.getToolFromItemStack(itemStack).getDurability() : itemStack.getType().getMaxDurability();
boolean overMax = (finalDurability >= maxDurability);
itemStack.setDurability(overMax ? maxDurability : finalDurability);
return itemStack;
}
/**
* Simulate a block break event.
*