Class DamageRegistry

java.lang.Object
studio.magemonkey.codex.registry.DamageRegistry

public class DamageRegistry extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    deal(org.bukkit.entity.LivingEntity target, studio.magemonkey.codex.api.damage.DamageRequest request)
    Deals the damage a request describes, with the request announced through DamageContexts for the duration of the hit.
    static boolean
    dealDamage(org.bukkit.entity.LivingEntity entity, double amount, String damageType, org.bukkit.entity.LivingEntity damager)
     
    static void
    registerProvider(studio.magemonkey.codex.registry.provider.DamageTypeProvider provider)
     
    static void
    unregisterProvider(Class<? extends studio.magemonkey.codex.registry.provider.DamageTypeProvider> providerClass)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DamageRegistry

      public DamageRegistry()
  • Method Details

    • registerProvider

      public static void registerProvider(studio.magemonkey.codex.registry.provider.DamageTypeProvider provider)
    • unregisterProvider

      public static void unregisterProvider(Class<? extends studio.magemonkey.codex.registry.provider.DamageTypeProvider> providerClass)
    • dealDamage

      public static boolean dealDamage(@NotNull org.bukkit.entity.LivingEntity entity, double amount, String damageType, @Nullable org.bukkit.entity.LivingEntity damager)
    • deal

      public static boolean deal(@NotNull org.bukkit.entity.LivingEntity target, @NotNull studio.magemonkey.codex.api.damage.DamageRequest request)
      Deals the damage a request describes, with the request announced through DamageContexts for the duration of the hit.

      The target takes DamageRequest.getTotal() damage through Bukkit, attributed to the request's source if it has one. If the request names a cause and the server is 1.20.4 or newer, the damage is dealt with a real damage source of the matching vanilla type, so the event carries that cause; otherwise the cause is only carried in the request. A plugin that calculates damage can pick the request up from the damage event with DamageContexts.claim(EntityDamageEvent). If none does, the hit is ordinary damage of that amount.

      Unlike dealDamage(LivingEntity, double, String, LivingEntity), this does not go through the registered providers, so it works whether or not any plugin provides the damage types named in the request.

      Parameters:
      target - the entity to damage
      request - the description of the hit
      Returns:
      whether a damage event claimed the request. False does not mean the target was not damaged: the damage call has been made either way, so do not deal the damage again in response