forked from SBDevelopment/VehiclesPlusConverter
Bumped to v0.1.3: Fixed PRE3 support
This commit is contained in:
parent
074064b551
commit
8f8b3051e5
6
pom.xml
6
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>tech.sbdevelopment</groupId>
|
<groupId>tech.sbdevelopment</groupId>
|
||||||
<artifactId>VehiclesPlusConverter</artifactId>
|
<artifactId>VehiclesPlusConverter</artifactId>
|
||||||
<version>0.1.2</version>
|
<version>0.1.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>VehiclesPlusConverter</name>
|
<name>VehiclesPlusConverter</name>
|
||||||
|
@ -82,9 +82,9 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>nl.sbdeveloper</groupId>
|
<groupId>nl.sbdeveloper</groupId>
|
||||||
<artifactId>VehiclesPlus-v3</artifactId>
|
<artifactId>VehiclesPlus-v3</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-PRE3</version>
|
||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${project.basedir}/src/libs/VehiclesPlus-3.0.0-SNAPSHOT.jar</systemPath>
|
<systemPath>${project.basedir}/src/libs/VehiclesPlus-3.0.0-PRE3.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -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.Rotor;
|
||||||
import me.legofreak107.vehiclesplus.vehicles.vehicles.objects.addons.skins.Skin;
|
import me.legofreak107.vehiclesplus.vehicles.vehicles.objects.addons.skins.Skin;
|
||||||
import me.legofreak107.vehiclesplus.vehicles.vehicles.objects.addons.skins.Turret;
|
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.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 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;
|
||||||
|
@ -72,11 +75,11 @@ public class Converter {
|
||||||
|
|
||||||
private static void convertRims() {
|
private static void convertRims() {
|
||||||
for (Map.Entry<String, RimDesign> entry : VehiclesPlus.getVehicleManager().getRimDesignHashMap().entrySet()) {
|
for (Map.Entry<String, RimDesign> entry : VehiclesPlus.getVehicleManager().getRimDesignHashMap().entrySet()) {
|
||||||
nl.sbdeveloper.vehiclesplus.api.vehicles.rims.RimDesign rd = nl.sbdeveloper.vehiclesplus.api.vehicles.rims.RimDesign.builder()
|
nl.sbdeveloper.vehiclesplus.api.vehicles.rims.RimDesign rd = new nl.sbdeveloper.vehiclesplus.api.vehicles.rims.RimDesign(
|
||||||
.name(entry.getValue().getName())
|
entry.getValue().getName(),
|
||||||
.price(entry.getValue().getPrice())
|
entry.getValue().getSkin(),
|
||||||
.skin(entry.getValue().getSkin())
|
entry.getValue().getPrice()
|
||||||
.build();
|
);
|
||||||
|
|
||||||
nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI.getRimDesigns().put(entry.getKey(), rd);
|
nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI.getRimDesigns().put(entry.getKey(), rd);
|
||||||
}
|
}
|
||||||
|
@ -86,8 +89,8 @@ public class Converter {
|
||||||
for (Map.Entry<String, FuelType> entry : VehiclesPlus.getVehicleManager().getFuelTypeHashMap().entrySet()) {
|
for (Map.Entry<String, FuelType> entry : VehiclesPlus.getVehicleManager().getFuelTypeHashMap().entrySet()) {
|
||||||
nl.sbdeveloper.vehiclesplus.api.vehicles.fuel.FuelType ft = new nl.sbdeveloper.vehiclesplus.api.vehicles.fuel.FuelType(
|
nl.sbdeveloper.vehiclesplus.api.vehicles.fuel.FuelType ft = new nl.sbdeveloper.vehiclesplus.api.vehicles.fuel.FuelType(
|
||||||
entry.getValue().getName(),
|
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);
|
nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI.getFuelTypes().put(entry.getKey(), ft);
|
||||||
|
@ -134,7 +137,8 @@ public class Converter {
|
||||||
bikeSkin.getXOffset(),
|
bikeSkin.getXOffset(),
|
||||||
bikeSkin.getYOffset(),
|
bikeSkin.getYOffset(),
|
||||||
bikeSkin.getZOffset(),
|
bikeSkin.getZOffset(),
|
||||||
bikeSkin.getSkinColored()
|
bikeSkin.getSkinColored(),
|
||||||
|
HolderItemPosition.HEAD
|
||||||
));
|
));
|
||||||
} else if (part instanceof Rotor) {
|
} else if (part instanceof Rotor) {
|
||||||
Rotor rotor = (Rotor) part;
|
Rotor rotor = (Rotor) part;
|
||||||
|
@ -142,7 +146,8 @@ public class Converter {
|
||||||
rotor.getXOffset(),
|
rotor.getXOffset(),
|
||||||
rotor.getYOffset(),
|
rotor.getYOffset(),
|
||||||
rotor.getZOffset(),
|
rotor.getZOffset(),
|
||||||
rotor.getSkinColored()
|
rotor.getSkinColored(),
|
||||||
|
HolderItemPosition.HEAD
|
||||||
));
|
));
|
||||||
} else if (part instanceof Turret) {
|
} else if (part instanceof Turret) {
|
||||||
Turret turret = (Turret) part;
|
Turret turret = (Turret) part;
|
||||||
|
@ -151,6 +156,7 @@ public class Converter {
|
||||||
turret.getYOffset(),
|
turret.getYOffset(),
|
||||||
turret.getZOffset(),
|
turret.getZOffset(),
|
||||||
turret.getSkin(),
|
turret.getSkin(),
|
||||||
|
HolderItemPosition.HEAD,
|
||||||
turret.getExplosionSize(),
|
turret.getExplosionSize(),
|
||||||
turret.getAmmo()
|
turret.getAmmo()
|
||||||
));
|
));
|
||||||
|
@ -160,7 +166,8 @@ public class Converter {
|
||||||
skin.getXOffset(),
|
skin.getXOffset(),
|
||||||
skin.getYOffset(),
|
skin.getYOffset(),
|
||||||
skin.getZOffset(),
|
skin.getZOffset(),
|
||||||
skin.getSkinColored()
|
skin.getSkinColored(),
|
||||||
|
HolderItemPosition.HEAD
|
||||||
));
|
));
|
||||||
} else if (part instanceof Wheel) {
|
} else if (part instanceof Wheel) {
|
||||||
Wheel wheel = (Wheel) part;
|
Wheel wheel = (Wheel) part;
|
||||||
|
@ -247,18 +254,34 @@ public class Converter {
|
||||||
private static void convertVehicles() {
|
private static void convertVehicles() {
|
||||||
for (Map.Entry<UUID, List<StorageVehicle>> set : VehiclesPlusAPI.getVehicleManager().getPlayerVehicleHashMap().entrySet()) {
|
for (Map.Entry<UUID, List<StorageVehicle>> set : VehiclesPlusAPI.getVehicleManager().getPlayerVehicleHashMap().entrySet()) {
|
||||||
UUID ownerUUID = set.getKey();
|
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()) {
|
for (StorageVehicle vehicle : set.getValue()) {
|
||||||
try {
|
try {
|
||||||
nl.sbdeveloper.vehiclesplus.api.vehicles.impl.StorageVehicle newVehicle = new nl.sbdeveloper.vehiclesplus.api.vehicles.impl.StorageVehicle(
|
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())),
|
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
|
|
||||||
);
|
);
|
||||||
|
|
||||||
newVehicle.save();
|
newVehicle.save();
|
||||||
|
garage.addVehicle(newVehicle.getUuid());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
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!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue