|
|
|
@ -19,13 +19,13 @@ import java.util.regex.Pattern;
|
|
|
|
|
public class LinkedBeaconTeleporterManager {
|
|
|
|
|
// Stores all placed Beacon-Teleporters for fast access
|
|
|
|
|
// TODO: Evaluate necessity of 2 HashMaps with main reason of performance
|
|
|
|
|
public HashMap<String, List<LinkedBeaconTeleporter>> placedLBTsById = new HashMap();
|
|
|
|
|
public HashMap<String, LinkedBeaconTeleporterBlock> placedLBTByLoc = new HashMap();
|
|
|
|
|
public static HashMap<String, List<LinkedBeaconTeleporter>> placedLBTsById = new HashMap();
|
|
|
|
|
public static HashMap<String, LinkedBeaconTeleporterBlock> placedLBTByLoc = new HashMap();
|
|
|
|
|
|
|
|
|
|
// Regex to match item-name&lore and extract id (group 1)
|
|
|
|
|
String regex;
|
|
|
|
|
static String regex;
|
|
|
|
|
|
|
|
|
|
public LinkedBeaconTeleporterManager(){
|
|
|
|
|
public static void init(){
|
|
|
|
|
Main.log.info("Loading LinkedBeaconTeleporter from config..");
|
|
|
|
|
|
|
|
|
|
// Construct search item-regex
|
|
|
|
@ -80,7 +80,7 @@ public class LinkedBeaconTeleporterManager {
|
|
|
|
|
Main.log.info("All done!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void constructAndAddRecipes(){
|
|
|
|
|
static void constructAndAddRecipes(){
|
|
|
|
|
// Create result-item
|
|
|
|
|
ItemStack item = getItemStackFromData("-");
|
|
|
|
|
item.setAmount(2);
|
|
|
|
@ -102,7 +102,7 @@ public class LinkedBeaconTeleporterManager {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Conversion-methods
|
|
|
|
|
public ItemStack getItemStackFromData(String teleporterId){
|
|
|
|
|
public static ItemStack getItemStackFromData(String teleporterId){
|
|
|
|
|
ItemStack item = new ItemStack(Material.BEACON);
|
|
|
|
|
ItemMeta itemMeta = item.getItemMeta();
|
|
|
|
|
|
|
|
|
@ -126,7 +126,7 @@ public class LinkedBeaconTeleporterManager {
|
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
public LinkedBeaconTeleporterItem getLbtItemFromItemStack(ItemStack itemStack){
|
|
|
|
|
public static LinkedBeaconTeleporterItem getLbtItemFromItemStack(ItemStack itemStack){
|
|
|
|
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
|
|
|
|
|
|
|
|
|
// Serialize
|
|
|
|
@ -150,13 +150,13 @@ public class LinkedBeaconTeleporterManager {
|
|
|
|
|
return lbtItem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LinkedBeaconTeleporterBlock getLbtBlockFromLocation(Location loc){
|
|
|
|
|
public static LinkedBeaconTeleporterBlock getLbtBlockFromLocation(Location loc){
|
|
|
|
|
// Serialize
|
|
|
|
|
String serializedLoc = Function.serialiseBlockLocation(loc);
|
|
|
|
|
|
|
|
|
|
return placedLBTByLoc.get(serializedLoc);
|
|
|
|
|
}
|
|
|
|
|
public List<LinkedBeaconTeleporter> getLbtBlocksFromTeleportId(String teleportId){
|
|
|
|
|
public static List<LinkedBeaconTeleporter> getLbtBlocksFromTeleportId(String teleportId){
|
|
|
|
|
return placedLBTsById.get(teleportId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -174,7 +174,7 @@ public class LinkedBeaconTeleporterManager {
|
|
|
|
|
|
|
|
|
|
return regex;
|
|
|
|
|
}
|
|
|
|
|
String serialiseBeaconItem(String name, List<String> lore){
|
|
|
|
|
static String serialiseBeaconItem(String name, List<String> lore){
|
|
|
|
|
// get name and remove control-chars
|
|
|
|
|
String str = name.replace("\\", "\\\\");
|
|
|
|
|
if(lore != null){
|
|
|
|
|