forked from LogBlock/LogBlock
Improve logging of 1.14 blocks
This commit is contained in:
@ -144,6 +144,10 @@ public class BukkitUtils {
|
|||||||
singleBlockPlants.add(Material.OXEYE_DAISY);
|
singleBlockPlants.add(Material.OXEYE_DAISY);
|
||||||
singleBlockPlants.add(Material.BROWN_MUSHROOM);
|
singleBlockPlants.add(Material.BROWN_MUSHROOM);
|
||||||
singleBlockPlants.add(Material.RED_MUSHROOM);
|
singleBlockPlants.add(Material.RED_MUSHROOM);
|
||||||
|
singleBlockPlants.add(Material.SWEET_BERRY_BUSH);
|
||||||
|
singleBlockPlants.add(Material.LILY_OF_THE_VALLEY);
|
||||||
|
singleBlockPlants.add(Material.CORNFLOWER);
|
||||||
|
singleBlockPlants.add(Material.WITHER_ROSE);
|
||||||
|
|
||||||
doublePlants = EnumSet.noneOf(Material.class);
|
doublePlants = EnumSet.noneOf(Material.class);
|
||||||
doublePlants.add(Material.TALL_GRASS);
|
doublePlants.add(Material.TALL_GRASS);
|
||||||
@ -178,6 +182,7 @@ public class BukkitUtils {
|
|||||||
relativeBreakable.add(Material.WALL_TORCH);
|
relativeBreakable.add(Material.WALL_TORCH);
|
||||||
relativeBreakable.add(Material.TRIPWIRE_HOOK);
|
relativeBreakable.add(Material.TRIPWIRE_HOOK);
|
||||||
relativeBreakable.add(Material.COCOA);
|
relativeBreakable.add(Material.COCOA);
|
||||||
|
relativeBreakable.add(Material.BELL);
|
||||||
|
|
||||||
// Blocks that break when they are on top of a block
|
// Blocks that break when they are on top of a block
|
||||||
relativeTopBreakable = EnumSet.noneOf(Material.class);
|
relativeTopBreakable = EnumSet.noneOf(Material.class);
|
||||||
@ -206,13 +211,18 @@ public class BukkitUtils {
|
|||||||
relativeTopBreakable.add(Material.REPEATER);
|
relativeTopBreakable.add(Material.REPEATER);
|
||||||
relativeTopBreakable.add(Material.COMPARATOR);
|
relativeTopBreakable.add(Material.COMPARATOR);
|
||||||
relativeTopBreakable.add(Material.TORCH);
|
relativeTopBreakable.add(Material.TORCH);
|
||||||
relativeTopBreakable.add(Material.WALL_TORCH);
|
|
||||||
relativeTopBreakable.add(Material.REDSTONE_TORCH);
|
relativeTopBreakable.add(Material.REDSTONE_TORCH);
|
||||||
relativeTopBreakable.add(Material.REDSTONE_WALL_TORCH);
|
|
||||||
relativeTopBreakable.addAll(woodenDoors);
|
relativeTopBreakable.addAll(woodenDoors);
|
||||||
relativeTopBreakable.add(Material.IRON_DOOR);
|
relativeTopBreakable.add(Material.IRON_DOOR);
|
||||||
relativeTopBreakable.addAll(carpets);
|
relativeTopBreakable.addAll(carpets);
|
||||||
relativeTopBreakable.addAll(doublePlants);
|
relativeTopBreakable.addAll(doublePlants);
|
||||||
|
relativeTopBreakable.add(Material.BAMBOO);
|
||||||
|
relativeTopBreakable.add(Material.BAMBOO_SAPLING);
|
||||||
|
for(Material m : Material.values()) {
|
||||||
|
if(m.name().startsWith("POTTED_")) {
|
||||||
|
relativeTopBreakable.add(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Blocks that break falling entities
|
// Blocks that break falling entities
|
||||||
fallingEntityKillers = EnumSet.noneOf(Material.class);
|
fallingEntityKillers = EnumSet.noneOf(Material.class);
|
||||||
@ -314,6 +324,10 @@ public class BukkitUtils {
|
|||||||
containerBlocks.add(Material.RED_SHULKER_BOX);
|
containerBlocks.add(Material.RED_SHULKER_BOX);
|
||||||
containerBlocks.add(Material.WHITE_SHULKER_BOX);
|
containerBlocks.add(Material.WHITE_SHULKER_BOX);
|
||||||
containerBlocks.add(Material.YELLOW_SHULKER_BOX);
|
containerBlocks.add(Material.YELLOW_SHULKER_BOX);
|
||||||
|
containerBlocks.add(Material.BARREL);
|
||||||
|
containerBlocks.add(Material.BLAST_FURNACE);
|
||||||
|
containerBlocks.add(Material.SMOKER);
|
||||||
|
containerBlocks.add(Material.LECTERN);
|
||||||
// Doesn't actually have a block inventory
|
// Doesn't actually have a block inventory
|
||||||
// containerBlocks.add(Material.ENDER_CHEST);
|
// containerBlocks.add(Material.ENDER_CHEST);
|
||||||
|
|
||||||
@ -329,6 +343,7 @@ public class BukkitUtils {
|
|||||||
projectileItems.put(EntityType.SPLASH_POTION, Material.SPLASH_POTION);
|
projectileItems.put(EntityType.SPLASH_POTION, Material.SPLASH_POTION);
|
||||||
projectileItems.put(EntityType.THROWN_EXP_BOTTLE, Material.EXPERIENCE_BOTTLE);
|
projectileItems.put(EntityType.THROWN_EXP_BOTTLE, Material.EXPERIENCE_BOTTLE);
|
||||||
projectileItems.put(EntityType.WITHER_SKULL, Material.WITHER_SKELETON_SKULL);
|
projectileItems.put(EntityType.WITHER_SKULL, Material.WITHER_SKELETON_SKULL);
|
||||||
|
projectileItems.put(EntityType.FIREWORK, Material.FIREWORK_ROCKET);
|
||||||
|
|
||||||
nonFluidProofBlocks = EnumSet.noneOf(Material.class);
|
nonFluidProofBlocks = EnumSet.noneOf(Material.class);
|
||||||
nonFluidProofBlocks.addAll(singleBlockPlants);
|
nonFluidProofBlocks.addAll(singleBlockPlants);
|
||||||
@ -588,7 +603,7 @@ public class BukkitUtils {
|
|||||||
|
|
||||||
public static int saveSpawnHeight(Location loc) {
|
public static int saveSpawnHeight(Location loc) {
|
||||||
final World world = loc.getWorld();
|
final World world = loc.getWorld();
|
||||||
final Chunk chunk = world.getChunkAt(loc);
|
world.getChunkAt(loc);
|
||||||
final int x = loc.getBlockX(), z = loc.getBlockZ();
|
final int x = loc.getBlockX(), z = loc.getBlockZ();
|
||||||
int y = loc.getBlockY();
|
int y = loc.getBlockY();
|
||||||
boolean lower = world.getBlockAt(x, y, z).isEmpty(), upper = world.getBlockAt(x, y + 1, z).isEmpty();
|
boolean lower = world.getBlockAt(x, y, z).isEmpty(), upper = world.getBlockAt(x, y + 1, z).isEmpty();
|
||||||
|
@ -10,7 +10,9 @@ import org.bukkit.block.BlockFace;
|
|||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.block.data.Directional;
|
import org.bukkit.block.data.Directional;
|
||||||
|
import org.bukkit.block.data.type.Bell;
|
||||||
|
import org.bukkit.block.data.type.Bell.Attachment;
|
||||||
|
import org.bukkit.block.data.type.Lantern;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static de.diddiz.LogBlock.config.Config.getWorldConfig;
|
import static de.diddiz.LogBlock.config.Config.getWorldConfig;
|
||||||
@ -110,8 +112,9 @@ public class LoggingUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Block checkBlock = origin.getRelative(BlockFace.UP);
|
Block checkBlock = origin.getRelative(BlockFace.UP);
|
||||||
if (BukkitUtils.getRelativeTopBreakabls().contains(checkBlock.getType())) {
|
Material typeAbove = checkBlock.getType();
|
||||||
if (checkBlock.getType() == Material.IRON_DOOR || BukkitUtils.isWoodenDoor(checkBlock.getType())) {
|
if (BukkitUtils.getRelativeTopBreakabls().contains(typeAbove)) {
|
||||||
|
if (typeAbove == Material.IRON_DOOR || BukkitUtils.isWoodenDoor(typeAbove)) {
|
||||||
Block doorBlock = checkBlock;
|
Block doorBlock = checkBlock;
|
||||||
// If the doorBlock is the top half a door the player simply punched a door
|
// If the doorBlock is the top half a door the player simply punched a door
|
||||||
// this will be handled later.
|
// this will be handled later.
|
||||||
@ -123,7 +126,7 @@ public class LoggingUtil {
|
|||||||
}
|
}
|
||||||
consumer.queueBlockBreak(actor, checkBlock.getState());
|
consumer.queueBlockBreak(actor, checkBlock.getState());
|
||||||
}
|
}
|
||||||
} else if (BukkitUtils.isDoublePlant(checkBlock.getType())) {
|
} else if (BukkitUtils.isDoublePlant(typeAbove)) {
|
||||||
Block plantBlock = checkBlock;
|
Block plantBlock = checkBlock;
|
||||||
// If the plantBlock is the top half of a double plant the player simply
|
// If the plantBlock is the top half of a double plant the player simply
|
||||||
// punched the plant this will be handled later.
|
// punched the plant this will be handled later.
|
||||||
@ -138,16 +141,48 @@ public class LoggingUtil {
|
|||||||
} else {
|
} else {
|
||||||
consumer.queueBlockBreak(actor, checkBlock.getState());
|
consumer.queueBlockBreak(actor, checkBlock.getState());
|
||||||
}
|
}
|
||||||
|
} else if(typeAbove == Material.LANTERN) {
|
||||||
|
Lantern lantern = (Lantern) checkBlock.getBlockData();
|
||||||
|
if(!lantern.isHanging()) {
|
||||||
|
consumer.queueBlockBreak(actor, checkBlock.getState());
|
||||||
|
}
|
||||||
|
}else if(typeAbove == Material.BELL) {
|
||||||
|
Bell bell = (Bell) checkBlock.getBlockData();
|
||||||
|
if(bell.getAttachment() == Attachment.FLOOR) {
|
||||||
|
consumer.queueBlockBreak(actor, checkBlock.getState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkBlock = origin.getRelative(BlockFace.DOWN);
|
||||||
|
Material typeBelow = checkBlock.getType();
|
||||||
|
if(typeBelow == Material.LANTERN) {
|
||||||
|
Lantern lantern = (Lantern) checkBlock.getBlockData();
|
||||||
|
if(lantern.isHanging()) {
|
||||||
|
consumer.queueBlockBreak(actor, checkBlock.getState());
|
||||||
|
}
|
||||||
|
} else if(typeBelow == Material.BELL) {
|
||||||
|
Bell bell = (Bell) checkBlock.getBlockData();
|
||||||
|
if(bell.getAttachment() == Attachment.CEILING) {
|
||||||
|
consumer.queueBlockBreak(actor, checkBlock.getState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<Location> relativeBreakables = BukkitUtils.getBlocksNearby(origin, BukkitUtils.getRelativeBreakables());
|
List<Location> relativeBreakables = BukkitUtils.getBlocksNearby(origin, BukkitUtils.getRelativeBreakables());
|
||||||
if (relativeBreakables.size() != 0) {
|
if (relativeBreakables.size() != 0) {
|
||||||
for (Location location : relativeBreakables) {
|
for (Location location : relativeBreakables) {
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
BlockData blockData = block.getBlockData();
|
BlockData blockData = block.getBlockData();
|
||||||
if (blockData instanceof Directional) {
|
if (blockData instanceof Directional) {
|
||||||
if (block.getRelative(((Directional) blockData).getFacing().getOppositeFace()).equals(origin)) {
|
if (blockData.getMaterial() == Material.BELL) {
|
||||||
consumer.queueBlockBreak(actor, block.getState());
|
if (((Bell) blockData).getAttachment() == Attachment.SINGLE_WALL) {
|
||||||
|
if (block.getRelative(((Bell) blockData).getFacing()).equals(origin)) {
|
||||||
|
consumer.queueBlockBreak(actor, block.getState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (block.getRelative(((Directional) blockData).getFacing().getOppositeFace()).equals(origin)) {
|
||||||
|
consumer.queueBlockBreak(actor, block.getState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user