SPIGOT-7633: Clearer error message for missing particle data

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-04-25 16:38:33 +10:00
parent 8a69fc5946
commit 18cee9d332
4 changed files with 9 additions and 14 deletions

View File

@@ -61,7 +61,15 @@ public abstract class CraftParticle<D> implements Keyed {
}
public static <D> ParticleParam createParticleParam(Particle particle, D data) {
Preconditions.checkArgument(particle != null);
Preconditions.checkArgument(particle != null, "particle cannot be null");
data = CraftParticle.convertLegacy(data);
if (particle.getDataType() != Void.class) {
Preconditions.checkArgument(data != null, "missing required data %s", particle.getDataType());
}
if (data != null) {
Preconditions.checkArgument(particle.getDataType().isInstance(data), "data (%s) should be %s", data.getClass(), particle.getDataType());
}
CraftParticle<D> craftParticle = (CraftParticle<D>) CRAFT_PARTICLE_REGISTRY.get(particle.getKey());