ronantakizawa/codereview-bench huggingface dataset:
Repository: PaperMC/Paper
File: paper-api/src/main/java/io/papermc/paper/raytracing/PositionedRayTraceConfigurationBuilder.java (Java)

Code before:
package io.papermc.paper.raytracing;

import org.bukkit.FluidCollisionMode;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.function.Predicate;

/**
 * Holds information about how to cast a raytrace.
 */
public interface PositionedRayTraceConfigurationBuilder {

    /**
     * Gets the starting location.
     *
     * @return the starting location
     */
    @Nullable
    Location start();

    /**
     * Sets the starting location.
     *
     * @param start the new starting location
     * @return a reference to this object
     */
    @NotNull
    @Contract("_ -> this")
    PositionedRayTraceConfigurationBuilder start(@NotNull Location start);

Review comment (suggestion):
After NullMarked, only need to use the jspecify Nullable annotation.

Code after:
package io.papermc.paper.raytracing;

import java.util.function.Predicate;
import org.bukkit.FluidCollisionMode;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
import org.checkerframework.checker.index.qual.NonNegative;
import org.jetbrains.annotations.Contract;
import org.jspecify.annotations.NullMarked;

/**
 * A builder for configuring a raytrace with a starting location
 * and direction.
 */
@NullMarked
public interface PositionedRayTraceConfigurationBuilder {

    /**
     * Sets the starting location.
     *
     * @param start the new starting location
     * @return a reference to this object
     */
    @Contract(value = "_ -> this", mutates = "this")
    PositionedRayTraceConfigurationBuilder start(Location start);

    /**
     * Sets the direction.
     *
     * @param direction the new direction
     * @return a reference to this object
     */
    @Contract(value = "_ -> this", mutates = "this")
Repository: PaperMC/Paper
File: paper-api/src/main/java/io/papermc/paper/event/entity/EntityEquipmentChangedEvent.java (Java)

Code before:
    /**
     * Gets a map of changed slots to their respective equipment changes.
     *
     * @return the equipment changes map
     */
    @Unmodifiable
    public Map<EquipmentSlot, EquipmentChange> getEquipmentChanges() {
        return equipmentChanges;
    }

    @Override
    public HandlerList getHandlers() {
        return HANDLER_LIST;
    }

    public static HandlerList getHandlerList() {
        return HANDLER_LIST;
    }

    /**
     * Represents a change in equipment for a single equipment slot.
     *
     * @param oldItem the existing item that is being replaced
     * @param newItem the new item that is replacing the existing item
     */
    public record EquipmentChange(ItemStack oldItem, ItemStack newItem) {

    }

}


Review comment (suggestion):
This should probably be another interface + package private record impl combo.
We also should be defensively copying the stacks on access to prevent plugins from changing these accidentally.

Code after:

    /**
     * Gets a map of changed slots to their respective equipment changes.
     *
     * @return the equipment changes map
     */
    public @Unmodifiable Map<EquipmentSlot, EquipmentChange> getEquipmentChanges() {
        return Collections.unmodifiableMap(this.equipmentChanges);
    }

    @Override
    public HandlerList getHandlers() {
        return HANDLER_LIST;
    }

    public static HandlerList getHandlerList() {
        return HANDLER_LIST;
    }

    /**
     * Represents a change in equipment for a single equipment slot.
     */
    @ApiStatus.NonExtendable
    public interface EquipmentChange {

        /**
         * Gets the existing item that is being replaced.
         *
         * @return the existing item
         */
        @Contract(pure = true, value = "-> new")
        ItemStack oldItem();

        /**
         * Gets the new item that is replacing the existing item.
         *
         * @return the new item
         */
        @Contract(pure = true, value = "-> new")
        ItemStack newItem();
    }
}
Repository: PaperMC/Paper
File: paper-api/src/main/java/org/bukkit/block/TrialSpawner.java (Java)

Code before:
package org.bukkit.block;

import java.util.Collection;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.spawner.TrialSpawnerConfiguration;
import org.jetbrains.annotations.NotNull;

/**
 * Represents a captured state of a trial spawner.
 */
public interface TrialSpawner extends TileState {

