Tristan Butterworth

can you make a plugin where bed bomming does 0 damage so when you try sleep in nether you take no damage

Kodari AI
KodariOct 26 at 9:50 pm 1
BedExplosionProtection
BedExplosionProtection is a Minecraft plugin that prevents all damage from bed explosions in the Nether and End dimensions. When a player attempts to sleep in a bed in these dangerous dimensions, the bed still explodes as normal, but the explosion deals zero damage to players, entities, and the environment. The plugin intercepts the explosion event and cancels all damage while preserving the visual and sound effects of the explosion. This allows players to safely attempt sleeping without the risk of death or injury, making exploration of these dimensions more forgiving and accessible.
  • Create the Gradle plugin project and its plugin.yml.

  • Cancel player block-explosion damage in the Nether, preventing bed explosions from hurting players.

Created NetherBedSafety. Players take no block-explosion damage in the Nether, including from beds; this also protects them from TNT block explosions there.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 59
src/main/java/com/kodari/netherbedsafety/NetherBedSafetyPlugin.java
package com.kodari.netherbedsafety;

import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class NetherBedSafetyPlugin extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler(ignoreCancelled = true)
    public void onPlayerDamage(EntityDamageEvent event) {
        if (!(event.getEntity() instanceof Player player)) {
            return;
        }
        if (player.getWorld().getEnvironment() != World.Environment.NETHER) {
            return;
        }
        if (event.getCause() == EntityDamageEvent.DamageCause.BLOCK_EXPLOSION) {
            event.setCancelled(true);
        }
    }
}