From 6e536f81aca975fd44371b142eb9152fc1281d1c Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Sun, 12 Apr 2020 00:57:50 +0200 Subject: [PATCH] Add more entity categories --- .../plotsquared/bukkit/util/BukkitUtil.java | 22 +++++++++++++++++++ .../plotsquared/plot/commands/Debug.java | 10 +++++++++ .../plot/util/entity/EntityCategories.java | 3 +++ 3 files changed, 35 insertions(+) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java index 52bfb1645..eddd3473c 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java @@ -58,17 +58,25 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; import org.bukkit.block.data.Directional; import org.bukkit.block.data.type.WallSign; +import org.bukkit.entity.Ambient; import org.bukkit.entity.Animals; +import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Boss; +import org.bukkit.entity.EnderCrystal; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Ghast; import org.bukkit.entity.Golem; import org.bukkit.entity.Hanging; import org.bukkit.entity.Monster; +import org.bukkit.entity.NPC; +import org.bukkit.entity.Phantom; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.entity.Slime; import org.bukkit.entity.Tameable; import org.bukkit.entity.Vehicle; +import org.bukkit.entity.WaterMob; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -560,6 +568,8 @@ public class BukkitUtil extends WorldUtil { case "animal": { allowedInterfaces.add(Golem.class); allowedInterfaces.add(Animals.class); + allowedInterfaces.add(WaterMob.class); + allowedInterfaces.add(Ambient.class); } break; case "tameable": { allowedInterfaces.add(Tameable.class); @@ -571,10 +581,22 @@ public class BukkitUtil extends WorldUtil { allowedInterfaces.add(Monster.class); allowedInterfaces.add(Boss.class); allowedInterfaces.add(Slime.class); + allowedInterfaces.add(Ghast.class); + allowedInterfaces.add(Phantom.class); + allowedInterfaces.add(EnderCrystal.class); } break; case "hanging": { allowedInterfaces.add(Hanging.class); } break; + case "villager": { + allowedInterfaces.add(NPC.class); + } break; + case "projectile": { + allowedInterfaces.add(Projectile.class); + } break; + case "decoration": { + allowedInterfaces.add(ArmorStand.class); + } break; default: { PlotSquared.log(Captions.PREFIX + "Unknown entity category requested: " + category); } break; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Debug.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Debug.java index fef6f015b..92b701dd9 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Debug.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Debug.java @@ -37,6 +37,7 @@ import com.github.intellectualsites.plotsquared.plot.util.entity.EntityCategorie import com.github.intellectualsites.plotsquared.plot.util.entity.EntityCategory; import com.sk89q.worldedit.world.entity.EntityType; +import java.util.Comparator; import java.util.Map; @CommandDeclaration(command = "debug", @@ -74,6 +75,15 @@ public class Debug extends SubCommand { } player.sendMessage(Captions.PREFIX.getTranslated() + builder.toString()); }); + EntityType.REGISTRY.values().stream() + .sorted(Comparator.comparing(EntityType::getId)) + .forEach(entityType -> { + long categoryCount = EntityCategory.REGISTRY.values() + .stream() + .filter(category -> category.contains(entityType)) + .count(); + player.sendMessage(Captions.PREFIX.getTranslated() + entityType.getName() + " is in " + categoryCount + " categories"); + }); return true; } if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/entity/EntityCategories.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/entity/EntityCategories.java index 0f0ae5748..78a518715 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/entity/EntityCategories.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/entity/EntityCategories.java @@ -35,6 +35,9 @@ public class EntityCategories { public static final EntityCategory VEHICLE = register("vehicle"); public static final EntityCategory HOSTILE = register("hostile"); public static final EntityCategory HANGING = register("hanging"); + public static final EntityCategory VILLAGER = register("villager"); + public static final EntityCategory PROJECTILE = register("projectile"); + public static final EntityCategory DECORATION = register("decoration"); public static EntityCategory register(final String id) { final EntityCategory entityCategory = new EntityCategory(id);