diff --git a/worldguard-bukkit/build.gradle.kts b/worldguard-bukkit/build.gradle.kts index 12096fbc..6b0e5d5e 100644 --- a/worldguard-bukkit/build.gradle.kts +++ b/worldguard-bukkit/build.gradle.kts @@ -20,8 +20,8 @@ dependencies { "api"(project(":worldguard-core")) - "compileOnly"("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT") - "runtimeOnly"("org.spigotmc:spigot-api:1.20.6-R0.1-SNAPSHOT") { + "compileOnly"("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT") + "runtimeOnly"("org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT") { exclude("junit", "junit") } "api"("com.sk89q.worldedit:worldedit-bukkit:${Versions.WORLDEDIT}") { isTransitive = false } diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/BukkitUtil.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/BukkitUtil.java index c290b7cf..2d43d208 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/BukkitUtil.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/BukkitUtil.java @@ -55,23 +55,6 @@ public static int getPotionEffectBits(ItemStack item) { return item.getDurability() & 0x3F; } - /** - * Get a blacklist target for the given block. - * - * @param block the block - * @param effectiveMaterial The effective material, if different - * @return a target - */ - public static Target createTarget(Block block, Material effectiveMaterial) { - checkNotNull(block); - checkNotNull(block.getType()); - if (block.getType() == effectiveMaterial) { - return createTarget(block.getType()); - } else { - return createTarget(effectiveMaterial); - } - } - /** * Get a blacklist target for the given block. * diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/BlacklistListener.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/BlacklistListener.java index bfb569f5..3b907717 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/BlacklistListener.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/BlacklistListener.java @@ -96,7 +96,7 @@ public void onBreakBlock(final BreakBlockEvent event) { event.filter(target -> { if (!wcfg.getBlacklist().check( new BlockBreakBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(target), - createTarget(target.getBlock(), event.getEffectiveMaterial())), false, false)) { + createTarget(target.getBlock())), false, false)) { return false; } else if (!wcfg.getBlacklist().check( new ItemDestroyWithBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(target), @@ -124,7 +124,7 @@ public void onPlaceBlock(final PlaceBlockEvent event) { final LocalPlayer localPlayer = getPlugin().wrapPlayer(player); event.filter(target -> wcfg.getBlacklist().check(new BlockPlaceBlacklistEvent( - localPlayer, BukkitAdapter.asBlockVector(target), createTarget(target.getBlock(), event.getEffectiveMaterial())), false, false)); + localPlayer, BukkitAdapter.asBlockVector(target), createTarget(target.getBlock())), false, false)); } @EventHandler(ignoreCancelled = true) @@ -143,7 +143,7 @@ public void onUseBlock(final UseBlockEvent event) { final LocalPlayer localPlayer = getPlugin().wrapPlayer(player); event.filter(target -> wcfg.getBlacklist().check(new BlockInteractBlacklistEvent( - localPlayer, BukkitAdapter.asBlockVector(target), createTarget(target.getBlock(), event.getEffectiveMaterial())), false, false)); + localPlayer, BukkitAdapter.asBlockVector(target), createTarget(target.getBlock())), false, false)); } @EventHandler(ignoreCancelled = true) diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/BuildPermissionListener.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/BuildPermissionListener.java index 2ad78b4b..7958b685 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/BuildPermissionListener.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/BuildPermissionListener.java @@ -101,12 +101,14 @@ public void onUseBlock(final UseBlockEvent event) { if (rootCause instanceof Player) { final Player player = (Player) rootCause; - final Material material = event.getEffectiveMaterial(); - if (!hasBuildPermission(player, "block." + material.name().toLowerCase() + ".interact") - && !hasBuildPermission(player, "block.interact." + material.name().toLowerCase())) { + boolean blocked = event.filter(loc -> { + String blacklistName = loc.getBlock().getType().name().toLowerCase(); + return hasBuildPermission(player, "block." + blacklistName + ".interact") || + hasBuildPermission(player, "block.interact." + blacklistName); + }, true); + if (blocked && !event.isSilent()) { tellErrorMessage(player, event.getWorld()); - event.setCancelled(true); } } } diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java index e39a4c3c..14c49c2a 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java @@ -65,6 +65,7 @@ import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Waterlogged; import org.bukkit.block.data.type.Dispenser; +import org.bukkit.entity.AbstractWindCharge; import org.bukkit.entity.AreaEffectCloud; import org.bukkit.entity.Creeper; import org.bukkit.entity.Entity; @@ -218,8 +219,8 @@ public void onBlockPlace(BlockPlaceEvent event) { Events.fireToCancel(event, new BreakBlockEvent(event, create(event.getPlayer()), previousState.getLocation(), previousState.getType())); } - if (!event.isCancelled()) { - ItemStack itemStack = new ItemStack(event.getBlockPlaced().getType(), 1); + ItemStack itemStack = event.getItemInHand(); + if (!event.isCancelled() && itemStack.getType() != Material.AIR) { Events.fireToCancel(event, new UseItemEvent(event, create(event.getPlayer()), event.getPlayer().getWorld(), itemStack)); } @@ -357,6 +358,13 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) { @EventHandler(ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { Entity entity = event.getEntity(); + if (entity instanceof AbstractWindCharge) { + UseBlockEvent useEvent = new UseBlockEvent(event, create(entity), event.getLocation().getWorld(), event.blockList(), Material.AIR); + useEvent.getRelevantFlags().add(Flags.WIND_CHARGE_BURST); + useEvent.setSilent(true); + Events.fireBulkEventToCancel(event, useEvent); + return; + } Events.fireBulkEventToCancel(event, new BreakBlockEvent(event, create(entity), event.getLocation().getWorld(), event.blockList(), Material.AIR)); if (entity instanceof Creeper) { Cause.untrackParentCause(entity); diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java index e562a3be..f5942d75 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java @@ -244,13 +244,13 @@ public void onUseBlock(final UseBlockEvent event) { if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled if (isWhitelisted(event.getCause(), event.getWorld(), false)) return; // Whitelisted cause - final Material type = event.getEffectiveMaterial(); final RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery(); final RegionAssociable associable = createRegionAssociable(event.getCause()); event.filter((Predicate) target -> { boolean canUse; String what; + final Material type = target.getBlock().getType(); /* Saplings, etc. */ if (Materials.isConsideredBuildingIfUsed(type)) { diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Materials.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Materials.java index 6cdd4924..231a0bbe 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Materials.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Materials.java @@ -80,6 +80,10 @@ private static void putMaterialTag(Tag tag, Integer value) { ENTITY_ITEMS.put(EntityType.ARMOR_STAND, Material.ARMOR_STAND); ENTITY_ITEMS.put(EntityType.END_CRYSTAL, Material.END_CRYSTAL); + // preset some tags to a default value, override some of them: + putMaterialTag(Tag.DOORS, MODIFIED_ON_RIGHT); + putMaterialTag(Tag.TRAPDOORS, MODIFIED_ON_RIGHT); + MATERIAL_FLAGS.put(Material.AIR, 0); MATERIAL_FLAGS.put(Material.STONE, 0); MATERIAL_FLAGS.put(Material.GRASS_BLOCK, 0); @@ -150,12 +154,6 @@ private static void putMaterialTag(Tag tag, Integer value) { MATERIAL_FLAGS.put(Material.CAKE, MODIFIED_ON_RIGHT); MATERIAL_FLAGS.put(Material.REPEATER, MODIFIED_ON_RIGHT); // MATERIAL_FLAGS.put(Material.STAINED_GLASS, 0); - MATERIAL_FLAGS.put(Material.ACACIA_TRAPDOOR, MODIFIED_ON_RIGHT); - MATERIAL_FLAGS.put(Material.BIRCH_TRAPDOOR, MODIFIED_ON_RIGHT); - MATERIAL_FLAGS.put(Material.DARK_OAK_TRAPDOOR, MODIFIED_ON_RIGHT); - MATERIAL_FLAGS.put(Material.JUNGLE_TRAPDOOR, MODIFIED_ON_RIGHT); - MATERIAL_FLAGS.put(Material.OAK_TRAPDOOR, MODIFIED_ON_RIGHT); - MATERIAL_FLAGS.put(Material.SPRUCE_TRAPDOOR, MODIFIED_ON_RIGHT); MATERIAL_FLAGS.put(Material.INFESTED_STONE, 0); MATERIAL_FLAGS.put(Material.INFESTED_STONE_BRICKS, 0); MATERIAL_FLAGS.put(Material.INFESTED_MOSSY_STONE_BRICKS, 0); @@ -227,11 +225,6 @@ private static void putMaterialTag(Tag tag, Integer value) { MATERIAL_FLAGS.put(Material.IRON_TRAPDOOR, 0); MATERIAL_FLAGS.put(Material.RED_SANDSTONE, 0); MATERIAL_FLAGS.put(Material.RED_SANDSTONE_STAIRS, 0); - MATERIAL_FLAGS.put(Material.SPRUCE_DOOR, MODIFIED_ON_RIGHT); - MATERIAL_FLAGS.put(Material.BIRCH_DOOR, MODIFIED_ON_RIGHT); - MATERIAL_FLAGS.put(Material.JUNGLE_DOOR, MODIFIED_ON_RIGHT); - MATERIAL_FLAGS.put(Material.ACACIA_DOOR, MODIFIED_ON_RIGHT); - MATERIAL_FLAGS.put(Material.DARK_OAK_DOOR, MODIFIED_ON_RIGHT); MATERIAL_FLAGS.put(Material.DIRT_PATH, 0); MATERIAL_FLAGS.put(Material.CHORUS_PLANT, 0); @@ -247,7 +240,7 @@ private static void putMaterialTag(Tag tag, Integer value) { MATERIAL_FLAGS.put(Material.PURPUR_SLAB, 0); MATERIAL_FLAGS.put(Material.STRUCTURE_BLOCK, MODIFIED_ON_LEFT | MODIFIED_ON_RIGHT); MATERIAL_FLAGS.put(Material.REPEATING_COMMAND_BLOCK, MODIFIED_ON_RIGHT); - MATERIAL_FLAGS.put(Material.CHAIN_COMMAND_BLOCK , MODIFIED_ON_RIGHT); + MATERIAL_FLAGS.put(Material.CHAIN_COMMAND_BLOCK, MODIFIED_ON_RIGHT); MATERIAL_FLAGS.put(Material.MAGMA_BLOCK, 0); MATERIAL_FLAGS.put(Material.NETHER_WART_BLOCK, 0); @@ -677,7 +670,6 @@ private static void putMaterialTag(Tag tag, Integer value) { MATERIAL_FLAGS.put(Material.CRIMSON_FUNGUS, 0); MATERIAL_FLAGS.put(Material.CRIMSON_NYLIUM, 0); MATERIAL_FLAGS.put(Material.CRIMSON_ROOTS, 0); - MATERIAL_FLAGS.put(Material.CRIMSON_TRAPDOOR, MODIFIED_ON_RIGHT); MATERIAL_FLAGS.put(Material.CRYING_OBSIDIAN, 0); MATERIAL_FLAGS.put(Material.GILDED_BLACKSTONE, 0); MATERIAL_FLAGS.put(Material.LODESTONE, 0); @@ -718,7 +710,6 @@ private static void putMaterialTag(Tag tag, Integer value) { MATERIAL_FLAGS.put(Material.WARPED_FUNGUS_ON_A_STICK, 0); MATERIAL_FLAGS.put(Material.WARPED_NYLIUM, 0); MATERIAL_FLAGS.put(Material.WARPED_ROOTS, 0); - MATERIAL_FLAGS.put(Material.WARPED_TRAPDOOR, MODIFIED_ON_RIGHT); MATERIAL_FLAGS.put(Material.WARPED_WART_BLOCK, 0); MATERIAL_FLAGS.put(Material.WEEPING_VINES, 0); MATERIAL_FLAGS.put(Material.WEEPING_VINES_PLANT, 0); @@ -843,9 +834,47 @@ private static void putMaterialTag(Tag tag, Integer value) { MATERIAL_FLAGS.put(Material.ARMADILLO_SCUTE, 0); MATERIAL_FLAGS.put(Material.WOLF_ARMOR, 0); - // Generated via tag - putMaterialTag(Tag.WOODEN_DOORS, MODIFIED_ON_RIGHT); - putMaterialTag(Tag.WOODEN_TRAPDOORS, MODIFIED_ON_RIGHT); + // 1.21 + MATERIAL_FLAGS.put(Material.CHISELED_TUFF, 0); + MATERIAL_FLAGS.put(Material.POLISHED_TUFF, 0); + MATERIAL_FLAGS.put(Material.TUFF_BRICKS, 0); + MATERIAL_FLAGS.put(Material.CHISELED_TUFF_BRICKS, 0); + MATERIAL_FLAGS.put(Material.HEAVY_CORE, 0); + MATERIAL_FLAGS.put(Material.CHISELED_COPPER, 0); + MATERIAL_FLAGS.put(Material.EXPOSED_CHISELED_COPPER, 0); + MATERIAL_FLAGS.put(Material.WEATHERED_CHISELED_COPPER, 0); + MATERIAL_FLAGS.put(Material.OXIDIZED_CHISELED_COPPER, 0); + MATERIAL_FLAGS.put(Material.WAXED_CHISELED_COPPER, 0); + MATERIAL_FLAGS.put(Material.WAXED_EXPOSED_CHISELED_COPPER, 0); + MATERIAL_FLAGS.put(Material.WAXED_WEATHERED_CHISELED_COPPER, 0); + MATERIAL_FLAGS.put(Material.WAXED_OXIDIZED_CHISELED_COPPER, 0); + MATERIAL_FLAGS.put(Material.CRAFTER, 0); + MATERIAL_FLAGS.put(Material.FLOW_BANNER_PATTERN, 0); + MATERIAL_FLAGS.put(Material.GUSTER_BANNER_PATTERN, 0); + MATERIAL_FLAGS.put(Material.COPPER_GRATE, 0); + MATERIAL_FLAGS.put(Material.WEATHERED_COPPER_GRATE, 0); + MATERIAL_FLAGS.put(Material.EXPOSED_COPPER_GRATE, 0); + MATERIAL_FLAGS.put(Material.OXIDIZED_COPPER_GRATE, 0); + MATERIAL_FLAGS.put(Material.WAXED_COPPER_GRATE, 0); + MATERIAL_FLAGS.put(Material.WAXED_WEATHERED_COPPER_GRATE, 0); + MATERIAL_FLAGS.put(Material.WAXED_EXPOSED_COPPER_GRATE, 0); + MATERIAL_FLAGS.put(Material.WAXED_OXIDIZED_COPPER_GRATE, 0); + MATERIAL_FLAGS.put(Material.COPPER_BULB, 0); + MATERIAL_FLAGS.put(Material.WEATHERED_COPPER_BULB, 0); + MATERIAL_FLAGS.put(Material.EXPOSED_COPPER_BULB, 0); + MATERIAL_FLAGS.put(Material.OXIDIZED_COPPER_BULB, 0); + MATERIAL_FLAGS.put(Material.WAXED_COPPER_BULB, 0); + MATERIAL_FLAGS.put(Material.WAXED_WEATHERED_COPPER_BULB, 0); + MATERIAL_FLAGS.put(Material.WAXED_EXPOSED_COPPER_BULB, 0); + MATERIAL_FLAGS.put(Material.WAXED_OXIDIZED_COPPER_BULB, 0); + MATERIAL_FLAGS.put(Material.TRIAL_SPAWNER, 0); + MATERIAL_FLAGS.put(Material.TRIAL_KEY, 0); + MATERIAL_FLAGS.put(Material.OMINOUS_TRIAL_KEY, 0); + MATERIAL_FLAGS.put(Material.VAULT, MODIFIED_ON_RIGHT); + MATERIAL_FLAGS.put(Material.OMINOUS_BOTTLE, 0); + MATERIAL_FLAGS.put(Material.BREEZE_ROD, 0); + MATERIAL_FLAGS.put(Material.WIND_CHARGE, 0); + putMaterialTag(Tag.SHULKER_BOXES, MODIFIED_ON_RIGHT); putMaterialTag(Tag.ITEMS_BOATS, 0); putMaterialTag(Tag.BANNERS, 0); @@ -864,7 +893,6 @@ private static void putMaterialTag(Tag tag, Integer value) { putMaterialTag(Tag.ALL_SIGNS, 0); putMaterialTag(Tag.SMALL_FLOWERS, 0); putMaterialTag(Tag.BEDS, MODIFIED_ON_RIGHT); - putMaterialTag(Tag.ITEMS_MUSIC_DISCS, 0); putMaterialTag(Tag.ITEMS_BANNERS, 0); putMaterialTag(Tag.FENCE_GATES, MODIFIED_ON_RIGHT); putMaterialTag(Tag.FENCES, 0); @@ -903,6 +931,9 @@ private static void putMaterialTag(Tag tag, Integer value) { if (isSpawnEgg(material)) { MATERIAL_FLAGS.put(material, 0); } + if (material.name().startsWith("MUSIC_DISC_")) { + MATERIAL_FLAGS.put(material, 0); + } if (!MATERIAL_FLAGS.containsKey(material)) { logger.fine("Missing material definition for " + (material.isBlock() ? "block " : "item ") + material.name()); } @@ -910,15 +941,15 @@ private static void putMaterialTag(Tag tag, Integer value) { // DAMAGE_EFFECTS.add(PotionEffectType.SPEED); DAMAGE_EFFECTS.add(PotionEffectType.SLOWNESS); -// DAMAGE_EFFECTS.add(PotionEffectType.FAST_DIGGING); +// DAMAGE_EFFECTS.add(PotionEffectType.HASTE); DAMAGE_EFFECTS.add(PotionEffectType.MINING_FATIGUE); -// DAMAGE_EFFECTS.add(PotionEffectType.INCREASE_DAMAGE); -// DAMAGE_EFFECTS.add(PotionEffectType.HEAL); +// DAMAGE_EFFECTS.add(PotionEffectType.STRENGTH); +// DAMAGE_EFFECTS.add(PotionEffectType.INSTANT_HEALTH); DAMAGE_EFFECTS.add(PotionEffectType.INSTANT_DAMAGE); -// DAMAGE_EFFECTS.add(PotionEffectType.JUMP); +// DAMAGE_EFFECTS.add(PotionEffectType.JUMP_BOOST); DAMAGE_EFFECTS.add(PotionEffectType.NAUSEA); // DAMAGE_EFFECTS.add(PotionEffectType.REGENERATION); -// DAMAGE_EFFECTS.add(PotionEffectType.DAMAGE_RESISTANCE); +// DAMAGE_EFFECTS.add(PotionEffectType.RESISTANCE); // DAMAGE_EFFECTS.add(PotionEffectType.FIRE_RESISTANCE); // DAMAGE_EFFECTS.add(PotionEffectType.WATER_BREATHING); // DAMAGE_EFFECTS.add(PotionEffectType.INVISIBILITY); @@ -941,6 +972,11 @@ private static void putMaterialTag(Tag tag, Integer value) { DAMAGE_EFFECTS.add(PotionEffectType.BAD_OMEN); // DAMAGE_EFFECTS.add(PotionEffectType.HERO_OF_THE_VILLAGE); DAMAGE_EFFECTS.add(PotionEffectType.DARKNESS); + DAMAGE_EFFECTS.add(PotionEffectType.TRIAL_OMEN); + DAMAGE_EFFECTS.add(PotionEffectType.WIND_CHARGED); + DAMAGE_EFFECTS.add(PotionEffectType.WEAVING); + DAMAGE_EFFECTS.add(PotionEffectType.OOZING); + DAMAGE_EFFECTS.add(PotionEffectType.INFESTED); } private Materials() { @@ -1127,6 +1163,7 @@ public static boolean isInventoryBlock(Material material) { || material == Material.BLAST_FURNACE || material == Material.SMOKER || material == Material.CHISELED_BOOKSHELF + || material == Material.CRAFTER || Tag.ITEMS_CHEST_BOATS.isTagged(material) || Tag.SHULKER_BOXES.isTagged(material); } @@ -1140,10 +1177,11 @@ public static EntityType getEntitySpawnEgg(Material material) { case ALLAY_SPAWN_EGG -> EntityType.ALLAY; case ARMADILLO_SPAWN_EGG -> EntityType.ARMADILLO; case AXOLOTL_SPAWN_EGG -> EntityType.AXOLOTL; - case SPIDER_SPAWN_EGG -> EntityType.SPIDER; case BAT_SPAWN_EGG -> EntityType.BAT; case BEE_SPAWN_EGG -> EntityType.BEE; case BLAZE_SPAWN_EGG -> EntityType.BLAZE; + case BOGGED_SPAWN_EGG -> EntityType.BOGGED; + case BREEZE_SPAWN_EGG -> EntityType.BREEZE; case CAT_SPAWN_EGG -> EntityType.CAT; case CAMEL_SPAWN_EGG -> EntityType.CAMEL; case CAVE_SPIDER_SPAWN_EGG -> EntityType.CAVE_SPIDER; @@ -1193,6 +1231,7 @@ public static EntityType getEntitySpawnEgg(Material material) { case SLIME_SPAWN_EGG -> EntityType.SLIME; case SNIFFER_SPAWN_EGG -> EntityType.SNIFFER; case SNOW_GOLEM_SPAWN_EGG -> EntityType.SNOW_GOLEM; + case SPIDER_SPAWN_EGG -> EntityType.SPIDER; case SQUID_SPAWN_EGG -> EntityType.SQUID; case STRAY_SPAWN_EGG -> EntityType.STRAY; case STRIDER_SPAWN_EGG -> EntityType.STRIDER; @@ -1284,7 +1323,7 @@ public static boolean isUseFlagApplicable(Material material) { } return switch (material) { case LEVER, LECTERN, ENCHANTING_TABLE, BELL, LOOM, - CARTOGRAPHY_TABLE, STONECUTTER, GRINDSTONE -> true; + CARTOGRAPHY_TABLE, STONECUTTER, GRINDSTONE, VAULT -> true; default -> false; }; } @@ -1367,15 +1406,13 @@ public static boolean hasDamageEffect(Collection effects) { * @return true if equippable armor */ public static boolean isArmor(Material type) { + if (Tag.ITEMS_HEAD_ARMOR.isTagged(type) || Tag.ITEMS_CHEST_ARMOR.isTagged(type) || + Tag.ITEMS_LEG_ARMOR.isTagged(type) || Tag.ITEMS_FOOT_ARMOR.isTagged(type) || + Tag.ITEMS_SKULLS.isTagged(type)) { + return true; + } return switch (type) { - case LEATHER_HELMET, LEATHER_CHESTPLATE, LEATHER_LEGGINGS, LEATHER_BOOTS, - CHAINMAIL_HELMET, CHAINMAIL_CHESTPLATE, CHAINMAIL_LEGGINGS, CHAINMAIL_BOOTS, - IRON_HELMET, IRON_CHESTPLATE, IRON_LEGGINGS, IRON_BOOTS, - DIAMOND_HELMET, DIAMOND_CHESTPLATE, DIAMOND_LEGGINGS, DIAMOND_BOOTS, - GOLDEN_HELMET, GOLDEN_CHESTPLATE, GOLDEN_LEGGINGS, GOLDEN_BOOTS, - NETHERITE_HELMET, NETHERITE_CHESTPLATE, NETHERITE_LEGGINGS, NETHERITE_BOOTS, - TURTLE_HELMET, ELYTRA -> - true; + case CARVED_PUMPKIN, ELYTRA -> true; default -> false; }; } @@ -1466,27 +1503,18 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat public static boolean isFire(Material type) { return type == Material.FIRE || type == Material.SOUL_FIRE; } - + public static boolean isWaxedCopper(Material type) { - return switch (type) { - case WAXED_COPPER_BLOCK, WAXED_EXPOSED_COPPER, WAXED_WEATHERED_COPPER, WAXED_OXIDIZED_COPPER, - WAXED_CUT_COPPER, WAXED_EXPOSED_CUT_COPPER, WAXED_WEATHERED_CUT_COPPER, - WAXED_OXIDIZED_CUT_COPPER, WAXED_CUT_COPPER_STAIRS, WAXED_EXPOSED_CUT_COPPER_STAIRS, - WAXED_WEATHERED_CUT_COPPER_STAIRS, WAXED_OXIDIZED_CUT_COPPER_STAIRS, WAXED_CUT_COPPER_SLAB, - WAXED_EXPOSED_CUT_COPPER_SLAB, WAXED_WEATHERED_CUT_COPPER_SLAB, WAXED_OXIDIZED_CUT_COPPER_SLAB -> - true; - default -> false; - }; + // copied from the MaterialTags class in Paper + return type.name().startsWith("WAXED_") && type.name().contains("COPPER"); } - + public static boolean isUnwaxedCopper(Material type) { + // copied from the MaterialTags class in Paper return switch (type) { - case COPPER_BLOCK, EXPOSED_COPPER, WEATHERED_COPPER, OXIDIZED_COPPER, CUT_COPPER, - EXPOSED_CUT_COPPER, WEATHERED_CUT_COPPER, OXIDIZED_CUT_COPPER, CUT_COPPER_STAIRS, - EXPOSED_CUT_COPPER_STAIRS, WEATHERED_CUT_COPPER_STAIRS, OXIDIZED_CUT_COPPER_STAIRS, - CUT_COPPER_SLAB, EXPOSED_CUT_COPPER_SLAB, WEATHERED_CUT_COPPER_SLAB, OXIDIZED_CUT_COPPER_SLAB -> - true; - default -> false; + case COPPER_BLOCK, CHISELED_COPPER, COPPER_DOOR, COPPER_TRAPDOOR, COPPER_GRATE, COPPER_BULB -> true; + default -> type.name().startsWith("EXPOSED_") || type.name().startsWith("WEATHERED_") || + type.name().startsWith("OXIDIZED_") || type.name().startsWith("CUT_COPPER"); }; } diff --git a/worldguard-bukkit/src/main/resources/plugin.yml b/worldguard-bukkit/src/main/resources/plugin.yml index 223be72f..bccbfe3b 100644 --- a/worldguard-bukkit/src/main/resources/plugin.yml +++ b/worldguard-bukkit/src/main/resources/plugin.yml @@ -3,4 +3,4 @@ main: com.sk89q.worldguard.bukkit.WorldGuardPlugin version: "${internalVersion}" depend: [WorldEdit] softdepend: [CommandBook] -api-version: "1.20" +api-version: "1.21" diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/Flags.java b/worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/Flags.java index 24cc675e..5702cfe1 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/Flags.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/Flags.java @@ -93,6 +93,7 @@ public final class Flags { public static final StateFlag ENDERDRAGON_BLOCK_DAMAGE = register(new StateFlag("enderdragon-block-damage", true)); public static final StateFlag GHAST_FIREBALL = register(new StateFlag("ghast-fireball", true)); public static final StateFlag OTHER_EXPLOSION = register(new StateFlag("other-explosion", true)); + public static final StateFlag WIND_CHARGE_BURST = register(new StateFlag("wind-charge-burst", true)); public static final StateFlag WITHER_DAMAGE = register(new StateFlag("wither-damage", true)); public static final StateFlag ENDER_BUILD = register(new StateFlag("enderman-grief", true)); public static final StateFlag SNOWMAN_TRAILS = register(new StateFlag("snowman-trails", true));