Class DamageScope

java.lang.Object
studio.magemonkey.codex.api.damage.DamageScope
All Implemented Interfaces:
AutoCloseable

public final class DamageScope extends Object implements AutoCloseable
An open DamageRequest for one target, from DamageContexts.open(Entity, DamageRequest). Closing it withdraws the request. Always use it in a try-with-resources statement, so that it is closed even when the damage event is cancelled or something throws.
  • Method Details

    • isClaimed

      public boolean isClaimed()
      Whether a damage event picked the request up. If it is still false after the call to damage(), nothing read the request and the hit was handled as ordinary damage.
    • close

      public void close()
      Withdraws the request. Closing a scope twice does nothing.
      Specified by:
      close in interface AutoCloseable
    • getRequest

      @NotNull public DamageRequest getRequest()
    • isClosed

      public boolean isClosed()