mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Added Dynamite
This commit is contained in:
parent
f47023ac60
commit
bbb44dedbd
@ -0,0 +1,74 @@
|
||||
package com.willfp.ecoenchants.enchantments.ecoenchants.spell;
|
||||
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.itemtypes.Spell;
|
||||
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
|
||||
import com.willfp.ecoenchants.nms.BlockBreak;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class Dynamite extends Spell {
|
||||
public Dynamite() {
|
||||
super("dynamite");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRightClick(Player player, int level, PlayerInteractEvent event) {
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (block.hasMetadata("from-drill") || block.hasMetadata("from-lumberjack") || block.hasMetadata("from-blastmining") || block.hasMetadata("from-vein")) {
|
||||
return;
|
||||
}
|
||||
|
||||
AnticheatManager.exemptPlayer(player);
|
||||
|
||||
Set<Block> toBreak = new HashSet<>();
|
||||
|
||||
int baseDiff = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "base-bonus");
|
||||
int bonusPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "per-level-bonus");
|
||||
final int size = baseDiff + (bonusPerLevel * (level - 1));
|
||||
|
||||
|
||||
for(int x = -size; size <= 1; x++) {
|
||||
for(int y = -size; y <= size; y++) {
|
||||
for (int z = -size; z <= size; z++) {
|
||||
if(x == 0 && y == 0 && z == 0) {
|
||||
if(this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "enable-sound")) {
|
||||
block.getWorld().createExplosion(block.getLocation().clone().add(0.5, 0.5, 0.5), 0, false);
|
||||
} 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));
|
||||
|
||||
if(this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks").contains(block1.getType().name().toLowerCase())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(block1.getType().getHardness() > block.getType().getHardness() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "hardness-check")) continue;
|
||||
|
||||
if(!AntigriefManager.canBreakBlock(player, block1)) continue;
|
||||
|
||||
toBreak.add(block1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toBreak.forEach((block1 -> {
|
||||
block1.setMetadata("from-blastmining", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true));
|
||||
BlockBreak.breakBlock(player, block1);
|
||||
block1.removeMetadata("from-blastmining", EcoEnchantsPlugin.getInstance());
|
||||
}));
|
||||
|
||||
AnticheatManager.unexemptPlayer(player);
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import org.bukkit.entity.WitherSkull;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
public class Missile extends Spell {
|
||||
@ -16,7 +17,7 @@ public class Missile extends Spell {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRightClick(Player player, int level) {
|
||||
public void onRightClick(Player player, int level, PlayerInteractEvent event) {
|
||||
WitherSkull skull = player.launchProjectile(WitherSkull.class, player.getEyeLocation().getDirection().multiply(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity")));
|
||||
skull.setCharged(true);
|
||||
skull.setIsIncendiary(false);
|
||||
|
@ -6,6 +6,7 @@ import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -15,7 +16,7 @@ public class Quake extends Spell {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRightClick(Player player, int level) {
|
||||
public void onRightClick(Player player, int level, PlayerInteractEvent event) {
|
||||
int radius = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "radius-per-level") * level;
|
||||
int damage = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * level;
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.spell;
|
||||
import com.willfp.ecoenchants.enchantments.itemtypes.Spell;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class Vitalize extends Spell {
|
||||
public Vitalize() {
|
||||
@ -10,7 +11,7 @@ public class Vitalize extends Spell {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRightClick(Player player, int level) {
|
||||
public void onRightClick(Player player, int level, PlayerInteractEvent event) {
|
||||
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public abstract class Spell extends EcoEnchant {
|
||||
|
||||
SpellRunnable runnable = cooldownTracker.get(player.getUniqueId());
|
||||
runnable.setTask(() -> {
|
||||
this.onRightClick(player, level);
|
||||
this.onRightClick(player, level, event);
|
||||
});
|
||||
|
||||
long msLeft = runnable.getEndTime() - System.currentTimeMillis();
|
||||
@ -64,5 +64,5 @@ public abstract class Spell extends EcoEnchant {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
public abstract void onRightClick(Player player, int level);
|
||||
public abstract void onRightClick(Player player, int level, PlayerInteractEvent event);
|
||||
}
|
||||
|
29
Plugin/src/main/resources/enchants/spell/dynamite.yml
Normal file
29
Plugin/src/main/resources/enchants/spell/dynamite.yml
Normal file
@ -0,0 +1,29 @@
|
||||
#
|
||||
# Dynamite EcoEnchant
|
||||
#
|
||||
|
||||
name: "Dynamite"
|
||||
description: Mines blocks in a large area.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: legendary
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- pickaxe
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 2
|
||||
|
||||
config:
|
||||
cooldown: 30 # In seconds
|
||||
enable-sound: true # Play explosion sound
|
||||
hardness-check: true # Only break blocks with hardness less than or equal to first block
|
||||
blacklisted-blocks:
|
||||
- bedrock
|
||||
base-bonus: 2 # Base extra blocks on all sides to break (1 = 3x3x3, 2 = 5x5x5, 3 = 7x7x7)
|
||||
per-level-bonus: 1 # Extra blocks on all sides per level
|
Loading…
Reference in New Issue
Block a user