now it works in pre4. #3

Closed
JuliGame wants to merge 1 commits from JuliGame/VehiclesPlusConverter:master into master
1 changed files with 21 additions and 11 deletions

View File

@ -21,6 +21,7 @@ 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 nl.sbdeveloper.vehiclesplus.utils.jackson.ColorList;
import org.bukkit.Bukkit;
import org.bukkit.Particle;
import org.bukkit.command.CommandSender;
@ -100,11 +101,11 @@ public class Converter {
private static void convertVehicleModels() {
for (BaseVehicle baseVehicle : VehiclesPlusAPI.getVehicleManager().getBaseVehicleMap().values()) {
try {
VehicleModel.VehicleModelBuilder vehicleModelBuilder = VehicleModel.builder()
VehicleModel.Builder vehicleModelBuilder = VehicleModel.builder()
.id(baseVehicle.getName())
.displayName(baseVehicle.getName())
.typeId(getTypeIdByClass(baseVehicle.getName(), getClassByFullName(baseVehicle.getVehicleType())))
.availableColors(baseVehicle.getBaseColorList());
.availableColors(new ColorList(baseVehicle.getBaseColorList()));
for (Part part : baseVehicle.getPartList()) {
if (part instanceof BikeSeat) {
@ -188,29 +189,32 @@ public class Converter {
baseVehicle.getSpeedSettings().getBase(),
baseVehicle.getSpeedSettings().getMax(),
baseVehicle.getSpeedSettings().getStep(),
baseVehicle.getSpeedSettings().getUpgradeCost()
baseVehicle.getSpeedSettings().getUpgradeCost(), "km/h"
))
.fuelTank(new UpgradableSetting(
baseVehicle.getFuelTankSettings().getBase(),
baseVehicle.getFuelTankSettings().getMax(),
baseVehicle.getFuelTankSettings().getStep(),
baseVehicle.getFuelTankSettings().getUpgradeCost()
baseVehicle.getFuelTankSettings().getUpgradeCost(), "L"
))
.turningRadius(new UpgradableSetting(
baseVehicle.getTurningRadiusSettings().getBase(),
baseVehicle.getTurningRadiusSettings().getMax(),
baseVehicle.getTurningRadiusSettings().getStep(),
baseVehicle.getTurningRadiusSettings().getUpgradeCost()
baseVehicle.getTurningRadiusSettings().getUpgradeCost(), ""
))
.acceleration(new UpgradableSetting(
baseVehicle.getAccelerationSettings().getBase(),
baseVehicle.getAccelerationSettings().getMax(),
baseVehicle.getAccelerationSettings().getStep(),
baseVehicle.getAccelerationSettings().getUpgradeCost()
baseVehicle.getAccelerationSettings().getUpgradeCost(), ""
))
.horn(new Horn(
baseVehicle.getHornSettings().getEnabled(),
baseVehicle.getHornSettings().getSound().name()
new Sounds.Sound(
baseVehicle.getHornSettings().getSound().name(),
1
)
))
.drift(baseVehicle.getDrift())
.exhaust(new Exhaust(
@ -235,15 +239,21 @@ public class Converter {
))
.realisticSteering(baseVehicle.getSteeringType())
.permissions(Permissions.builder()
.buy(baseVehicle.getPermissions().getBuyPermission())
.ride(baseVehicle.getPermissions().getRidePermission())
.sitWithoutRidePermission(baseVehicle.getPermissions().getEnterWithoutRidePermission())
// this was hardcoded because if a config had no permission it produced a null pointer.
.buy("vp.buy." + baseVehicle.getName())
.ride("vp.ride." + baseVehicle.getName())
.sitWithoutRidePermission(false)
.adjust("vp.adjust." + baseVehicle.getName())
.spawn("vp.spawn." + baseVehicle.getName())
.build())
.sounds(defaultSounds)
.gearbox(new Gearbox(true, 10))
.build();
// Idk why but it was detecting type as "car" and it should be "cars" to work
if (model.getTypeId().equals("car"))
model.setTypeId("cars");
saveToVehiclesPlus(model, "vehicles/" + model.getTypeId(), model.getId());
} catch (Exception e) {
e.printStackTrace();
@ -280,7 +290,7 @@ public class Converter {
garage.save();
} catch (DataStorageException e) {
e.printStackTrace();
Bukkit.getLogger().severe("Could not convert vehicle for player with UUID " + ownerUUID + ", could not save the garage!");
Bukkit.getLogger().severe("Could not convert vehicles for player with UUID " + ownerUUID + ", could not save the garage!");
}
}
}