1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
This commit is contained in:
TheBusyBiscuit 2020-09-11 00:07:26 +02:00
parent 6fd90bde4f
commit 74edbe499c
8 changed files with 103 additions and 19 deletions

View File

@ -24,12 +24,16 @@
## Release Candidate 17 (TBD)
#### Additions
* (API) Added custom tags for developers
#### Changes
* Improved Auto-Updater (Multi-Threading and more)
#### Fixes
* Fixed #2300
* Fixed #2296
* Fixed #2238
## Release Candidate 16 (07 Sep 2020)
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16

View File

@ -1,6 +1,9 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.backpacks;
import org.bukkit.Material;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@ -9,6 +12,7 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
@ -28,6 +32,7 @@ public class SlimefunBackpack extends SimpleSlimefunItem<ItemUseHandler> {
private final int size;
@ParametersAreNonnullByDefault
public SlimefunBackpack(int size, Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
@ -55,9 +60,9 @@ public class SlimefunBackpack extends SimpleSlimefunItem<ItemUseHandler> {
*
* @return Whether the given {@link ItemStack} is allowed to be put into this {@link SlimefunBackpack}
*/
public boolean isItemAllowed(ItemStack item, SlimefunItem itemAsSlimefunItem) {
public boolean isItemAllowed(@Nonnull ItemStack item, @Nullable SlimefunItem itemAsSlimefunItem) {
// Shulker Boxes are not allowed!
if (item.getType() == Material.SHULKER_BOX || item.getType().toString().endsWith("_SHULKER_BOX")) {
if (SlimefunTag.SHULKER_BOXES.isTagged(item.getType())) {
return false;
}

View File

@ -26,6 +26,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import io.papermc.lib.PaperLib;
import io.papermc.lib.features.blockstatesnapshot.BlockStateSnapshotResult;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
@ -73,10 +74,13 @@ public class BlockPlacer extends SlimefunItem {
private BlockDispenseHandler onBlockDispense() {
return (e, dispenser, facedBlock, machine) -> {
if (!hasPermission(dispenser, facedBlock)) {
e.setCancelled(true);
return;
}
if (isShulkerBox(e.getItem().getType())) {
Material material = e.getItem().getType();
if (SlimefunTag.SHULKER_BOXES.isTagged(material)) {
// Since vanilla Dispensers can already place Shulker boxes, we
// simply fallback to the vanilla behaviour.
return;
@ -84,7 +88,13 @@ public class BlockPlacer extends SlimefunItem {
e.setCancelled(true);
if (facedBlock.isEmpty() && e.getItem().getType().isBlock() && !isBlacklisted(e.getItem().getType())) {
if (!material.isBlock() || SlimefunTag.BLOCK_PLACER_IGNORED_MATERIALS.isTagged(material)) {
// Some materials cannot be reliably placed, like beds, it would look
// kinda wonky, so we just ignore these altogether
return;
}
if (facedBlock.isEmpty() && !isBlacklisted(material)) {
SlimefunItem item = SlimefunItem.getByItem(e.getItem());
if (item != null) {
@ -125,10 +135,6 @@ public class BlockPlacer extends SlimefunItem {
return SlimefunPlugin.getProtectionManager().hasPermission(player, target, ProtectableAction.PLACE_BLOCK);
}
private boolean isShulkerBox(Material type) {
return type == Material.SHULKER_BOX || type.name().endsWith("_SHULKER_BOX");
}
private boolean isBlacklisted(Material type) {
for (String blockType : blacklist.getValue()) {
if (type.toString().equals(blockType)) {

View File

@ -18,6 +18,7 @@ import org.bukkit.Tag;
import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.CropGrowthAccelerator;
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner.IndustrialMiner;
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick;
@ -38,18 +39,21 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.tools.SmeltersPic
*/
public enum SlimefunTag implements Tag<Material> {
/**
* Materials which are sensitive to break.
* Things like Saplings or Pressure plates which break as well when you break
* the block beneath them.
*/
SENSITIVE_MATERIALS,
/**
* Minecraft ores.
*/
ORES,
/**
* All Shulker boxes, normal and colored.
*/
SHULKER_BOXES,
/**
* Every mushroom type, red, brown and nether ones.
*/
MUSHROOMS,
/**
* Every glass variant, includes both blocks and panes.
* Also stained glass and stained glass panes.
@ -92,6 +96,18 @@ public enum SlimefunTag implements Tag<Material> {
*/
CONCRETE_POWDERS,
/**
* Materials which are sensitive to break.
* Things like Saplings or Pressure plates which break as well when you break
* the block beneath them.
*/
SENSITIVE_MATERIALS,
/**
* Materials which cannot be reliably placed using a {@link BlockPlacer}.
*/
BLOCK_PLACER_IGNORED_MATERIALS,
/**
* All materials which the {@link ExplosiveShovel} can break.
*/
@ -196,13 +212,13 @@ public enum SlimefunTag implements Tag<Material> {
return Collections.unmodifiableSet(includedMaterials);
}
else {
Set<Material> values = new HashSet<>(includedMaterials);
Set<Material> materials = new HashSet<>(includedMaterials);
for (Tag<Material> tag : additionalTags) {
values.addAll(tag.getValues());
materials.addAll(tag.getValues());
}
return Collections.unmodifiableSet(values);
return materials;
}
}

View File

@ -0,0 +1,16 @@
{
"values" : [
"#slimefun:sensitive_materials",
"#slimefun:mushrooms",
"#minecraft:tall_flowers",
"#minecraft:beds",
"#minecraft:doors",
"minecraft:sugar_cane",
"minecraft:lily_pad",
"minecraft:dead_bush",
{
"id" : "minecraft:bamboo",
"required" : false
}
]
}

View File

@ -0,0 +1,14 @@
{
"values" : [
"minecraft:red_mushroom",
"minecraft:brown_mushroom",
{
"id" : "minecraft:crimson_fungus",
"required" : false
},
{
"id" : "minecraft:warped_fungus",
"required" : false
}
]
}

View File

@ -0,0 +1,21 @@
{
"values" : [
"minecraft:shulker_box",
"minecraft:white_shulker_box",
"minecraft:orange_shulker_box",
"minecraft:magenta_shulker_box",
"minecraft:light_blue_shulker_box",
"minecraft:yellow_shulker_box",
"minecraft:lime_shulker_box",
"minecraft:pink_shulker_box",
"minecraft:gray_shulker_box",
"minecraft:light_gray_shulker_box",
"minecraft:cyan_shulker_box",
"minecraft:purple_shulker_box",
"minecraft:blue_shulker_box",
"minecraft:brown_shulker_box",
"minecraft:green_shulker_box",
"minecraft:red_shulker_box",
"minecraft:black_shulker_box"
]
}

View File

@ -81,6 +81,7 @@ public final class TestUtilities {
server.createMaterialTag(NamespacedKey.minecraft("wooden_fences"), Material.OAK_FENCE, Material.BIRCH_FENCE, Material.JUNGLE_FENCE, Material.SPRUCE_FENCE, Material.ACACIA_FENCE, Material.DARK_OAK_FENCE);
server.createMaterialTag(NamespacedKey.minecraft("planks"), Material.OAK_PLANKS, Material.BIRCH_PLANKS, Material.SPRUCE_PLANKS, Material.JUNGLE_PLANKS, Material.ACACIA_PLANKS, Material.DARK_OAK_PLANKS);
server.createMaterialTag(NamespacedKey.minecraft("small_flowers"), Material.POPPY, Material.DANDELION, Material.AZURE_BLUET, Material.LILY_OF_THE_VALLEY);
server.createMaterialTag(NamespacedKey.minecraft("tall_flowers"), Material.PEONY, Material.SUNFLOWER);
server.createMaterialTag(NamespacedKey.minecraft("leaves"), Material.OAK_LEAVES, Material.BIRCH_LEAVES, Material.SPRUCE_LEAVES, Material.JUNGLE_LEAVES, Material.ACACIA_LEAVES, Material.DARK_OAK_LEAVES);
server.createMaterialTag(NamespacedKey.minecraft("saplings"), Material.OAK_SAPLING, Material.BIRCH_SAPLING, Material.SPRUCE_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING);
server.createMaterialTag(NamespacedKey.minecraft("coral_blocks"), Material.BRAIN_CORAL_BLOCK, Material.BUBBLE_CORAL_BLOCK, Material.FIRE_CORAL_BLOCK, Material.HORN_CORAL_BLOCK, Material.TUBE_CORAL_BLOCK);
@ -89,6 +90,7 @@ public final class TestUtilities {
server.createMaterialTag(NamespacedKey.minecraft("sand"), Material.SAND, Material.RED_SAND);
server.createMaterialTag(NamespacedKey.minecraft("crops"), Material.WHEAT, Material.CARROTS, Material.POTATOES, Material.BEETROOTS);
server.createMaterialTag(NamespacedKey.minecraft("ice"), Material.ICE, Material.PACKED_ICE, Material.FROSTED_ICE, Material.BLUE_ICE);
server.createMaterialTag(NamespacedKey.minecraft("beds"), Material.RED_BED, Material.BLUE_BED);
server.createMaterialTag(NamespacedKey.minecraft("fishes"), Material.COD, Material.SALMON);
}