Skip to content

Commit

Permalink
Fix MOVING_PISTON material crashing the plugin on load
Browse files Browse the repository at this point in the history
  • Loading branch information
T14D3 committed Jan 2, 2025
1 parent d50162d commit f180d86
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/main/java/de/t14d3/zones/utils/Types.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.t14d3.zones.utils;

import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.block.Container;
import org.bukkit.block.data.Powerable;
import org.bukkit.entity.EntityType;
Expand Down Expand Up @@ -57,19 +58,35 @@ public void populateTypes() {

// Populate containerTypes
for (Material material : Material.values()) {
if (material.isBlock() && material.createBlockData().createBlockState() instanceof Container) {
containerTypes.add(material.name());
containerTypes.add("!" + material.name());
if (material.isBlock()) {
BlockState state;
try {
state = material.createBlockData().createBlockState();
} catch (Exception ignored) {
continue;
}
if (state instanceof Container) {
containerTypes.add(material.name());
containerTypes.add("!" + material.name());
}
}
}
containerTypes.add("true");
containerTypes.add("false");

// Populate redstoneTypes
for (Material material : Material.values()) {
if (material.isBlock() && material.createBlockData().createBlockState() instanceof Powerable) {
redstoneTypes.add(material.name());
redstoneTypes.add("!" + material.name());
if (material.isBlock()) {
BlockState state;
try {
state = material.createBlockData().createBlockState();
} catch (Exception ignored) {
continue;
}
if (state instanceof Powerable) {
redstoneTypes.add(material.name());
redstoneTypes.add("!" + material.name());
}
}
}
redstoneTypes.add("true");
Expand Down

0 comments on commit f180d86

Please sign in to comment.