diff --git a/build.gradle.kts b/build.gradle.kts index 72bcfb8..f6b1e59 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -95,7 +95,7 @@ indraSpotlessLicenser { } val runVersions = listOf( - "21.1", + "21.4", ) tasks { @@ -186,7 +186,7 @@ sourceSets { } val releaseNotes = providers.environmentVariable("RELEASE_NOTES") -val versions = listOf("1.19.4", "1.20.6", "1.21") +val versions = listOf("1.21.4") val shadowJar = tasks.shadowJar.flatMap { it.archiveFile } hangarPublish.publications.register("plugin") { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bf97d3d..f8d1d9e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,7 +21,7 @@ cloud-minecraft-extras = { module = "org.incendo:cloud-minecraft-extras" } brigadier = "com.mojang:brigadier:1.0.18" # paper -paperApi = "io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT" +paperApi = "io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT" paperTrail = "io.papermc:paper-trail:1.0.1" # config diff --git a/resources/ChessCraft_Resource_Pack.zip b/resources/ChessCraft_Resource_Pack.zip index b313a07..150dbb7 100644 Binary files a/resources/ChessCraft_Resource_Pack.zip and b/resources/ChessCraft_Resource_Pack.zip differ diff --git a/src/main/java/xyz/jpenilla/chesscraft/config/PieceOptions.java b/src/main/java/xyz/jpenilla/chesscraft/config/PieceOptions.java index 7f745bc..91756e6 100644 --- a/src/main/java/xyz/jpenilla/chesscraft/config/PieceOptions.java +++ b/src/main/java/xyz/jpenilla/chesscraft/config/PieceOptions.java @@ -17,12 +17,16 @@ */ package xyz.jpenilla.chesscraft.config; +import io.papermc.paper.datacomponent.DataComponentTypes; import java.lang.reflect.Type; import java.util.Arrays; +import java.util.Locale; import java.util.Map; +import net.kyori.adventure.key.Key; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.checkerframework.checker.nullness.qual.Nullable; +import org.intellij.lang.annotations.Subst; import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.serialize.SerializationException; @@ -55,7 +59,6 @@ enum Mode { @ConfigSerializable final class DisplayEntity implements PieceOptions { - private Material material = Material.PAPER; private Map heights = Map.of( PieceType.PAWN, 2.0D - 11.5D / 16.0D, PieceType.BISHOP, 2.0D - 3.5D / 16.0D, @@ -64,33 +67,18 @@ final class DisplayEntity implements PieceOptions { PieceType.QUEEN, 2.0D - 4.0D / 16.0D, PieceType.KING, 2.0D ); - private Map whiteCustomModelData = Map.of( - PieceType.PAWN, 7, - PieceType.BISHOP, 8, - PieceType.KNIGHT, 9, - PieceType.ROOK, 10, - PieceType.QUEEN, 11, - PieceType.KING, 12 - ); - private Map blackCustomModelData = Map.of( - PieceType.PAWN, 1, - PieceType.BISHOP, 2, - PieceType.KNIGHT, 3, - PieceType.ROOK, 4, - PieceType.QUEEN, 5, - PieceType.KING, 6 - ); - private int customModelData(final Piece piece) { + private Key itemModel(final Piece piece) { + @Subst("pawn") final String type = piece.type().name().toLowerCase(Locale.ROOT); if (piece.color() == PieceColor.WHITE) { - return this.whiteCustomModelData.get(piece.type()); + return Key.key("chesscraft", "chess_" + type + "_white"); } - return this.blackCustomModelData.get(piece.type()); + return Key.key("chesscraft", "chess_" + type + "_black"); } public ItemStack item(final Piece piece) { - final ItemStack stack = new ItemStack(this.material); - stack.editMeta(meta -> meta.setCustomModelData(this.customModelData(piece))); + final ItemStack stack = ItemStack.of(Material.PAPER); + stack.setData(DataComponentTypes.ITEM_MODEL, this.itemModel(piece)); return stack; } @@ -111,7 +99,6 @@ public Mode mode() { @ConfigSerializable final class ItemFrame implements PieceOptions { - private Material material = Material.PAPER; private Map heightOffsets = Map.of( PieceType.PAWN, -11.5D / 16.0D, PieceType.BISHOP, -3.5D / 16.0D, @@ -120,37 +107,22 @@ final class ItemFrame implements PieceOptions { PieceType.QUEEN, -4.0D / 16.0D, PieceType.KING, 0.0D ); - private Map whiteCustomModelData = Map.of( - PieceType.PAWN, 7, - PieceType.BISHOP, 8, - PieceType.KNIGHT, 9, - PieceType.ROOK, 10, - PieceType.QUEEN, 11, - PieceType.KING, 12 - ); - private Map blackCustomModelData = Map.of( - PieceType.PAWN, 1, - PieceType.BISHOP, 2, - PieceType.KNIGHT, 3, - PieceType.ROOK, 4, - PieceType.QUEEN, 5, - PieceType.KING, 6 - ); public double heightOffset(final PieceType type) { return this.heightOffsets.getOrDefault(type, 0.0D); } - private int customModelData(final Piece piece) { + private Key itemModel(final Piece piece) { + @Subst("pawn") final String type = piece.type().name().toLowerCase(Locale.ROOT); if (piece.color() == PieceColor.WHITE) { - return this.whiteCustomModelData.get(piece.type()); + return Key.key("chesscraft", "chess_" + type + "_white"); } - return this.blackCustomModelData.get(piece.type()); + return Key.key("chesscraft", "chess_" + type + "_black"); } public ItemStack item(final Piece piece) { - final ItemStack stack = new ItemStack(this.material); - stack.editMeta(meta -> meta.setCustomModelData(this.customModelData(piece))); + final ItemStack stack = ItemStack.of(Material.PAPER); + stack.setData(DataComponentTypes.ITEM_MODEL, this.itemModel(piece)); return stack; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index dc286af..967e206 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,4 +2,4 @@ name: ChessCraft version: $version main: xyz.jpenilla.chesscraft.dependency.io.papermc.papertrail.RequiresPaperPlugins author: jmp -api-version: 1.21.1 +api-version: 1.21.4