Commits

DerFrZocker authored 139cc0c3698
Add commodore for EntityType
No tags
experimental

src/main/java/org/bukkit/entity/EntityType.java

Modified
353 353 private static <E extends EntityType> E getEntityType(@NotNull String key, int typeId) {
354 354 NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
355 355 EntityType entityType = Registry.ENTITY_TYPE.get(namespacedKey);
356 356 Preconditions.checkNotNull(entityType, "No EntityType found for %s. This is a bug.", namespacedKey);
357 357 if (typeId > 0) {
358 358 ID_MAP.put((short) typeId, entityType);
359 359 }
360 360 return (E) entityType;
361 361 }
362 362
363 + /**
364 + * Yields this EntityType as a typed version of itself with a specific entity representing it.
365 + *
366 + * @param entityClass the class to type this {@link EntityType} with
367 + * @param <E> the generic type of the entity to type this particle with
368 + * @return the typed entity type
369 + * @throws IllegalArgumentException when the given class is not the same as {@link #getEntityClass()}
370 + * @throws UnsupportedOperationException when {@link #isTyped()} returns false
371 + * @see #isTyped()
372 + * @see #getEntityClass()
373 + */
374 + @NotNull
375 + public abstract <E extends Entity> EntityType.Typed<E> typed(@NotNull Class<E> entityClass);
376 +
377 + /**
378 + * Returns true if this EntityType is typed.
379 + *
380 + * @return true if this EntityType is typed
381 + * @see #getEntityClass()
382 + * @see #typed(Class)
383 + */
384 + public abstract boolean isTyped();
385 +
363 386 /**
364 387 * Some entities cannot be spawned using {@link
365 388 * RegionAccessor#spawnEntity(Location, EntityType.Typed)} or {@link
366 389 * World#spawn(Location, Class)}, usually because they require additional
367 390 * information in order to spawn.
368 391 *
369 392 * @return False if the entity type cannot be spawned
370 393 */
371 394 public abstract boolean isSpawnable();
372 395
373 396 public abstract boolean isAlive();
374 397
398 + /**
399 + * Gets the Entity class of this EntityType.
400 + *
401 + * @return the entity class
402 + * @throws UnsupportedOperationException when {@link #isTyped()} returns false
403 + * @see #isTyped()
404 + * @see #typed(Class)
405 + */
375 406 @Nullable
376 407 public abstract Class<? extends Entity> getEntityClass();
377 408
378 409 /**
379 410 * Gets if this EntityType is enabled by feature in a world.
380 411 *
381 412 * @param world the world to check
382 413 * @return true if this EntityType can be used to spawn an Entity for this World.
383 414 */
384 415 public abstract boolean isEnabledByFeature(@NotNull World world);

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut