-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force start after 30 seconds #42
Draft
thiccaxe
wants to merge
4
commits into
Minestom:master
Choose a base branch
from
thiccaxe:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
import net.minestom.arena.Messenger; | ||
import net.minestom.arena.feature.Feature; | ||
import net.minestom.arena.feature.Features; | ||
import net.minestom.arena.game.ArenaManager; | ||
import net.minestom.arena.game.Generator; | ||
import net.minestom.arena.game.SingleInstanceArena; | ||
import net.minestom.arena.group.Group; | ||
|
@@ -149,6 +150,9 @@ public final class MobArena implements SingleInstanceArena { | |
|
||
private static final int SPAWN_RADIUS = 10; | ||
private static final int HEIGHT = 16; | ||
|
||
private static final Duration ROUND_WAIT_TIME = Duration.ofSeconds(30); | ||
|
||
private final AtomicInteger mobCount = new AtomicInteger(); | ||
private boolean stageInProgress; | ||
private int initialMobCount; | ||
|
@@ -365,8 +369,40 @@ private void onStageCleared() { | |
bossBar.color(BossBar.Color.GREEN); | ||
|
||
group().playSound(Sound.sound(SoundEvent.UI_TOAST_CHALLENGE_COMPLETE, Sound.Source.MASTER, 0.5f, 1), Sound.Emitter.self()); | ||
arenaInstance.showTitle(Title.title( | ||
Component.text("Stage Cleared", NamedTextColor.GREEN), | ||
Component.text(ROUND_WAIT_TIME.getSeconds() + " seconds to prepare for next stage"), | ||
Title.Times.times(Duration.ZERO, Duration.ofSeconds(2), Duration.ofMillis(300)) | ||
)); | ||
Messenger.info(group(), "Stage " + stage + " cleared! Talk to the NPC to continue to the next stage"); | ||
new NextStageNPC().setInstance(arenaInstance, new Pos(0.5, HEIGHT, 0.5)); | ||
|
||
startForceContinueCountdown(); | ||
} | ||
|
||
private void startForceContinueCountdown() { | ||
final AtomicInteger countdown = new AtomicInteger((int) ROUND_WAIT_TIME.getSeconds()); | ||
MinecraftServer.getSchedulerManager().submitTask(() -> { | ||
final int count = countdown.getAndDecrement(); | ||
|
||
if (stageInProgress() || !ArenaManager.list().contains(this)) { | ||
return TaskSchedule.stop(); | ||
} | ||
if (count == 0) { | ||
continueToNextStage(false); | ||
return TaskSchedule.stop(); | ||
} | ||
|
||
if (count > 3) { | ||
if (count % 10 == 0) { | ||
Messenger.info(group(), count + " seconds remain to prepare for the next stage."); | ||
} | ||
} else { | ||
Messenger.info(group(), count + " seconds remain."); | ||
} | ||
|
||
return TaskSchedule.seconds(1); | ||
}); | ||
} | ||
|
||
public void continueToNextStage(Player player) { | ||
|
@@ -381,13 +417,8 @@ public void continueToNextStage(Player player) { | |
if (untilStart <= 0) { | ||
Messenger.info(group(), player.getUsername() + " has continued. Starting the next wave."); | ||
|
||
bossBar.name(Component.text("Wave starting...")); | ||
bossBar.progress(1); | ||
bossBar.color(BossBar.Color.BLUE); | ||
continueToNextStage(true); | ||
|
||
Messenger.countdown(group(), 3) | ||
.thenRun(this::nextStage) | ||
.thenRun(continued::clear); | ||
} else { | ||
Messenger.info(group(), player.getUsername() + " has continued. " + untilStart + " more players must continue to start the next wave."); | ||
|
||
|
@@ -398,6 +429,20 @@ public void continueToNextStage(Player player) { | |
} | ||
} | ||
|
||
private void continueToNextStage(boolean showCountdown) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the showCountdown? If you don't want to show the countdown, just call nextStage() |
||
bossBar.name(Component.text("Wave starting...")); | ||
bossBar.progress(1); | ||
bossBar.color(BossBar.Color.BLUE); | ||
continued.clear(); | ||
|
||
if (showCountdown) { | ||
Messenger.countdown(group(), 3) | ||
.thenRun(this::nextStage); | ||
} else { | ||
nextStage(); | ||
} | ||
} | ||
|
||
public int stage() { | ||
return stage; | ||
} | ||
|
@@ -439,7 +484,8 @@ public void nextStage() { | |
|
||
arenaInstance.showTitle(Title.title( | ||
Component.text("Stage " + stage, NamedTextColor.GREEN), | ||
Component.text(initialMobCount + mobOrMobs) | ||
Component.text(initialMobCount + mobOrMobs), | ||
Title.Times.times(Duration.ofMillis(500), Duration.ofSeconds(1), Duration.ofMillis(500)) | ||
)); | ||
|
||
arenaInstance.playSound(Sound.sound(SoundEvent.BLOCK_NOTE_BLOCK_PLING, Sound.Source.MASTER, 1f, 2f)); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also display the countdown in an action bar? Just an idea, not a must.