Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main' into 1.20.4-f…
Browse files Browse the repository at this point in the history
…abric

# Conflicts:
#	.github/workflows/build.yml
#	src/main/java/me/melontini/commander/impl/builtin/brigadier/ArithmeticaCommand.java
#	src/main/java/me/melontini/commander/impl/mixin/AdvancementRewardsMixin.java
  • Loading branch information
melontini committed Apr 26, 2024
2 parents 02f1729 + b775df7 commit 5393617
Show file tree
Hide file tree
Showing 37 changed files with 276 additions and 251 deletions.
129 changes: 7 additions & 122 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,127 +1,12 @@

name: build
on:
push:
workflow_dispatch:
inputs:
version_type:
description: "The type of this version. e.g alpha"
type: choice
default: beta
options:
- release
- beta
- alpha
required: false
on: [ push, pull_request ]

jobs:
build:
runs-on: ubuntu-latest
if: |
!contains(github.event.head_commit.message, '[ci skip]')
outputs:
version_info: ${{ steps.get_version.outputs.version_info }}
version_plain: ${{ steps.get_version.outputs.version_plain }}
steps:
- name: checkout repository
uses: actions/[email protected]
- name: validate gradle wrapper
uses: gradle/[email protected]
- name: setup jdk
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: 17
cache: gradle
- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: get version #https://stackoverflow.com/questions/71089787/how-to-get-version-name-from-android-gradle-file-in-github-actions
id: get_version
run: |
echo "version_info=$(${{github.workspace}}/gradlew -q printVersionName)" >> $GITHUB_OUTPUT
echo "version_plain=$(${{github.workspace}}/gradlew -q printVersion)" >> $GITHUB_OUTPUT
- name: capture build artifacts
uses: actions/[email protected]
with:
name: Artifacts
path: build/libs/
- name: capture processed mappings
uses: actions/[email protected]
with:
name: Mappings
path: .gradle/commander/mappings/

packages:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/[email protected]
- name: setup jdk
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: 17
cache: gradle
- uses: actions/[email protected]
with:
name: Mappings
path: .gradle/commander/mappings/
- uses: geekyeggo/delete-artifact@v5
with:
name: Mappings
- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew publish
publish:
needs: build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' }}
steps:
- name: checkout repository
uses: actions/[email protected]
- uses: actions/[email protected]
with:
name: Artifacts
path: build/libs

- name: publish release
uses: Kir-Antipov/[email protected]
with:
version-type: ${{ inputs.version_type }}
changelog-file: CHANGELOG.md
name: ${{ needs.build.outputs.version_info }}
version: ${{ needs.build.outputs.version_plain }}

