Skip to content

Commit

Permalink
Maven Uploads & Upgrades lock/unlock command
Browse files Browse the repository at this point in the history
Github Actions will not push a snapshot to our maven on project push, publish.yml will need updated when we merge
  • Loading branch information
Jeryn99 committed Dec 17, 2023
1 parent ec9d508 commit 3476acd
Show file tree
Hide file tree
Showing 14 changed files with 225 additions and 73 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
21 changes: 20 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -51,6 +69,7 @@ allprojects {
dirs '../modlibs'
}


}

tasks.withType(JavaCompile) {
Expand Down
19 changes: 19 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -14,6 +15,7 @@ public class TardisRefinedCommand {
public static void register(CommandDispatcher<CommandSourceStack> 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))));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Upgrade> {

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 <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
return SharedSuggestionProvider.suggestResource(Upgrades.UPGRADE_REGISTRY.keySet(), builder);
}

@Override
public Collection<String> getExamples() {
return ArgumentType.super.getExamples();
}
}
Original file line number Diff line number Diff line change
@@ -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<CommandSourceStack, ?> register(CommandDispatcher<CommandSourceStack> 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<CommandSourceStack> 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<CommandSourceStack> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,4 @@ public class Upgrades {




}
14 changes: 10 additions & 4 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
17 changes: 12 additions & 5 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}


Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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\"}"
}
]
}
Loading

0 comments on commit 3476acd

Please sign in to comment.