Repository: PaperMC/Paper
File: paper-server/src/main/java/io/papermc/paper/registry/data/PaperDamageTypeRegistryEntry.java (Java)

Code before:
package io.papermc.paper.registry.data;

import io.papermc.paper.registry.PaperRegistryBuilder;
import io.papermc.paper.registry.data.util.Conversions;
import net.minecraft.world.damagesource.*;
import org.bukkit.craftbukkit.damage.CraftDamageEffect;
import org.bukkit.craftbukkit.damage.CraftDamageType;
import org.bukkit.damage.DamageEffect;
import org.jspecify.annotations.Nullable;

import static io.papermc.paper.registry.data.util.Checks.asConfigured;

public class PaperDamageTypeRegistryEntry implements DamageTypeRegistryEntry {
    protected @Nullable String messageId;
    protected float exhaustion;
    protected @Nullable DamageScaling damageScaling;
    protected @Nullable DamageEffects damageEffects;
    protected @Nullable DeathMessageType deathMessageType;

    protected final Conversions conversions;

    public PaperDamageTypeRegistryEntry(
            final Conversions conversions,
            final @Nullable DamageType internal
    ) {
        this.conversions = conversions;
        if (internal == null) return;

        this.messageId = internal.msgId();
        this.exhaustion = internal.exhaustion();
        this.damageScaling = internal.scaling();
        this.damageEffects = internal.effects();
        this.deathMessageType = internal.deathMessageType();
    }

    @Override
    public String messageId() {
        return asConfigured(messageId, "messsageId");
    }


Review comment (suggestion):
This should be nullable, and then the getter and `build` method should check that it's been set. It's not an optional field, so we want people to explicitly set it. Right now it defaults to 0.

Code after:
package io.papermc.paper.registry.data;

import io.papermc.paper.registry.PaperRegistryBuilder;
import io.papermc.paper.registry.data.util.Conversions;
import net.minecraft.world.damagesource.DamageEffects;
import net.minecraft.world.damagesource.DamageScaling;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.world.damagesource.DeathMessageType;
import org.bukkit.craftbukkit.damage.CraftDamageEffect;
import org.bukkit.craftbukkit.damage.CraftDamageType;
import org.bukkit.damage.DamageEffect;
import org.jspecify.annotations.Nullable;

import static io.papermc.paper.registry.data.util.Checks.asConfigured;

public class PaperDamageTypeRegistryEntry implements DamageTypeRegistryEntry {

    protected @Nullable String messageId;
    protected @Nullable Float exhaustion;
    protected @Nullable DamageScaling damageScaling;
    protected DamageEffects damageEffects = DamageEffects.HURT;
    protected DeathMessageType deathMessageType = DeathMessageType.DEFAULT;

    protected final Conversions conversions;

    public PaperDamageTypeRegistryEntry(
        final Conversions conversions,
        final @Nullable DamageType internal
    ) {
        this.conversions = conversions;
        if (internal == null) return;

        this.messageId = internal.msgId();
        this.exhaustion = internal.exhaustion();
        this.damageScaling = internal.scaling();
        this.damageEffects = internal.effects();
        this.deathMessageType = internal.deathMessageType();
    }

    @Override