game-versions: |
1.20.4
loaders: |
fabric
java: |
17
files: |
build/libs/!(*-@(dev|sources|javadoc|dependencies|full-dependencies)).jar
build/libs/*-@(dev|sources|javadoc).jar
github-tag: ${{ needs.build.outputs.version_plain }}
github-token: ${{ secrets.GITHUB_TOKEN }}
github-commitish: ${{ github.sha }}
github-prerelease: false

modrinth-id: 86bUtxWv
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
modrinth-featured: true
modrinth-unfeature-mode: subset
modrinth-dependencies: |
fabric-api(required)
dark-matter(embedded)
uses: constellation-mc/actions/.github/workflows/gradle-build.yml@main
with:
java: 17
gradle_tasks: spotbugs
reviewdog: |
cat ./build/reports/spotbugs/main/spotbugs.sarif | reviewdog -name="spotbugs" -f=sarif -reporter=github-check -level=warning
23 changes: 0 additions & 23 deletions .github/workflows/build_pr.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

name: publish
on:
workflow_dispatch:
inputs:
version_type:
description: "The type of this version. e.g alpha"
type: choice
default: BETA
options:
- STABLE
- BETA
- ALPHA
- NONE
required: false

jobs:
publish:
uses: constellation-mc/actions/.github/workflows/mc-publish.yml@main
with:
java: 17
version_type: ${{ inputs.version_type }}
secrets: inherit
9 changes: 4 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
### What's New:

* Exposed Expressions in the `api` package.
* You can now specify `commander:commands` in advancement rewards.
* Mappings are no longer downloaded on startup.
* Added shaded licenses.
* Fixed conditioned selector crash on 1.20.4.
* Added entity parameter to `cmd:explode`. The entity will be marked as the "creator" of the explosion and other entities will redirect their anger to the entity if affected by the explosion.
* Added fire parameter to `cmd:explode`. Creates fire, if true.
* Fixed `double` casts converting numbers to scientific notation.
* `long` and `int` casts no longer actually convert to their types, instead they truncate the trailing zeros.
83 changes: 75 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ plugins {
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
id 'io.freefair.lombok' version '8.3'
id 'com.github.spotbugs-base' version '6.0.12'
id 'com.diffplug.spotless' version '6.25.0'
id "me.modmuss50.mod-publish-plugin" version "0.5.1"
}

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.spotbugs.snom.SpotBugsTask
import me.modmuss50.mpp.ReleaseType

def local = !System.getenv().containsKey("GITHUB_RUN_NUMBER");

Expand Down Expand Up @@ -75,6 +80,38 @@ dependencies {
implementation shade("net.fabricmc:mapping-io:${project.mappingio_version}")
}

tasks.register("spotbugs", SpotBugsTask) { task ->
sourceSets.each {
task.sourceDirs.from(task.sourceDirs.files, it.allSource.sourceDirectories)
task.classDirs.from(task.classDirs.files, it.output)
task.auxClassPaths.from(task.auxClassPaths.files, it.compileClasspath)
}
excludeFilter = file("spotbugs.xml")
ignoreFailures = true
reports {
if (local) {
html {
required = true
outputLocation = file("$buildDir/reports/spotbugs/main/spotbugs.html")
stylesheet = 'fancy-hist.xsl'
}
} else {
sarif {
required = true
outputLocation = file("$buildDir/reports/spotbugs/main/spotbugs.sarif")
}
}
}
}

spotless {
java {
removeUnusedImports()
trimTrailingWhitespace()
formatAnnotations()
}
}

loom {
accessWidenerPath = file("src/main/resources/commander.accesswidener")
}
Expand Down Expand Up @@ -150,15 +187,45 @@ publishing {
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/constellation-mc/commander"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
if (!local) {
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/constellation-mc/commander"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
}

publishMods {
file = remapJar.archiveFile
additionalFiles.from(remapSourcesJar.archiveFile)

changelog = file("CHANGELOG.md").text
type = ReleaseType.valueOf(providers.environmentVariable("VERSION_TYPE").getOrElse("BETA"))
modLoaders.add("fabric")

displayName = "${project.mod_version} (${project.minecraft_version})"

modrinth {
projectId = "86bUtxWv"
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
minecraftVersions.add("${project.minecraft_version}")

requires("fabric-api")
embeds("dark-matter")
}
github {
repository = "constellation-mc/commander"
accessToken = providers.environmentVariable("GITHUB_TOKEN")
commitish = providers.environmentVariable("GITHUB_SHA").getOrElse("${project.minecraft_version}-fabric")

type = STABLE
}

dryRun = local
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.9
# Mod Properties
mod_version=0.2.2
mod_version=0.3.0
maven_group=me.melontini
archives_base_name=commander
# Dependencies
Expand Down
7 changes: 4 additions & 3 deletions gradle/mappings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import net.fabricmc.mappingio.adapter.MappingSourceNsSwitch
import net.fabricmc.mappingio.format.MappingFormat
import net.fabricmc.mappingio.tree.MemoryMappingTree

import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.util.zip.DeflaterOutputStream

Expand All @@ -35,12 +36,12 @@ tasks.register("downloadCommanderMappings") {
Files.createDirectories(processed.toPath().getParent())

MemoryMappingTree tree = new MemoryMappingTree()
MappingReader.read(new InputStreamReader(new URL(getManifest().getAsJsonObject("downloads").getAsJsonObject("server_mappings").get("url").getAsString()).openStream()), new MappingSourceNsSwitch(tree, "target", true))
MappingReader.read(new InputStreamReader(new URL(getManifest().getAsJsonObject("downloads").getAsJsonObject("server_mappings").get("url").getAsString()).openStream(), StandardCharsets.UTF_8), new MappingSourceNsSwitch(tree, "target", true))
tree.setSrcNamespace("official")
tree.setDstNamespaces(List.of("mojang"))

OutputStream stream = Files.newOutputStream(processed.toPath())
tree.accept(MappingWriter.create(new OutputStreamWriter(new DeflaterOutputStream(stream)), MappingFormat.TINY_FILE))
tree.accept(MappingWriter.create(new OutputStreamWriter(new DeflaterOutputStream(stream), StandardCharsets.UTF_8), MappingFormat.TINY_FILE))
}
}

Expand All @@ -62,5 +63,5 @@ JsonObject getManifest() {
}

static JsonObject downloadObject(URL url) {
return JsonParser.parseReader(new InputStreamReader(url.openStream())).getAsJsonObject()
return JsonParser.parseReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8)).getAsJsonObject()
}
11 changes: 11 additions & 0 deletions spotbugs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<!-- Must be a full match -->
<Class name="~.*\.mixin\..*Mixin" />
<Bug pattern="BC_IMPOSSIBLE_CAST, MS_SHOULD_BE_FINAL" />
</Match>
<Match>
<Bug pattern="EI_EXPOSE_REP, EI_EXPOSE_REP2, PA_PUBLIC_PRIMITIVE_ATTRIBUTE, BC_UNCONFIRMED_CAST" />
</Match>
</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static Selector register(Identifier identifier, Selector selector) {
}

@Override
default ServerCommandSource apply(LootContext context) {
default @Nullable ServerCommandSource apply(LootContext context) {
return this.select(context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import java.util.Map;
import java.util.IdentityHashMap;

public interface EventContext {

Expand All @@ -14,13 +14,15 @@ public interface EventContext {
return new EventContextImpl.Builder(type);
}

EventType type();

<T> @NotNull T getParameter(EventKey<T> key);
@NotNull LootContext lootContext();

void setReturnValue(Object value);
<T> T getReturnValue(T def);

EventContext with(Map<EventKey<?>, Object> parameters);
EventContext with(IdentityHashMap<EventKey<?>, Object> parameters);

interface Builder {
<T> Builder addParameter(EventKey<T> key, T value);
Expand Down
Loading

0 comments on commit 5393617

Please sign in to comment.