diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterBlock.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterBlock.java index 5a486af..9b8d4c0 100644 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterBlock.java +++ b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterBlock.java @@ -1,9 +1,15 @@ package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter; +import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main; +import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockState; +import org.bukkit.inventory.ItemStack; + +import java.util.List; public class LinkedBeaconTeleporterBlock extends LinkedBeaconTeleporter { + // FIXME: Storing the block like this will block the world from unloading and might be dangerous Block block; public LinkedBeaconTeleporterBlock(String teleporterId, Block block) { @@ -15,4 +21,13 @@ public class LinkedBeaconTeleporterBlock extends LinkedBeaconTeleporter { public Block block(){ return block; } + + + // Conversion methods + public static LinkedBeaconTeleporterBlock getFromLocation(Location loc){ + return Main.lbtManager.getLbtBlockFromLocation(loc); + } + public static List getListFromTeleportId(String teleportId){ + return Main.lbtManager.getLbtBlocksFromTeleportId(teleportId); + } } diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterManager.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterManager.java index b57bded..e8d0e3d 100644 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterManager.java +++ b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterManager.java @@ -121,6 +121,16 @@ public class LinkedBeaconTeleporterManager { return lbtItem; } + public LinkedBeaconTeleporterBlock getLbtBlockFromLocation(Location loc){ + // Serialize + String serializedLoc = Function.serialiseBlockLocation(loc); + + return linkedBeaconTeleporterByLoc.get(serializedLoc); + } + public List getLbtBlocksFromTeleportId(String teleportId){ + return linkedBeaconTeleporterById.get(teleportId); + } + String constructRegex(String name, List lore){ // Serialize String regex = serialiseBeaconItem(name, lore);