QOL #203
@ -39,10 +39,47 @@ import org.bukkit.util.RayTraceResult;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class PlaceItemUtils {
|
public class PlaceItemUtils {
|
||||||
|
|
||||||
|
// https://github.com/Articdive/ArticData/blob/1.20.1/1_20_1_tags/1_20_1_block_tags.json
|
||||||
|
// #minecraft:replaceable
|
||||||
|
private static final Set<String> replaceables;
|
||||||
|
|
||||||
|
static {
|
||||||
|
replaceables = new HashSet<>(Arrays.asList(
|
||||||
|
"minecraft:air",
|
||||||
|
"minecraft:water",
|
||||||
|
"minecraft:lava",
|
||||||
|
"minecraft:grass",
|
||||||
|
"minecraft:fern",
|
||||||
|
"minecraft:dead_bush",
|
||||||
|
"minecraft:seagrass",
|
||||||
|
"minecraft:tall_seagrass",
|
||||||
|
"minecraft:fire",
|
||||||
|
"minecraft:soul_fire",
|
||||||
|
"minecraft:snow",
|
||||||
|
"minecraft:vine",
|
||||||
|
"minecraft:glow_lichen",
|
||||||
|
"minecraft:light",
|
||||||
|
"minecraft:tall_grass",
|
||||||
|
"minecraft:large_fern",
|
||||||
|
"minecraft:structure_void",
|
||||||
|
"minecraft:void_air",
|
||||||
|
"minecraft:cave_air",
|
||||||
|
"minecraft:bubble_column",
|
||||||
|
"minecraft:warped_roots",
|
||||||
|
"minecraft:nether_sprouts",
|
||||||
|
"minecraft:crimson_roots",
|
||||||
|
"minecraft:hanging_roots"))
|
||||||
|
.stream()
|
||||||
|
.map(s -> s.substring(10))
|
||||||
|
.map(String::toUpperCase)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
private static final Map<Material, Material> ITEM_MATERIAL_TO_BLOCK_MATERIAL = new HashMap<>();
|
private static final Map<Material, Material> ITEM_MATERIAL_TO_BLOCK_MATERIAL = new HashMap<>();
|
||||||
private static final Map<Material, Material> BLOCK_MATERIAL_TO_WALL_BLOCK_MATERIAL = new HashMap<>();
|
private static final Map<Material, Material> BLOCK_MATERIAL_TO_WALL_BLOCK_MATERIAL = new HashMap<>();
|
||||||
|
|
||||||
@ -488,13 +525,8 @@ public class PlaceItemUtils {
|
|||||||
|
|
||||||
private boolean canPlace(Block block, BlockData blockData, boolean force) {
|
private boolean canPlace(Block block, BlockData blockData, boolean force) {
|
||||||
if (!force && !block.canPlace(blockData)) return false;
|
if (!force && !block.canPlace(blockData)) return false;
|
||||||
if (block.getType().name().equals("LIGHT")) return true;
|
|
||||||
if (block.getType().isSolid()) return false;
|
if (block.getType().isSolid()) return false;
|
||||||
if (block.getType() == Material.LADDER) return false;
|
return replaceables.contains(block.getType().name());
|
||||||
if (block.getType() == Material.SCAFFOLDING) return false;
|
|
||||||
if (block.getType() == Material.LEVER) return false;
|
|
||||||
if (block.getType().name().endsWith("_BUTTON")) return false;
|
|
||||||
return block.getPistonMoveReaction() == PistonMoveReaction.BREAK || block.isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren