Skip to content

Commit

Permalink
Added win and lose messages
Browse files Browse the repository at this point in the history
  • Loading branch information
BomBardyGamer committed Dec 11, 2023
1 parent 95ba827 commit 9d6e46b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

dependencies {
implementation("dev.emortal.minestom:game-sdk:7e04cd0")
implementation("dev.emortal.minestom:game-sdk:5fdd697")

implementation("dev.hollowcube:polar:1.3.1")
implementation("com.github.EmortalMC:MinestomPvP:6aefcba403")
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
3 changes: 2 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ private void playChestCloseSound(@NotNull Point pos) {

private void registerBackgroundTasks() {
// Chest periodic refill task
this.instance.scheduler().buildTask(() -> {
if (game.getEnded().get()) return; // Stop refilling chests once game has been won
this.refillChests();
})
this.instance.scheduler()
.buildTask(() -> {
if (this.game.hasEnded()) return; // Stop refilling chests once game has been won
this.refillChests();
})
.delay(CHEST_REFILL_INTERVAL)
.repeat(CHEST_REFILL_INTERVAL)
.schedule();
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/dev/emortal/minestom/battle/game/BattleGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import dev.emortal.minestom.gamesdk.MinestomGameServer;
import dev.emortal.minestom.gamesdk.config.GameCreationInfo;
import dev.emortal.minestom.gamesdk.game.Game;
import dev.emortal.minestom.gamesdk.util.GameWinLoseMessages;
import io.github.bloepiloepi.pvp.config.DamageConfig;
import io.github.bloepiloepi.pvp.config.PvPConfig;
import io.github.bloepiloepi.pvp.potion.PotionListener;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.title.Title;
import net.minestom.server.MinecraftServer;
Expand Down Expand Up @@ -89,14 +91,14 @@ void beginTimer() {
}

public void checkPlayerCounts() {
Set<Player> alivePlayers = getAlivePlayers();
Set<Player> alivePlayers = this.getAlivePlayers();

if (alivePlayers.isEmpty()) {
this.finish();
return;
}

if (alivePlayers.size() == 1 && !MinestomGameServer.TEST_MODE) {
if (alivePlayers.size() == 1) {
if (this.started.get()) {
this.victory(alivePlayers.iterator().next());
} else {
Expand All @@ -119,12 +121,12 @@ public void victory(@Nullable Player winner) {

Title victoryTitle = Title.title(
MINI_MESSAGE.deserialize("<gradient:#ffc570:gold><bold>VICTORY!"),
Component.empty(),
Component.text(GameWinLoseMessages.randomVictory(), NamedTextColor.GRAY),
Title.Times.times(Duration.ZERO, Duration.ofSeconds(3), Duration.ofSeconds(3))
);
Title defeatTitle = Title.title(
MINI_MESSAGE.deserialize("<gradient:#ff474e:#ff0d0d><bold>DEFEAT!"),
Component.empty(),
Component.text(GameWinLoseMessages.randomDefeat(), NamedTextColor.GRAY),
Title.Times.times(Duration.ZERO, Duration.ofSeconds(3), Duration.ofSeconds(3))
);

Expand Down Expand Up @@ -185,7 +187,7 @@ public void cleanUp() {
return Collections.unmodifiableSet(Sets.filter(this.getPlayers(), player -> player.getGameMode() == GameMode.ADVENTURE));
}

public AtomicBoolean getEnded() {
return ended;
public boolean hasEnded() {
return this.ended.get();
}
}

0 comments on commit 9d6e46b

Please sign in to comment.