    /**
     * Gets the Gametime in ticks when the cooldown ends. 0 if not currently in cooldown.
     *
     * @return the Gametime in ticks
     */
    public long getCooldownEndsAt();

    /**
     * Sets the Gametime in ticks when the cooldown ends.
     *
     * @param ticks the GameTime in ticks for the new cooldown
     */
    public void setCooldownEndsAt(long ticks);

    /**
     * Gets the Gametime in ticks when the next spawn attempt happens. 0 if not currently active.
     *
     * @return the Gametime in ticks
     */
    public long getNextMobSpawnsAt();

    /**
     * Sets the Gametime in ticks when the next spawn attempt happens.
     *
     * @param ticks the Gametime in ticks for the next mob spawn
     */
    public void setNextMobSpawnsAt(long ticks);

    /**
     * Gets the length in ticks the spawner will stay in cooldown for.
     *

Review comment (suggestion):
Not a big fan of these method names, they feel *really* spigot.
`getCooldownEnd` is probably better.

Code after:
package org.bukkit.block;

import java.util.Collection;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.spawner.TrialSpawnerConfiguration;
import org.jspecify.annotations.NullMarked;

/**
 * Represents a captured state of a trial spawner.
 */
@NullMarked
public interface TrialSpawner extends TileState {

    /**
     * Gets the game time in ticks when the cooldown ends. 0 if not currently in cooldown.
     *
     * @return the game time in ticks
     * @see org.bukkit.World#getGameTime()
     */
    long getCooldownEnd();

    /**
     * Sets the game time in ticks when the cooldown ends.
     *
     * @param ticks the game time in ticks for the new cooldown
     */
    void setCooldownEnd(long ticks);

    /**
     * Gets the game time in ticks when the next spawn attempt happens. 0 if not currently active.
     *
     * @return the game time in ticks
     * @see org.bukkit.World#getGameTime()
     */
    long getNextSpawnAttempt();

    /**
     * Sets the game time in ticks when the next spawn attempt happens.
     *
     * @param ticks the game time in ticks for the next mob spawn
     */
    void setNextSpawnAttempt(long ticks);
Repository: PaperMC/Paper
File: paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArmadillo.java (Java)

Code before:
    }

    @Override
    public String toString() {
        return "CraftArmadillo";
    }

    private State stateToBukkit(net.minecraft.world.entity.animal.armadillo.Armadillo.ArmadilloState state) {
        return switch (state) {
            case IDLE -> State.IDLE;
            case ROLLING -> State.ROLLING;
            case SCARED -> State.SCARED;
            case UNROLLING -> State.UNROLLING;
        };
    }

    private net.minecraft.world.entity.animal.armadillo.Armadillo.ArmadilloState stateToNMS(State state) {
        return switch (state) {
            case State.IDLE -> net.minecraft.world.entity.animal.armadillo.Armadillo.ArmadilloState.IDLE;
            case State.ROLLING -> net.minecraft.world.entity.animal.armadillo.Armadillo.ArmadilloState.ROLLING;
            case State.SCARED -> net.minecraft.world.entity.animal.armadillo.Armadillo.ArmadilloState.SCARED;
            case State.UNROLLING -> net.minecraft.world.entity.animal.armadillo.Armadillo.ArmadilloState.UNROLLING;
        };
    }
}


Review comment (suggestion):
Lets make these static and public. Maybe useful elsewhere in the future to convert between the two types.

Also you can import the nms type. No need to fully qualify the name.

Code after:
        this.getHandle().lastHurtByMob = null; // Clear this memory to not have the sensor trigger rollUp instantly for damaged armadillo
        this.getHandle().getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, ArmadilloState.UNROLLING.animationDuration());
    }

    @Override
    public String toString() {
        return "CraftArmadillo";
    }

    public static State stateToBukkit(ArmadilloState state) {
        return switch (state) {
            case IDLE -> State.IDLE;
            case ROLLING -> State.ROLLING;
            case SCARED -> State.SCARED;
            case UNROLLING -> State.UNROLLING;
        };
    }

    public static ArmadilloState stateToNMS(State state) {
        return switch (state) {
            case State.IDLE -> ArmadilloState.IDLE;
            case State.ROLLING -> ArmadilloState.ROLLING;
            case State.SCARED -> ArmadilloState.SCARED;
            case State.UNROLLING -> ArmadilloState.UNROLLING;
        };
    }
}
Repository: PaperMC/Paper
File: paper-api/src/main/java/org/bukkit/entity/Armadillo.java (Java)

