Fixed 1.12.2 blockdata issues, closes #17
This commit is contained in:
parent
9d5de9c0e7
commit
8f9a825935
5 changed files with 8 additions and 18 deletions
|
@ -9,7 +9,6 @@ import org.bukkit.block.BlockFace;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class LiftBlock implements Comparable<LiftBlock> {
|
public class LiftBlock implements Comparable<LiftBlock> {
|
||||||
|
@ -31,7 +30,7 @@ public class LiftBlock implements Comparable<LiftBlock> {
|
||||||
@Getter @Setter private boolean active = false;
|
@Getter @Setter private boolean active = false;
|
||||||
|
|
||||||
//Only used for chests
|
//Only used for chests
|
||||||
public Map[] serializedItemStacks = null;
|
public Map<String, Object>[] serializedItemStacks = null;
|
||||||
|
|
||||||
/* Floor based liftblock, no material */
|
/* Floor based liftblock, no material */
|
||||||
public LiftBlock(String world, int x, int y, int z, String floor) {
|
public LiftBlock(String world, int x, int y, int z, String floor) {
|
||||||
|
|
|
@ -4,8 +4,6 @@ import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Getter @Setter @NoArgsConstructor
|
@Getter @Setter @NoArgsConstructor
|
||||||
public class LiftSign {
|
public class LiftSign {
|
||||||
private String world;
|
private String world;
|
||||||
|
|
|
@ -413,9 +413,7 @@ public class MoveLift implements Runnable {
|
||||||
block = world.getBlockAt(rope.getX(), rope.getCurrently(), rope.getZ());
|
block = world.getBlockAt(rope.getX(), rope.getCurrently(), rope.getZ());
|
||||||
block.setType(rope.getType());
|
block.setType(rope.getType());
|
||||||
if (XMaterial.isNewVersion()) {
|
if (XMaterial.isNewVersion()) {
|
||||||
org.bukkit.block.data.Directional data = (org.bukkit.block.data.Directional) block.getBlockData();
|
DirectionUtil.setDirection(block, rope.getFace());
|
||||||
data.setFacing(rope.getFace());
|
|
||||||
block.setBlockData(data);
|
|
||||||
} else {
|
} else {
|
||||||
BlockState state = block.getState();
|
BlockState state = block.getState();
|
||||||
org.bukkit.material.Ladder ladder = new org.bukkit.material.Ladder(rope.getType());
|
org.bukkit.material.Ladder ladder = new org.bukkit.material.Ladder(rope.getType());
|
||||||
|
@ -430,9 +428,7 @@ public class MoveLift implements Runnable {
|
||||||
block = world.getBlockAt(rope.getX(), rope.getCurrently(), rope.getZ());
|
block = world.getBlockAt(rope.getX(), rope.getCurrently(), rope.getZ());
|
||||||
block.setType(rope.getType());
|
block.setType(rope.getType());
|
||||||
if (XMaterial.isNewVersion()) {
|
if (XMaterial.isNewVersion()) {
|
||||||
org.bukkit.block.data.Directional data = (org.bukkit.block.data.Directional) block.getBlockData();
|
DirectionUtil.setDirection(block, rope.getFace());
|
||||||
data.setFacing(rope.getFace());
|
|
||||||
block.setBlockData(data);
|
|
||||||
} else {
|
} else {
|
||||||
BlockState state = block.getState();
|
BlockState state = block.getState();
|
||||||
org.bukkit.material.Ladder ladder = new org.bukkit.material.Ladder(rope.getType());
|
org.bukkit.material.Ladder ladder = new org.bukkit.material.Ladder(rope.getType());
|
||||||
|
|
|
@ -857,9 +857,7 @@ public class V10LiftAPI {
|
||||||
|
|
||||||
BlockFace face;
|
BlockFace face;
|
||||||
if (XMaterial.isNewVersion()) {
|
if (XMaterial.isNewVersion()) {
|
||||||
org.bukkit.block.data.type.Ladder ladder = (org.bukkit.block.data.type.Ladder) block.getBlockData();
|
face = DirectionUtil.getDirection(block);
|
||||||
Bukkit.getLogger().info(ladder.getFacing().toString());
|
|
||||||
face = ladder.getFacing();
|
|
||||||
} else {
|
} else {
|
||||||
BlockState state = block.getState();
|
BlockState state = block.getState();
|
||||||
org.bukkit.material.Ladder ladder = (org.bukkit.material.Ladder) state.getData();
|
org.bukkit.material.Ladder ladder = (org.bukkit.material.Ladder) state.getData();
|
||||||
|
|
|
@ -2,7 +2,6 @@ package nl.SBDeveloper.V10Lift.Utils;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.data.Directional;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -12,8 +11,8 @@ public class DirectionUtil {
|
||||||
@Nullable
|
@Nullable
|
||||||
public static BlockFace getDirection(@Nonnull Block block) {
|
public static BlockFace getDirection(@Nonnull Block block) {
|
||||||
if (!XMaterial.isNewVersion()) return null;
|
if (!XMaterial.isNewVersion()) return null;
|
||||||
if (block.getBlockData() instanceof Directional) {
|
if (block.getBlockData() instanceof org.bukkit.block.data.Directional) {
|
||||||
Directional dir = (Directional) block.getBlockData();
|
org.bukkit.block.data.Directional dir = (org.bukkit.block.data.Directional) block.getBlockData();
|
||||||
return dir.getFacing();
|
return dir.getFacing();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -21,9 +20,9 @@ public class DirectionUtil {
|
||||||
|
|
||||||
public static void setDirection(@Nonnull Block block, BlockFace blockFace) {
|
public static void setDirection(@Nonnull Block block, BlockFace blockFace) {
|
||||||
if (!XMaterial.isNewVersion()) return;
|
if (!XMaterial.isNewVersion()) return;
|
||||||
if (blockFace != null && block.getBlockData() instanceof Directional) {
|
if (blockFace != null && block.getBlockData() instanceof org.bukkit.block.data.Directional) {
|
||||||
org.bukkit.block.data.BlockData bd = block.getBlockData();
|
org.bukkit.block.data.BlockData bd = block.getBlockData();
|
||||||
Directional dir = (Directional) bd;
|
org.bukkit.block.data.Directional dir = (org.bukkit.block.data.Directional) bd;
|
||||||
dir.setFacing(blockFace);
|
dir.setFacing(blockFace);
|
||||||
block.setBlockData(bd);
|
block.setBlockData(bd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue