Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '21'
java-version: '25'
- name: Cache Gradle dependencies
uses: actions/cache@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ run/
# LabyGradle | Addon Plugin
build-data.txt
.assetsroot
resources_index.json
access_widener_index.json

# Don't ignore libraries
!libs/*.jar
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.rappytv.speedruntimer.util;
package com.rappytv.speedruntimer.api;

import com.rappytv.speedruntimer.api.event.CountdownCompleteEvent;
import net.labymod.api.Laby;
import net.labymod.api.client.component.Component;
import net.labymod.api.client.component.format.NamedTextColor;
import net.labymod.api.client.component.format.TextDecoration;
Expand All @@ -9,23 +11,18 @@ public class Timer {

private static final String displayFormat = "%s:%s:%s";
private static final java.util.Timer timer = new java.util.Timer();
private final Runnable onCountdownComplete;
private TimerState state = TimerState.OFF;
private TimerDirection direction = TimerDirection.COUNT_DOWN;
private long seconds = 0;

public Timer(Runnable onCountdownComplete) {
this.onCountdownComplete = onCountdownComplete;
}

public void startCountUp() {
if(this.state != TimerState.OFF) return;
this.direction = TimerDirection.COUNT_UP;
this.seconds = 0;
this.start();
}

public void startCountDown(long seconds) {
public void startCountdown(long seconds) {
if(this.state != TimerState.OFF) return;
this.direction = TimerDirection.COUNT_DOWN;
this.seconds = seconds;
Expand Down Expand Up @@ -70,7 +67,7 @@ else if(Timer.this.direction == TimerDirection.COUNT_DOWN) {
if(Timer.this.seconds < 0) {
Timer.this.seconds = 0;
Timer.this.state = TimerState.PAUSED;
Timer.this.onCountdownComplete.run();
Laby.fireEvent(new CountdownCompleteEvent());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.rappytv.speedruntimer.api.event;

import net.labymod.api.event.Event;

public class CountdownCompleteEvent implements Event {

}
12 changes: 0 additions & 12 deletions api/src/main/java/com/rappytv/speedruntimer/sound/TimerSound.java

This file was deleted.

7 changes: 6 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";")

group = "com.rappytv.speedruntimer"
version = providers.environmentVariable("VERSION").getOrElse("1.0.1")
version = providers.environmentVariable("VERSION").getOrElse("1.0.2")

labyMod {
defaultPackageName = "com.rappytv.speedruntimer"
Expand Down Expand Up @@ -37,4 +37,9 @@ subprojects {

group = rootProject.group
version = rootProject.version

extensions.findByType(JavaPluginExtension::class.java)?.apply {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.rappytv.speedruntimer;

import com.rappytv.speedruntimer.api.generated.ReferenceStorage;
import com.rappytv.speedruntimer.command.TimerCommand;
import com.rappytv.speedruntimer.hudwidget.TimerHudWidget;
import com.rappytv.speedruntimer.sound.DefaultTimerSound;
import com.rappytv.speedruntimer.sound.TimerSound;
import com.rappytv.speedruntimer.util.Timer;
package com.rappytv.speedruntimer.core;

import com.rappytv.speedruntimer.core.command.TimerCommand;
import com.rappytv.speedruntimer.api.event.CountdownCompleteEvent;
import com.rappytv.speedruntimer.core.hudwidget.TimerHudWidget;
import com.rappytv.speedruntimer.api.Timer;
import net.labymod.api.Laby;
import net.labymod.api.addon.LabyAddon;
import net.labymod.api.client.component.Component;
import net.labymod.api.client.component.format.NamedTextColor;
import net.labymod.api.client.component.format.TextDecoration;
import net.labymod.api.client.resources.ResourceLocation;
import net.labymod.api.event.Subscribe;
import net.labymod.api.loader.MinecraftVersions;
import net.labymod.api.models.addon.annotation.AddonMain;
import org.jetbrains.annotations.NotNull;

Expand All @@ -25,24 +25,29 @@ public class SpeedrunTimerAddon extends LabyAddon<SpeedrunTimerConfig> {
.append(Component.space());

private Timer timer;
private ResourceLocation timerSound;

@SuppressWarnings("ConstantConditions")
@Override
protected void enable() {
TimerSound timerSound = ((ReferenceStorage) this.referenceStorageAccessor()).getTimerSound();
if(timerSound == null)
timerSound = new DefaultTimerSound();
ResourceLocation sound = timerSound.getNotificationSound();
this.timer = new Timer(() -> {
if(this.configuration().countdownSound().get()) {
Laby.references().minecraftSounds().playSound(sound, 1f, 1f);
}
});
public void enable() {
this.timer = new Timer();
this.initializeTimerSound();
this.registerSettingCategory();
this.registerCommand(new TimerCommand(this));
Laby.labyAPI().hudWidgetRegistry().register(new TimerHudWidget(this));
}

@Subscribe
public void onCountDownComplete(CountdownCompleteEvent event) {
if(!this.configuration().countdownSound().get() || this.timerSound == null) {
return;
}
Laby.references().minecraftSounds().playSound(
this.timerSound,
1f,
1f
);
}

@Override
protected Class<? extends SpeedrunTimerConfig> configurationClass() {
return SpeedrunTimerConfig.class;
Expand All @@ -56,4 +61,16 @@ public Timer getTimer() {
public static Component prefix() {
return prefix;
}

private void initializeTimerSound() {
String path;
if(MinecraftVersions.current().equals(MinecraftVersions.V1_8_9)) {
path = "note.pling";
} else if(MinecraftVersions.current().equals(MinecraftVersions.V1_12_2)) {
path = "block.note.pling";
} else {
path = "block.note_block.pling";
}
this.timerSound = ResourceLocation.create("minecraft", path);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.rappytv.speedruntimer;
package com.rappytv.speedruntimer.core;

import net.labymod.api.addon.AddonConfig;
import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.rappytv.speedruntimer.command;
package com.rappytv.speedruntimer.core.command;

import com.rappytv.speedruntimer.SpeedrunTimerAddon;
import com.rappytv.speedruntimer.util.Timer;
import com.rappytv.speedruntimer.util.Timer.TimerDirection;
import com.rappytv.speedruntimer.util.Timer.TimerState;
import com.rappytv.speedruntimer.core.SpeedrunTimerAddon;
import com.rappytv.speedruntimer.api.Timer;
import com.rappytv.speedruntimer.api.Timer.TimerDirection;
import com.rappytv.speedruntimer.api.Timer.TimerState;
import net.labymod.api.Laby;
import net.labymod.api.client.chat.command.Command;
import net.labymod.api.client.chat.command.SubCommand;
Expand Down Expand Up @@ -134,7 +134,7 @@ public boolean execute(String prefix, String[] arguments) {
return true;
}

this.timer.startCountDown(seconds);
this.timer.startCountdown(seconds);
this.displayMessage(
Component.empty()
.append(SpeedrunTimerAddon.prefix())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.rappytv.speedruntimer.hudwidget;
package com.rappytv.speedruntimer.core.hudwidget;

import com.rappytv.speedruntimer.SpeedrunTimerAddon;
import com.rappytv.speedruntimer.util.Timer.TimerState;
import net.labymod.api.Laby;
import com.rappytv.speedruntimer.core.SpeedrunTimerAddon;
import com.rappytv.speedruntimer.api.Timer.TimerState;
import net.labymod.api.client.gfx.pipeline.renderer.text.TextRenderingOptions;
import net.labymod.api.client.gui.hud.HudWidgetRendererAccessor;
import net.labymod.api.client.gui.hud.binding.dropzone.HudWidgetDropzone;
import net.labymod.api.client.gui.hud.binding.dropzone.NamedHudWidgetDropzones;
Expand All @@ -12,21 +12,17 @@
import net.labymod.api.client.gui.hud.position.HudWidgetAnchor;
import net.labymod.api.client.gui.icon.Icon;
import net.labymod.api.client.gui.screen.ScreenContext;
import net.labymod.api.client.render.font.ComponentRenderer;
import net.labymod.api.client.render.font.RenderableComponent;
import net.labymod.api.client.render.matrix.Stack;
import net.labymod.api.client.resources.ResourceLocation;
import net.labymod.api.util.bounds.area.RectangleAreaPosition;

public class TimerHudWidget extends SimpleHudWidget<HudWidgetConfig> {

private final SpeedrunTimerAddon addon;
private final ComponentRenderer renderer;

public TimerHudWidget(SpeedrunTimerAddon addon) {
super("speedruntimer_display", HudWidgetConfig.class);
this.addon = addon;
this.renderer = Laby.references().renderPipeline().componentRenderer();

this.bindDropzones(new TimerHudWidgetDropzone());
this.setIcon(Icon.texture(ResourceLocation.create(
Expand All @@ -45,11 +41,16 @@ public void initializePreConfigured(HudWidgetConfig config) {

@Override
public void render(RenderPhase phase, ScreenContext context, boolean isEditorContext, HudSize size) {
Stack stack = context.stack();
RenderableComponent statusComponent = RenderableComponent.of(this.addon.getTimer().getDisplay());
if (stack != null) {
this.renderer.builder().text(statusComponent).pos(this.anchor.isLeft() ? 2 : (this.anchor.isCenter() ? statusComponent.getWidth() / 2.0f : 2.0f), 0).color(-1).shadow(true).centered(this.anchor.isCenter()).render(stack);
}
context.canvas().submitRenderableComponent(
statusComponent,
this.anchor.isCenter() ? statusComponent.getWidth() / 2 : 0,
0,
-1,
TextRenderingOptions.SHADOW | (this.anchor.isCenter()
? TextRenderingOptions.CENTERED
: TextRenderingOptions.NONE
));
size.set(statusComponent.getWidth(), statusComponent.getHeight());
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
org.gradle.jvmargs=-Xmx4096m
net.labymod.minecraft-versions=1.8.9;1.12.2;1.16.5;1.17.1;1.18.2;1.19.2;1.19.3;1.19.4;1.20.1;1.20.2;1.20.4;1.20.5;1.20.6;1.21;1.21.1;1.21.3;1.21.4;1.21.5
net.labymod.minecraft-versions=1.8.9;1.12.2;1.16.5;1.17.1;1.18.2;1.19.4;1.20.1;1.20.6;1.21;1.21.1;1.21.3;1.21.4;1.21.5;1.21.8;1.21.10;1.21.11
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rootProject.name = "speedruntimer"

pluginManagement {
val labyGradlePluginVersion = "0.5.9"
val labyGradlePluginVersion = "0.6.0"

buildscript {
repositories {
Expand Down