Code before:
     *
     * @return the state of the armadillo
     */
    State getState();

    /**
     * Set a new state for the armadillo.
     * <br>
     * This will also make the armadillo make the transition to the new state.
     *
     * @param state the new state
     */
    void setState(final State state);

    /**
     * Attempt to roll up if it in {@link State#IDLE}
     */
    void rollUp();

    /**
     * Attempt to roll out if it's not in {@link State#IDLE}
     */
    void rollOut();

    /**
     * Represents the current state of the Armadillo.
     */
    enum State {
        IDLE,
        ROLLING,
        SCARED,
        UNROLLING;
    }

}


Review comment (suggestion):
```suggestion
     * Represents the current state of the armadillo.
```

Code after:
     *
     * @return the state of the armadillo
     */
    State getState();

    /**
     * Attempt to roll up if the armadillo is {@link State#IDLE}
     */
    void rollUp();

    /**
     * Attempt to roll out if the armadillo is not {@link State#IDLE}
     */
    void rollOut();

    /**
     * Represents the current state of the armadillo.
     */
    enum State {
        IDLE,
        ROLLING,
        SCARED,
        UNROLLING;
    }

}
Repository: PaperMC/Paper
File: paper-api/src/main/java/org/bukkit/entity/Armadillo.java (Java)

Code before:
package org.bukkit.entity;

import org.jspecify.annotations.NullMarked;

/**
 * Represents an Armadillo.
 */
@NullMarked
public interface Armadillo extends Animals {

    /**
     * Get the current state of the armadillo.
     *
     * @return the state of the armadillo
     */
    State getState();

    /**
     * Attempt to roll up if it in {@link State#IDLE}
     */
    void rollUp();

    /**
     * Attempt to roll out if it's not in {@link State#IDLE}
     */
    void rollOut();

    /**
     * Represents the current state of the armadillo.
     */
    enum State {
        IDLE,
        ROLLING,
        SCARED,
        UNROLLING;
    }

}


Review comment (suggestion):
```suggestion
     * Attempt to roll up if the armadillo is {@link State#IDLE}
```

Code after:
package org.bukkit.entity;

import org.jspecify.annotations.NullMarked;

/**
 * Represents an Armadillo.
 */
@NullMarked
public interface Armadillo extends Animals {

    /**
     * Get the current state of the armadillo.
     *
     * @return the state of the armadillo
     */
    State getState();

    /**
     * Attempt to roll up if the armadillo is {@link State#IDLE}
     */
    void rollUp();

    /**
     * Attempt to roll out if the armadillo is not {@link State#IDLE}
     */
    void rollOut();

    /**
     * Represents the current state of the armadillo.
     */
    enum State {
        IDLE,
        ROLLING,
        SCARED,
        UNROLLING;
    }

}
Repository: PaperMC/Paper
File: paper-api/src/main/java/org/bukkit/entity/Armadillo.java (Java)

Code before:
package org.bukkit.entity;

import org.jspecify.annotations.NullMarked;

/**
 * Represents an Armadillo.
 */
@NullMarked
public interface Armadillo extends Animals {

    /**
     * Get the current state of the armadillo.
     *
     * @return the state of the armadillo
     */
    State getState();

    /**
     * Attempt to roll up if it in {@link State#IDLE}
     */
    void rollUp();

    /**
     * Attempt to roll out if it's not in {@link State#IDLE}
     */
    void rollOut();

    /**
     * Represents the current state of the armadillo.
     */
    enum State {
        IDLE,
        ROLLING,
        SCARED,
        UNROLLING;
    }

}


Review comment (suggestion):
```suggestion
     * Attempt to roll out if the armadillo is not {@link State#IDLE}
```

Code after:
package org.bukkit.entity;

import org.jspecify.annotations.NullMarked;

/**
 * Represents an Armadillo.
 */
@NullMarked
public interface Armadillo extends Animals {

    /**
     * Get the current state of the armadillo.
     *
     * @return the state of the armadillo
     */
    State getState();

