Fixed Dynamite

This commit is contained in:
Auxilor 2020-11-07 13:25:54 +00:00
parent bbb44dedbd
commit d3aae09ff6
3 changed files with 15 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import com.willfp.ecoenchants.enchantments.ecoenchants.curse.MisfortuneCurse;
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.PermanenceCurse;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.*;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.*;
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Dynamite;
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Missile;
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Quake;
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Vitalize;
@ -253,6 +254,7 @@ public class EcoEnchants {
public static final EcoEnchant MISSILE = new Missile();
public static final EcoEnchant QUAKE = new Quake();
public static final EcoEnchant VITALIZE = new Vitalize();
public static final EcoEnchant DYNAMITE = new Dynamite();
/**
* Get all registered {@link EcoEnchant}s

View File

@ -24,6 +24,8 @@ public class Dynamite extends Spell {
public void onRightClick(Player player, int level, PlayerInteractEvent event) {
Block block = event.getClickedBlock();
if(block == null) return;
if (block.hasMetadata("from-drill") || block.hasMetadata("from-lumberjack") || block.hasMetadata("from-blastmining") || block.hasMetadata("from-vein")) {
return;
}
@ -37,7 +39,7 @@ public class Dynamite extends Spell {
final int size = baseDiff + (bonusPerLevel * (level - 1));
for(int x = -size; size <= 1; x++) {
for(int x = -size; x <= size; x++) {
for(int y = -size; y <= size; y++) {
for (int z = -size; z <= size; z++) {
if(x == 0 && y == 0 && z == 0) {
@ -46,7 +48,6 @@ public class Dynamite extends Spell {
} else {
block.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, block.getLocation().clone().add(0.5, 0.5, 0.5), 1);
}
continue;
}
Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(x, y, z));

View File

@ -1,5 +1,6 @@
package com.willfp.ecoenchants.enchantments.itemtypes;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.config.ConfigManager;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
@ -7,12 +8,15 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
import com.willfp.ecoenchants.enchantments.util.SpellRunnable;
import com.willfp.ecoenchants.util.optional.Prerequisite;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
@ -20,6 +24,7 @@ import java.util.UUID;
*/
public abstract class Spell extends EcoEnchant {
private final HashMap<UUID, SpellRunnable> cooldownTracker = new HashMap<>();
private final Set<UUID> runningSpell = new HashSet<>();
protected Spell(String key, Prerequisite... prerequisites) {
super(key, EnchantmentType.SPELL, prerequisites);
@ -36,6 +41,11 @@ public abstract class Spell extends EcoEnchant {
Player player = event.getPlayer();
if(runningSpell.contains(player.getUniqueId())) return;
runningSpell.add(player.getUniqueId());
Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> runningSpell.remove(player.getUniqueId()), 1);
if(!EnchantChecks.mainhand(player, this))
return;