diff --git a/pom.xml b/pom.xml
index 1d2a0c1..2e705bc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
tech.sbdevelopment
VehiclesPlusConverter
- 0.1.2
+ 0.1.3
jar
VehiclesPlusConverter
@@ -82,9 +82,9 @@
nl.sbdeveloper
VehiclesPlus-v3
- 3.0.0-SNAPSHOT
+ 3.0.0-PRE3
system
- ${project.basedir}/src/libs/VehiclesPlus-3.0.0-SNAPSHOT.jar
+ ${project.basedir}/src/libs/VehiclesPlus-3.0.0-PRE3.jar
diff --git a/src/main/java/tech/sbdevelopment/vehiclesplusconverter/handlers/Converter.java b/src/main/java/tech/sbdevelopment/vehiclesplusconverter/handlers/Converter.java
index ea275e1..69bad9d 100644
--- a/src/main/java/tech/sbdevelopment/vehiclesplusconverter/handlers/Converter.java
+++ b/src/main/java/tech/sbdevelopment/vehiclesplusconverter/handlers/Converter.java
@@ -15,9 +15,12 @@ import me.legofreak107.vehiclesplus.vehicles.vehicles.objects.addons.skins.BikeS
import me.legofreak107.vehiclesplus.vehicles.vehicles.objects.addons.skins.Rotor;
import me.legofreak107.vehiclesplus.vehicles.vehicles.objects.addons.skins.Skin;
import me.legofreak107.vehiclesplus.vehicles.vehicles.objects.addons.skins.Turret;
+import nl.sbdeveloper.vehiclesplus.api.garages.Garage;
+import nl.sbdeveloper.vehiclesplus.api.vehicles.HolderItemPosition;
import nl.sbdeveloper.vehiclesplus.api.vehicles.VehicleModel;
import nl.sbdeveloper.vehiclesplus.api.vehicles.settings.UpgradableSetting;
import nl.sbdeveloper.vehiclesplus.api.vehicles.settings.impl.*;
+import nl.sbdeveloper.vehiclesplus.storage.db.exceptions.DataStorageException;
import org.bukkit.Bukkit;
import org.bukkit.Particle;
import org.bukkit.command.CommandSender;
@@ -72,11 +75,11 @@ public class Converter {
private static void convertRims() {
for (Map.Entry entry : VehiclesPlus.getVehicleManager().getRimDesignHashMap().entrySet()) {
- nl.sbdeveloper.vehiclesplus.api.vehicles.rims.RimDesign rd = nl.sbdeveloper.vehiclesplus.api.vehicles.rims.RimDesign.builder()
- .name(entry.getValue().getName())
- .price(entry.getValue().getPrice())
- .skin(entry.getValue().getSkin())
- .build();
+ nl.sbdeveloper.vehiclesplus.api.vehicles.rims.RimDesign rd = new nl.sbdeveloper.vehiclesplus.api.vehicles.rims.RimDesign(
+ entry.getValue().getName(),
+ entry.getValue().getSkin(),
+ entry.getValue().getPrice()
+ );
nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI.getRimDesigns().put(entry.getKey(), rd);
}
@@ -86,8 +89,8 @@ public class Converter {
for (Map.Entry entry : VehiclesPlus.getVehicleManager().getFuelTypeHashMap().entrySet()) {
nl.sbdeveloper.vehiclesplus.api.vehicles.fuel.FuelType ft = new nl.sbdeveloper.vehiclesplus.api.vehicles.fuel.FuelType(
entry.getValue().getName(),
- entry.getValue().getPricePerLiter(),
- entry.getValue().getFuelItem()
+ entry.getValue().getFuelItem(),
+ entry.getValue().getPricePerLiter()
);
nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI.getFuelTypes().put(entry.getKey(), ft);
@@ -134,7 +137,8 @@ public class Converter {
bikeSkin.getXOffset(),
bikeSkin.getYOffset(),
bikeSkin.getZOffset(),
- bikeSkin.getSkinColored()
+ bikeSkin.getSkinColored(),
+ HolderItemPosition.HEAD
));
} else if (part instanceof Rotor) {
Rotor rotor = (Rotor) part;
@@ -142,7 +146,8 @@ public class Converter {
rotor.getXOffset(),
rotor.getYOffset(),
rotor.getZOffset(),
- rotor.getSkinColored()
+ rotor.getSkinColored(),
+ HolderItemPosition.HEAD
));
} else if (part instanceof Turret) {
Turret turret = (Turret) part;
@@ -151,6 +156,7 @@ public class Converter {
turret.getYOffset(),
turret.getZOffset(),
turret.getSkin(),
+ HolderItemPosition.HEAD,
turret.getExplosionSize(),
turret.getAmmo()
));
@@ -160,7 +166,8 @@ public class Converter {
skin.getXOffset(),
skin.getYOffset(),
skin.getZOffset(),
- skin.getSkinColored()
+ skin.getSkinColored(),
+ HolderItemPosition.HEAD
));
} else if (part instanceof Wheel) {
Wheel wheel = (Wheel) part;
@@ -247,18 +254,34 @@ public class Converter {
private static void convertVehicles() {
for (Map.Entry> set : VehiclesPlusAPI.getVehicleManager().getPlayerVehicleHashMap().entrySet()) {
UUID ownerUUID = set.getKey();
+ String ownerName = Bukkit.getOfflinePlayer(ownerUUID).getName();
+ if (ownerName == null) {
+ Bukkit.getLogger().severe("Could not convert vehicle for player with UUID " + ownerUUID + ", the player name is unknown!");
+ continue;
+ }
+
+ final Garage garage = nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI.getGarage(ownerName).orElseGet(() -> new Garage(ownerName, ownerUUID));
+
for (StorageVehicle vehicle : set.getValue()) {
try {
nl.sbdeveloper.vehiclesplus.api.vehicles.impl.StorageVehicle newVehicle = new nl.sbdeveloper.vehiclesplus.api.vehicles.impl.StorageVehicle(
- nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI.getVehicleModels().values().stream().filter(v -> v.getId().equalsIgnoreCase(vehicle.getBaseVehicle())).findFirst().orElseThrow(() -> new ConversionException("No VehicleModel found for", vehicle.getUuid())),
- ownerUUID
+ nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI.getVehicleModels().values().stream().filter(v -> v.getId().equalsIgnoreCase(vehicle.getBaseVehicle())).findFirst().orElseThrow(() -> new ConversionException("No VehicleModel found for", vehicle.getUuid()))
);
newVehicle.save();
+ garage.addVehicle(newVehicle.getUuid());
} catch (Exception e) {
e.printStackTrace();
+ Bukkit.getLogger().severe("Could not convert vehicle for player with UUID " + ownerUUID + ", could not save the vehicle!");
}
}
+
+ try {
+ garage.save();
+ } catch (DataStorageException e) {
+ e.printStackTrace();
+ Bukkit.getLogger().severe("Could not convert vehicle for player with UUID " + ownerUUID + ", could not save the garage!");
+ }
}
}
}