@ -19,7 +19,7 @@ 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 Block > > linkedBeaconTeleporterById = new HashMap ( ) ;
HashMap < String , List < LinkedBeaconTeleporter > > linkedBeaconTeleporterById = new HashMap ( ) ;
HashMap < String , LinkedBeaconTeleporterBlock > linkedBeaconTeleporterByLoc = new HashMap ( ) ;
HashMap < String , LinkedBeaconTeleporterBlock > linkedBeaconTeleporterByLoc = new HashMap ( ) ;
// Regex to match item-name&lore and extract id (group 1)
// Regex to match item-name&lore and extract id (group 1)
@ -42,7 +42,7 @@ public class LinkedBeaconTeleporterManager {
ConfigurationSection teleportersData = Main . data . getConfigurationSection ( teleporterId ) ;
ConfigurationSection teleportersData = Main . data . getConfigurationSection ( teleporterId ) ;
// New list for this id
// New list for this id
ArrayList< LinkedBeaconTeleporterBlock > lbtBlock s = new ArrayList ( ) ;
List< LinkedBeaconTeleporter > linkedBeaconTeleporter s = new ArrayList ( ) ;
for ( String blockId : teleportersData . getKeys ( false ) ) {
for ( String blockId : teleportersData . getKeys ( false ) ) {
ConfigurationSection teleporterData = teleportersData . getConfigurationSection ( blockId ) ;
ConfigurationSection teleporterData = teleportersData . getConfigurationSection ( blockId ) ;
@ -67,16 +67,15 @@ public class LinkedBeaconTeleporterManager {
// Construct block
// Construct block
LinkedBeaconTeleporterBlock lbtBlock = new LinkedBeaconTeleporterBlock ( teleporterId , block ) ;
LinkedBeaconTeleporterBlock lbtBlock = new LinkedBeaconTeleporterBlock ( teleporterId , block ) ;
// Write reference of list
// Add block to id-list
lbtBlock . linkedBeaconTeleporters = linkedBeaconTeleporters ;
lbtBlocks . add ( lbtBlock ) ;
// Save to loc-list
// Save to loc-list
linkedBeaconTeleporterByLoc . put ( serializedLoc , lbtBlock ) ;
linkedBeaconTeleporterByLoc . put ( serializedLoc , lbtBlock ) ;
}
}
// Save list to id-list
// Save list to id-list
linkedBeaconTeleporterById . put ( teleporterId , l btBlock s) ;
linkedBeaconTeleporterById . put ( teleporterId , l inkedBeaconTeleporter s) ;
}
}
Main . log . info ( "All done!" ) ;
Main . log . info ( "All done!" ) ;
@ -84,7 +83,7 @@ public class LinkedBeaconTeleporterManager {
public LinkedBeaconTeleporterBlock placeLbtItem ( LinkedBeaconTeleporterItem lbtItem , Block block ) {
public LinkedBeaconTeleporterBlock placeLbtItem ( LinkedBeaconTeleporterItem lbtItem , Block block ) {
// Check if id already exists
// Check if id already exists
List < LinkedBeaconTeleporter Block > lbtBlocks = linkedBeaconTeleporterById . get ( lbtItem . teleporterId ( ) ) ;
List < LinkedBeaconTeleporter > lbtBlocks = linkedBeaconTeleporterById . get ( lbtItem . teleporterId ( ) ) ;
if ( lbtBlocks = = null ) {
if ( lbtBlocks = = null ) {
// Create empty if not found
// Create empty if not found
lbtBlocks = new ArrayList < > ( ) ;
lbtBlocks = new ArrayList < > ( ) ;
@ -107,7 +106,7 @@ public class LinkedBeaconTeleporterManager {
public LinkedBeaconTeleporterItem breakLbtBlock ( LinkedBeaconTeleporterBlock lbtBlock ) {
public LinkedBeaconTeleporterItem breakLbtBlock ( LinkedBeaconTeleporterBlock lbtBlock ) {
// Get list by id
// Get list by id
List < LinkedBeaconTeleporter Block > lbtBlocks = linkedBeaconTeleporterById . get ( lbtBlock . teleporterId ( ) ) ;
List < LinkedBeaconTeleporter > lbtBlocks = linkedBeaconTeleporterById . get ( lbtBlock . teleporterId ( ) ) ;
// Remove from list
// Remove from list
lbtBlocks . remove ( lbtBlock ) ;
lbtBlocks . remove ( lbtBlock ) ;
@ -198,7 +197,7 @@ public class LinkedBeaconTeleporterManager {
return linkedBeaconTeleporterByLoc . get ( serializedLoc ) ;
return linkedBeaconTeleporterByLoc . get ( serializedLoc ) ;
}
}
public List < LinkedBeaconTeleporter Block > getLbtBlocksFromTeleportId ( String teleportId ) {
public List < LinkedBeaconTeleporter > getLbtBlocksFromTeleportId ( String teleportId ) {
return linkedBeaconTeleporterById . get ( teleportId ) ;
return linkedBeaconTeleporterById . get ( teleportId ) ;
}
}