|
|
|
@ -7,7 +7,7 @@ import org.bukkit.Location;
|
|
|
|
|
import org.bukkit.Material;
|
|
|
|
|
import org.bukkit.NamespacedKey;
|
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
|
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
import org.bukkit.inventory.ShapelessRecipe;
|
|
|
|
|
import org.bukkit.inventory.meta.ItemMeta;
|
|
|
|
@ -39,18 +39,17 @@ public class LinkedBeaconTeleporterManager {
|
|
|
|
|
|
|
|
|
|
// Load teleporters
|
|
|
|
|
for(String teleporterId : Main.data.getKeys(false)){
|
|
|
|
|
ConfigurationSection teleportersData = Main.data.getConfigurationSection(teleporterId);
|
|
|
|
|
List<String> serialisedLocs = Main.data.getStringList(teleporterId);
|
|
|
|
|
|
|
|
|
|
// New list for this id
|
|
|
|
|
List<LinkedBeaconTeleporter> linkedBeaconTeleporters = new ArrayList();
|
|
|
|
|
|
|
|
|
|
for(String serializedLoc : teleportersData.getKeys(false)) {
|
|
|
|
|
ConfigurationSection teleporterData = teleportersData.getConfigurationSection(serializedLoc);
|
|
|
|
|
for(String serializedLoc : serialisedLocs) {
|
|
|
|
|
|
|
|
|
|
// Load location
|
|
|
|
|
Location loc;
|
|
|
|
|
try {
|
|
|
|
|
loc = Function.deserializeBlockLocation(teleporterData.getString("loc"));
|
|
|
|
|
loc = Function.deserializeBlockLocation(serializedLoc);
|
|
|
|
|
} catch (InvalidPropertiesFormatException e) {
|
|
|
|
|
Main.log.severe("Could not load location='"+ serializedLoc +"' from "+ teleporterId);
|
|
|
|
|
continue;
|
|
|
|
@ -80,6 +79,31 @@ public class LinkedBeaconTeleporterManager {
|
|
|
|
|
Main.log.info("All done!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void saveData(){
|
|
|
|
|
Main.log.info("Saving data..");
|
|
|
|
|
|
|
|
|
|
Main.data = new YamlConfiguration();
|
|
|
|
|
for(String teleporterId : placedLBTsById.keySet()){
|
|
|
|
|
List<LinkedBeaconTeleporter> LBTs = placedLBTsById.get(teleporterId);
|
|
|
|
|
|
|
|
|
|
// Generate clean array with data we want
|
|
|
|
|
List<String> dataList = new ArrayList<>();
|
|
|
|
|
for(LinkedBeaconTeleporter lbt : LBTs){
|
|
|
|
|
dataList.add(
|
|
|
|
|
Function.serialiseBlockLocation(
|
|
|
|
|
((LinkedBeaconTeleporterBlock)lbt).block().getLocation()
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Main.data.set(teleporterId, dataList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Main.saveData();
|
|
|
|
|
|
|
|
|
|
Main.log.info("done");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void constructAndAddRecipes(){
|
|
|
|
|
// Create result-item
|
|
|
|
|
ItemStack item = getItemStackFromData("-");
|
|
|
|
@ -160,7 +184,7 @@ public class LinkedBeaconTeleporterManager {
|
|
|
|
|
return placedLBTsById.get(teleportId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String constructRegex(String name, List<String> lore){
|
|
|
|
|
static String constructRegex(String name, List<String> lore){
|
|
|
|
|
// Serialize
|
|
|
|
|
String regex = serialiseBeaconItem(name, lore);
|
|
|
|
|
|
|
|
|
|