mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Entity categories implementation
This commit is contained in:
parent
5c1f0f51df
commit
e6c76ad3f3
@ -33,6 +33,9 @@ import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.entity.EntityCategories;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.entity.EntityCategory;
|
||||||
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -60,6 +63,19 @@ public class Debug extends SubCommand {
|
|||||||
Thread.currentThread().getName()));
|
Thread.currentThread().getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (args.length > 0 && "entitytypes".equalsIgnoreCase(args[0])) {
|
||||||
|
EntityCategories.init();
|
||||||
|
player.sendMessage(Captions.PREFIX.getTranslated() + "§cEntity Categories: ");
|
||||||
|
EntityCategory.REGISTRY.forEach(category -> {
|
||||||
|
final StringBuilder builder = new StringBuilder("§7- §6")
|
||||||
|
.append(category.getId()).append("§7: §6");
|
||||||
|
for (final EntityType entityType : category.getAll()) {
|
||||||
|
builder.append(entityType.getId()).append(" ");
|
||||||
|
}
|
||||||
|
player.sendMessage(Captions.PREFIX.getTranslated() + builder.toString());
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
|
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
|
||||||
StringBuilder msg = new StringBuilder();
|
StringBuilder msg = new StringBuilder();
|
||||||
for (Captions caption : Captions.values()) {
|
for (Captions caption : Captions.values()) {
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2020 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
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 EntityCategory register(final String id, final EntityType ... types) {
|
||||||
|
final EntityCategory entityCategory = new EntityCategory(id, new HashSet<>(Arrays.asList(types)));
|
||||||
|
EntityCategory.REGISTRY.register(entityCategory.getId(), entityCategory);
|
||||||
|
return entityCategory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init() {}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2020 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.github.intellectualsites.plotsquared.plot.util.entity;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.registry.Category;
|
||||||
|
import com.sk89q.worldedit.registry.Keyed;
|
||||||
|
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||||
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Categories to which an {@link com.sk89q.worldedit.entity.Entity} may belong
|
||||||
|
*/
|
||||||
|
public class EntityCategory extends Category<EntityType> implements Keyed {
|
||||||
|
|
||||||
|
public static final NamespacedRegistry<EntityCategory> REGISTRY = new NamespacedRegistry<>("entity type");
|
||||||
|
|
||||||
|
private final Set<EntityType> types;
|
||||||
|
|
||||||
|
protected EntityCategory(final String id, final Set<EntityType> types) {
|
||||||
|
super("plotsquared:" + id);
|
||||||
|
this.types = types;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected Set<EntityType> load() {
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user