Change anvil usage to build permissions and add use-anvil flag (#1644)

This commit is contained in:
JOO200 2020-10-17 23:51:39 +02:00 committed by GitHub
parent 60b16fc4c7
commit 5921be432c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -268,6 +268,11 @@ public class RegionProtectionListener extends AbstractListener {
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.CHEST_ACCESS));
what = "take that";
/* Anvils */
} else if (Materials.isAnvil(type)) {
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.USE_ANVIL));
what = "use that";
/* Beds */
} else if (Materials.isBed(type)) {
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT, Flags.SLEEP));

View File

@ -1263,6 +1263,10 @@ public final class Materials {
return Tag.BEDS.isTagged(material);
}
public static boolean isAnvil(Material material) {
return Tag.ANVIL.isTagged(material);
}
public static boolean isCoral(Material material) {
return Tag.CORAL_BLOCKS.isTagged(material) ||
Tag.CORAL_PLANTS.isTagged(material) ||
@ -1319,8 +1323,7 @@ public final class Materials {
|| Tag.DOORS.isTagged(material)
|| Tag.WOODEN_TRAPDOORS.isTagged(material)
|| Tag.FENCE_GATES.isTagged(material)
|| Tag.PRESSURE_PLATES.isTagged(material)
|| Tag.ANVIL.isTagged(material)) {
|| Tag.PRESSURE_PLATES.isTagged(material)) {
return true;
}
switch (material) {

View File

@ -71,6 +71,7 @@ public final class Flags {
public static final StateFlag ITEM_FRAME_ROTATE = register(new StateFlag("item-frame-rotation", false));
public static final StateFlag TRAMPLE_BLOCKS = register(new StateFlag("block-trampling", false));
public static final StateFlag FIREWORK_DAMAGE = register(new StateFlag("firework-damage", false));
public static final StateFlag USE_ANVIL = register(new StateFlag("use-anvil", false));
// These flags are similar to the ones above (used in tandem with BUILD),
// but their defaults are set to TRUE because it is more user friendly.