Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@

package plugily.projects.minigamesbox.api.events.game;

import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import plugily.projects.minigamesbox.api.arena.IPluginArena;
import plugily.projects.minigamesbox.api.events.PlugilyEvent;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* @author Tigerpanzer_02
* <p>
Expand All @@ -32,9 +37,11 @@
public class PlugilyGameStartEvent extends PlugilyEvent {

private static final HandlerList HANDLERS = new HandlerList();
private final List<Player> players;

public PlugilyGameStartEvent(IPluginArena arena) {
super(arena);
players = Collections.unmodifiableList(new ArrayList<>(arena.getPlayers()));

Check failure on line 44 in MiniGamesBox API/src/main/java/plugily/projects/minigamesbox/api/events/game/PlugilyGameStartEvent.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Fix this access that will throw a NullPointerException when executed.

See more on https://sonarcloud.io/project/issues?id=Plugily-Projects_MiniGamesBox&issues=AaBSIyFMYMfOgvIw3tx6&open=AaBSIyFMYMfOgvIw3tx6&pullRequest=80
}

public static HandlerList getHandlerList() {
Expand All @@ -46,4 +53,13 @@
return HANDLERS;
}

/**
* Gets a snapshot of the players who were in the arena when the game started.
*
* @return an immutable list of players
*/
public List<Player> getPlayers() {
return players;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@

package plugily.projects.minigamesbox.api.events.game;

import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import plugily.projects.minigamesbox.api.arena.IPluginArena;
import plugily.projects.minigamesbox.api.events.PlugilyEvent;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* @author Tigerpanzer_02
* <p>
Expand All @@ -31,9 +36,11 @@
public class PlugilyGameStopEvent extends PlugilyEvent {

private static final HandlerList HANDLERS = new HandlerList();
private final List<Player> players;

public PlugilyGameStopEvent(IPluginArena arena) {
super(arena);
players = Collections.unmodifiableList(new ArrayList<>(arena.getPlayers()));

Check failure on line 43 in MiniGamesBox API/src/main/java/plugily/projects/minigamesbox/api/events/game/PlugilyGameStopEvent.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Fix this access that will throw a NullPointerException when executed.

See more on https://sonarcloud.io/project/issues?id=Plugily-Projects_MiniGamesBox&issues=AaBSIyDTYMfOgvIw3tx5&open=AaBSIyDTYMfOgvIw3tx5&pullRequest=80
}

public static HandlerList getHandlerList() {
Expand All @@ -45,4 +52,13 @@
return HANDLERS;
}

/**
* Gets a snapshot of the players who were in the arena when the game stopped.
*
* @return an immutable list of players
*/
public List<Player> getPlayers() {
return players;
}

}