mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-27 13:07:29 +01:00
Revert USE flag's functionality to 5.x, add new INTERACT flag.
This commit is contained in:
parent
7580583fbf
commit
93ced5ca7a
@ -254,22 +254,27 @@ public boolean apply(Location target) {
|
|||||||
|
|
||||||
/* Inventory */
|
/* Inventory */
|
||||||
} else if (Materials.isInventoryBlock(type)) {
|
} else if (Materials.isInventoryBlock(type)) {
|
||||||
canUse = query.testBuild(target, associable, DefaultFlag.USE, DefaultFlag.CHEST_ACCESS);
|
canUse = query.testBuild(target, associable, DefaultFlag.INTERACT, DefaultFlag.CHEST_ACCESS);
|
||||||
what = "open that";
|
what = "open that";
|
||||||
|
|
||||||
/* Beds */
|
/* Beds */
|
||||||
} else if (type == Material.BED_BLOCK) {
|
} else if (type == Material.BED_BLOCK) {
|
||||||
canUse = query.testBuild(target, associable, DefaultFlag.USE, DefaultFlag.SLEEP);
|
canUse = query.testBuild(target, associable, DefaultFlag.INTERACT, DefaultFlag.SLEEP);
|
||||||
what = "sleep";
|
what = "sleep";
|
||||||
|
|
||||||
/* TNT */
|
/* TNT */
|
||||||
} else if (type == Material.TNT) {
|
} else if (type == Material.TNT) {
|
||||||
canUse = query.testBuild(target, associable, DefaultFlag.TNT);
|
canUse = query.testBuild(target, associable, DefaultFlag.INTERACT, DefaultFlag.TNT);
|
||||||
what = "use explosives";
|
what = "use explosives";
|
||||||
|
|
||||||
|
/* Legacy USE flag */
|
||||||
|
} else if (Materials.isUseFlagApplicable(type)) {
|
||||||
|
canUse = query.testBuild(target, associable, DefaultFlag.INTERACT, DefaultFlag.USE);
|
||||||
|
what = "use that";
|
||||||
|
|
||||||
/* Everything else */
|
/* Everything else */
|
||||||
} else {
|
} else {
|
||||||
canUse = query.testBuild(target, associable, DefaultFlag.USE);
|
canUse = query.testBuild(target, associable, DefaultFlag.INTERACT);
|
||||||
what = "use that";
|
what = "use that";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +388,7 @@ public void onUseEntity(UseEntityEvent event) {
|
|||||||
|
|
||||||
/* Everything else */
|
/* Everything else */
|
||||||
} else {
|
} else {
|
||||||
canUse = query.testBuild(target, associable, DefaultFlag.USE);
|
canUse = query.testBuild(target, associable, DefaultFlag.INTERACT);
|
||||||
what = "use that";
|
what = "use that";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,7 +443,7 @@ public void onDamageEntity(DamageEntityEvent event) {
|
|||||||
|
|
||||||
/* Everything else */
|
/* Everything else */
|
||||||
} else {
|
} else {
|
||||||
canDamage = query.testBuild(target, associable, DefaultFlag.USE);
|
canDamage = query.testBuild(target, associable, DefaultFlag.INTERACT);
|
||||||
what = "hit that";
|
what = "hit that";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,7 +463,7 @@ public void onVehicleExit(VehicleExitEvent event) {
|
|||||||
if (!isWhitelisted(Cause.create(player), vehicle.getWorld())) {
|
if (!isWhitelisted(Cause.create(player), vehicle.getWorld())) {
|
||||||
RegionQuery query = getPlugin().getRegionContainer().createQuery();
|
RegionQuery query = getPlugin().getRegionContainer().createQuery();
|
||||||
Location location = vehicle.getLocation();
|
Location location = vehicle.getLocation();
|
||||||
if (!query.testBuild(location, player, DefaultFlag.USE)) {
|
if (!query.testBuild(location, player, DefaultFlag.INTERACT)) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
Long lastTime = WGMetadata.getIfPresent(player, DISEMBARK_MESSAGE_KEY, Long.class);
|
Long lastTime = WGMetadata.getIfPresent(player, DISEMBARK_MESSAGE_KEY, Long.class);
|
||||||
if (lastTime == null || now - lastTime >= LAST_MESSAGE_DELAY) {
|
if (lastTime == null || now - lastTime >= LAST_MESSAGE_DELAY) {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
|
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -576,6 +577,40 @@ public static boolean isInventoryBlock(Material material) {
|
|||||||
|| material == Material.DROPPER;
|
|| material == Material.DROPPER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test whether the given material is affected by
|
||||||
|
* {@link DefaultFlag#USE}.
|
||||||
|
*
|
||||||
|
* <p>Generally, materials that are considered by this method are those
|
||||||
|
* that are not inventories but can be used.</p>
|
||||||
|
*
|
||||||
|
* @param material the material
|
||||||
|
* @return true if covered by the use flag
|
||||||
|
*/
|
||||||
|
public static boolean isUseFlagApplicable(Material material) {
|
||||||
|
return material == Material.LEVER
|
||||||
|
|| material == Material.STONE_BUTTON
|
||||||
|
|| material == Material.WOOD_BUTTON
|
||||||
|
|| material == Material.NOTE_BLOCK
|
||||||
|
|| material == Material.DIODE_BLOCK_OFF
|
||||||
|
|| material == Material.DIODE_BLOCK_ON
|
||||||
|
|| material == Material.WOODEN_DOOR
|
||||||
|
|| material == Material.TRAP_DOOR
|
||||||
|
|| material == Material.FENCE_GATE
|
||||||
|
|| material == Material.JUKEBOX
|
||||||
|
|| material == Material.DISPENSER
|
||||||
|
|| material == Material.FURNACE
|
||||||
|
|| material == Material.BURNING_FURNACE
|
||||||
|
|| material == Material.WORKBENCH
|
||||||
|
|| material == Material.BREWING_STAND
|
||||||
|
|| material == Material.ENCHANTMENT_TABLE
|
||||||
|
|| material == Material.CAULDRON
|
||||||
|
|| material == Material.BEACON
|
||||||
|
|| material == Material.ANVIL
|
||||||
|
|| material == Material.HOPPER
|
||||||
|
|| material == Material.DROPPER;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether the given type is Redstone ore.
|
* Test whether the given type is Redstone ore.
|
||||||
*
|
*
|
||||||
|
@ -47,6 +47,7 @@ public final class DefaultFlag {
|
|||||||
public static final StateFlag BLOCK_BREAK = new StateFlag("block-break", false);
|
public static final StateFlag BLOCK_BREAK = new StateFlag("block-break", false);
|
||||||
public static final StateFlag BLOCK_PLACE = new StateFlag("block-place", false);
|
public static final StateFlag BLOCK_PLACE = new StateFlag("block-place", false);
|
||||||
public static final StateFlag USE = new StateFlag("use", false);
|
public static final StateFlag USE = new StateFlag("use", false);
|
||||||
|
public static final StateFlag INTERACT = new StateFlag("interact", false);
|
||||||
public static final StateFlag PVP = new StateFlag("pvp", false);
|
public static final StateFlag PVP = new StateFlag("pvp", false);
|
||||||
public static final StateFlag SLEEP = new StateFlag("sleep", false);
|
public static final StateFlag SLEEP = new StateFlag("sleep", false);
|
||||||
public static final StateFlag TNT = new StateFlag("tnt", false);
|
public static final StateFlag TNT = new StateFlag("tnt", false);
|
||||||
@ -128,7 +129,7 @@ public final class DefaultFlag {
|
|||||||
|
|
||||||
public static final Flag<?>[] flagsList = new Flag<?>[] {
|
public static final Flag<?>[] flagsList = new Flag<?>[] {
|
||||||
PASSTHROUGH, BUILD, CONSTRUCT, BLOCK_BREAK, BLOCK_PLACE, PVP, CHEST_ACCESS, PISTONS,
|
PASSTHROUGH, BUILD, CONSTRUCT, BLOCK_BREAK, BLOCK_PLACE, PVP, CHEST_ACCESS, PISTONS,
|
||||||
TNT, LIGHTER, USE, PLACE_VEHICLE, DESTROY_VEHICLE, SLEEP,
|
TNT, LIGHTER, USE, INTERACT, PLACE_VEHICLE, DESTROY_VEHICLE, SLEEP,
|
||||||
MOB_DAMAGE, MOB_SPAWNING, DENY_SPAWN, INVINCIBILITY, EXP_DROPS,
|
MOB_DAMAGE, MOB_SPAWNING, DENY_SPAWN, INVINCIBILITY, EXP_DROPS,
|
||||||
CREEPER_EXPLOSION, OTHER_EXPLOSION, ENDERDRAGON_BLOCK_DAMAGE, GHAST_FIREBALL, ENDER_BUILD,
|
CREEPER_EXPLOSION, OTHER_EXPLOSION, ENDERDRAGON_BLOCK_DAMAGE, GHAST_FIREBALL, ENDER_BUILD,
|
||||||
DENY_MESSAGE, GREET_MESSAGE, FAREWELL_MESSAGE, NOTIFY_ENTER, NOTIFY_LEAVE,
|
DENY_MESSAGE, GREET_MESSAGE, FAREWELL_MESSAGE, NOTIFY_ENTER, NOTIFY_LEAVE,
|
||||||
|
Loading…
Reference in New Issue
Block a user