Skip to content

Commit

Permalink
Merge pull request #22 from RappyLabyAddons/feat/fallbackReferenceSto…
Browse files Browse the repository at this point in the history
…rage

Add fallback ITbwSounds to also support future versions
  • Loading branch information
RappyTV committed Jun 17, 2024
2 parents 7acaa34 + 9a265da commit 7324186
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 349 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@ on:
branches: [ "master", "main" ]
workflow_dispatch:

env:
PUBLIC_RELEASE_BUILD: true
PUBLIC_RELEASE_BUILD_TOKEN: ${{ secrets.PUBLIC_RELEASE_BUILD_TOKEN }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
java-version: '21'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand Down
4 changes: 2 additions & 2 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ labyModProcessor {
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
18 changes: 7 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ plugins {
group = "org.example"
version = "1.0.0"

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
Expand All @@ -20,8 +18,8 @@ labyMod {
displayName = "Toolbreak Warning"
author = "RappyTV"
description = "Stops you from using your currently used tool when its almost destroyed."
minecraftVersion = "1.8<1.20.4"
version = System.getenv().getOrDefault("VERSION", "1.4.0")
minecraftVersion = "*"
version = System.getenv().getOrDefault("VERSION", "1.4.1")
}

minecraft {
Expand All @@ -36,7 +34,9 @@ labyMod {
"1.19.4",
"1.20.1",
"1.20.2",
"1.20.4"
"1.20.4",
"1.20.5",
"1.20.6"
) { version, provider ->
configureRun(provider, version)
}
Expand All @@ -49,7 +49,7 @@ labyMod {
}

addonDev {
snapshotRelease()
productionRelease()
}
}

Expand Down Expand Up @@ -77,11 +77,7 @@ fun configureRun(provider: net.labymod.gradle.core.minecraft.provider.VersionPro
args("--addon-dev-environment", "true")
}

provider.javaVersion = when (gameVersion) {
else -> {
JavaVersion.VERSION_17
}
}
provider.javaVersion = JavaVersion.VERSION_21

provider.mixin {
val mixinMinVersion = when (gameVersion) {
Expand Down
4 changes: 2 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ labyModProcessor {
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
16 changes: 10 additions & 6 deletions core/src/main/java/com/rappytv/toolwarn/TbwAddon.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.rappytv.toolwarn;

import com.rappytv.toolwarn.api.DefaultTbwSounds;
import com.rappytv.toolwarn.config.TbwConfiguration;
import com.rappytv.toolwarn.core.generated.DefaultReferenceStorage;
import com.rappytv.toolwarn.listener.ConfigMigrationListener;
import com.rappytv.toolwarn.listener.GameTickListener;
import com.rappytv.toolwarn.util.ITbwSounds;
import com.rappytv.toolwarn.api.ITbwSounds;
import net.labymod.api.Laby;
import net.labymod.api.addon.LabyAddon;
import net.labymod.api.client.component.Component;
Expand All @@ -15,10 +16,14 @@
import net.labymod.api.revision.SimpleRevision;
import net.labymod.api.util.version.SemanticVersion;

@SuppressWarnings("ConstantConditions")
@AddonMain
public class TbwAddon extends LabyAddon<TbwConfiguration> {

public static Component prefix;
public static Component prefix = Component
.text("TBW ", Style.builder().color(NamedTextColor.RED).decorate(TextDecoration.BOLD).build())
.append(Component.text("» ", NamedTextColor.DARK_GRAY));

private static ITbwSounds sounds;
private static TbwAddon instance;

Expand All @@ -31,12 +36,11 @@ protected void preConfigurationLoad() {

@Override
protected void enable() {
prefix = Component
.text("TBW ", Style.builder().color(NamedTextColor.RED).decorate(TextDecoration.BOLD).build())
.append(Component.text("» ", NamedTextColor.DARK_GRAY));
sounds = ((DefaultReferenceStorage) this.referenceStorageAccessor()).iTbwSounds();
registerSettingCategory();
instance = this;
sounds = ((DefaultReferenceStorage) this.referenceStorageAccessor()).iTbwSounds();
if(sounds == null)
sounds = new DefaultTbwSounds();

registerListener(new GameTickListener(this));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package com.rappytv.toolwarn.v1_19_2;
package com.rappytv.toolwarn.api;

import com.rappytv.toolwarn.util.ITbwSounds;
import javax.inject.Singleton;
import net.labymod.api.client.resources.ResourceLocation;
import net.labymod.api.models.Implements;
import org.jetbrains.annotations.NotNull;
import javax.inject.Singleton;

@Singleton
@Implements(ITbwSounds.class)
public class TbwSoundImpl implements ITbwSounds {
public class DefaultTbwSounds implements ITbwSounds {

private final ResourceLocation plingSound = ResourceLocation.create("minecraft", "block.note_block.pling");
private final ResourceLocation levelUpSound = ResourceLocation.create("minecraft", "entity.player.levelup");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.rappytv.toolwarn.util;
package com.rappytv.toolwarn.api;

import net.labymod.api.client.resources.ResourceLocation;
import net.labymod.api.reference.annotation.Referenceable;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.rappytv.toolwarn.util.WarnTool;
import com.rappytv.toolwarn.util.WarnTool.Type;
import net.labymod.api.client.gui.mouse.MutableMouse;
import net.labymod.api.client.gui.screen.LabyScreen;
import net.labymod.api.client.gui.screen.Parent;
import net.labymod.api.client.gui.screen.activity.Activity;
import net.labymod.api.client.gui.screen.activity.AutoActivity;
Expand All @@ -26,7 +25,6 @@
import net.labymod.api.client.gui.screen.widget.widgets.layout.ScrollWidget;
import net.labymod.api.client.gui.screen.widget.widgets.layout.list.HorizontalListWidget;
import net.labymod.api.client.gui.screen.widget.widgets.layout.list.VerticalListWidget;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -316,11 +314,6 @@ private void setAction(Action action) {
this.reload();
}

@Override
public <T extends LabyScreen> @Nullable T renew() {
return null;
}

private enum Action {
ADD, EDIT, REMOVE
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.rappytv.toolwarn.v1_12_2;

import com.rappytv.toolwarn.util.ITbwSounds;
import com.rappytv.toolwarn.api.ITbwSounds;
import javax.inject.Singleton;
import net.labymod.api.client.resources.ResourceLocation;
import net.labymod.api.models.Implements;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 7324186

Please sign in to comment.