    /**
     * Attempt to roll up if the armadillo is {@link State#IDLE}
     */
    void rollUp();

    /**
     * Attempt to roll out if the armadillo is not {@link State#IDLE}
     */
    void rollOut();

    /**
     * Represents the current state of the armadillo.
     */
    enum State {
        IDLE,
        ROLLING,
        SCARED,
        UNROLLING;
    }

}
Repository: PaperMC/Paper
File: paper-api/src/main/java/io/papermc/paper/math/Rotation.java (Java)

Code before:
package io.papermc.paper.math;

import org.jspecify.annotations.NullMarked;

/**
 * Represents a rotation with specified pitch and yaw values.
 */
@NullMarked
public interface Rotation {
    /**
     * Retrieves the pitch component of the rotation, measured in degrees.
     *
     * @return the pitch value in degrees
     */
    float pitch();

    /**
     * Retrieves the yaw component of the rotation, measured in degrees.
     *
     * @return the yaw value in degrees
     */
    float yaw();
}


Review comment (suggestion):
There should be some way to obtain an instance of this if we want it to be useful outside of commands, RotationImpl can be moved into the math package in api and a static method can be added in this class, the same is currently done in Position for example.

Code after:
package io.papermc.paper.math;

import org.jspecify.annotations.NullMarked;

/**
 * Represents a rotation with specified pitch and yaw values.
 */
@NullMarked
public interface Rotation {
    /**
     * Creates a new rotation with the specified yaw and pitch values.
     *
     * @param yaw   the yaw component of the rotation, measured in degrees
     * @param pitch the pitch component of the rotation, measured in degrees
     * @return a new {@code Rotation} instance with the specified yaw and pitch
     */
    static Rotation rotation(float yaw, float pitch) {
        return new RotationImpl(yaw, pitch);
    }

    /**
     * Retrieves the pitch component of the rotation, measured in degrees.
     *
     * @return the pitch value in degrees
     */
    float pitch();

    /**
     * Retrieves the yaw component of the rotation, measured in degrees.
     *
     * @return the yaw value in degrees
     */
    float yaw();
}
Repository: PaperMC/Paper
File: paper-api/src/main/java/org/bukkit/entity/Creaking.java (Java)

Code before:

import org.bukkit.Location;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
 * Represents a Creaking.
 */
@NullMarked
public interface Creaking extends Monster {

    /**
     * Gets the home location for this Creaking (where its {@link org.bukkit.block.CreakingHeart} could be found).
     *
     * @return the location of the home if available, null otherwise
     */
    @Nullable
    Location getHome();

    /**
     * Detach the home for this Creaking.
     */
    void detachHome();

    /**
     * Activates this Creaking to target and follow a player.
     *
     * @param player the target
     */
    void activate(final Player player);

    /**
     * Deactivates the entity, clearing its current attack target and
     * marking it as inactive.
     */
    void deactivate();

    /**
     * Gets if this Creaking is active.
     *
     * @return true if active
     */
    boolean isActive();

}


Review comment (suggestion):
```suggestion
     * Activates this creaking to target and follow a player.
```

Code after:

import org.bukkit.Location;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
 * Represents a Creaking.
 */
@NullMarked
public interface Creaking extends Monster {

    /**
     * Gets the home location for this creaking (where its {@link org.bukkit.block.CreakingHeart} could be found).
     *
     * @return the location of the home if available, null otherwise
     */
    @Nullable
    Location getHome();

    /**
     * Activates this creaking to target and follow a player.
     *
     * @param player the target
     */
    void activate(final Player player);

    /**
     * Deactivates the creaking, clearing its current attack target and
     * marking it as inactive.
     */
    void deactivate();

    /**
     * Returns if this creaking is currently active and hunting.
     *
     * @see #activate(Player)
     *
     * @return true if active
     */
    boolean isActive();

}
Repository: PaperMC/Paper
File: paper-api/src/main/java/org/bukkit/entity/Creaking.java (Java)

Code before:
 */
@NullMarked
public interface Creaking extends Monster {

    /**
     * Gets the home location for this Creaking (where its {@link org.bukkit.block.CreakingHeart} could be found).
     *
     * @return the location of the home if available, null otherwise
     */
    @Nullable
    Location getHome();

