Testing things with blockstate

This commit is contained in:
stijnb1234 2020-02-02 12:57:28 +01:00
parent 1bb722d639
commit f24b35a2df
7 changed files with 185 additions and 77 deletions

View file

@ -4,14 +4,15 @@ import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.UUID;
@Getter @Setter
public class Floor {
private String world;
private int y;
private ArrayList<LiftBlock> doorBlocks;
private ArrayList<UUID> whitelist;
private final String world;
private final int y;
private final ArrayList<LiftBlock> doorBlocks = new ArrayList<>();
private final HashSet<UUID> whitelist = new HashSet<>();
public Floor(int y, String world) {
this.y = y;

View file

@ -9,46 +9,37 @@ import java.util.*;
public class Lift {
@Getter @Setter private String worldName;
@Getter @Setter private int y;
@Getter private ArrayList<UUID> owners;
@Getter private ArrayList<String> whitelist;
@Getter private TreeSet<LiftBlock> blocks;
@Getter private LinkedHashMap<String, Floor> floors;
@Getter private ArrayList<LiftSign> signs;
@Getter private ArrayList<LiftBlock> inputs;
@Getter private ArrayList<LiftBlock> offlineInputs;
@Getter @Setter private LinkedHashMap<String, Floor> queue;
@Getter private ArrayList<LiftRope> ropes;
@Getter private ArrayList<V10Entity> toMove;
@Getter private final HashSet<UUID> owners;
@Getter @Setter private ArrayList<String> whitelist;
@Getter private final TreeSet<LiftBlock> blocks = new TreeSet<>();
@Getter private final LinkedHashMap<String, Floor> floors = new LinkedHashMap<>();
@Getter private final HashSet<LiftSign> signs = new HashSet<>();
@Getter private final HashSet<LiftBlock> inputs = new HashSet<>();
@Getter private HashSet<LiftBlock> offlineInputs = new HashSet<>();
@Getter @Setter private LinkedHashMap<String, Floor> queue = null;
@Getter private final HashSet<LiftRope> ropes = new HashSet<>();
@Getter private final ArrayList<V10Entity> toMove = new ArrayList<>();
@Getter @Setter private int speed;
@Getter @Setter private boolean realistic;
@Getter @Setter private boolean offline;
@Getter @Setter private boolean sound;
@Getter @Setter private boolean defective;
@Getter @Setter private String signText;
@Getter @Setter private int counter;
@Getter @Setter private Floor doorOpen;
@Getter @Setter private DoorCloser doorCloser;
@Getter @Setter private boolean offline = false;
@Getter @Setter private boolean sound = true;
@Getter @Setter private boolean defective = false;
@Getter @Setter private String signText = null;
@Getter @Setter private int counter = 0;
@Getter @Setter private Floor doorOpen = null;
@Getter @Setter private DoorCloser doorCloser = null;
public Lift(ArrayList<UUID> owners, int speed, boolean realistic) {
public Lift(HashSet<UUID> owners, int speed, boolean realistic) {
this.owners = owners;
this.speed = speed;
this.realistic = realistic;
this.blocks = new TreeSet<>();
this.signs = new ArrayList<>();
this.whitelist = new ArrayList<>();
this.floors = new LinkedHashMap<>();
this.inputs = new ArrayList<>();
this.offlineInputs = new ArrayList<>();
this.queue = new LinkedHashMap<>();
this.ropes = new ArrayList<>();
this.toMove = new ArrayList<>();
this.offline = false;
this.sound = true;
this.defective = false;
this.counter = 0;
}
public Lift(UUID owner, int speed, boolean realistic) {
new Lift(new ArrayList<>(Collections.singletonList(owner)), speed, realistic);
HashSet<UUID> hs = new HashSet<>();
hs.add(owner);
this.owners = hs;
this.speed = speed;
this.realistic = realistic;
}
}

View file

@ -10,53 +10,75 @@ import java.util.Map;
public class LiftBlock implements Comparable<LiftBlock> {
@Getter @Setter private String world;
@Getter @Setter private int x;
@Getter private final int x;
@Getter @Setter private int y;
@Getter @Setter private int z;
@Getter private final int z;
//Only used for cabine blocks, because those need caching!
@Getter @Setter private Material mat;
@Getter @Setter private String[] signLines;
@Getter private final Material mat;
@Getter private final byte data;
@Getter private final String[] signLines;
//Only used for inputs!
@Getter @Setter private String floor;
@Getter private final String floor;
@Getter @Setter private boolean active = false;
//Only used for chests
public Map<String, Object>[] serializedItemStacks = null;
/**
* Add lift block with material
*
* @param world Worldname
* @param x x-pos
* @param y y-pos
* @param z z-pos
* @param mat the material
*/
public LiftBlock(String world, int x, int y, int z, Material mat) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.mat = mat;
}
public LiftBlock(String world, int x, int y, int z, String floor) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.mat = null;
this.data = 0;
this.signLines = null;
this.floor = floor;
}
public LiftBlock(String world, int x, int y, int z, Material mat) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.mat = mat;
this.data = 0;
this.signLines = null;
this.floor = null;
}
public LiftBlock(String world, int x, int y, int z, Material mat, byte data) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.mat = mat;
this.data = data;
this.signLines = null;
this.floor = null;
}
public LiftBlock(String world, int x, int y, int z, Material mat, String[] signLines) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.mat = mat;
this.data = 0;
this.signLines = signLines;
this.floor = null;
}
public LiftBlock(String world, int x, int y, int z, Material mat, byte data, String[] signLines) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.mat = mat;
this.data = data;
this.signLines = signLines;
this.floor = null;
}
@Override

