mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-01-23 00:31:20 +01:00
Unified block metas into block-ignore
This commit is contained in:
parent
26d6287123
commit
95264c1b04
@ -27,9 +27,8 @@ public class BlastMining extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) {
|
||||
if (block.hasMetadata("from-drill") || block.hasMetadata("from-lumberjack") || block.hasMetadata("from-blastmining") || block.hasMetadata("from-vein")) {
|
||||
if (block.hasMetadata("block-ignore"))
|
||||
return;
|
||||
}
|
||||
|
||||
if(player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) return;
|
||||
|
||||
@ -67,9 +66,9 @@ public class BlastMining extends EcoEnchant {
|
||||
}
|
||||
|
||||
toBreak.forEach((block1 -> {
|
||||
block1.setMetadata("from-blastmining", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true));
|
||||
block1.setMetadata("block-ignore", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true));
|
||||
BlockBreak.breakBlock(player, block1);
|
||||
block1.removeMetadata("from-blastmining", EcoEnchantsPlugin.getInstance());
|
||||
block1.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance());
|
||||
}));
|
||||
|
||||
AnticheatManager.unexemptPlayer(player);
|
||||
|
@ -23,9 +23,8 @@ public class Drill extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) {
|
||||
if (block.hasMetadata("from-drill") || block.hasMetadata("from-lumberjack") || block.hasMetadata("from-blastmining") || block.hasMetadata("from-vein")) {
|
||||
if (block.hasMetadata("block-ignore"))
|
||||
return;
|
||||
}
|
||||
|
||||
if(player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) return;
|
||||
|
||||
@ -36,7 +35,7 @@ public class Drill extends EcoEnchant {
|
||||
for(int i = 1; i <= blocks; i++) {
|
||||
Vector simplified = VectorUtils.simplifyVector(player.getLocation().getDirection().normalize()).multiply(i);
|
||||
Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(simplified));
|
||||
block1.setMetadata("from-drill", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true));
|
||||
block1.setMetadata("block-ignore", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true));
|
||||
|
||||
if(this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks").contains(block1.getType().name().toLowerCase())) {
|
||||
continue;
|
||||
@ -47,7 +46,7 @@ public class Drill extends EcoEnchant {
|
||||
if(!AntigriefManager.canBreakBlock(player, block1)) continue;
|
||||
|
||||
BlockBreak.breakBlock(player, block1);
|
||||
block1.removeMetadata("from-drill", EcoEnchantsPlugin.getInstance());
|
||||
block1.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance());
|
||||
}
|
||||
|
||||
AnticheatManager.unexemptPlayer(player);
|
||||
|
@ -30,9 +30,8 @@ public class Lumberjack extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) {
|
||||
if (block.hasMetadata("from-drill") || block.hasMetadata("from-blastmining") || block.hasMetadata("from-lumberjack") || block.hasMetadata("from-vein")) {
|
||||
if (block.hasMetadata("block-ignore"))
|
||||
return;
|
||||
}
|
||||
|
||||
if(player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) return;
|
||||
|
||||
@ -50,12 +49,12 @@ public class Lumberjack extends EcoEnchant {
|
||||
AnticheatManager.exemptPlayer(player);
|
||||
|
||||
for(Block treeBlock : treeBlocks) {
|
||||
treeBlock.setMetadata("from-lumberjack", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true));
|
||||
treeBlock.setMetadata("block-ignore", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true));
|
||||
if(!AntigriefManager.canBreakBlock(player, treeBlock)) continue;
|
||||
|
||||
BlockBreak.breakBlock(player, treeBlock);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> treeBlock.removeMetadata("from-lumberjack", EcoEnchantsPlugin.getInstance()),1);
|
||||
Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> treeBlock.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance()),1);
|
||||
}
|
||||
|
||||
AnticheatManager.unexemptPlayer(player);
|
||||
|
@ -30,9 +30,8 @@ public class Vein extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) {
|
||||
if (block.hasMetadata("from-drill") || block.hasMetadata("from-blastmining") || block.hasMetadata("from-lumberjack") || block.hasMetadata("from-vein")) {
|
||||
if (block.hasMetadata("block-ignore"))
|
||||
return;
|
||||
}
|
||||
|
||||
if(player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) return;
|
||||
|
||||
@ -50,12 +49,12 @@ public class Vein extends EcoEnchant {
|
||||
AnticheatManager.exemptPlayer(player);
|
||||
|
||||
for(Block veinBlock : blockSet) {
|
||||
veinBlock.setMetadata("from-vein", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true));
|
||||
veinBlock.setMetadata("block-ignore", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true));
|
||||
if(!AntigriefManager.canBreakBlock(player, veinBlock)) continue;
|
||||
|
||||
BlockBreak.breakBlock(player, veinBlock);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> veinBlock.removeMetadata("from-vein", EcoEnchantsPlugin.getInstance()),1);
|
||||
Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> veinBlock.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance()),1);
|
||||
}
|
||||
|
||||
AnticheatManager.unexemptPlayer(player);
|
||||
|
Loading…
Reference in New Issue
Block a user