add kill best surviving team event
# Conflicts: # src/main/java/gent/zeus/mc13dtl/events/EventRunner.java
This commit is contained in:
parent
ad6b6966e0
commit
6ebb48f7ce
4 changed files with 58 additions and 9 deletions
|
@ -97,7 +97,7 @@ public class TeamScoreBoard {
|
||||||
List<Player> players = new ArrayList<>();
|
List<Player> players = new ArrayList<>();
|
||||||
for (String entry : team.getEntries()) {
|
for (String entry : team.getEntries()) {
|
||||||
Player player = Bukkit.getPlayer(entry);
|
Player player = Bukkit.getPlayer(entry);
|
||||||
if (player != null) {
|
if (player != null && player.isOnline()) {
|
||||||
players.add(player);
|
players.add(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import gent.zeus.mc13dtl.MC13DTL;
|
||||||
|
|
||||||
public class EventRunner implements Runnable {
|
public class EventRunner implements Runnable {
|
||||||
static List<Event> currentEvents = new ArrayList<>();
|
static List<Event> currentEvents = new ArrayList<>();
|
||||||
public static List<Integer> startTimes = List.of(5000, 13000, 1000, 13000, 1000, 500);
|
public static List<Integer> startTimes = List.of(5000, 13000, 1000, 13000, 1000, 500, 10000);
|
||||||
|
|
||||||
private long day;
|
private long day;
|
||||||
|
|
||||||
|
@ -44,8 +44,9 @@ public class EventRunner implements Runnable {
|
||||||
case 1 -> new KillMobs1Event(team, difficulty, getDayScore());
|
case 1 -> new KillMobs1Event(team, difficulty, getDayScore());
|
||||||
case 2 -> new CraftEvent(team, difficulty, getDayScore());
|
case 2 -> new CraftEvent(team, difficulty, getDayScore());
|
||||||
case 3 -> new ClimbEvent(team, difficulty, getDayScore());
|
case 3 -> new ClimbEvent(team, difficulty, getDayScore());
|
||||||
case 4 -> new KillPlayerEvent(team, difficulty, getDayScore(), teams);
|
case 4 -> new KillPlayerEvent(team, difficulty, getDayScore());
|
||||||
case 5 -> new StructureEvent(team, difficulty, getDayScore());
|
case 5 -> new StructureEvent(team, difficulty, getDayScore());
|
||||||
|
case 6 -> new KillSurvivingTeamEvent(team, difficulty, getDayScore());
|
||||||
default -> throw new IllegalStateException("Unexpected day: " + (int) day);
|
default -> throw new IllegalStateException("Unexpected day: " + (int) day);
|
||||||
};
|
};
|
||||||
event.start();
|
event.start();
|
||||||
|
|
|
@ -9,18 +9,19 @@ import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class KillPlayerEvent extends Event {
|
public class KillPlayerEvent extends Event {
|
||||||
|
|
||||||
private Team huntingTeam;
|
private Team huntingTeam;
|
||||||
|
|
||||||
public KillPlayerEvent(Team team, Difficulty difficulty, int scoreOnSuccess, List<Team> teams) {
|
public KillPlayerEvent(Team team, Difficulty difficulty, int scoreOnSuccess) {
|
||||||
super(team, difficulty, scoreOnSuccess);
|
super(team, difficulty, scoreOnSuccess);
|
||||||
|
|
||||||
for (Team t : teams) {
|
for (Team t : MC13DTL.board.getTeams()) {
|
||||||
if (t != team && (huntingTeam == null ||
|
if (!MC13DTL.board.getPlayers(t).isEmpty()
|
||||||
Math.abs(MC13DTL.board.getScore(t) - MC13DTL.board.getScore(team)) < Math.abs(MC13DTL.board.getScore(huntingTeam) - MC13DTL.board.getScore(team)))) {
|
&& t != team
|
||||||
|
&& (huntingTeam == null ||
|
||||||
|
Math.abs(MC13DTL.board.getScore(t) - MC13DTL.board.getScore(team)) < Math.abs(MC13DTL.board.getScore(huntingTeam) - MC13DTL.board.getScore(team))
|
||||||
|
)) {
|
||||||
huntingTeam = t;
|
huntingTeam = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package gent.zeus.mc13dtl.events.catalog;
|
||||||
|
|
||||||
|
import gent.zeus.mc13dtl.MC13DTL;
|
||||||
|
import gent.zeus.mc13dtl.events.Difficulty;
|
||||||
|
import gent.zeus.mc13dtl.events.Event;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
|
public class KillSurvivingTeamEvent extends Event {
|
||||||
|
|
||||||
|
private Team huntingTeam;
|
||||||
|
|
||||||
|
public KillSurvivingTeamEvent(Team team, Difficulty difficulty, int scoreOnSuccess) {
|
||||||
|
super(team, difficulty, scoreOnSuccess);
|
||||||
|
|
||||||
|
for (Team t : MC13DTL.board.getTeams()) {
|
||||||
|
if (!MC13DTL.board.getPlayers(t).isEmpty()
|
||||||
|
&& (huntingTeam == null || MC13DTL.board.getDaysAlive(t) > MC13DTL.board.getDaysAlive(huntingTeam)
|
||||||
|
)) {
|
||||||
|
huntingTeam = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
@Override
|
||||||
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
|
if (MC13DTL.board.getPlayers(team).contains(event.getPlayer())) {
|
||||||
|
eventFailed();
|
||||||
|
} else if (MC13DTL.board.getPlayers(huntingTeam).contains(event.getPlayer())) {
|
||||||
|
eventSuccess();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getMessage() {
|
||||||
|
if (team.getName().equals(huntingTeam.getName())) {
|
||||||
|
return "Your team is being hunted by everyone!!! RUN";
|
||||||
|
} else {
|
||||||
|
return "A member of team " + huntingTeam.getName() + " has to die before dawn because this team has survived the longest (cross teaming is allowed)";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue