mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-22 04:37:42 +01:00
Added a 1s cooldown to Bouncing Crack
This commit is contained in:
parent
57e3ecee99
commit
923f8786ee
@ -0,0 +1,12 @@
|
||||
package net.Indyuce.mmoitems.api.event;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BouncingCrackBlockBreakEvent extends BlockBreakEvent {
|
||||
public BouncingCrackBlockBreakEvent(@NotNull Block theBlock, @NotNull Player player) {
|
||||
super(theBlock, player);
|
||||
}
|
||||
}
|
@ -5,6 +5,8 @@ import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.comp.flags.CustomFlag;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.event.BouncingCrackBlockBreakEvent;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -43,7 +45,8 @@ public class Tool extends UseItem {
|
||||
}
|
||||
}
|
||||
|
||||
if (getNBTItem().getBoolean("MMOITEMS_BOUNCING_CRACK"))
|
||||
if (getNBTItem().getBoolean("MMOITEMS_BOUNCING_CRACK") && !getPlayerData().isOnCooldown(PlayerData.CooldownType.BOUNCING_CRACK)) {
|
||||
getPlayerData().applyCooldown(PlayerData.CooldownType.BOUNCING_CRACK, 1);
|
||||
new BukkitRunnable() {
|
||||
final Vector v = player.getEyeLocation().getDirection().multiply(.5);
|
||||
final Location loc = block.getLocation().clone().add(.5, .5, .5);
|
||||
@ -58,7 +61,7 @@ public class Tool extends UseItem {
|
||||
if (block.getType() == Material.AIR || MMOItems.plugin.getLanguage().isBlacklisted(block.getType()))
|
||||
return;
|
||||
|
||||
BlockBreakEvent breakEvent = new BlockBreakEvent(block, player);
|
||||
BlockBreakEvent breakEvent = new BouncingCrackBlockBreakEvent(block, player);
|
||||
Bukkit.getPluginManager().callEvent(breakEvent);
|
||||
if (breakEvent.isCancelled()) {
|
||||
cancel();
|
||||
@ -69,6 +72,7 @@ public class Tool extends UseItem {
|
||||
loc.getWorld().playSound(loc, Sound.BLOCK_GRAVEL_BREAK, 1, 1);
|
||||
}
|
||||
}.runTaskTimer(MMOItems.plugin, 0, 1);
|
||||
}
|
||||
|
||||
/*if (getNBTItem().hasTag("MMOITEMS_BREAK_SIZE")) {
|
||||
int breakSize = getNBTItem().getInteger("MMOITEMS_BREAK_SIZE");
|
||||
|
@ -17,6 +17,7 @@ import net.Indyuce.mmoitems.api.ItemSet.SetBonuses;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.crafting.CraftingStatus;
|
||||
import net.Indyuce.mmoitems.api.event.RefreshInventoryEvent;
|
||||
import net.Indyuce.mmoitems.api.interaction.Tool;
|
||||
import net.Indyuce.mmoitems.api.item.ItemReference;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
|
||||
import net.Indyuce.mmoitems.api.player.inventory.EquippedItem;
|
||||
@ -28,6 +29,7 @@ import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -471,6 +473,16 @@ public class PlayerData {
|
||||
*/
|
||||
SPECIAL_ATTACK,
|
||||
|
||||
/**
|
||||
* Bouncing Crack calls block breaking events which can
|
||||
* trigger Bouncing Crack again and crash the game. A
|
||||
* cooldown is therefore required. Bouncing Crack max
|
||||
* duration is 10 ticks so a 1s cooldown is perfect
|
||||
*
|
||||
* @see {@link Tool#miningEffects(Block)}
|
||||
*/
|
||||
BOUNCING_CRACK,
|
||||
|
||||
/**
|
||||
* Special item set attack effects including slashing, piercing and
|
||||
* blunt attack effects
|
||||
|
Loading…
Reference in New Issue
Block a user