    /**
     * Detach the home for this Creaking.
     */
    void detachHome();

    /**
     * Activates this Creaking to target and follow a player.
     *
     * @param player the target
     */
    void activate(final Player player);

    /**
     * Deactivates the entity, clearing its current attack target and
     * marking it as inactive.
     */
    void deactivate();

    /**
     * Gets if this Creaking is active.
     *
     * @return true if active
     */
    boolean isActive();

}


Review comment (suggestion):
```suggestion
     * Deactivates the creaking, clearing its current attack target and
```

Code after:
 */
@NullMarked
public interface Creaking extends Monster {

    /**
     * Gets the home location for this creaking (where its {@link org.bukkit.block.CreakingHeart} could be found).
     *
     * @return the location of the home if available, null otherwise
     */
    @Nullable
    Location getHome();

    /**
     * Activates this creaking to target and follow a player.
     *
     * @param player the target
     */
    void activate(final Player player);

    /**
     * Deactivates the creaking, clearing its current attack target and
     * marking it as inactive.
     */
    void deactivate();

    /**
     * Returns if this creaking is currently active and hunting.
     *
     * @see #activate(Player)
     *
     * @return true if active
     */
    boolean isActive();

}
Repository: PaperMC/Paper
File: paper-api/src/main/java/org/bukkit/entity/Creaking.java (Java)

Code before:
     *
     * @return the location of the home if available, null otherwise
     */
    @Nullable
    Location getHome();

    /**
     * Detach the home for this Creaking.
     */
    void detachHome();

    /**
     * Activates this Creaking to target and follow a player.
     *
     * @param player the target
     */
    void activate(final Player player);

    /**
     * Deactivates the entity, clearing its current attack target and
     * marking it as inactive.
     */
    void deactivate();

    /**
     * Gets if this Creaking is active.
     *
     * @return true if active
     */
    boolean isActive();

}


Review comment (suggestion):
```suggestion
     * Returns if this creaking is currently active and hunting.
     *
     * @see #activate(Player)
```

Code after:
     *
     * @return the location of the home if available, null otherwise
     */
    @Nullable
    Location getHome();

    /**
     * Activates this creaking to target and follow a player.
     *
     * @param player the target
     */
    void activate(final Player player);

    /**
     * Deactivates the creaking, clearing its current attack target and
     * marking it as inactive.
     */
    void deactivate();

    /**
     * Returns if this creaking is currently active and hunting.
     *
     * @see #activate(Player)
     *
     * @return true if active
     */
    boolean isActive();

}
Repository: PaperMC/Paper
File: paper-api/src/main/java/org/bukkit/entity/Creaking.java (Java)

Code before:
package org.bukkit.entity;

import org.bukkit.Location;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
 * Represents a Creaking.
 */
@NullMarked
public interface Creaking extends Monster {

    /**
     * Gets the home location for this Creaking (where its {@link org.bukkit.block.CreakingHeart} could be found).
     *
     * @return the location of the home if available, null otherwise
     */
    @Nullable
    Location getHome();

    /**
     * Detach the home for this Creaking.
     */
    void detachHome();

    /**
     * Activates this creaking to target and follow a player.
     *
     * @param player the target
     */
    void activate(final Player player);

    /**
     * Deactivates the creaking, clearing its current attack target and
     * marking it as inactive.
     */
    void deactivate();

    /**

Review comment (suggestion):
```suggestion
     * Gets the home location for this creaking (where its {@link org.bukkit.block.CreakingHeart} could be found).
```

Code after:
package org.bukkit.entity;

import org.bukkit.Location;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
 * Represents a Creaking.
 */
@NullMarked
public interface Creaking extends Monster {

    /**
     * Gets the home location for this creaking (where its {@link org.bukkit.block.CreakingHeart} could be found).
     *
     * @return the location of the home if available, null otherwise
     */
    @Nullable
    Location getHome();

    /**
     * Activates this creaking to target and follow a player.
     *
     * @param player the target
     */
    void activate(final Player player);

    /**
     * Deactivates the creaking, clearing its current attack target and
     * marking it as inactive.
     */
    void deactivate();

    /**
     * Returns if this creaking is currently active and hunting.
     *
     * @see #activate(Player)
     *
     * @return true if active