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