From 2f621d7a9bd15c8cb1fa9be807c6bb2bdb87526f Mon Sep 17 00:00:00 2001 From: Ruakij Date: Sun, 9 May 2021 22:46:18 +0200 Subject: [PATCH] Implemented getter for LinkedBeaconTeleporterBlock from Location and teleportId --- .../LinkedBeaconTeleporterBlock.java | 15 +++++++++++++++ .../LinkedBeaconTeleporterManager.java | 10 ++++++++++ 2 files changed, 25 insertions(+) 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);