mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-16 07:35:23 +01:00
Merge pull request #2089 from EngineHub/feat/mc-1.21
* Fix compilation for MC 1.21. Nothing tested yet. * Update Materials.java with 1.21 tags and materials * Fix ItemStack conversion on block place on MC 1.21 (#2093) * Fix ItemStack conversion on block place This issue is present in 1.21 because some materials do not convert 1:1 to item types. This throws an exception in the ItemStack constructor. Example: WALL_TORCH is a valid block but not a valid item, only TORCH is a valid item. So, use the item in hand instead, creating a copy with quantity set to 1, for issueing the use item event. * Use ItemStack as-is. Closes #2092. * Fix ItemStack conversion for spigot compatibility * Special handling for WindCharges * Do not call as a bulk event, because it has to check every blocks type * WindCharge -> AbstractWindCharge * Fix UseBlockFlag for multiple uses at the same time, add windburst-flag * Cleanup code * Handle vaults as use, crafters as chest-access. --------- Co-authored-by: Joo200 <github@joo200.de> Co-authored-by: Lennart <1535717+lenis0012@users.noreply.github.com> Co-authored-by: Brokkonaut <hannos17@gmx.de>
This commit is contained in:
commit
1bfae45484
@ -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 }
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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<Location>) target -> {
|
||||
boolean canUse;
|
||||
String what;
|
||||
final Material type = target.getBlock().getType();
|
||||
|
||||
/* Saplings, etc. */
|
||||
if (Materials.isConsideredBuildingIfUsed(type)) {
|
||||
|
@ -80,6 +80,10 @@ private static void putMaterialTag(Tag<Material> 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<Material> 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<Material> 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<Material> 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<Material> 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<Material> 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<Material> 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<Material> 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<Material> 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<Material> 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<Material> 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<PotionEffect> 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");
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -3,4 +3,4 @@ main: com.sk89q.worldguard.bukkit.WorldGuardPlugin
|
||||
version: "${internalVersion}"
|
||||
depend: [WorldEdit]
|
||||
softdepend: [CommandBook]
|
||||
api-version: "1.20"
|
||||
api-version: "1.21"
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user