mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-24 12:16:36 +01:00
Added support for hanging signs
This commit is contained in:
parent
cde18dc529
commit
47a000a57f
@ -6,6 +6,7 @@ import java.util.Map;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
@ -206,4 +207,9 @@ public class BukkitAdapter implements BukkitInterface {
|
||||
return scanType.hasGravity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSign(Material material) {
|
||||
return Tag.SIGNS.isTagged(material);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -65,4 +65,6 @@ public interface BukkitInterface {
|
||||
|
||||
public boolean hasGravity(Material scanType);
|
||||
|
||||
public boolean isSign(Material material);
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.util.HashSet;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.sign.Side;
|
||||
|
||||
@ -16,6 +17,7 @@ public class Bukkit_v1_20 extends Bukkit_v1_19 implements BukkitInterface {
|
||||
public Bukkit_v1_20() {
|
||||
BlockGroup.CONTAINERS = new HashSet<>(Arrays.asList(Material.JUKEBOX, Material.DISPENSER, Material.CHEST, Material.FURNACE, Material.BREWING_STAND, Material.TRAPPED_CHEST, Material.HOPPER, Material.DROPPER, Material.ARMOR_STAND, Material.ITEM_FRAME, Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.ORANGE_SHULKER_BOX, Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.LIGHT_GRAY_SHULKER_BOX, Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX, Material.BARREL, Material.BLAST_FURNACE, Material.SMOKER, Material.LECTERN, Material.CHISELED_BOOKSHELF));
|
||||
BlockGroup.UPDATE_STATE = new HashSet<>(Arrays.asList(Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.RAIL, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FURNACE, Material.BLAST_FURNACE, Material.SMOKER, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.GLOWSTONE, Material.JACK_O_LANTERN, Material.REPEATER, Material.REDSTONE_LAMP, Material.BEACON, Material.COMPARATOR, Material.DAYLIGHT_DETECTOR, Material.REDSTONE_BLOCK, Material.HOPPER, Material.CHEST, Material.TRAPPED_CHEST, Material.ACTIVATOR_RAIL, Material.SOUL_TORCH, Material.SOUL_WALL_TORCH, Material.SHROOMLIGHT, Material.RESPAWN_ANCHOR, Material.CRYING_OBSIDIAN, Material.TARGET, Material.SMALL_AMETHYST_BUD, Material.MEDIUM_AMETHYST_BUD, Material.LARGE_AMETHYST_BUD, Material.AMETHYST_CLUSTER, Material.CAVE_VINES, Material.CAVE_VINES_PLANT, Material.GLOW_LICHEN, Material.LIGHT, Material.LAVA_CAULDRON, Material.CHISELED_BOOKSHELF));
|
||||
BlockGroup.TRACK_BOTTOM.addAll(Tag.CEILING_HANGING_SIGNS.getValues());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,4 +99,9 @@ public class Bukkit_v1_20 extends Bukkit_v1_19 implements BukkitInterface {
|
||||
return scanType.hasGravity() || scanType == Material.SUSPICIOUS_GRAVEL || scanType == Material.SUSPICIOUS_SAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSign(Material material) {
|
||||
return Tag.ALL_SIGNS.isTagged(material);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -823,7 +823,7 @@ public class Rollback extends Queue {
|
||||
blockCount1++;
|
||||
}
|
||||
}
|
||||
else if (Tag.SIGNS.isTagged(rowType)) {// sign
|
||||
else if (BukkitAdapter.ADAPTER.isSign(rowType)) {// sign
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
Queue.queueSignUpdate(rowUser, block.getState(), rollbackType, rowTime);
|
||||
|
||||
|
@ -7,7 +7,6 @@ import java.util.Locale;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Banner;
|
||||
import org.bukkit.block.Block;
|
||||
@ -274,7 +273,7 @@ public final class BlockBreakListener extends Queue implements Listener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (log && Tag.SIGNS.isTagged(blockType)) {
|
||||
if (log && BukkitAdapter.ADAPTER.isSign(blockType)) {
|
||||
if (Config.getConfig(world).SIGN_TEXT) {
|
||||
try {
|
||||
Location location = blockState.getLocation();
|
||||
|
@ -8,7 +8,6 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -115,7 +114,7 @@ public final class BlockExplodeListener extends Queue implements Listener {
|
||||
Block block = entry.getValue();
|
||||
Material blockType = block.getType();
|
||||
BlockState blockState = block.getState();
|
||||
if (Tag.SIGNS.isTagged(blockType) && Config.getConfig(world).SIGN_TEXT) {
|
||||
if (BukkitAdapter.ADAPTER.isSign(blockType) && Config.getConfig(world).SIGN_TEXT) {
|
||||
try {
|
||||
Location location = blockState.getLocation();
|
||||
Sign sign = (Sign) blockState;
|
||||
|
@ -4,7 +4,6 @@ import java.util.Locale;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -107,7 +106,7 @@ public final class BlockPlaceListener extends Queue implements Listener {
|
||||
|
||||
Queue.queueBlockPlace(player.getName(), blockState, blockPlaced.getType(), blockReplaced, forceType, forceData, 0, bBlockData);
|
||||
|
||||
if (Tag.SIGNS.isTagged(blockType)) {
|
||||
if (BukkitAdapter.ADAPTER.isSign(blockType)) {
|
||||
if (Config.getConfig(world).SIGN_TEXT) {
|
||||
try {
|
||||
Location location = blockState.getLocation();
|
||||
|
@ -188,7 +188,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
||||
final Material type = block.getType();
|
||||
boolean isInteractBlock = BlockGroup.INTERACT_BLOCKS.contains(type);
|
||||
boolean isContainerBlock = BlockGroup.CONTAINERS.contains(type);
|
||||
boolean isSignBlock = Tag.SIGNS.isTagged(type);
|
||||
boolean isSignBlock = BukkitAdapter.ADAPTER.isSign(type);
|
||||
|
||||
if (isInteractBlock || isContainerBlock || isSignBlock) {
|
||||
final Block clickedBlock = event.getClickedBlock();
|
||||
@ -550,7 +550,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
||||
if (event.useInteractedBlock() != Event.Result.DENY) {
|
||||
boolean isCake = false;
|
||||
|
||||
if (Tag.SIGNS.isTagged(type)) {
|
||||
if (BukkitAdapter.ADAPTER.isSign(type)) {
|
||||
// check if right clicked sign with dye
|
||||
Set<Material> dyeSet = EnumSet.of(Material.BLACK_DYE, Material.BLUE_DYE, Material.BROWN_DYE, Material.CYAN_DYE, Material.GRAY_DYE, Material.GREEN_DYE, Material.LIGHT_BLUE_DYE, Material.LIGHT_GRAY_DYE, Material.LIME_DYE, Material.MAGENTA_DYE, Material.ORANGE_DYE, Material.PINK_DYE, Material.PURPLE_DYE, Material.RED_DYE, Material.WHITE_DYE, Material.YELLOW_DYE);
|
||||
Material handType = null;
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
import org.bukkit.block.data.Bisected.Half;
|
||||
@ -44,7 +43,7 @@ public class WorldEditLogger extends Queue {
|
||||
}
|
||||
|
||||
protected static BaseBlock getBaseBlock(Extent extent, BlockVector3 position, Location location, Material oldType, com.sk89q.worldedit.world.block.BlockState oldBlock) {
|
||||
if (oldType == Material.SPAWNER || (Config.getConfig(location.getWorld()).SIGN_TEXT && Tag.SIGNS.isTagged(oldType))) {
|
||||
if (oldType == Material.SPAWNER || (Config.getConfig(location.getWorld()).SIGN_TEXT && net.coreprotect.bukkit.BukkitAdapter.ADAPTER.isSign(oldType))) {
|
||||
return extent.getFullBlock(position);
|
||||
}
|
||||
|
||||
@ -67,7 +66,7 @@ public class WorldEditLogger extends Queue {
|
||||
if (!oldType.equals(newType) || !oldBlockDataString.equals(newBlockDataString)) {
|
||||
try {
|
||||
if (baseBlock != null && baseBlock.hasNbtData()) {
|
||||
if (Config.getConfig(location.getWorld()).SIGN_TEXT && Tag.SIGNS.isTagged(oldType)) {
|
||||
if (Config.getConfig(location.getWorld()).SIGN_TEXT && net.coreprotect.bukkit.BukkitAdapter.ADAPTER.isSign(oldType)) {
|
||||
CompoundTag compoundTag = baseBlock.getNbtData();
|
||||
if (!compoundTag.containsKey("front_text")) {
|
||||
String line1 = getSignText(compoundTag.getString("Text1"));
|
||||
|
Loading…
Reference in New Issue
Block a user