View file

@ -9,7 +9,7 @@ public class LiftSign {
private int x;
private int z;
private int y;
private String oldText;
private String oldText = null;
private final byte type;
private byte state;

View file

@ -3,6 +3,7 @@ package nl.SBDeveloper.V10Lift.API.Runnables;
import nl.SBDeveloper.V10Lift.API.Objects.*;
import nl.SBDeveloper.V10Lift.Managers.DataManager;
import nl.SBDeveloper.V10Lift.Utils.LocationSerializer;
import nl.SBDeveloper.V10Lift.Utils.XMaterial;
import nl.SBDeveloper.V10Lift.Utils.XSound;
import nl.SBDeveloper.V10Lift.V10LiftPlugin;
import org.bukkit.*;
@ -124,7 +125,6 @@ public class MoveLift implements Runnable {
down = true;
}
String tmpw = lift.getWorldName();
if (up) {
if (!V10LiftPlugin.getAPI().closeDoor(liftName)) return;
@ -183,7 +183,12 @@ public class MoveLift implements Runnable {
block.setType(Material.AIR);
lib.setY(lib.getY() + 1);
block = Objects.requireNonNull(Bukkit.getWorld(lib.getWorld()), "World is null at MoveLift").getBlockAt(lib.getX(), lib.getY(), lib.getZ());
block.setType(lib.getMat());
BlockState state = block.getState();
state.setType(lb.getMat());
if (!XMaterial.isNewVersion()) {
state.setRawData(lb.getData());
}
state.update(true);
lb = lift.getBlocks().first();
for (Entity ent : Objects.requireNonNull(Bukkit.getWorld(lib.getWorld()), "World is null at MoveLift").getBlockAt(lib.getX(), lib.getY(), lib.getZ()).getChunk().getEntities()) {
v10ent = new V10Entity(ent, null, 0);
@ -218,7 +223,12 @@ public class MoveLift implements Runnable {
}
for (LiftBlock lib : tb) {
block = Objects.requireNonNull(Bukkit.getWorld(lib.getWorld()), "World is null at MoveLift").getBlockAt(lib.getX(), lib.getY(), lib.getZ());
block.setType(lib.getMat(), true);
BlockState state = block.getState();
state.setType(lb.getMat());
if (!XMaterial.isNewVersion()) {
state.setRawData(lb.getData());
}
state.update(true);
lift.getBlocks().add(lib);
if (lib.getSignLines() != null) {
bs = block.getState();
@ -298,7 +308,12 @@ public class MoveLift implements Runnable {
lib.setY(lib.getY() - 1);
y = lib.getY();
block = world.getBlockAt(lib.getX(), lib.getY(), lib.getZ());
block.setType(lib.getMat(), true);
BlockState state = block.getState();
state.setType(lb.getMat());
if (!XMaterial.isNewVersion()) {
state.setRawData(lb.getData());
}
state.update(true);
}
veiter = lift.getToMove().iterator();
while (veiter.hasNext()) {
@ -313,7 +328,12 @@ public class MoveLift implements Runnable {
}
for (LiftBlock lib : tb) {
block = Objects.requireNonNull(Bukkit.getWorld(lib.getWorld()), "World is null at MoveLift").getBlockAt(lib.getX(), lib.getY(), lib.getZ());
block.setType(lib.getMat(), true);
BlockState state = block.getState();
state.setType(lb.getMat());
if (!XMaterial.isNewVersion()) {
state.setRawData(lb.getData());
}
state.update(true);
lift.getBlocks().add(lib);
if (lib.getSignLines() != null) {
bs = block.getState();

View file

@ -7,6 +7,7 @@ import nl.SBDeveloper.V10Lift.Managers.AntiCopyBlockManager;
import nl.SBDeveloper.V10Lift.Managers.DataManager;
import nl.SBDeveloper.V10Lift.Managers.ForbiddenBlockManager;
import nl.SBDeveloper.V10Lift.Utils.LocationSerializer;
import nl.SBDeveloper.V10Lift.Utils.XMaterial;
import nl.SBDeveloper.V10Lift.V10LiftPlugin;
import org.bukkit.*;
import org.bukkit.block.Block;
@ -48,6 +49,7 @@ public class V10LiftAPI {
/* Private API methods */
private void sortFloors(@Nonnull Lift lift) {
Bukkit.getLogger().info("[V10Lift] Sorting floors for lift...");
ArrayList<Map.Entry<String, Floor>> as = new ArrayList<>(lift.getFloors().entrySet());
as.sort(Comparator.comparingInt(o -> o.getValue().getY()));
Iterator<Map.Entry<String, Floor>> iter = as.iterator();
@ -60,6 +62,7 @@ public class V10LiftAPI {
}
private void startLift(String liftName) {
Bukkit.getLogger().info("[V10Lift] Starting lift " + liftName);
if (!DataManager.containsMovingTask(liftName)) {
Lift lift = DataManager.getLift(liftName);
DataManager.addMovingTask(liftName, Bukkit.getScheduler().scheduleSyncRepeatingTask(V10LiftPlugin.getInstance(), new MoveLift(liftName, lift.getSpeed()), lift.getSpeed(), lift.getSpeed()));
@ -76,6 +79,7 @@ public class V10LiftAPI {
* @return true if created, false if null or already exists
*/
public boolean createLift(Player p, String liftName) {
Bukkit.getLogger().info("[V10Lift] Creating lift " + liftName);
if (p == null || liftName == null || DataManager.containsLift(liftName)) return false;
//TODO Add defaults to config
@ -90,6 +94,7 @@ public class V10LiftAPI {
* @return true if removed, false if null or doesn't exists
*/
public boolean removeLift(String liftName) {
Bukkit.getLogger().info("[V10Lift] Removing lift " + liftName);
if (liftName == null || !DataManager.containsLift(liftName)) return false;
//TODO Remove lift from all data maps
@ -107,6 +112,7 @@ public class V10LiftAPI {
* @param newName The new name of the lift
*/
public void renameLift(String liftName, String newName) {
Bukkit.getLogger().info("[V10Lift] Renaming lift " + liftName);
if (liftName == null || newName == null || !DataManager.containsLift(liftName)) return;
Lift lift = DataManager.getLift(liftName);
@ -145,13 +151,24 @@ public class V10LiftAPI {
* @return 0 if added, -1 if null or doesn't exists, -2 if forbidden, -3 if already added
*/
public int addBlockToLift(Set<LiftBlock> blocks, @Nonnull Block block) {
Bukkit.getLogger().info("[V10Lift] Adding Block to lift...");
Material type = block.getType();
LiftBlock lb;
if (type.toString().contains("SIGN")) {
//SIGN
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, ((Sign) block.getState()).getLines());
if (XMaterial.isNewVersion()) {
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, ((Sign) block.getState()).getLines());
} else {
Bukkit.getLogger().info("Using deprecated method! " + block.getState().getRawData());
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, block.getState().getRawData(), ((Sign) block.getState()).getLines());
}
} else {
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type);
if (XMaterial.isNewVersion()) {
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type);
} else {
Bukkit.getLogger().info("Using deprecated method! " + block.getState().getRawData());
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, block.getState().getRawData());
}
}
return addBlockToLift(blocks, lb);
}
@ -164,7 +181,8 @@ public class V10LiftAPI {
* @param block The LiftBlock
* @return 0 if added, -1 if null or doesn't exists, -2 if forbidden, -3 if already added
*/
public int addBlockToLift(Set<LiftBlock> blocks, @Nonnull LiftBlock block) {
public int addBlockToLift(@Nonnull Set<LiftBlock> blocks, @Nonnull LiftBlock block) {
Bukkit.getLogger().info("[V10Lift] Adding Block to lift 2...");
if (getFBM().isForbidden(block.getMat())) return -2;
if (blocks.contains(block)) return -3;
blocks.add(block);
@ -186,9 +204,19 @@ public class V10LiftAPI {
LiftBlock lb;
if (type.toString().contains("SIGN")) {
//SIGN
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, ((Sign) block.getState()).getLines());
if (XMaterial.isNewVersion()) {
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, ((Sign) block.getState()).getLines());
} else {
Bukkit.getLogger().info("Using deprecated method! " + block.getState().getRawData());
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, block.getState().getRawData(), ((Sign) block.getState()).getLines());
}
} else {
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type);
if (XMaterial.isNewVersion()) {
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type);
} else {
Bukkit.getLogger().info("Using deprecated method! " + block.getState().getRawData());
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, block.getState().getRawData());
}
}
if (!lift.getBlocks().contains(lb)) return -2;
lift.getBlocks().remove(lb);
@ -204,6 +232,7 @@ public class V10LiftAPI {
* @return 0 if added, 1 if removed, -1 if null or doesn't exists, -2 if not added
*/
public int switchBlockAtLift(String liftName, Block block) {
Bukkit.getLogger().info("[V10Lift] Switching block at lift...");
if (liftName == null || block == null || !DataManager.containsLift(liftName)) return -1;
return switchBlockAtLift(DataManager.getLift(liftName).getBlocks(), block);
}
@ -217,15 +246,26 @@ public class V10LiftAPI {
* @return 0 if added, 1 if removed, -1 if null or doesn't exists, -2 if not added
*/
public int switchBlockAtLift(TreeSet<LiftBlock> blocks, Block block) {
Bukkit.getLogger().info("[V10Lift] Switching block at lift 2...");
if (blocks == null || block == null) return -1;
Material type = block.getType();
if (getFBM().isForbidden(type)) return -2;
LiftBlock lb;
if (type.toString().contains("SIGN")) {
//SIGN
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, ((Sign) block.getState()).getLines());
if (XMaterial.isNewVersion()) {
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, ((Sign) block.getState()).getLines());
} else {
Bukkit.getLogger().info("Using deprecated method! " + block.getState().getRawData());
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, block.getState().getRawData(), ((Sign) block.getState()).getLines());
}
} else {
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type);
if (XMaterial.isNewVersion()) {
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type);
} else {
Bukkit.getLogger().info("Using deprecated method! " + block.getState().getRawData());
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, block.getState().getRawData());
}
}
if (blocks.contains(lb)) {
blocks.remove(lb);
@ -242,6 +282,7 @@ public class V10LiftAPI {
* @param liftName The name of the lift
*/
public void sortLiftBlocks(String liftName) {
Bukkit.getLogger().info("[V10Lift] Sorting blocks at lift...");
if (liftName != null && DataManager.containsLift(liftName)) {
Lift lift = DataManager.getLift(liftName);
if (lift.getWorldName() == null) lift.setWorldName(lift.getBlocks().first().getWorld());
@ -308,6 +349,7 @@ public class V10LiftAPI {
* @return true/false
*/
public boolean openDoor(Lift lift, String liftName, Floor f) {
Bukkit.getLogger().info("[V10Lift] Opening door...");
if (lift == null || liftName == null || f == null) return false;
if (lift.getDoorOpen() != null && !closeDoor(liftName)) return false;
@ -335,6 +377,7 @@ public class V10LiftAPI {
* @return true if door was closed, false if else.
*/
public boolean closeDoor(String liftName) {
Bukkit.getLogger().info("[V10Lift] Closing door...");
if (liftName == null || !DataManager.containsLift(liftName)) return false;
Lift lift = DataManager.getLift(liftName);
@ -361,7 +404,12 @@ public class V10LiftAPI {
if (!blocked) {
for (LiftBlock lb : lift.getDoorOpen().getDoorBlocks()) {
Block block = Objects.requireNonNull(Bukkit.getWorld(lb.getWorld()), "World is null at closeDoor").getBlockAt(lb.getX(), lb.getY(), lb.getZ());
block.setType(lb.getMat(), true);
BlockState state = block.getState();
state.setType(lb.getMat());
if (!XMaterial.isNewVersion()) {
state.setRawData(lb.getData());
}
state.update(true);
}
lift.setDoorOpen(null);
if (lift.getDoorCloser() != null) lift.getDoorCloser().stop();
@ -377,6 +425,7 @@ public class V10LiftAPI {
* @return true if open, false if else
*/
public boolean hasDoorOpen(String liftName) {
Bukkit.getLogger().info("[V10Lift] Opening door...");
return (liftName != null && DataManager.containsLift(liftName)) && DataManager.getLift(liftName).getDoorOpen() != null;
}
@ -389,6 +438,7 @@ public class V10LiftAPI {
* @return 0 if added, -1 if null or doesn't exists, -2 if height is to high, -3 if floor already exists
*/
public int addFloor(String liftName, String floorName, Floor floor) {
Bukkit.getLogger().info("[V10Lift] Adding door to " + floorName);
if (liftName == null || floorName == null || floor == null || !DataManager.containsLift(liftName) || floor.getWorld() == null) return -1;
if (floor.getY() > Objects.requireNonNull(Bukkit.getServer().getWorld(floor.getWorld()), "World is null at addNewFloor!").getMaxHeight()) return -2;
if (floorName.length() > 13) floorName = floorName.substring(0, 13).trim();
@ -408,6 +458,7 @@ public class V10LiftAPI {
* @return true if removed, false if null or doesn't exists
*/
public boolean removeFloor(String liftName, String floorName) {
Bukkit.getLogger().info("[V10Lift] Removing floor at " + liftName);
if (liftName == null || floorName == null || !DataManager.containsLift(liftName)) return false;
Lift lift = DataManager.getLift(liftName);
if (!lift.getFloors().containsKey(floorName)) return false;
@ -426,6 +477,7 @@ public class V10LiftAPI {
* @return 0 if renamed, -1 if null or doesn't exists, -2 if floor doesn't exists, -3 if floor already exists
*/
public int renameFloor(String liftName, String oldName, String newName) {
Bukkit.getLogger().info("[V10Lift] Renaming floor at " + liftName);
if (liftName == null || oldName == null || newName == null || !DataManager.containsLift(liftName)) return -1;
Lift lift = DataManager.getLift(liftName);
if (!lift.getFloors().containsKey(oldName)) return -2;
@ -469,6 +521,7 @@ public class V10LiftAPI {
* @return 0 if set, -1 if null or doesn't exists, -2 if same state, -3 if no signs, -4 if wrong sign
*/
public int setDefective(String liftName, boolean state) {
Bukkit.getLogger().info("[V10Lift] Set defective");
if (liftName == null || !DataManager.containsLift(liftName)) return -1;
Lift lift = DataManager.getLift(liftName);
boolean oldState = lift.isDefective();
@ -556,8 +609,8 @@ public class V10LiftAPI {
* @param floorName The name of the floor
* @return list with UUIDs of the players
*/
public ArrayList<UUID> getWhitelist(String liftName, String floorName) {
ArrayList<UUID> ret = new ArrayList<>();
public HashSet<UUID> getWhitelist(String liftName, String floorName) {
HashSet<UUID> ret = new HashSet<>();
if (liftName != null && floorName != null && DataManager.containsLift(liftName)) {
Lift lift = DataManager.getLift(liftName);
if (lift.getFloors().containsKey(floorName)) {
@ -757,6 +810,7 @@ public class V10LiftAPI {
* @return 0 if added, -1 if null or doesn't exists, -2 if not same mat, -3 if already a rope, -4 if forbidden material
*/
public int addRope(String lift, World world, int x, int minY, int maxY, int z) {
Bukkit.getLogger().info("[V10Lift] Adding rope to " + lift);
if (lift == null || !DataManager.containsLift(lift) || world == null) return -1;
boolean change = minY > maxY;
@ -783,6 +837,7 @@ public class V10LiftAPI {
* @return true/false
*/
public boolean removeRope(String lift, Block block) {
Bukkit.getLogger().info("[V10Lift] Removing rope from " + lift);
if (lift == null || block == null || !DataManager.containsLift(lift) || !containsRope(lift, block)) return false;
String world = block.getWorld().getName();
@ -845,6 +900,7 @@ public class V10LiftAPI {
* @return true/false
*/
public boolean addToQueue(String lift, int y, @Nonnull World world, String floorName) {
Bukkit.getLogger().info("[V10Lift] Adding to queue: " + lift);
return addToQueue(lift, new Floor(y, world.getName()), floorName);
}
@ -858,6 +914,7 @@ public class V10LiftAPI {
* @return true/false
*/
public boolean addToQueue(String lift, Floor floor, String floorName) {
Bukkit.getLogger().info("[V10Lift] Adding to queue: " + lift);
if (lift == null || floor == null || !DataManager.containsLift(lift)) return false;
Lift l = DataManager.getLift(lift);

View file

@ -22,7 +22,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import javax.xml.crypto.Data;
import java.util.Iterator;
import java.util.Map;
@ -34,9 +33,12 @@ public class PlayerInteractListener implements Listener {
Block block = e.getClickedBlock();
if (block == null) return;
Material button = block.getType();
Bukkit.getLogger().severe("Button pressed! " + action + " || " + e.getHand() + " || " + button);
if (action == Action.RIGHT_CLICK_BLOCK
&& e.getHand() != EquipmentSlot.OFF_HAND
&& (button.toString().contains("BUTTON") || button == XMaterial.LEVER.parseMaterial())) {
&& (button.toString().contains("_BUTTON") || button == XMaterial.LEVER.parseMaterial())) {
String world = block.getWorld().getName();
int x = block.getX();
int y = block.getY();
@ -50,6 +52,15 @@ public class PlayerInteractListener implements Listener {
return;
}
}
if (lift.isOffline()) return;
for (LiftBlock lb : lift.getInputs()) {
if (world.equals(lb.getWorld()) && x == lb.getX() && y == lb.getY() && z == lb.getZ()) {
V10LiftPlugin.getAPI().addToQueue(entry.getKey(), lift.getFloors().get(lb.getFloor()), lb.getFloor());
return;
}
}
}
}
}
@ -208,7 +219,13 @@ public class PlayerInteractListener implements Listener {
p.sendMessage(ChatColor.RED + "The material " + e.getClickedBlock().getType().toString() + " is currently not supported!");
return;
}
LiftBlock lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), block.getType());
LiftBlock lb;
if (XMaterial.isNewVersion()) {
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), block.getType());
} else {
Bukkit.getLogger().info("Using deprecated method! " + block.getState().getRawData());
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), block.getType(), block.getState().getRawData());
}
Lift lift = DataManager.getLift(DataManager.getEditPlayer(p.getUniqueId()));
Floor floor = lift.getFloors().get(DataManager.getDoorEditPlayer(p.getUniqueId()));
if (floor.getDoorBlocks().contains(lb)) {