Skip to content

Commit

Permalink
Fix flag beams dying in the void
Browse files Browse the repository at this point in the history
Signed-off-by: Pablete1234 <[email protected]>
  • Loading branch information
Pablete1234 authored and Electroid committed Apr 11, 2021
1 parent b290d11 commit 266ad0b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/src/main/java/tc/oc/pgm/flag/LegacyFlagBeamMatchModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,24 @@ public void unload() {
beams.clear();
}

private void showLater(MatchPlayer player) {
match
.getExecutor(MatchScope.LOADED)
.schedule(() -> beams().forEach(b -> b.show(player)), 50, TimeUnit.MILLISECONDS);
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
MatchPlayer player = match.getPlayer(event.getPlayer());
if (player == null) return;

if (event.getWorld() == match.getWorld()) beams().forEach(beam -> beam.show(player));
if (event.getWorld() == match.getWorld()) showLater(player);
else beams().forEach(beam -> beam.hide(player));
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinMatchEvent event) {
beams().forEach(beam -> beam.show(event.getPlayer()));
showLater(event.getPlayer());
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
Expand Down Expand Up @@ -201,6 +207,7 @@ public void update(MatchPlayer player) {
carrier().map(c -> c.getBukkit().getLocation()).orElseGet(() -> location().orElse(null));
if (loc == null) return;
loc = loc.clone().add(0, 2.75, 0);
if (loc.getY() < -64) loc.setY(-64);
loc.setPitch(0f);
loc.setYaw(0f);
base(player).teleport(player.getBukkit(), loc);
Expand Down

0 comments on commit 266ad0b

Please sign in to comment.