Skip to content

Commit 586412e

Browse files
Add import compat for MySQL import
1 parent e7bd91b commit 586412e

1 file changed

Lines changed: 18 additions & 20 deletions

File tree

src/main/java/com/nuclyon/technicallycoded/inventoryrollback/util/BackupConversionUtil.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import me.danjono.inventoryrollback.config.ConfigData;
55
import me.danjono.inventoryrollback.config.MessageData;
66
import me.danjono.inventoryrollback.data.LogType;
7+
import me.danjono.inventoryrollback.data.PlayerData;
78
import me.danjono.inventoryrollback.data.YAML;
89
import me.danjono.inventoryrollback.inventory.RestoreInventory;
910
import org.apache.commons.lang.Validate;
@@ -82,12 +83,9 @@ private static ArrayList<File> getFilesToConvert(File[] availableFiles) {
8283
// Sanity check files in the folder & add them to a list to process later
8384
for (File file : availableFiles) {
8485
String originalFileName = file.getName();
85-
System.out.println(originalFileName);
8686
String[] fileParts = originalFileName.split("\\.");
8787
String fileUUIDStr = fileParts[0];
88-
System.out.println(fileUUIDStr);
8988
String fileExtension = fileParts[1];
90-
System.out.println(fileExtension);
9189

9290
UUID playerUuid;
9391
try {
@@ -143,8 +141,6 @@ public static void convertBackupFile(Logger logger, File backupFile, LogType log
143141
continue;
144142
}
145143

146-
YAML loadedYamlBackup = new YAML(uuid, logTypeProcessing, timestamp);
147-
148144
// ---- Load all data from the old config ----
149145

150146
String packageVersion = oldBackupDataConfig.getString("data." + timestamp + ".version");
@@ -169,17 +165,19 @@ public static void convertBackupFile(Logger logger, File backupFile, LogType log
169165

170166
// ---- Process all loaded data ----
171167

172-
loadedYamlBackup.setMainInventory(mainInvItems);
173-
loadedYamlBackup.setArmour(armorItems);
174-
loadedYamlBackup.setEnderChest(enderChestItems);
175-
loadedYamlBackup.setXP(xp);
176-
loadedYamlBackup.setHealth(health);
177-
loadedYamlBackup.setFoodLevel(foodLevel);
178-
loadedYamlBackup.setSaturation(saturation);
179-
loadedYamlBackup.setWorld(worldName);
180-
loadedYamlBackup.setX(posX);
181-
loadedYamlBackup.setY(posY);
182-
loadedYamlBackup.setZ(posZ);
168+
PlayerData importedData = new PlayerData(uuid, logTypeProcessing, timestamp);
169+
170+
importedData.setMainInventory(mainInvItems);
171+
importedData.setArmour(armorItems);
172+
importedData.setEnderChest(enderChestItems);
173+
importedData.setXP(xp);
174+
importedData.setHealth(health);
175+
importedData.setFoodLevel(foodLevel);
176+
importedData.setSaturation(saturation);
177+
importedData.setWorld(worldName);
178+
importedData.setX(posX);
179+
importedData.setY(posY);
180+
importedData.setZ(posZ);
183181

184182
// Sanity check log type
185183
if (logTypeStoredString == null) {
@@ -205,12 +203,12 @@ public static void convertBackupFile(Logger logger, File backupFile, LogType log
205203
}
206204

207205
// Apply last data after sanity checks & conversions
208-
loadedYamlBackup.setLogType(logTypeStored);
209-
loadedYamlBackup.setVersion(packageVersion);
210-
if (deathReason != null) loadedYamlBackup.setDeathReason(deathReason);
206+
importedData.setLogType(logTypeStored);
207+
importedData.setVersion(packageVersion);
208+
if (deathReason != null) importedData.setDeathReason(deathReason);
211209

212210
// Save the data to the new folder location
213-
loadedYamlBackup.saveData();
211+
importedData.saveData();
214212
} catch (Exception e) {
215213
InventoryRollbackPlus.getPluginLogger().warning(
216214
MessageData.getPluginPrefix() + "Error converting backup file at " +

0 commit comments

Comments
 (0)