From 3476acd94c7038aa166e519890abc49fc835d472 Mon Sep 17 00:00:00 2001 From: Craig Date: Sun, 17 Dec 2023 13:16:34 +0000 Subject: [PATCH] Maven Uploads & Upgrades lock/unlock command Github Actions will not push a snapshot to our maven on project push, publish.yml will need updated when we merge --- .github/workflows/publish.yml | 31 ++++++++++ build.gradle | 21 ++++++- changelog.md | 19 ++++++ .../command/TardisRefinedCommand.java | 2 + .../arguments/UpgradeArgumentType.java | 45 ++++++++++++++ .../command/sub/UpgradesCommand.java | 55 +++++++++++++++++ .../common/capability/upgrades/Upgrades.java | 1 - fabric/build.gradle | 14 +++-- .../fabric/TardisRefinedFabric.java | 6 ++ forge/build.gradle | 17 ++++-- .../3fcdc37ad136e2a9e4d043224d2db5bc1dee2659 | 4 +- .../patterns/shell/police_box.json | 60 ------------------- .../commands/ForgeTRCommands.java | 20 +++++++ .../neoforge/TardisRefinedForge.java | 3 + 14 files changed, 225 insertions(+), 73 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 changelog.md create mode 100644 common/src/main/java/whocraft/tardis_refined/command/arguments/UpgradeArgumentType.java create mode 100644 common/src/main/java/whocraft/tardis_refined/command/sub/UpgradesCommand.java create mode 100644 forge/src/main/java/whocraft/tardis_refined/commands/ForgeTRCommands.java diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..84b487714 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,31 @@ +name: Publish to Maven Repository + +on: + push: + branches: + - new_assets + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '17' + + - name: Make Gradlew Executable + run: chmod +x ./gradlew + + - name: Build and Publish + run: | + ./gradlew publish + + env: + MAVEN_REPO_USERNAME: ${{ secrets.MAVEN_REPO_USERNAME }} + MAVEN_REPO_PASSWORD: ${{ secrets.MAVEN_REPO_PASSWORD }} diff --git a/build.gradle b/build.gradle index baacdf526..c3b00a670 100644 --- a/build.gradle +++ b/build.gradle @@ -26,13 +26,31 @@ subprojects { } } +def gitHash = { -> + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'rev-parse', '--short', 'HEAD' + standardOutput = stdout + } + return stdout.toString().trim() +} + +def gitBranch() { + def branch = "" + def proc = "git rev-parse --abbrev-ref HEAD".execute() + proc.in.eachLine { line -> branch = line } + proc.err.eachLine { line -> println line } + proc.waitFor() + branch +} + allprojects { apply plugin: "java" apply plugin: "architectury-plugin" apply plugin: "maven-publish" archivesBaseName = rootProject.jar_name - version = "${rootProject.minecraft_version}-${rootProject.mod_version}" + version = "${rootProject.minecraft_version}-${rootProject.mod_version}-${gitHash()}-${gitBranch()}" group = rootProject.maven_group repositories { @@ -51,6 +69,7 @@ allprojects { dirs '../modlibs' } + } tasks.withType(JavaCompile) { diff --git a/changelog.md b/changelog.md new file mode 100644 index 000000000..91313a48f --- /dev/null +++ b/changelog.md @@ -0,0 +1,19 @@ + + +## Upgrades +#### Additions + + +## Particles +#### Additions +- Added ARS Leaves Particles + +## Models +### Shells +#### Updates +- Updated Police Box Shell Model +- Updated Factory Shell Model +#### Additions +- Added Lift Shell +- Added Hieroglyph +- Added Castle \ No newline at end of file diff --git a/common/src/main/java/whocraft/tardis_refined/command/TardisRefinedCommand.java b/common/src/main/java/whocraft/tardis_refined/command/TardisRefinedCommand.java index bb6ea4153..4fd1cd489 100644 --- a/common/src/main/java/whocraft/tardis_refined/command/TardisRefinedCommand.java +++ b/common/src/main/java/whocraft/tardis_refined/command/TardisRefinedCommand.java @@ -6,6 +6,7 @@ import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.command.sub.InteriorCommand; import whocraft.tardis_refined.command.sub.LevelCommand; +import whocraft.tardis_refined.command.sub.UpgradesCommand; import whocraft.tardis_refined.command.sub.export.ExportDesktopCommand; import whocraft.tardis_refined.common.util.Platform; @@ -14,6 +15,7 @@ public class TardisRefinedCommand { public static void register(CommandDispatcher dispatcher) { dispatcher.register(Commands.literal(TardisRefined.MODID).requires(commandSource -> commandSource.hasPermission(Platform.getServer().getOperatorUserPermissionLevel())) .then(InteriorCommand.register(dispatcher)) + .then(UpgradesCommand.register(dispatcher)) .then(Commands.literal("data").then(Commands.literal("export").then(ExportDesktopCommand.register(dispatcher)))) .then(Commands.literal("level").then(LevelCommand.register(dispatcher)))); } diff --git a/common/src/main/java/whocraft/tardis_refined/command/arguments/UpgradeArgumentType.java b/common/src/main/java/whocraft/tardis_refined/command/arguments/UpgradeArgumentType.java new file mode 100644 index 000000000..c35e4147b --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/command/arguments/UpgradeArgumentType.java @@ -0,0 +1,45 @@ +package whocraft.tardis_refined.command.arguments; + +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.arguments.ArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import whocraft.tardis_refined.common.capability.upgrades.Upgrade; +import whocraft.tardis_refined.common.capability.upgrades.Upgrades; + +import java.util.Collection; +import java.util.concurrent.CompletableFuture; + +public class UpgradeArgumentType implements ArgumentType { + + public static final DynamicCommandExceptionType INVALID_UPGRADE_EXCEPTION = new DynamicCommandExceptionType((UPGRADE) -> Component.translatable("argument.regeneration.upgrade.invalid", UPGRADE)); + + public static UpgradeArgumentType upgradeArgumentType() { + return new UpgradeArgumentType(); + } + + @Override + public Upgrade parse(StringReader reader) throws CommandSyntaxException { + ResourceLocation location = ResourceLocation.read(reader); + Upgrade upgrade = Upgrades.UPGRADE_DEFERRED_REGISTRY.getRegistry().get(location); + if (upgrade != null) { + return upgrade; + } + throw INVALID_UPGRADE_EXCEPTION.create(location); } + + @Override + public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { + return SharedSuggestionProvider.suggestResource(Upgrades.UPGRADE_REGISTRY.keySet(), builder); + } + + @Override + public Collection getExamples() { + return ArgumentType.super.getExamples(); + } +} \ No newline at end of file diff --git a/common/src/main/java/whocraft/tardis_refined/command/sub/UpgradesCommand.java b/common/src/main/java/whocraft/tardis_refined/command/sub/UpgradesCommand.java new file mode 100644 index 000000000..450da8364 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/command/sub/UpgradesCommand.java @@ -0,0 +1,55 @@ +package whocraft.tardis_refined.command.sub; + +import com.mojang.brigadier.Command; +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.builder.ArgumentBuilder; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.DimensionArgument; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; +import whocraft.tardis_refined.command.arguments.UpgradeArgumentType; +import whocraft.tardis_refined.common.capability.TardisLevelOperator; +import whocraft.tardis_refined.common.capability.upgrades.Upgrade; +import whocraft.tardis_refined.common.util.CommandHelper; + +public class UpgradesCommand { + + public static ArgumentBuilder register(CommandDispatcher dispatcher) { + return Commands.literal("upgrades") + .then(Commands.literal("lock") + .then(Commands.argument("dimension", DimensionArgument.dimension()).suggests(CommandHelper.SUGGEST_TARDISES) + .then(Commands.argument("upgrade", UpgradeArgumentType.upgradeArgumentType()) + .executes(UpgradesCommand::setUpgradeLocked)))) + .then(Commands.literal("unlock") + .then(Commands.argument("dimension", DimensionArgument.dimension()).suggests(CommandHelper.SUGGEST_TARDISES) + .then(Commands.argument("upgrade", UpgradeArgumentType.upgradeArgumentType()) + .executes(UpgradesCommand::setUpgradeUnlocked)))); + } + + private static int setUpgradeLocked(CommandContext context) throws CommandSyntaxException { + ServerLevel dimension = DimensionArgument.getDimension(context, "dimension"); + Upgrade upgrade = context.getArgument("upgrade", Upgrade.class); + + TardisLevelOperator.get(dimension).ifPresent(tardisLevelOperator -> { + tardisLevelOperator.getUpgradeHandler().lockUpgrade(upgrade); + context.getSource().sendSystemMessage(Component.literal("Tardis: " + dimension.toString().split(":")[1] + " locked " + upgrade.getDisplayName())); + }); + + return Command.SINGLE_SUCCESS; + } + + private static int setUpgradeUnlocked(CommandContext context) throws CommandSyntaxException { + ServerLevel dimension = DimensionArgument.getDimension(context, "dimension"); + Upgrade upgrade = context.getArgument("upgrade", Upgrade.class); + + TardisLevelOperator.get(dimension).ifPresent(tardisLevelOperator -> { + tardisLevelOperator.getUpgradeHandler().unlockUpgrade(upgrade); + context.getSource().sendSystemMessage(Component.literal("Tardis: " + dimension.toString().split(":")[1] + " unlocked " + upgrade.getDisplayName())); + }); + + return Command.SINGLE_SUCCESS; + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/capability/upgrades/Upgrades.java b/common/src/main/java/whocraft/tardis_refined/common/capability/upgrades/Upgrades.java index 6f8d35eff..fe9e4b22c 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/capability/upgrades/Upgrades.java +++ b/common/src/main/java/whocraft/tardis_refined/common/capability/upgrades/Upgrades.java @@ -71,5 +71,4 @@ public class Upgrades { - } diff --git a/fabric/build.gradle b/fabric/build.gradle index 252b01216..6010559dc 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -174,14 +174,20 @@ components.java { publishing { publications { - mavenFabric(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name + mavenForge(MavenPublication) { + artifactId = archives_base_name + "_" + project.name from components.java } } - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { - // Add repositories to publish to here. + maven { + url = project.findProperty("maven_repo_url") ?: "http://craig.software:8081/repository/whocraft/" + credentials { + username = System.getenv("MAVEN_REPO_USERNAME") + password = System.getenv("MAVEN_REPO_PASSWORD") + } + allowInsecureProtocol = true + } } } \ No newline at end of file diff --git a/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabric.java b/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabric.java index d086eec79..f824a5b82 100644 --- a/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabric.java +++ b/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabric.java @@ -2,8 +2,10 @@ import fuzs.forgeconfigapiport.api.config.v3.ForgeConfigRegistry; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.command.v2.ArgumentTypeRegistry; import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; +import net.minecraft.commands.synchronization.SingletonArgumentInfo; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.resources.PreparableReloadListener; @@ -12,6 +14,7 @@ import net.neoforged.fml.config.ModConfig; import whocraft.tardis_refined.TRConfig; import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.command.arguments.UpgradeArgumentType; import whocraft.tardis_refined.common.tardis.TardisDesktops; import whocraft.tardis_refined.common.util.fabric.PlatformImpl; import whocraft.tardis_refined.common.world.fabric.TRFabricBiomeModifiers; @@ -64,6 +67,9 @@ public void onInitialize() { ForgeConfigRegistry.INSTANCE.register(TardisRefined.MODID, ModConfig.Type.CLIENT, TRConfig.CLIENT_SPEC); ForgeConfigRegistry.INSTANCE.register(TardisRefined.MODID, ModConfig.Type.SERVER, TRConfig.SERVER_SPEC); + ArgumentTypeRegistry.registerArgumentType(new ResourceLocation(TardisRefined.MODID, "upgrades"), UpgradeArgumentType.class, SingletonArgumentInfo.contextFree(UpgradeArgumentType::upgradeArgumentType)); + + register(SERVER_DATA, new ResourceLocation(TardisRefined.MODID, TardisRefined.MODID + "/" + "console_patterns"), ConsolePatterns.getReloadListener()); register(SERVER_DATA, new ResourceLocation(TardisRefined.MODID, TardisRefined.MODID + "/" + "desktops"), TardisDesktops.getReloadListener()); diff --git a/forge/build.gradle b/forge/build.gradle index 110ff639d..4dc051ce6 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -145,17 +145,24 @@ tasks.withType(JavaCompile) { options.encoding = "UTF-8" options.release = 17 } - publishing { publications { mavenForge(MavenPublication) { - artifactId = archives_base_name + "-" + project.name + artifactId = archives_base_name + "_" + project.name from components.java } } - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { - // Add repositories to publish to here. + maven { + url = project.findProperty("maven_repo_url") ?: "http://craig.software:8081/repository/whocraft/" + credentials { + username = System.getenv("MAVEN_REPO_USERNAME") + password = System.getenv("MAVEN_REPO_PASSWORD") + } + allowInsecureProtocol = true + } } -} \ No newline at end of file +} + + diff --git a/forge/src/generated/resources/.cache/3fcdc37ad136e2a9e4d043224d2db5bc1dee2659 b/forge/src/generated/resources/.cache/3fcdc37ad136e2a9e4d043224d2db5bc1dee2659 index a509a0ec2..f229348e6 100644 --- a/forge/src/generated/resources/.cache/3fcdc37ad136e2a9e4d043224d2db5bc1dee2659 +++ b/forge/src/generated/resources/.cache/3fcdc37ad136e2a9e4d043224d2db5bc1dee2659 @@ -1,4 +1,4 @@ -// 1.20.2 2023-12-10T20:38:52.4743381 Shell Patterns +// 1.20.2 2023-12-17T14:37:14.1934321 Shell Patterns 24c3b07d5ebcb921f1a4014c0c7b7ce1db66d291 data/tardis_refined/tardis_refined/patterns/shell/big_ben.json c023593375b56bf2ba50df33b355f0f99d062227 data/tardis_refined/tardis_refined/patterns/shell/briefcase.json 0c683f48298e8e97709fa8f659a659440e35dc61 data/tardis_refined/tardis_refined/patterns/shell/castle.json @@ -12,7 +12,7 @@ a033e392d5ce58b74e9dd2561b2a3012b49525d2 data/tardis_refined/tardis_refined/patt 9636dacb9cae8d3d893a7f9bfca195631397973b data/tardis_refined/tardis_refined/patterns/shell/nuka.json bb9b537f1b29c2414d9284828094163a425bcd70 data/tardis_refined/tardis_refined/patterns/shell/pagoda.json 9acf33da121ce7c83457b3d85c0a92d5ba511efd data/tardis_refined/tardis_refined/patterns/shell/phone_booth.json -67d26906e3655e7f9f08a906b56b225f71248726 data/tardis_refined/tardis_refined/patterns/shell/police_box.json +d137e095ef4d32650e62dc8cba9a8abdb6634ef2 data/tardis_refined/tardis_refined/patterns/shell/police_box.json ba4b42fe3655f24a4263e59b614b0644229730a8 data/tardis_refined/tardis_refined/patterns/shell/portaloo.json fdc997718013ffac35fe5192e0fbf32b60323720 data/tardis_refined/tardis_refined/patterns/shell/present.json 23066a16183502e0751e16f152356bde64f17045 data/tardis_refined/tardis_refined/patterns/shell/vending.json diff --git a/forge/src/generated/resources/data/tardis_refined/tardis_refined/patterns/shell/police_box.json b/forge/src/generated/resources/data/tardis_refined/tardis_refined/patterns/shell/police_box.json index 9c57ffe0c..e169a6a3b 100644 --- a/forge/src/generated/resources/data/tardis_refined/tardis_refined/patterns/shell/police_box.json +++ b/forge/src/generated/resources/data/tardis_refined/tardis_refined/patterns/shell/police_box.json @@ -11,66 +11,6 @@ "texture": "tardis_refined:textures/blockentity/shell/police_box/police_box_interior.png" }, "name_component": "{\"color\":\"yellow\",\"text\":\"Default\"}" - }, - { - "exterior": { - "emissive": false, - "texture": "tardis_refined:textures/blockentity/shell/police_box/marble.png" - }, - "id": "tardis_refined:marble", - "interior": { - "emissive": false, - "texture": "tardis_refined:textures/blockentity/shell/police_box/marble_interior.png" - }, - "name_component": "{\"color\":\"yellow\",\"text\":\"Marble\"}" - }, - { - "exterior": { - "emissive": false, - "texture": "tardis_refined:textures/blockentity/shell/police_box/gaudy.png" - }, - "id": "tardis_refined:gaudy", - "interior": { - "emissive": false, - "texture": "tardis_refined:textures/blockentity/shell/police_box/gaudy_interior.png" - }, - "name_component": "{\"color\":\"yellow\",\"text\":\"Gaudy\"}" - }, - { - "exterior": { - "emissive": false, - "texture": "tardis_refined:textures/blockentity/shell/police_box/metal.png" - }, - "id": "tardis_refined:metal", - "interior": { - "emissive": false, - "texture": "tardis_refined:textures/blockentity/shell/police_box/metal_interior.png" - }, - "name_component": "{\"color\":\"yellow\",\"text\":\"Metal\"}" - }, - { - "exterior": { - "emissive": false, - "texture": "tardis_refined:textures/blockentity/shell/police_box/stone.png" - }, - "id": "tardis_refined:stone", - "interior": { - "emissive": false, - "texture": "tardis_refined:textures/blockentity/shell/police_box/stone_interior.png" - }, - "name_component": "{\"color\":\"yellow\",\"text\":\"Stone\"}" - }, - { - "exterior": { - "emissive": false, - "texture": "tardis_refined:textures/blockentity/shell/police_box/red.png" - }, - "id": "tardis_refined:red", - "interior": { - "emissive": false, - "texture": "tardis_refined:textures/blockentity/shell/police_box/red_interior.png" - }, - "name_component": "{\"color\":\"yellow\",\"text\":\"Red\"}" } ] } \ No newline at end of file diff --git a/forge/src/main/java/whocraft/tardis_refined/commands/ForgeTRCommands.java b/forge/src/main/java/whocraft/tardis_refined/commands/ForgeTRCommands.java new file mode 100644 index 000000000..a111b1ea0 --- /dev/null +++ b/forge/src/main/java/whocraft/tardis_refined/commands/ForgeTRCommands.java @@ -0,0 +1,20 @@ +package whocraft.tardis_refined.commands; + + +import net.minecraft.commands.synchronization.ArgumentTypeInfo; +import net.minecraft.commands.synchronization.ArgumentTypeInfos; +import net.minecraft.commands.synchronization.SingletonArgumentInfo; +import net.minecraft.core.registries.Registries; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.command.arguments.UpgradeArgumentType; +import whocraft.tardis_refined.registry.DeferredRegistry; +import whocraft.tardis_refined.registry.RegistrySupplier; + +public class ForgeTRCommands { + + public static final DeferredRegistry> COMMAND_ARGUMENT_TYPES = DeferredRegistry.create(TardisRefined.MODID, Registries.COMMAND_ARGUMENT_TYPE); + + + public static final RegistrySupplier> UPGRADE_ARGUMENT = COMMAND_ARGUMENT_TYPES.register("upgrade", () -> + ArgumentTypeInfos.registerByClass(UpgradeArgumentType.class, SingletonArgumentInfo.contextFree(UpgradeArgumentType::upgradeArgumentType))); +} \ No newline at end of file diff --git a/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java b/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java index 2d029bdeb..ef8d0d11d 100644 --- a/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java +++ b/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java @@ -10,6 +10,7 @@ import net.neoforged.neoforge.data.event.GatherDataEvent; import whocraft.tardis_refined.TRConfig; import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.commands.ForgeTRCommands; import whocraft.tardis_refined.common.data.*; @Mod(TardisRefined.MODID) @@ -23,6 +24,8 @@ public TardisRefinedForge() { ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, TRConfig.CLIENT_SPEC); ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, TRConfig.SERVER_SPEC); + ForgeTRCommands.COMMAND_ARGUMENT_TYPES.register(); + /* if (ModCompatChecker.immersivePortals()) { if(TRConfig.COMMON.COMPATIBILITY_IP.get()) { ImmersivePortals.init();