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
Showing only changes of commit b42876541f - Show all commits

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