Compare commits

...

4 Commits

4 changed files with 41 additions and 33 deletions

20
pom.xml
View File

@ -6,14 +6,13 @@
<groupId>tech.sbdevelopment</groupId>
<artifactId>VehiclesPlusConverter</artifactId>
<version>0.1.3</version>
<version>0.1.4</version>
<packaging>jar</packaging>
<name>VehiclesPlusConverter</name>
<description>Conversion plugin for v2 to v3.</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>sbdevelopment.tech</url>
@ -23,16 +22,15 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.13.0</version>
<configuration>
<source>10</source>
<target>10</target>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<version>3.6.0</version>
<executions>
<execution>
<phase>package</phase>
@ -69,22 +67,22 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>nl.sbdeveloper</groupId>
<artifactId>VehiclesPlus-v2</artifactId>
<version>2.3.5</version>
<version>2.4.6.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/libs/VehiclesPlus-2.3.5.jar</systemPath>
<systemPath>${project.basedir}/src/libs/VehiclesPlus-2.4.6.2.jar</systemPath>
</dependency>
<dependency>
<groupId>nl.sbdeveloper</groupId>
<artifactId>VehiclesPlus-v3</artifactId>
<version>3.0.0-PRE3</version>
<version>3.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/libs/VehiclesPlus-3.0.0-PRE3.jar</systemPath>
<systemPath>${project.basedir}/src/libs/VehiclesPlus-3.0.0-SNAPSHOT-Clean.jar</systemPath>
</dependency>
</dependencies>
</project>

3
renovate.json Normal file
View File

@ -0,0 +1,3 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
}

View File

@ -21,8 +21,8 @@ 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;
import org.bukkit.scheduler.BukkitRunnable;
import tech.sbdevelopment.vehiclesplusconverter.VehiclesPlusConverter;
@ -100,11 +100,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) {
@ -175,8 +175,9 @@ public class Converter {
wheel.getXOffset(),
wheel.getYOffset(),
wheel.getZOffset(),
VehiclesPlus.getVehicleManager().getRimDesignHashMap().values().stream().findFirst().orElseThrow(() -> new ConversionException("No RimDesign found while loading Wheel in file", baseVehicle.getName())).getName(),
nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI.getRimDesign(VehiclesPlus.getVehicleManager().getRimDesignHashMap().values().stream().findFirst().orElseThrow(() -> new ConversionException("No RimDesign found while loading Wheel in file", baseVehicle.getName())).getName()).orElseThrow(() -> new ConversionException("No matching RimDesign found while loading Wheel in file", baseVehicle.getName())),
wheel.getColor(),
HolderItemPosition.HEAD,
wheel.getSteering(),
wheel.getRotationOffset()
));
@ -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().parseSound().name(),
1
)
))
.drift(baseVehicle.getDrift())
.exhaust(new Exhaust(
@ -218,7 +222,7 @@ public class Converter {
baseVehicle.getExhaustSettings().getXOffset(),
baseVehicle.getExhaustSettings().getYOffset(),
baseVehicle.getExhaustSettings().getZOffset(),
Particle.valueOf(baseVehicle.getExhaustSettings().getParticleName())
baseVehicle.getExhaustSettings().getParticle().get()
))
.exitWhileMoving(baseVehicle.getCanExitWhileMoving())
.price(baseVehicle.getPrice())
@ -242,6 +246,7 @@ public class Converter {
.spawn("vp.spawn." + baseVehicle.getName())
.build())
.sounds(defaultSounds)
.gearbox(new Gearbox(true, 10))
.build();
saveToVehiclesPlus(model, "vehicles/" + model.getTypeId(), model.getId());
@ -256,7 +261,7 @@ public class Converter {
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!");
Bukkit.getLogger().severe("Could not convert vehicles for player with UUID " + ownerUUID + ", the player name is unknown!");
continue;
}
@ -265,22 +270,24 @@ public class Converter {
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()))
UUID.randomUUID(),
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())),
false
);
newVehicle.save();
newVehicle.forceSave();
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!");
Bukkit.getLogger().severe("Could not convert vehicles for player with UUID " + ownerUUID + ", could not save the vehicle!");
}
}
try {
garage.save();
garage.forceSave();
} 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!");
}
}
}

View File

@ -27,17 +27,17 @@ public class MainUtil {
public static String getTypeIdByClass(String baseVehicle, String type) throws ConversionException {
switch (type) {
case "BikeType":
return "bike";
return "bikes";
case "BoatType":
return "boat";
return "boats";
case "CarType":
return "car";
return "cars";
case "HelicopterType":
return "helicopter";
return "helicopters";
case "HovercraftType":
return "hovercraft";
return "hovercrafts";
case "PlaneType":
return "plane";
return "planes";
default:
throw new InvalidConversionException("vehicleType", baseVehicle);
}