mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Added unbreakable tag
This commit is contained in:
parent
a770378025
commit
b14f0b76c0
@ -11,10 +11,10 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent;
|
import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -40,7 +40,7 @@ public class MinerAndroid extends ProgrammableAndroid {
|
|||||||
protected void dig(Block b, BlockMenu menu, Block block) {
|
protected void dig(Block b, BlockMenu menu, Block block) {
|
||||||
Collection<ItemStack> drops = block.getDrops(effectivePickaxe);
|
Collection<ItemStack> drops = block.getDrops(effectivePickaxe);
|
||||||
|
|
||||||
if (!MaterialCollections.getAllUnbreakableBlocks().contains(block.getType()) && !drops.isEmpty()) {
|
if (!SlimefunTag.UNBREAKABLE_MATERIALS.isTagged(block.getType()) && !drops.isEmpty()) {
|
||||||
OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")));
|
OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")));
|
||||||
|
|
||||||
if (SlimefunPlugin.getProtectionManager().hasPermission(owner, block.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
if (SlimefunPlugin.getProtectionManager().hasPermission(owner, block.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||||
@ -71,7 +71,7 @@ public class MinerAndroid extends ProgrammableAndroid {
|
|||||||
protected void moveAndDig(Block b, BlockMenu menu, BlockFace face, Block block) {
|
protected void moveAndDig(Block b, BlockMenu menu, BlockFace face, Block block) {
|
||||||
Collection<ItemStack> drops = block.getDrops(effectivePickaxe);
|
Collection<ItemStack> drops = block.getDrops(effectivePickaxe);
|
||||||
|
|
||||||
if (!MaterialCollections.getAllUnbreakableBlocks().contains(block.getType()) && !drops.isEmpty()) {
|
if (!SlimefunTag.UNBREAKABLE_MATERIALS.isTagged(block.getType()) && !drops.isEmpty()) {
|
||||||
OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")));
|
OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")));
|
||||||
|
|
||||||
if (SlimefunPlugin.getProtectionManager().hasPermission(owner, block.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
if (SlimefunPlugin.getProtectionManager().hasPermission(owner, block.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||||
|
@ -18,7 +18,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
|
import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||||
@ -49,7 +48,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
*/
|
*/
|
||||||
public class BlockPlacer extends SlimefunItem {
|
public class BlockPlacer extends SlimefunItem {
|
||||||
|
|
||||||
private final ItemSetting<List<String>> blacklist = new ItemSetting<>("unplaceable-blocks", MaterialCollections.getAllUnbreakableBlocks().stream().map(Material::name).collect(Collectors.toList()));
|
private final ItemSetting<List<String>> blacklist = new ItemSetting<>("unplaceable-blocks", SlimefunTag.UNBREAKABLE_MATERIALS.stream().map(Material::name).collect(Collectors.toList()));
|
||||||
|
|
||||||
public BlockPlacer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
public BlockPlacer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
super(category, item, recipeType, recipe);
|
super(category, item, recipeType, recipe);
|
||||||
|
@ -14,13 +14,13 @@ import org.bukkit.block.data.Waterlogged;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
@ -65,7 +65,7 @@ public class Crucible extends SimpleSlimefunItem<BlockUseHandler> implements Rec
|
|||||||
items.add(new ItemStack(Material.WATER_BUCKET));
|
items.add(new ItemStack(Material.WATER_BUCKET));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Material sapling : MaterialCollections.getAllTerracottaColors()) {
|
for (Material sapling : SlimefunTag.TERRACOTTA.getValues()) {
|
||||||
items.add(new ItemStack(sapling, 12));
|
items.add(new ItemStack(sapling, 12));
|
||||||
items.add(new ItemStack(Material.LAVA_BUCKET));
|
items.add(new ItemStack(Material.LAVA_BUCKET));
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import org.bukkit.event.block.BlockExplodeEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem;
|
||||||
@ -21,6 +20,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
||||||
@ -113,7 +113,7 @@ class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements NotPla
|
|||||||
if (b.isEmpty() || b.isLiquid()) {
|
if (b.isEmpty() || b.isLiquid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (MaterialCollections.getAllUnbreakableBlocks().contains(b.getType())) {
|
else if (SlimefunTag.UNBREAKABLE_MATERIALS.isTagged(b.getType())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (!b.getWorld().getWorldBorder().isInside(b.getLocation())) {
|
else if (!b.getWorld().getWorldBorder().isInside(b.getLocation())) {
|
||||||
|
@ -49,6 +49,11 @@ public enum SlimefunTag implements Tag<Material> {
|
|||||||
*/
|
*/
|
||||||
SHULKER_BOXES,
|
SHULKER_BOXES,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All command block variants
|
||||||
|
*/
|
||||||
|
COMMAND_BLOCKS,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Every mushroom type, red, brown and nether ones.
|
* Every mushroom type, red, brown and nether ones.
|
||||||
*/
|
*/
|
||||||
@ -103,6 +108,11 @@ public enum SlimefunTag implements Tag<Material> {
|
|||||||
*/
|
*/
|
||||||
SENSITIVE_MATERIALS,
|
SENSITIVE_MATERIALS,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These materials are just unbreakable, like bedrock for example.
|
||||||
|
*/
|
||||||
|
UNBREAKABLE_MATERIALS,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Materials which cannot be reliably placed using a {@link BlockPlacer}.
|
* Materials which cannot be reliably placed using a {@link BlockPlacer}.
|
||||||
*/
|
*/
|
||||||
|
7
src/main/resources/tags/command_blocks.json
Normal file
7
src/main/resources/tags/command_blocks.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"values" : [
|
||||||
|
"minecraft:command_block",
|
||||||
|
"minecraft:chain_command_block",
|
||||||
|
"minecraft:repeating_command_block"
|
||||||
|
]
|
||||||
|
}
|
13
src/main/resources/tags/unbreakable_materials.json
Normal file
13
src/main/resources/tags/unbreakable_materials.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"values" : [
|
||||||
|
"#slimefun:command_blocks",
|
||||||
|
"minecraft:bedrock",
|
||||||
|
"minecraft:barrier",
|
||||||
|
"minecraft:nether_portal",
|
||||||
|
"minecraft:end_portal",
|
||||||
|
"minecraft:end_portal_frame",
|
||||||
|
"minecraft:end_gateway",
|
||||||
|
"minecraft:structure_block",
|
||||||
|
"minecraft:structure_void"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user