55import net .md_5 .bungee .api .ChatColor ;
66import net .md_5 .bungee .api .chat .ClickEvent ;
77import net .md_5 .bungee .api .chat .TextComponent ;
8- import org .bukkit .Chunk ;
9- import org .bukkit .Location ;
10- import org .bukkit .Material ;
8+ import org .bukkit .*;
119import org .bukkit .block .Block ;
1210import org .bukkit .command .CommandSender ;
1311import org .bukkit .enchantments .Enchantment ;
@@ -84,6 +82,7 @@ public void clearChunks(int chunkBusterArea, Location chunkBusterLocation, Playe
8482 Set <Material > ignoredBlocks = main .getConfigValues ().getIgnoredBlocks ();
8583 if (chunkBusterArea % 2 != 0 ) {
8684 RemovalQueue removalQueue = new RemovalQueue (main , p );
85+ WorldBorder border = chunkBusterLocation .getWorld ().getWorldBorder ();
8786 // Variables for the area to loop through
8887 int upperBound = ((chunkBusterArea -1 )/2 )+1 ;
8988 int lowerBound = (chunkBusterArea -1 )/-2 ;
@@ -98,7 +97,9 @@ public void clearChunks(int chunkBusterArea, Location chunkBusterLocation, Playe
9897 for (int z = 0 ; z < 16 ; z ++) {
9998 Block b = chunk .getBlock (x , y , z );
10099 if (!b .getType ().equals (Material .AIR ) && !ignoredBlocks .contains (b .getType ())) {
101- removalQueue .getBlocks ().add (b );
100+ if (!main .getConfigValues ().worldborderHookEnabled () || insideBorder (b , border )) {
101+ removalQueue .getBlocks ().add (b );
102+ }
102103 }
103104 }
104105 }
@@ -113,8 +114,17 @@ public void clearChunks(int chunkBusterArea, Location chunkBusterLocation, Playe
113114 }
114115 }
115116
117+ private boolean insideBorder (Block block , WorldBorder border ) {
118+ Location blockLocation = block .getLocation ().add (0.5 , 0 , 0.5 );
119+ double x = blockLocation .getX ();
120+ double z = blockLocation .getZ ();
121+ double size = border .getSize ()/2 ;
122+ Location center = border .getCenter ();
123+ return !((x >= center .clone ().add (size , 0 , 0 ).getX () || z >= center .clone ().add (0 , 0 , size ).getZ ()) || (x <= center .clone ().subtract (size ,0 ,0 ).getX () || (z <= center .clone ().subtract (0 ,0 , size ).getZ ())));
124+ }
125+
116126 public void updateConfig (ChunkBuster main ) { // Basic config updater that saves the old config, loads the new one, and inserts the old keys
117- if (main .getConfigValues ().getConfigVersion () < 2.1 ) {
127+ if (main .getConfigValues ().getConfigVersion () < 2.2 ) {
118128 Map <String , Object > oldValues = new HashMap <>();
119129 for (String oldKey : main .getConfig ().getKeys (true )) {
120130 oldValues .put (oldKey , main .getConfig ().get (oldKey ));
@@ -126,7 +136,7 @@ public void updateConfig(ChunkBuster main) { // Basic config updater that saves
126136 main .getConfig ().set (newKey , oldValues .get (newKey ));
127137 }
128138 }
129- main .getConfig ().set ("config-version" , 2.1 );
139+ main .getConfig ().set ("config-version" , 2.2 );
130140 main .saveConfig ();
131141 }
132142 }
0 commit comments