From b2c390af2399af9e911c6040322d6f82b7ea82da Mon Sep 17 00:00:00 2001 From: DerFrZocker Date: Sun, 4 Dec 2022 21:21:28 +0100 Subject: [PATCH] Fix merge --- src/main/java/org/bukkit/Material.java | 1 + src/main/java/org/bukkit/block/BlockType.java | 27 +++++++++--- .../java/org/bukkit/scoreboard/Criteria.java | 41 ++++++++----------- src/test/java/org/bukkit/MaterialTest.java | 3 +- 4 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java index ba7b0119..553a22fe 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java @@ -5,6 +5,7 @@ import com.google.common.collect.Multimap; import java.util.function.Consumer; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeModifier; +import org.bukkit.block.Block; import org.bukkit.block.BlockType; import org.bukkit.block.data.BlockData; import org.bukkit.inventory.CreativeCategory; diff --git a/src/main/java/org/bukkit/block/BlockType.java b/src/main/java/org/bukkit/block/BlockType.java index 90405067..f0af9eca 100644 --- a/src/main/java/org/bukkit/block/BlockType.java +++ b/src/main/java/org/bukkit/block/BlockType.java @@ -18,6 +18,7 @@ import org.bukkit.block.data.Snowable; import org.bukkit.block.data.Waterlogged; import org.bukkit.block.data.type.AmethystCluster; import org.bukkit.block.data.type.Bamboo; +import org.bukkit.block.data.type.Barrel; import org.bukkit.block.data.type.Bed; import org.bukkit.block.data.type.Beehive; import org.bukkit.block.data.type.Bell; @@ -72,6 +73,7 @@ import org.bukkit.block.data.type.RespawnAnchor; import org.bukkit.block.data.type.Sapling; import org.bukkit.block.data.type.Scaffolding; import org.bukkit.block.data.type.SculkSensor; +import org.bukkit.block.data.type.SculkVein; import org.bukkit.block.data.type.SeaPickle; import org.bukkit.block.data.type.Sign; import org.bukkit.block.data.type.Slab; @@ -872,9 +874,9 @@ public interface BlockType extends Material { BlockType NETHER_BRICK_STAIRS = asBlockType(Material.NETHER_BRICK_STAIRS); BlockType SCULK = asBlockType(Material.SCULK); /** - * BlockData: {@link Waterlogged} + * BlockData: {@link SculkVein} */ - BlockType SCULK_VEIN = asBlockType(Material.SCULK_VEIN); + BlockType SCULK_VEIN = asBlockType(Material.SCULK_VEIN); BlockType SCULK_CATALYST = asBlockType(Material.SCULK_CATALYST); BlockType SCULK_SHRIEKER = asBlockType(Material.SCULK_SHRIEKER); BlockType ENCHANTING_TABLE = asBlockType(Material.ENCHANTING_TABLE); @@ -2176,9 +2178,9 @@ public interface BlockType extends Material { */ BlockType COMPOSTER = asBlockType(Material.COMPOSTER); /** - * BlockData: {@link Directional} + * BlockData: {@link Barrel} */ - BlockType BARREL = asBlockType(Material.BARREL); + BlockType BARREL = asBlockType(Material.BARREL); /** * BlockData: {@link Furnace} */ @@ -2819,9 +2821,22 @@ public interface BlockType extends Material { boolean isBurnable(); /** - * Check if the material is a block and completely blocks vision + * Check if the material is a block and occludes light in the lighting engine. + *

+ * Generally speaking, most full blocks will occlude light. Non-full blocks are + * not occluding (e.g. anvils, chests, tall grass, stairs, etc.), nor are specific + * full blocks such as barriers or spawners which block light despite their texture. + *

+ * An occluding block will have the following effects: + *

    + *
  • Chests cannot be opened if an occluding block is above it. + *
  • Mobs cannot spawn inside of occluding blocks. + *
  • Only occluding blocks can be "powered" ({@link Block#isBlockPowered()}). + *
+ * This list may be inconclusive. For a full list of the side effects of an occluding + * block, see the Minecraft Wiki. * - * @return True if this material is a block and completely blocks vision + * @return True if this material is a block and occludes light */ boolean isOccluding(); diff --git a/src/main/java/org/bukkit/scoreboard/Criteria.java b/src/main/java/org/bukkit/scoreboard/Criteria.java index fd1ec403..265a82da 100644 --- a/src/main/java/org/bukkit/scoreboard/Criteria.java +++ b/src/main/java/org/bukkit/scoreboard/Criteria.java @@ -256,26 +256,20 @@ public interface Criteria { // Good use case for a switch expression if (type == Type.BLOCK) { - switch (statistic) { - case MINE_BLOCK: - return Bukkit.getScoreboardCriteria("minecraft.mined:minecraft." + material.getKey().getKey()); - default: - break; + if (statistic == Statistic.MINE_BLOCK) { + return Bukkit.getScoreboardCriteria("minecraft.mined:minecraft." + material.getKey().getKey()); } } else if (type == Type.ITEM) { - switch (statistic) { - case BREAK_ITEM: - return Bukkit.getScoreboardCriteria("minecraft.broken:minecraft." + material.getKey().getKey()); - case CRAFT_ITEM: - return Bukkit.getScoreboardCriteria("minecraft.crafted:minecraft." + material.getKey().getKey()); - case USE_ITEM: - return Bukkit.getScoreboardCriteria("minecraft.used:minecraft." + material.getKey().getKey()); - case PICKUP: - return Bukkit.getScoreboardCriteria("minecraft.picked_up:minecraft." + material.getKey().getKey()); - case DROP: - return Bukkit.getScoreboardCriteria("minecraft.dropped:minecraft." + material.getKey().getKey()); - default: - break; + if (statistic == Statistic.BREAK_ITEM) { + return Bukkit.getScoreboardCriteria("minecraft.broken:minecraft." + material.getKey().getKey()); + } else if (statistic == Statistic.CRAFT_ITEM) { + return Bukkit.getScoreboardCriteria("minecraft.crafted:minecraft." + material.getKey().getKey()); + } else if (statistic == Statistic.USE_ITEM) { + return Bukkit.getScoreboardCriteria("minecraft.used:minecraft." + material.getKey().getKey()); + } else if (statistic == Statistic.PICKUP) { + return Bukkit.getScoreboardCriteria("minecraft.picked_up:minecraft." + material.getKey().getKey()); + } else if (statistic == Statistic.DROP) { + return Bukkit.getScoreboardCriteria("minecraft.dropped:minecraft." + material.getKey().getKey()); } } @@ -309,13 +303,10 @@ public interface Criteria { Preconditions.checkArgument(entityType != null, "entityType must not be null"); Preconditions.checkArgument(statistic.getType() == Type.ENTITY, "statistic type must be ENTITY, given %s", statistic.getType()); - switch (statistic) { - case KILL_ENTITY: - return Bukkit.getScoreboardCriteria("minecraft.killed:minecraft." + entityType.getKey().getKey()); - case ENTITY_KILLED_BY: - return Bukkit.getScoreboardCriteria("minecraft.killed_by:minecraft." + entityType.getKey().getKey()); - default: - break; + if (statistic == Statistic.KILL_ENTITY) { + return Bukkit.getScoreboardCriteria("minecraft.killed:minecraft." + entityType.getKey().getKey()); + } else if (statistic == Statistic.ENTITY_KILLED_BY) { + return Bukkit.getScoreboardCriteria("minecraft.killed_by:minecraft." + entityType.getKey().getKey()); } return statistic(statistic); // Fallback to a regular statistic diff --git a/src/test/java/org/bukkit/MaterialTest.java b/src/test/java/org/bukkit/MaterialTest.java index 090ea709..698a04c2 100644 --- a/src/test/java/org/bukkit/MaterialTest.java +++ b/src/test/java/org/bukkit/MaterialTest.java @@ -2,9 +2,10 @@ package org.bukkit; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; +import org.bukkit.support.AbstractTestingBase; import org.junit.Test; -public class MaterialTest { +public class MaterialTest extends AbstractTestingBase { @Test public void getByNameNull() {