From 0d2ed8205fb20ec5f0e7309e3d02d1a148af651a Mon Sep 17 00:00:00 2001 From: Joo200 Date: Thu, 7 Jul 2022 21:04:44 +0200 Subject: [PATCH] Properly protect chest_boats as vehicles --- .../worldguard/bukkit/util/Entities.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Entities.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Entities.java index ef3515ec..3ebf1a62 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Entities.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Entities.java @@ -101,8 +101,20 @@ public static boolean isRiddenOnUse(Entity entity) { * @return true if the type is a vehicle type */ public static boolean isVehicle(EntityType type) { - return type == EntityType.BOAT - || isMinecart(type); + return isBoat(type) || isMinecart(type); + } + + /** + * Test whether the given entity type is a Boat type. + * + * @param type the type + * @return true if the type is a Boat type + */ + public static boolean isBoat(EntityType type) { + return switch(type) { + case BOAT, CHEST_BOAT -> true; + default -> false; + }; } /** @@ -112,13 +124,11 @@ public static boolean isVehicle(EntityType type) { * @return true if the type is a Minecart type */ public static boolean isMinecart(EntityType type) { - return type == EntityType.MINECART - || type == EntityType.MINECART_CHEST - || type == EntityType.MINECART_COMMAND - || type == EntityType.MINECART_FURNACE - || type == EntityType.MINECART_HOPPER - || type == EntityType.MINECART_MOB_SPAWNER - || type == EntityType.MINECART_TNT; + return switch(type) { + case MINECART, MINECART_CHEST, MINECART_COMMAND, MINECART_FURNACE, + MINECART_HOPPER, MINECART_MOB_SPAWNER, MINECART_TNT -> true; + default -> false; + }; } /**