This commit is contained in:
Mathieu Strypsteen 2024-09-23 08:07:55 +02:00
parent ff6c4bdb2b
commit ff7e93fceb
6 changed files with 7 additions and 8 deletions

View file

@ -27,7 +27,7 @@ public class ClimbEvent extends Event {
@Override @Override
public void start() { public void start() {
if (MC13DTL.board.getPlayers(team).size() == 0) { if (MC13DTL.board.getPlayers(team).isEmpty()) {
return; return;
} }
Player player = MC13DTL.board.getPlayers(team).getFirst(); Player player = MC13DTL.board.getPlayers(team).getFirst();

View file

@ -60,7 +60,7 @@ public class EndEvent extends Event {
@EventHandler @EventHandler
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
if (event.getEntityType() == EntityType.ENDER_DRAGON) { if (event.getEntityType() == EntityType.ENDER_DRAGON) {
if (MC13DTL.board.getPlayers(team).size() > 0) { if (!MC13DTL.board.getPlayers(team).isEmpty()) {
eventSuccess(); eventSuccess();
} }
} }

View file

@ -30,7 +30,7 @@ public class FallEvent extends Event {
@Override @Override
public void start() { public void start() {
if (MC13DTL.board.getPlayers(team).size() == 0) { if (MC13DTL.board.getPlayers(team).isEmpty()) {
return; return;
} }
Player player = MC13DTL.board.getPlayers(team).getFirst(); Player player = MC13DTL.board.getPlayers(team).getFirst();

View file

@ -37,7 +37,7 @@ public class LightningEvent extends Event {
@Override @Override
public void run() { public void run() {
if (MC13DTL.board.getPlayers(team).size() == 0) { if (MC13DTL.board.getPlayers(team).isEmpty()) {
return; return;
} }
World world = Bukkit.getWorld("world"); World world = Bukkit.getWorld("world");

View file

@ -10,7 +10,7 @@ import gent.zeus.mc13dtl.MC13DTL;
public class SurvivalHandler implements Listener { public class SurvivalHandler implements Listener {
@EventHandler @EventHandler
public void onPlayerDeath(PlayerDeathEvent event) { public void onPlayerDeath(PlayerDeathEvent event) {
for (Team team : MC13DTL.board.getTeams().stream().toList()) { for (Team team : MC13DTL.board.getTeams()) {
if (MC13DTL.board.getPlayers(team).contains(event.getPlayer())) { if (MC13DTL.board.getPlayers(team).contains(event.getPlayer())) {
MC13DTL.board.setDaysAlive(team, 0); MC13DTL.board.setDaysAlive(team, 0);
} }

View file

@ -24,7 +24,7 @@ public class SurvivalRunner implements Runnable {
long day = Bukkit.getWorld("world").getFullTime() / 24000; long day = Bukkit.getWorld("world").getFullTime() / 24000;
if (day > lastRunDay) { if (day > lastRunDay) {
List<Pair<Team, Integer>> grantedScores = new ArrayList<>(); List<Pair<Team, Integer>> grantedScores = new ArrayList<>();
for (Team team : MC13DTL.board.getTeams().stream().toList()) { for (Team team : MC13DTL.board.getTeams()) {
if (!MC13DTL.board.getPlayers(team).isEmpty()) { if (!MC13DTL.board.getPlayers(team).isEmpty()) {
int currentDays = MC13DTL.board.getDaysAlive(team) + 1; int currentDays = MC13DTL.board.getDaysAlive(team) + 1;
int score = (int) Math.pow(2, currentDays); int score = (int) Math.pow(2, currentDays);
@ -39,8 +39,7 @@ public class SurvivalRunner implements Runnable {
for (Pair<Team, Integer> p : grantedScores) { for (Pair<Team, Integer> p : grantedScores) {
MC13DTL.instance.getServer().broadcast( MC13DTL.instance.getServer().broadcast(
Component.text("Team " + p.getFirst().getName()).color(p.getFirst().color()).append( Component.text("Team " + p.getFirst().getName()).color(p.getFirst().color()).append(
Component.text(" survived " + MC13DTL.board.getDaysAlive(p.getFirst()) + " days and was given " + p.getSecond() + " points").color(NamedTextColor.WHITE) Component.text(" survived " + MC13DTL.board.getDaysAlive(p.getFirst()) + " days and was given " + p.getSecond() + " points").color(NamedTextColor.WHITE)));
));
} }
} }
world.getPersistentDataContainer().set(eventKey, PersistentDataType.LONG, day); world.getPersistentDataContainer().set(eventKey, PersistentDataType.LONG, day);