Skip to content

Commit

Permalink
Allow level dropping to be disabled (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 authored Aug 16, 2023
1 parent 0e00e7a commit 7ed1e43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/main/java/xyz/nucleoid/spleef/game/SpleefActive.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ private void tick() {
this.map.tickLavaRise(this.world, time, lavaRise);
}

if (time > this.nextLevelDropTime) {
if (this.config.levelBreakInterval() < 0) {
this.timerBar.setBarNone();
} else if (time > this.nextLevelDropTime) {
if (this.nextLevelDropTime != -1) {
this.map.tryDropLevel(this.world);
}
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/xyz/nucleoid/spleef/game/SpleefTimerBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
import xyz.nucleoid.plasmid.game.common.widget.BossBarWidget;

public final class SpleefTimerBar {
private static final Text NONE_TITLE = getBarTitle(Text.translatable("text.spleef.bar.dropping.none"), Formatting.GREEN);
private static final Text LAVA_TITLE = getBarTitle(Text.translatable("game.spleef.lava.msg"), Formatting.RED);

private final BossBarWidget widget;

SpleefTimerBar(BossBarWidget widget) {
this.widget = widget;
}

static SpleefTimerBar create(GlobalWidgets widgets) {
var title = getBarTitle(Text.translatable("text.spleef.bar.dropping.none"), Formatting.GREEN);
return new SpleefTimerBar(widgets.addBossBar(title, BossBar.Color.GREEN, BossBar.Style.NOTCHED_10));
return new SpleefTimerBar(widgets.addBossBar(NONE_TITLE, BossBar.Color.GREEN, BossBar.Style.NOTCHED_10));
}

public void update(long ticksUntilDrop, long totalTicksUntilDrop) {
Expand All @@ -25,8 +27,13 @@ public void update(long ticksUntilDrop, long totalTicksUntilDrop) {
}
}

public void setBarNone() {
this.widget.setTitle(NONE_TITLE);
this.widget.setProgress(1f);
}

public void setBarLava(){
this.widget.setTitle(getBarTitle(Text.translatable("game.spleef.lava.msg"), Formatting.RED));
this.widget.setTitle(LAVA_TITLE);
this.widget.setStyle(BossBar.Color.RED, BossBar.Style.NOTCHED_10);
this.widget.setProgress(1f);
}
Expand Down

0 comments on commit 7ed1e43

Please sign in to comment.