From 6c2c58c60f0e906d997bba419f114a77b6a602fc Mon Sep 17 00:00:00 2001 From: SBDeveloper Date: Mon, 5 Aug 2024 20:29:21 +0200 Subject: [PATCH] First commit! --- .gitignore | 114 ++++++++++++++++++ pom.xml | 78 ++++++++++++ .../sbdevelopment/vp3apitest/VP3APItest.java | 19 +++ .../vp3apitest/models/DefaultSubmarine.java | 73 +++++++++++ .../sbdevelopment/vp3apitest/parts/Vent.java | 55 +++++++++ src/main/resources/plugin.yml | 5 + 6 files changed, 344 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/tech/sbdevelopment/vp3apitest/VP3APItest.java create mode 100644 src/main/java/tech/sbdevelopment/vp3apitest/models/DefaultSubmarine.java create mode 100644 src/main/java/tech/sbdevelopment/vp3apitest/parts/Vent.java create mode 100644 src/main/resources/plugin.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6e0a794 --- /dev/null +++ b/.gitignore @@ -0,0 +1,114 @@ +# User-specific stuff +.idea/ +.fleet/ + +*.iml +*.ipr +*.iws + +# IntelliJ +out/ + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +target/ + +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next + +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar +.flattened-pom.xml + +# Common working directory +run/ \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..c398563 --- /dev/null +++ b/pom.xml @@ -0,0 +1,78 @@ + + + 4.0.0 + + tech.sbdevelopment + vp3apitest + 1.0 + jar + + vp3apitest + + + 21 + UTF-8 + + + + clean package + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-shade-plugin + 3.5.3 + + + package + + shade + + + + + + + + src/main/resources + true + + + + + + + papermc-repo + https://repo.papermc.io/repository/maven-public/ + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + + + + io.papermc.paper + paper-api + 1.21-R0.1-SNAPSHOT + provided + + + nl.sbdeveloper + VehiclesPlus-API + 3.0.0-SNAPSHOT + provided + + + diff --git a/src/main/java/tech/sbdevelopment/vp3apitest/VP3APItest.java b/src/main/java/tech/sbdevelopment/vp3apitest/VP3APItest.java new file mode 100644 index 0000000..2917c3a --- /dev/null +++ b/src/main/java/tech/sbdevelopment/vp3apitest/VP3APItest.java @@ -0,0 +1,19 @@ +package tech.sbdevelopment.vp3apitest; + +import nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI; +import org.bukkit.plugin.java.JavaPlugin; +import tech.sbdevelopment.vp3apitest.parts.Vent; + +public final class VP3APItest extends JavaPlugin { + @Override + public void onEnable() { + VehiclesPlusAPI.registerHook(() -> { + VehiclesPlusAPI.registerPart(Vent.class); + getLogger().info("Hooked into VehiclesPlus!"); + }); + } + + @Override + public void onDisable() { + } +} diff --git a/src/main/java/tech/sbdevelopment/vp3apitest/models/DefaultSubmarine.java b/src/main/java/tech/sbdevelopment/vp3apitest/models/DefaultSubmarine.java new file mode 100644 index 0000000..223f473 --- /dev/null +++ b/src/main/java/tech/sbdevelopment/vp3apitest/models/DefaultSubmarine.java @@ -0,0 +1,73 @@ +package tech.sbdevelopment.vp3apitest.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.vp3apitest.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(); + } +} diff --git a/src/main/java/tech/sbdevelopment/vp3apitest/parts/Vent.java b/src/main/java/tech/sbdevelopment/vp3apitest/parts/Vent.java new file mode 100644 index 0000000..a5813a3 --- /dev/null +++ b/src/main/java/tech/sbdevelopment/vp3apitest/parts/Vent.java @@ -0,0 +1,55 @@ +package tech.sbdevelopment.vp3apitest.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)); + } + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..33c2307 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,5 @@ +name: VP3-APItest +version: '1.0' +main: tech.sbdevelopment.vp3apitest.VP3APItest +api-version: '1.21' +depend: [VehiclesPlus] \ No newline at end of file