mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-21 16:09:24 +00:00
Reworked custom entity system
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.willfp.ecobosses.proxy.proxies;
|
||||
|
||||
import com.willfp.eco.util.proxy.AbstractProxy;
|
||||
import com.willfp.ecobosses.proxy.util.CustomEntity;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface CustomEntitySpawnerProxy extends AbstractProxy {
|
||||
/**
|
||||
* Spawn custom entity.
|
||||
*
|
||||
* @param <T> The class.
|
||||
* @param entityClass The custom entity proxy class.
|
||||
* @param location The location.
|
||||
* @return The bukkit entity, or null if invalid class.
|
||||
*/
|
||||
@Nullable <T extends LivingEntity> T spawnCustomEntity(Class<? extends CustomEntity<? extends LivingEntity>> entityClass,
|
||||
@NotNull Location location);
|
||||
}
|
||||
@@ -5,4 +5,5 @@ import com.willfp.ecobosses.proxy.util.CustomEntity;
|
||||
import org.bukkit.entity.Illusioner;
|
||||
|
||||
public interface CustomIllusionerProxy extends AbstractProxy, CustomEntity<Illusioner> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.willfp.ecobosses.proxy.util;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.willfp.ecobosses.proxy.proxies.CustomIllusionerProxy;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@UtilityClass
|
||||
public class CustomEntities {
|
||||
/**
|
||||
* Registered custom entities.
|
||||
*/
|
||||
private static final BiMap<String, Class<? extends CustomEntity<? extends LivingEntity>>> REGISTRY = new ImmutableBiMap.Builder<String, Class<? extends CustomEntity<? extends LivingEntity>>>()
|
||||
.put("custom_illusioner", CustomIllusionerProxy.class)
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Get entity class.
|
||||
*
|
||||
* @param id The entity id.
|
||||
* @return The class.
|
||||
*/
|
||||
@Nullable
|
||||
public Class<? extends CustomEntity<? extends LivingEntity>> getEntityClass(@NotNull final String id) {
|
||||
return REGISTRY.get(id);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,7 @@
|
||||
package com.willfp.ecobosses.proxy.util;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public interface CustomEntity<T extends LivingEntity> {
|
||||
|
||||
public interface CustomEntity<T> {
|
||||
/**
|
||||
* Spawn a custom entity.
|
||||
*
|
||||
* @param location The location to spawn it at.
|
||||
* @return The created entity.
|
||||
*/
|
||||
T spawn(@NotNull Location location);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user