diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 1f0475f..1ca20f0 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -42,5 +42,5 @@ jobs: - name: Publish to Dairy Snapshots run: ./gradlew publishAllPublicationsToDairyReleasesRepository env: - ORG_GRADLE_PROJECT_dairyReleasesUsername: ${{ secrets.RELEASES_USERNAME }} - ORG_GRADLE_PROJECT_dairyReleasesPassword: ${{ secrets.RELEASES_PASSWORD }} + ORG_GRADLE_PROJECT_dairyReleasesUsername: ${{ secrets.SNAPSHOTS_USERNAME }} + ORG_GRADLE_PROJECT_dairyReleasesPassword: ${{ secrets.SNAPSHOTS_PASSWORD }} diff --git a/.github/workflows/snapshots.yml b/.github/workflows/snapshots.yml deleted file mode 100644 index aa04b7b..0000000 --- a/.github/workflows/snapshots.yml +++ /dev/null @@ -1,48 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle - -name: Publish Snapshots - -on: - push: - branches: - - 'master' - -jobs: - build: - - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'temurin' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 - - - name: Build with Gradle - run: ./gradlew build - - # The USERNAME and TOKEN need to correspond to the credentials environment variables used in - # the publishing section of your build.gradle - - name: Publish to Dairy Snapshots - run: ./gradlew publishAllPublicationsToDairySnapshotsRepository - env: - ORG_GRADLE_PROJECT_dairySnapshotsUsername: ${{ secrets.SNAPSHOTS_USERNAME }} - ORG_GRADLE_PROJECT_dairySnapshotsPassword: ${{ secrets.SNAPSHOTS_PASSWORD }} diff --git a/ftc/src/main/kotlin/page/j5155/expressway/ftc/actions/ActionBuilder.kt b/ftc/src/main/kotlin/page/j5155/expressway/ftc/actions/ActionBuilder.kt new file mode 100644 index 0000000..a2b5742 --- /dev/null +++ b/ftc/src/main/kotlin/page/j5155/expressway/ftc/actions/ActionBuilder.kt @@ -0,0 +1,58 @@ +package page.j5155.expressway.ftc.actions + +import com.acmerobotics.dashboard.telemetry.TelemetryPacket +import page.j5155.expressway.core.actions.Condition +import page.j5155.expressway.core.actions.InitLoopCondAction +import java.util.function.Consumer +import java.util.function.Supplier + +/** + * This class builds an InitLoopCondAction + * @param condition the condition for the action to complete + */ +class ActionBuilder(val condition: Condition) { + + private var initInternal: Supplier = Supplier { } + private var loopInternal: Consumer = Consumer { } + private var cleanupInternal: Supplier = Supplier { } + + /** + * Set the initialization function + * @param init the initialization function + */ + fun setInit(init: Supplier): ActionBuilder { + initInternal = init + return this + } + + /** + * Set the loop function + * @param loop the loop function + */ + fun setLoop(loop: Consumer): ActionBuilder { + loopInternal = loop + return this + } + + /** + * Set the cleanup function + * @param cleanup the cleanup function + */ + fun setCleanup(cleanup: Supplier): ActionBuilder { + cleanupInternal = cleanup + return this + } + + /** + * Builds the InitLoopCondAction + */ + fun build(): InitLoopCondAction { + return object: InitLoopCondAction(condition) { + override fun init() = initInternal.get() + + override fun loop(p: TelemetryPacket) = loopInternal.accept(p) + + override fun cleanup() = cleanupInternal.get() + } + } +} \ No newline at end of file