Skip to content

Commit fce68a8

Browse files
authored
Merge pull request #371 from OptimisticDeving/fix-spidey-npe
Fix NPE in spidey block iterator material checking
2 parents 4797268 + c7b0531 commit fce68a8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/pw/kaboom/extras/commands/CommandSpidey.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import net.kyori.adventure.text.Component;
44
import org.bukkit.Material;
55
import org.bukkit.World;
6+
import org.bukkit.block.Block;
67
import org.bukkit.command.Command;
78
import org.bukkit.command.CommandExecutor;
89
import org.bukkit.command.CommandSender;
@@ -37,10 +38,11 @@ public boolean onCommand(final @Nonnull CommandSender sender,
3738
distance
3839
);
3940

40-
while (blockIterator.hasNext()
41-
&& (Material.AIR.equals(blockIterator.next().getType())
42-
|| Material.CAVE_AIR.equals(blockIterator.next().getType()))) {
43-
blockIterator.next().setType(Material.COBWEB);
41+
while (blockIterator.hasNext()) {
42+
final Block block = blockIterator.next();
43+
44+
if (block.getType() != Material.COBWEB && !block.getType().isAir()) break;
45+
block.setType(Material.COBWEB);
4446
}
4547
return true;
4648
}

0 commit comments

Comments
 (0)