Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7633

NPE When Creating A Particle

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • Fedora 39

    • 1.20.5
    • Yes

      I cannot provide a jar to test at this moment, if it is required (though I think it shouldn't be) I can send one sometime tomorrow. 

       

      Spawn a particle like so:

      loc.getWorld().spawnParticle( // Line 1150
          this.particle,
          loc,
          this.count,
          this.offsetX,
          this.offsetY,
          this.offsetZ,
          this.extra,
          this.data
      );

      You may receive an error like:

      [22:52:28] [MBedwars: ARENA_TICKER/WARN]: java.lang.NullPointerException: Cannot invoke "org.bukkit.Color.asARGB()" because "color" is null
      [22:52:28] [MBedwars: ARENA_TICKER/WARN]:       at org.bukkit.craftbukkit.v1_20_R4.CraftParticle$CraftParticleRegistry$9.createParticleParam(CraftParticle.java:180)
      [22:52:28] [MBedwars: ARENA_TICKER/WARN]:       at org.bukkit.craftbukkit.v1_20_R4.CraftParticle$CraftParticleRegistry$9.createParticleParam(CraftParticle.java:177)
      [22:52:28] [MBedwars: ARENA_TICKER/WARN]:       at org.bukkit.craftbukkit.v1_20_R4.CraftParticle.createParticleParam(CraftParticle.java:70)
      [22:52:28] [MBedwars: ARENA_TICKER/WARN]:       at org.bukkit.craftbukkit.v1_20_R4.CraftWorld.spawnParticle(CraftWorld.java:1884)
      [22:52:28] [MBedwars: ARENA_TICKER/WARN]:       at org.bukkit.craftbukkit.v1_20_R4.CraftWorld.spawnParticle(CraftWorld.java:1868)
      [22:52:28] [MBedwars: ARENA_TICKER/WARN]:       at org.bukkit.craftbukkit.v1_20_R4.CraftWorld.spawnParticle(CraftWorld.java:1863)
      [22:52:28] [MBedwars: ARENA_TICKER/WARN]:       at de.marcely.bedwars.tools.VarParticle$TypeV9Particle.play(VarParticle.java:1150)
       

       

      I believe a null check for color just needs to be added here in CraftParticle

      BiFunction<NamespacedKey, ParticleType<?>, CraftParticle<?>> colorFunction = (name, particle) -> {
        return new CraftParticle<Color>(name, particle, Color.class) {
          public ParticleOptions createParticleParam(Color color) {
            return ColorParticleOption.create(particle, color.asARGB());
          }
        };
      }; 

       

       

      Its late, I apologize for the limited info and no test jar. I can create one in the morning if needed.

            Unassigned Unassigned
            metallicgoat Metallic Goat
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: