Use BlockTarget for blocks.

This commit is contained in:
Matthew Miller 2018-08-05 22:19:46 +10:00
parent d8dba47c0f
commit 3203a81710

View File

@ -22,6 +22,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.blacklist.target.BlockTarget;
import com.sk89q.worldguard.blacklist.target.ItemTarget;
import com.sk89q.worldguard.blacklist.target.Target;
import org.bukkit.ChatColor;
@ -186,7 +187,7 @@ public static boolean isIntensiveEntity(Entity entity) {
*/
public static Target createTarget(Block block) {
checkNotNull(block);
return new ItemTarget(BukkitAdapter.adapt(block.getBlockData()).getBlockType().getItemType());
return new BlockTarget(BukkitAdapter.adapt(block.getBlockData()).getBlockType());
}
/**
@ -208,6 +209,10 @@ public static Target createTarget(ItemStack item) {
*/
public static Target createTarget(Material material) {
checkNotNull(material);
return new ItemTarget(BukkitAdapter.asItemType(material));
if (material.isBlock()) {
return new BlockTarget(BukkitAdapter.asBlockType(material));
} else {
return new ItemTarget(BukkitAdapter.asItemType(material));
}
}
}