3
0
Fork 0

Add more example code

This commit is contained in:
cedric 2024-12-28 23:30:02 +01:00
parent 9730ae42d4
commit deb9bd2fc7
11 changed files with 295 additions and 9 deletions

83
custom model/pom.xml Normal file
View file

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>tech.sbdevelopment</groupId>
<artifactId>customModel</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>CustomModel</name>
<properties>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>sbdevelopment-repo-releases</id>
<name>SBDevelopment Repository</name>
<url>https://repo.sbdevelopment.tech/releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>nl.sbdeveloper</groupId>
<artifactId>VehiclesPlus-API</artifactId>
<version>3.0.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,19 @@
package tech.sbdevelopment.customModel;
import nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI;
import org.bukkit.plugin.java.JavaPlugin;
import tech.sbdevelopment.customModel.parts.Vent;
public final class CustomModel extends JavaPlugin {
@Override
public void onEnable() {
VehiclesPlusAPI.registerHook(() -> {
VehiclesPlusAPI.registerPart(Vent.class);
getLogger().info("Hooked into VehiclesPlus!");
});
}
@Override
public void onDisable() {
}
}

View file

@ -0,0 +1,73 @@
package tech.sbdevelopment.customModel.models;
import nl.sbdeveloper.vehiclesplus.api.vehicles.HolderItemPosition;
import nl.sbdeveloper.vehiclesplus.api.vehicles.VehicleModel;
import nl.sbdeveloper.vehiclesplus.api.vehicles.defaults.DefaultVehicleModel;
import nl.sbdeveloper.vehiclesplus.api.vehicles.parts.impl.seat.Seat;
import nl.sbdeveloper.vehiclesplus.api.vehicles.parts.impl.skin.Skin;
import nl.sbdeveloper.vehiclesplus.api.vehicles.settings.UpgradableSetting;
import nl.sbdeveloper.vehiclesplus.api.vehicles.settings.impl.*;
import nl.sbdeveloper.vehiclesplus.utils.ItemBuilder;
import nl.sbdeveloper.vehiclesplus.utils.jackson.ColorList;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Sound;
import tech.sbdevelopment.customModel.parts.Vent;
public class DefaultSubmarine extends DefaultVehicleModel {
@Override
public VehicleModel build() {
return VehicleModel.builder()
.id("ExampleSubmarine")
.displayName("&cExample &aSubmarine")
.typeId("submarines")
.part(new Skin(
0, 0.3, 0,
new ItemBuilder(Material.LEATHER_BOOTS)
.customModelData(4, (ib) -> ib
.durability((short) 4)
.unbreakable())
.armorColor(Color.WHITE)
.getItemStack(),
HolderItemPosition.HEAD
))
.part(new Seat(
-0.5, -0.5, 0.5, true
))
.part(new Vent())
.permissions(new Permissions("ExampleSubmarine"))
.sounds(defaultSounds)
.availableColors(ColorList.of(
Color.GRAY,
Color.BLACK
))
.maxSpeed(new UpgradableSetting(
10, 200, 5, 1000, "km/h"
))
.fuelTank(new UpgradableSetting(
100, 200, 5, 1000, "L"
))
.turningRadius(new UpgradableSetting(
5, 10, 1, 1000, ""
))
.acceleration(new UpgradableSetting(
50, 100, 1, 1000, ""
))
.horn(new Horn(
true, new Sounds.Sound(Sound.WEATHER_RAIN_ABOVE.getKey().toString(), 3)
))
.drift(false)
.exitWhileMoving(false)
.price(100000)
.fuel(new Fuel(
"gasoline", 6
))
.health(100)
.trunkSize(0)
.hitbox(new Hitbox(
4, 2, 1.2
))
.gearbox(new Gearbox(false))
.build();
}
}

View file

@ -0,0 +1,55 @@
package tech.sbdevelopment.customModel.parts;
import nl.sbdeveloper.vehiclesplus.api.vehicles.HolderItemPosition;
import nl.sbdeveloper.vehiclesplus.api.vehicles.movement.MovementInput;
import nl.sbdeveloper.vehiclesplus.api.vehicles.parts.EquipablePart;
import nl.sbdeveloper.vehiclesplus.api.vehicles.parts.PartTypeName;
import nl.sbdeveloper.vehiclesplus.api.vehicles.parts.impl.seat.Controllable;
import nl.sbdeveloper.vehiclesplus.utils.ItemBuilder;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@PartTypeName("vent")
public class Vent extends EquipablePart implements Controllable {
public Vent() {
super(-0.3, 0.95, 0,
new ItemBuilder(Material.LEATHER_CHESTPLATE)
.customModelData(4, (ib) -> ib
.durability((short) 4)
.unbreakable())
.armorColor(Color.GRAY)
.getItemStack(),
HolderItemPosition.HEAD);
}
public Vent(double xOffset, double yOffset, double zOffset, ItemStack skin, HolderItemPosition position) {
super(xOffset, yOffset, zOffset, skin, position);
}
@Override
public ItemStack getPartGUIItem() {
return new ItemBuilder(Material.LEATHER_BOOTS)
.displayname(ChatColor.GOLD + "Vent")
.lore(
ChatColor.GRAY + "This is the vent of the vehicle.",
ChatColor.GRAY + "It will provide a boost when the spacebar is pressed."
)
.unbreakable()
.durability(7)
.getItemStack();
}
@Override
public String asString() {
return "";
}
@Override
public void handleInput(MovementInput movementInput) {
if (movementInput.isSpace()) {
holder.getVehicle().getVelocity().add(holder.getVehicle().getLocation().getDirection().multiply(0.5));
}
}
}

View file

@ -0,0 +1,5 @@
name: VP3-APItest
version: '1.0'
main: tech.sbdevelopment.vp3apitest.VP3APItest
api-version: '1.21'
depend: [VehiclesPlus]