Compare commits

...

2 Commits

Author SHA1 Message Date
YouHaveTrouble ee3526c55d bump version 2024-07-04 21:43:34 +02:00
YouHaveTrouble 2189616a9e fix dangerous block blocker not having list of dangerous blocks 2024-07-04 21:43:19 +02:00
3 changed files with 22 additions and 2 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>me.youhavetrouble</groupId>
<artifactId>PreventStabby</artifactId>
<version>2.0.0-pre-4</version>
<version>2.0.0-pre-5</version>
<packaging>jar</packaging>
<name>PreventStabby</name>
@@ -1,6 +1,7 @@
package me.youhavetrouble.preventstabby.config;
import me.youhavetrouble.preventstabby.PreventStabby;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -33,6 +34,7 @@ public class ConfigCache {
public final double combat_time, login_protection_time, teleport_protection_time, bucket_stopper_radius,
fire_stopper_radius, block_stopper_radius;
private final Set<String> combatBlockedCommands = new HashSet<>();
private final Set<Material> dangerousBlocks = new HashSet<>();
private final FileConfiguration config;
@@ -124,6 +126,19 @@ public class ConfigCache {
2.5,
List.of("Distance from the player where placing dangerous blocks will be disallowed")
);
List<String> rawDangerousBlocks = getList(
"settings.environmental.block_stopper.blocks",
List.of("tnt", "magma_block", "cactus", "campfire"),
List.of("List of dangerous blocks that will be blocked when placed near players with pvp off")
);
for (String block : rawDangerousBlocks) {
Material material = Material.matchMaterial(block);
if (material != null) {
dangerousBlocks.add(material);
} else {
plugin.getLogger().warning("Invalid material: " + block);
}
}
@@ -175,6 +190,10 @@ public class ConfigCache {
return Collections.unmodifiableSet(combatBlockedCommands);
}
public Set<Material> getDangerousBlocks() {
return Collections.unmodifiableSet(dangerousBlocks);
}
private String getString(String path, @NotNull String def) {
return getString(path, def, null);
}
@@ -78,13 +78,14 @@ public class EnvironmentalListener implements Listener {
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockIgnite(BlockPlaceEvent event) {
public void onDangerousBlockPlace(BlockPlaceEvent event) {
ConfigCache config = plugin.getConfigCache();
if (!config.block_stopper_enabled) return;
Player player = event.getPlayer();
Location location = event.getBlock().getLocation().toCenterLocation();
Target target = Target.getTarget(player);
if (target == null) return;
if (!config.getDangerousBlocks().contains(event.getBlock().getType())) return;
double radius = config.block_stopper_radius;
BoundingBox boundingBox = BoundingBox.of(location.toVector(), radius, radius, radius);