Skip to content

Commit

Permalink
fix: don't send action bar packets before PLAY stage
Browse files Browse the repository at this point in the history
  • Loading branch information
LooFifteen committed Mar 14, 2024
1 parent 249e686 commit 9306a72
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/dev/emortal/minestom/marathon/MarathonGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
import net.minestom.server.entity.GameMode;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import net.minestom.server.event.EventListener;
import net.minestom.server.event.EventNode;
import net.minestom.server.event.player.PlayerMoveEvent;
import net.minestom.server.event.player.PlayerSpawnEvent;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.block.Block;
import net.minestom.server.network.ConnectionState;
import net.minestom.server.sound.SoundEvent;
import net.minestom.server.tag.Tag;
import net.minestom.server.timer.Task;
Expand Down Expand Up @@ -139,6 +142,10 @@ private void startRefreshDisplaysTask() {
}

private void refreshDisplays() {
// the player is added to the game during the configuration state,
// this stops action bars from being sent to the player during that time
if (this.player.getPlayerConnection().getConnectionState() != ConnectionState.PLAY) return;

long millisTaken = this.startTimestamp == -1 ? 0 : System.currentTimeMillis() - this.startTimestamp;
String formattedTime = DATE_FORMAT.format(new Date(millisTaken));
double secondsTaken = millisTaken / 1000.0;
Expand Down

0 comments on commit 9306a72

Please sign in to comment.