|
|
@ -19,8 +19,8 @@ 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
|
|
|
|
HashMap<String, List<LinkedBeaconTeleporter>> linkedBeaconTeleporterById = new HashMap();
|
|
|
|
public HashMap<String, List<LinkedBeaconTeleporter>> placedLBTsById = new HashMap();
|
|
|
|
HashMap<String, LinkedBeaconTeleporterBlock> linkedBeaconTeleporterByLoc = new HashMap();
|
|
|
|
public 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;
|
|
|
|
String regex;
|
|
|
@ -71,56 +71,16 @@ public class LinkedBeaconTeleporterManager {
|
|
|
|
lbtBlock.linkedBeaconTeleporters = linkedBeaconTeleporters;
|
|
|
|
lbtBlock.linkedBeaconTeleporters = linkedBeaconTeleporters;
|
|
|
|
|
|
|
|
|
|
|
|
// Save to loc-list
|
|
|
|
// Save to loc-list
|
|
|
|
linkedBeaconTeleporterByLoc.put(serializedLoc, lbtBlock);
|
|
|
|
placedLBTByLoc.put(serializedLoc, lbtBlock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Save list to id-list
|
|
|
|
// Save list to id-list
|
|
|
|
linkedBeaconTeleporterById.put(teleporterId, linkedBeaconTeleporters);
|
|
|
|
placedLBTsById.put(teleporterId, linkedBeaconTeleporters);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Main.log.info("All done!");
|
|
|
|
Main.log.info("All done!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public LinkedBeaconTeleporterBlock placeLbtItem(LinkedBeaconTeleporterItem lbtItem, Block block){
|
|
|
|
|
|
|
|
// Check if id already exists
|
|
|
|
|
|
|
|
List<LinkedBeaconTeleporter> lbtBlocks = linkedBeaconTeleporterById.get(lbtItem.teleporterId());
|
|
|
|
|
|
|
|
if(lbtBlocks == null){
|
|
|
|
|
|
|
|
// Create empty if not found
|
|
|
|
|
|
|
|
lbtBlocks = new ArrayList<>();
|
|
|
|
|
|
|
|
linkedBeaconTeleporterById.put(lbtItem.teleporterId(), lbtBlocks);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Block from item
|
|
|
|
|
|
|
|
LinkedBeaconTeleporterBlock lbtBlock = new LinkedBeaconTeleporterBlock(lbtItem.teleporterId(), block);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add to list
|
|
|
|
|
|
|
|
lbtBlocks.add(lbtBlock);
|
|
|
|
|
|
|
|
// Add to location
|
|
|
|
|
|
|
|
linkedBeaconTeleporterByLoc.put(
|
|
|
|
|
|
|
|
Function.serialiseBlockLocation(block.getLocation()),
|
|
|
|
|
|
|
|
lbtBlock
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return lbtBlock;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public LinkedBeaconTeleporterItem breakLbtBlock(LinkedBeaconTeleporterBlock lbtBlock){
|
|
|
|
|
|
|
|
// Get list by id
|
|
|
|
|
|
|
|
List<LinkedBeaconTeleporter> lbtBlocks = linkedBeaconTeleporterById.get(lbtBlock.teleporterId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Remove from list
|
|
|
|
|
|
|
|
lbtBlocks.remove(lbtBlock);
|
|
|
|
|
|
|
|
// Remove from location
|
|
|
|
|
|
|
|
linkedBeaconTeleporterByLoc.remove(
|
|
|
|
|
|
|
|
Function.serialiseBlockLocation(lbtBlock.block().getLocation())
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Item from block
|
|
|
|
|
|
|
|
LinkedBeaconTeleporterItem lbtItem = new LinkedBeaconTeleporterItem(lbtBlock.teleporterId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return lbtItem;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void constructAndAddRecipes(){
|
|
|
|
void constructAndAddRecipes(){
|
|
|
|
// Create result-item
|
|
|
|
// Create result-item
|
|
|
|
ItemStack item = getItemStackFromData("-");
|
|
|
|
ItemStack item = getItemStackFromData("-");
|
|
|
@ -195,10 +155,10 @@ public class LinkedBeaconTeleporterManager {
|
|
|
|
// Serialize
|
|
|
|
// Serialize
|
|
|
|
String serializedLoc = Function.serialiseBlockLocation(loc);
|
|
|
|
String serializedLoc = Function.serialiseBlockLocation(loc);
|
|
|
|
|
|
|
|
|
|
|
|
return linkedBeaconTeleporterByLoc.get(serializedLoc);
|
|
|
|
return placedLBTByLoc.get(serializedLoc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public List<LinkedBeaconTeleporter> getLbtBlocksFromTeleportId(String teleportId){
|
|
|
|
public List<LinkedBeaconTeleporter> getLbtBlocksFromTeleportId(String teleportId){
|
|
|
|
return linkedBeaconTeleporterById.get(teleportId);
|
|
|
|
return placedLBTsById.get(teleportId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String constructRegex(String name, List<String> lore){
|
|
|
|
String constructRegex(String name, List<String> lore){
|
|
|
|