Skip to content

Logging non-block types for block actions with the official API breaks the rollback preview #862

@guss-alberto

Description

@guss-alberto

The API allows logging block actions for any Material type, including non-block items, such as minecarts or boats, which is very useful.

They are simply ignored by rollbacks as expected, however enabling #preview on the rollback will throw a NullPointerException and abort the preview.

Steps to reproduce:

Expected result:

The rollback preview should be shown

Observed result:

[12:03:26 WARN]: java.lang.NullPointerException: Cannot invoke "org.bukkit.craftbukkit.block.data.CraftBlockData.getState()" because "block" is null
[12:03:26 WARN]:        at org.bukkit.craftbukkit.entity.CraftPlayer.sendBlockChange(CraftPlayer.java:921)
[12:03:26 WARN]:        at CoreProtect-23.1-nullcheck.jar//net.coreprotect.utility.Util.sendBlockChange(Util.java:24)
[12:03:26 WARN]:        at CoreProtect-23.1-nullcheck.jar//net.coreprotect.database.rollback.RollbackBlockHandler.applyBlockChanges(RollbackBlockHandler.java:527)
[12:03:26 WARN]:        at CoreProtect-23.1-nullcheck.jar//net.coreprotect.database.rollback.RollbackProcessor.processChunk(RollbackProcessor.java:246)
[12:03:26 WARN]:        at CoreProtect-23.1-nullcheck.jar//net.coreprotect.database.rollback.Rollback.lambda$performRollbackRestore$1(Rollback.java:261)
......
[12:03:26 INFO]: [CoreProtect] Rollback or restore aborted.

Cause:

Util.sendBlockChange has no check for blockData not being null, unlike BlockUtils.setTypeAndData which does.

Possible fixes:

Add a null check for blockData in Util.sendBlockChange

Retrun if createBlockData returns null in BlockUtils.prepareTypeAndData

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions