mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Make sure we clean up buffs from tools
This commit is contained in:
parent
e969598f58
commit
d7fe01579b
@ -449,16 +449,7 @@ public class BlockListener implements Listener {
|
|||||||
if (BlockUtils.canActivateAbilities(blockState)) {
|
if (BlockUtils.canActivateAbilities(blockState)) {
|
||||||
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
|
cleanupAbilityTools(player, mcMMOPlayer, blockState, heldItem);
|
||||||
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) {
|
|
||||||
SkillUtils.removeAbilityBuff(heldItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ((mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) {
|
|
||||||
SkillUtils.handleAbilitySpeedDecrease(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
||||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.HERBALISM);
|
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.HERBALISM);
|
||||||
@ -556,4 +547,28 @@ public class BlockListener implements Listener {
|
|||||||
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
|
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onBlockDamageCleanup(BlockDamageEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
BlockState blockState = event.getBlock().getState();
|
||||||
|
|
||||||
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
|
cleanupAbilityTools(player, mcMMOPlayer, blockState, heldItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cleanupAbilityTools(Player player, McMMOPlayer mcMMOPlayer, BlockState blockState, ItemStack heldItem) {
|
||||||
|
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
|
||||||
|
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) {
|
||||||
|
SkillUtils.removeAbilityBuff(heldItem);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) {
|
||||||
|
SkillUtils.handleAbilitySpeedDecrease(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user