Skip to content

Commit 37f3e76

Browse files
authored
Merge pull request #3 from RappyLabyAddons/development
Release v1.0.1
2 parents ac42c9b + 7dc4802 commit 37f3e76

File tree

14 files changed

+223
-166
lines changed

14 files changed

+223
-166
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,32 @@ jobs:
1111
build:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
- name: Set up JDK 21
16-
uses: actions/setup-java@v3
16+
uses: actions/setup-java@v4
1717
with:
1818
distribution: 'corretto'
1919
java-version: '21'
20+
- name: Cache Gradle dependencies
21+
uses: actions/cache@v4
22+
with:
23+
path: ~/.gradle/caches
24+
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
25+
restore-keys: |
26+
gradle-${{ runner.os }}-
27+
- name: Cache Gradle wrapper
28+
uses: actions/cache@v4
29+
with:
30+
path: ~/.gradle/wrapper
31+
key: gradle-wrapper-${{ runner.os }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
32+
restore-keys: |
33+
gradle-wrapper-${{ runner.os }}-
2034
- name: Grant execute permission for gradlew
2135
run: chmod +x gradlew
2236
- name: Build with Gradle
2337
run: ./gradlew build --full-stacktrace
2438
- name: Upload Artifact
25-
uses: actions/upload-artifact@v3
39+
uses: actions/upload-artifact@v4
2640
with:
2741
name: Artifacts
2842
path: build/libs/*-release.jar

core/src/main/java/com/rappytv/speedruntimer/sound/ITimerSound.java renamed to api/src/main/java/com/rappytv/speedruntimer/sound/TimerSound.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import net.labymod.api.client.resources.ResourceLocation;
44
import net.labymod.api.reference.annotation.Referenceable;
5+
import org.jetbrains.annotations.Nullable;
56

7+
@Nullable
68
@Referenceable
7-
public interface ITimerSound {
9+
public interface TimerSound {
810

911
ResourceLocation getNotificationSound();
1012
}

api/src/main/java/com/rappytv/speedruntimer/util/Timer.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ public Timer(Runnable onCountdownComplete) {
1919
}
2020

2121
public void startCountUp() {
22-
if(state != TimerState.OFF) return;
22+
if(this.state != TimerState.OFF) return;
2323
this.direction = TimerDirection.COUNT_UP;
2424
this.seconds = 0;
25-
start();
25+
this.start();
2626
}
2727

2828
public void startCountDown(long seconds) {
29-
if(state != TimerState.OFF) return;
29+
if(this.state != TimerState.OFF) return;
3030
this.direction = TimerDirection.COUNT_DOWN;
3131
this.seconds = seconds;
32-
start();
32+
this.start();
3333
}
3434

3535
public void reset() {
36-
if(state == TimerState.OFF) return;
36+
if(this.state == TimerState.OFF) return;
3737
this.direction = TimerDirection.COUNT_UP;
3838
this.seconds = 0;
3939
this.state = TimerState.OFF;
@@ -51,7 +51,7 @@ public Component getDisplay() {
5151
(String.valueOf(seconds).length() > 1 ? "" : "0") + seconds
5252
));
5353

54-
if(state == TimerState.PAUSED) component.decorate(TextDecoration.ITALIC).color(NamedTextColor.RED);
54+
if(this.state == TimerState.PAUSED) component.decorate(TextDecoration.ITALIC).color(NamedTextColor.RED);
5555
else component.color(NamedTextColor.GREEN);
5656
return component.decorate(TextDecoration.BOLD);
5757
}
@@ -61,16 +61,16 @@ private void start() {
6161
timer.schedule(new TimerTask() {
6262
@Override
6363
public void run() {
64-
if(state == TimerState.OFF) cancel();
65-
if(state == TimerState.PAUSED) return;
66-
67-
if(direction == TimerDirection.COUNT_UP) seconds++;
68-
else if(direction == TimerDirection.COUNT_DOWN) {
69-
seconds--;
70-
if(seconds < 0) {
71-
seconds = 0;
72-
state = TimerState.PAUSED;
73-
onCountdownComplete.run();
64+
if(Timer.this.state == TimerState.OFF) this.cancel();
65+
if(Timer.this.state == TimerState.PAUSED) return;
66+
67+
if(Timer.this.direction == TimerDirection.COUNT_UP) Timer.this.seconds++;
68+
else if(Timer.this.direction == TimerDirection.COUNT_DOWN) {
69+
Timer.this.seconds--;
70+
if(Timer.this.seconds < 0) {
71+
Timer.this.seconds = 0;
72+
Timer.this.state = TimerState.PAUSED;
73+
Timer.this.onCountdownComplete.run();
7474
}
7575
}
7676
}
@@ -99,7 +99,7 @@ public long resolveSeconds(String timeValue) {
9999
case "y" -> duration * 60 * 60 * 24 * 7 * 52;
100100
default -> {
101101
try {
102-
yield resolveSeconds(Integer.parseInt(timeValue) + "s");
102+
yield this.resolveSeconds(Integer.parseInt(timeValue) + "s");
103103
} catch (NumberFormatException e) {
104104
yield -1;
105105
}
@@ -108,23 +108,23 @@ public long resolveSeconds(String timeValue) {
108108
}
109109

110110
public TimerDirection getDirection() {
111-
return direction;
111+
return this.direction;
112112
}
113113

114114
public void setDirection(TimerDirection direction) {
115115
this.direction = direction;
116116
}
117117

118118
public TimerState getState() {
119-
return state;
119+
return this.state;
120120
}
121121

122122
public void setState(TimerState state) {
123123
this.state = state;
124124
}
125125

126126
public long getSeconds() {
127-
return seconds;
127+
return this.seconds;
128128
}
129129

130130
public void setSeconds(long seconds) {

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ plugins {
66
val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";")
77

88
group = "com.rappytv.speedruntimer"
9-
version = providers.environmentVariable("VERSION").getOrElse("1.0.0")
9+
version = providers.environmentVariable("VERSION").getOrElse("1.0.1")
1010

1111
labyMod {
1212
defaultPackageName = "com.rappytv.speedruntimer"
13+
1314
addonInfo {
1415
namespace = "speedruntimer"
1516
displayName = "SpeedrunTimer"

core/src/main/java/com/rappytv/speedruntimer/SpeedrunTimerAddon.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.rappytv.speedruntimer;
22

3+
import com.rappytv.speedruntimer.api.generated.ReferenceStorage;
34
import com.rappytv.speedruntimer.command.TimerCommand;
4-
import com.rappytv.speedruntimer.core.generated.DefaultReferenceStorage;
5-
import com.rappytv.speedruntimer.hudWidget.TimerHudWidget;
5+
import com.rappytv.speedruntimer.hudwidget.TimerHudWidget;
66
import com.rappytv.speedruntimer.sound.DefaultTimerSound;
7-
import com.rappytv.speedruntimer.sound.ITimerSound;
7+
import com.rappytv.speedruntimer.sound.TimerSound;
88
import com.rappytv.speedruntimer.util.Timer;
99
import net.labymod.api.Laby;
1010
import net.labymod.api.addon.LabyAddon;
@@ -29,17 +29,17 @@ public class SpeedrunTimerAddon extends LabyAddon<SpeedrunTimerConfig> {
2929
@SuppressWarnings("ConstantConditions")
3030
@Override
3131
protected void enable() {
32-
ITimerSound timerSound = ((DefaultReferenceStorage) this.referenceStorageAccessor()).iTimerSound();
32+
TimerSound timerSound = ((ReferenceStorage) this.referenceStorageAccessor()).getTimerSound();
3333
if(timerSound == null)
3434
timerSound = new DefaultTimerSound();
3535
ResourceLocation sound = timerSound.getNotificationSound();
36-
timer = new Timer(() -> {
37-
if(configuration().countdownSound().get()) {
36+
this.timer = new Timer(() -> {
37+
if(this.configuration().countdownSound().get()) {
3838
Laby.references().minecraftSounds().playSound(sound, 1f, 1f);
3939
}
4040
});
41-
registerSettingCategory();
42-
registerCommand(new TimerCommand(this));
41+
this.registerSettingCategory();
42+
this.registerCommand(new TimerCommand(this));
4343
Laby.labyAPI().hudWidgetRegistry().register(new TimerHudWidget(this));
4444
}
4545

@@ -50,7 +50,7 @@ protected Class<? extends SpeedrunTimerConfig> configurationClass() {
5050

5151
@NotNull
5252
public Timer getTimer() {
53-
return timer;
53+
return this.timer;
5454
}
5555

5656
public static Component prefix() {

core/src/main/java/com/rappytv/speedruntimer/SpeedrunTimerConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public class SpeedrunTimerConfig extends AddonConfig {
1919

2020
@Override
2121
public ConfigProperty<Boolean> enabled() {
22-
return enabled;
22+
return this.enabled;
2323
}
2424

2525
public ConfigProperty<Boolean> countdownSound() {
26-
return countdownSound;
26+
return this.countdownSound;
2727
}
2828
}

0 commit comments

Comments
 (0)