mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Add entity category loading code to WorldUtil (implemented in BukkitUtil)
This commit is contained in:
@ -39,6 +39,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -215,4 +216,7 @@ public abstract class WorldUtil {
|
||||
public abstract int getFoodLevel(PlotPlayer player);
|
||||
|
||||
public abstract void setFoodLevel(PlotPlayer player, int foodLevel);
|
||||
|
||||
public abstract Set<EntityType> getTypesInCategory(final String category);
|
||||
|
||||
}
|
||||
|
@ -25,29 +25,19 @@
|
||||
*/
|
||||
package com.github.intellectualsites.plotsquared.plot.util.entity;
|
||||
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* A collection of {@link EntityCategory entity categories}
|
||||
*/
|
||||
public class EntityCategories {
|
||||
|
||||
public static final EntityCategory ANIMAL = register("animal");
|
||||
public static final EntityCategory TAMEABLE = register("tameable",
|
||||
EntityTypes.HORSE, EntityTypes.OCELOT, EntityTypes.WOLF, EntityTypes.DONKEY,
|
||||
EntityTypes.MULE, EntityTypes.PARROT, EntityTypes.LLAMA);
|
||||
public static final EntityCategory VEHICLE = register("vehicle");
|
||||
public static final EntityCategory HOSTILE = register("hostile",
|
||||
EntityTypes.ZOMBIE);
|
||||
public static final EntityCategory HANGING = register("hanging",
|
||||
EntityTypes.PAINTING, EntityTypes.ITEM_FRAME);
|
||||
public static final EntityCategory TAMEABLE = register("tameable");
|
||||
public static final EntityCategory VEHICLE = register("vehicle");
|
||||
public static final EntityCategory HOSTILE = register("hostile");
|
||||
public static final EntityCategory HANGING = register("hanging");
|
||||
|
||||
public static EntityCategory register(final String id, final EntityType ... types) {
|
||||
final EntityCategory entityCategory = new EntityCategory(id, new HashSet<>(Arrays.asList(types)));
|
||||
public static EntityCategory register(final String id) {
|
||||
final EntityCategory entityCategory = new EntityCategory(id);
|
||||
EntityCategory.REGISTRY.register(entityCategory.getId(), entityCategory);
|
||||
return entityCategory;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.github.intellectualsites.plotsquared.plot.util.entity;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||
import com.sk89q.worldedit.registry.Category;
|
||||
import com.sk89q.worldedit.registry.Keyed;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
@ -39,15 +40,15 @@ public class EntityCategory extends Category<EntityType> implements Keyed {
|
||||
|
||||
public static final NamespacedRegistry<EntityCategory> REGISTRY = new NamespacedRegistry<>("entity type");
|
||||
|
||||
private final Set<EntityType> types;
|
||||
private final String key;
|
||||
|
||||
protected EntityCategory(final String id, final Set<EntityType> types) {
|
||||
protected EntityCategory(final String id) {
|
||||
super("plotsquared:" + id);
|
||||
this.types = types;
|
||||
this.key = id;
|
||||
}
|
||||
|
||||
@Override protected Set<EntityType> load() {
|
||||
return types;
|
||||
return WorldUtil.IMP.getTypesInCategory(this.key);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user