Skip to content
Merged
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
4 changes: 2 additions & 2 deletions API/src/main/java/dev/lrxh/api/match/ITeamFightMatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
public interface ITeamFightMatch extends IMatch {
List<IParticipant> getParticipants();

IMatchTeam getTeamA();
IMatchTeam getRedTeam();

IMatchTeam getTeamB();
IMatchTeam getBlueTeam();

IMatchTeam getWinner();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public interface IParticipant {

String getHitsDifferenceUncolored(IParticipant otherParticipant);

IMatch getMatch();

void reset();

void toggleFreeze();
Expand All @@ -66,4 +68,5 @@ public interface IParticipant {

void resetCombo();


}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public void startMatch(Participant playerRed, Participant playerBlue, Kit kit, V
playerBlue.setColor(ParticipantColor.BLUE);

SoloFightMatch match = new SoloFightMatch(arena, kit, duel, Arrays.asList(playerRed, playerBlue), playerRed, playerBlue, rounds);
playerRed.setMatch(match);
playerBlue.setMatch(match);
MatchReadyEvent event = new MatchReadyEvent(match);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
Expand All @@ -69,7 +71,9 @@ public void startMatch(MatchTeam teamA, MatchTeam teamB, Kit kit, VirtualArena a
participants.addAll(teamB.participants());

TeamFightMatch match = new TeamFightMatch(arena, kit, participants, teamA, teamB);

for (Participant participant : participants) {
participant.setMatch(match);
}
MatchReadyEvent event = new MatchReadyEvent(match);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
Expand Down Expand Up @@ -108,11 +112,6 @@ public void startMatch(IMatch match, Player redPlayer, Player bluePlayer) {
return;
}

List<Participant> participants = new ArrayList<>();
for (IParticipant participant : match.getParticipants()) {
participants.add((Participant) participant);
}

ArenaService.get().copyFrom(match.getArena()).createDuplicate().thenAccept(virtualArena ->{
Match neptuneMatch = new SoloFightMatch(
virtualArena,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class Participant implements IParticipant {
private boolean frozen = false;
private boolean bedBroken;
private Time time;
private Match match;

// ELO CHANGES
private int eloChange = 0;
Expand Down Expand Up @@ -206,7 +207,7 @@ public void handleHit(Participant opponent) {
Match match = API.getProfile(playerUUID).getMatch();
if (match.getKit().is(KitRule.BOXING)) {
if (match instanceof TeamFightMatch teamFightMatch
? hits >= teamFightMatch.getTeamA().getParticipants().size() * 100
? hits >= teamFightMatch.getRedTeam().getParticipants().size() * 100
: hits >= 100) {
opponent.setDeathCause(getLastAttacker() != null ? DeathCause.KILL : DeathCause.DIED);
match.onDeath(opponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@
@Setter
public class TeamFightMatch extends Match implements ITeamFightMatch {

private final MatchTeam teamA;
private final MatchTeam teamB;
private final MatchTeam redTeam;
private final MatchTeam blueTeam;

public TeamFightMatch(VirtualArena arena, Kit kit, List<Participant> participants,
MatchTeam teamA, MatchTeam teamB) {
MatchTeam redTeam, MatchTeam blueTeam) {
super(MatchState.STARTING, arena, kit, participants, 1, 1, true, false);
this.teamA = teamA;
this.teamB = teamB;
this.redTeam = redTeam;
this.blueTeam = blueTeam;
}

public MatchTeam getParticipantTeam(Participant participant) {
return teamA.participants().contains(participant) ? teamA : teamB;
return redTeam.participants().contains(participant) ? redTeam : blueTeam;
}

public IMatchTeam getParticipantTeam(IParticipant participant) {
return getParticipantTeam((Participant) participant);
}

public IMatchTeam getWinner() {
return teamA.isLoser() ? teamB : teamA;
return redTeam.isLoser() ? blueTeam : redTeam;
}

public IMatchTeam getLoser() {
return teamA.isLoser() ? teamA : teamB;
return redTeam.isLoser() ? redTeam : blueTeam;
}

@Override
Expand All @@ -71,7 +71,7 @@ public void win(Participant winner) {
@Override
public void end(Participant loser) {
setState(MatchState.ENDING);
MatchTeam winnerTeam = teamA.isLoser() ? teamB : teamA;
MatchTeam winnerTeam = redTeam.isLoser() ? blueTeam : redTeam;
MatchTeam loserTeam = getParticipantTeam(loser);


Expand All @@ -89,8 +89,8 @@ public void end(Participant loser) {

@Override
public void sendEndMessage() {
MatchTeam winnerTeam = teamA.isLoser() ? teamB : teamA;
MatchTeam loserTeam = teamA.isLoser() ? teamA : teamB;
MatchTeam winnerTeam = redTeam.isLoser() ? blueTeam : redTeam;
MatchTeam loserTeam = redTeam.isLoser() ? redTeam : blueTeam;

forEachParticipant(participant ->
MessagesLocale.MATCH_END_DETAILS_TEAM.send(participant.getPlayerUUID(), TagResolver.resolver(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,69 +15,15 @@ public PlaceholderManager() {
this.placeholders = new ArrayList<>();

placeholders.addAll(Arrays.asList(
new PingPlaceholder(),
new InMatchPlaceholder(),
new QueuedPlaceholder(),
new WinsPlaceholder(),
new LossesPlaceholder(),
new KillsPlaceholder(),
new DeathsPlaceholder(),
new MaxPingPlaceholder(),
new CurrentStreakPlaceholder(),
new BestStreakPlaceholder(),
new GlobalPlaceholders(),
new KitPlaceholders(),
new LastKitPlaceholder(),
new ColorPlaceholder(),
new KitDivisionPlaceholder(),
new KitWinsPlaceholder(),
new KitLossesPlaceholder(),
new KitKillsPlaceholder(),
new KitDeathsPlaceholder(),
new KitCurrentStreakPlaceholder(),
new KitBestStreakPlaceholder(),
new LeaderboardPlaceholder(),
new KitInMatchPlaceholder(),
new KitQueuedPlaceholder(),
new WinRatePlaceholder(),
new OpponentPlaceholder(),
new OpponentPingPlaceholder(),
new ComboPlaceholder(),
new OpponentComboPlaceholder(),
new HitsPlaceholder(),
new OpponentHitsPlaceholder(),
new HitDifferencePlaceholder(),
new TimePlaceholder(),
new KitPlaceholder(),
new ArenaPlaceholder(),
new MaxPointsPlaceholder(),
new PointsPlaceholder(),
new OpponentPointsPlaceholder(),
new BedBrokenPlaceholder(),
new OpponentBedBrokenPlaceholder(),
new PlayerRedNamePlaceholder(),
new PlayerBlueNamePlaceholder(),
new PlayerRedPingPlaceholder(),
new PlayerBluePingPlaceholder(),
new RedBedBrokenPlaceholder(),
new BlueBedBrokenPlaceholder(),
new AlivePlaceholder(),
new OpponentAlivePlaceholder(),
new MaxPlaceholder(),
new OpponentMaxPlaceholder(),
new InQueuePlaceholder(),
new IsTeamMatchPlaceholder(),
new KitEloPlaceholder(),
new DivisionPlaceholder(),
new EloPlaceholder(),
new LeaderPlaceholder(),
new SizePlaceholder(),
new RedAlivePlaceholder(),
new BlueAlivePlaceholder(),
new RedMaxPlaceholder(),
new BlueMaxPlaceholder(),
new LossesPlaceholder(),
new PartyMaxPlaceholder(),
new MatchPlaceholders(),
new PartyPlaceholders(),
new PlayerPlaceholders(),
new RecentMatchPlaceholder(),
new StatePlaceholder()
new TimePlaceholder()
));
}

Expand All @@ -90,7 +36,9 @@ public static PlaceholderManager get() {
public String parse(OfflinePlayer player, String text) {
for (PAPIPlaceholder placeholder : placeholders) {
if (placeholder.match(text)) {
text = placeholder.parse(player, text);
String parsed = placeholder.parse(player, text);
if (parsed == null) continue;
text = parsed;
}
}
return text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public TagResolver getPlaceholders(Player player) {
QueueEntry queue = QueueService.get().get(profile.getPlayerUUID());
placeholders = TagResolver.resolver(placeholders, getSettingsResolvers(profile),
Placeholder.parsed("division", globalStats.getDivision().getDisplayName()),
Placeholder.parsed("kill-effect", profile.getSettingData().getKillEffect().getDisplayName()),
Placeholder.parsed("kill-message", profile.getSettingData().getKillMessagePackage().getDisplayName()),
Placeholder.unparsed("max-ping", String.valueOf(profile.getSettingData().getMaxPing())),
Placeholder.unparsed("wins", String.valueOf(globalStats.getWins())),
Placeholder.unparsed("losses", String.valueOf(globalStats.getLosses())),
Expand Down Expand Up @@ -98,6 +96,7 @@ else if (profile.hasState(ProfileState.IN_GAME, ProfileState.IN_SPECTATOR) && ma
);
}
if (match != null) {
kit = match.getKit();
Participant participant = match.getParticipant(player);
placeholders = TagResolver.resolver(placeholders,
Placeholder.parsed("arena", match.getArena().getDisplayName()),
Expand All @@ -106,12 +105,6 @@ else if (profile.hasState(ProfileState.IN_GAME, ProfileState.IN_SPECTATOR) && ma
Placeholder.unparsed("round", String.valueOf(match.getCurrentRound())),
Placeholder.unparsed("time", match.getTime().formatTime())
);
if (kit.is(KitRule.BED_WARS) && participant != null) {
placeholders = TagResolver.resolver(placeholders,
Placeholder.unparsed("bed-broken", participant.isBedBroken() ? "&a✔" : "&c1"),
Placeholder.unparsed("opponent-bed-broken", participant.getOpponent().isBedBroken() ? "&a✔" : "&c1")
);
}
if (match instanceof SoloFightMatch sfm) {
Participant red = sfm.getRedParticipant();
Participant blue = sfm.getBlueParticipant();
Expand All @@ -120,8 +113,6 @@ else if (profile.hasState(ProfileState.IN_GAME, ProfileState.IN_SPECTATOR) && ma
placeholders = TagResolver.resolver(placeholders,
Placeholder.parsed("bed-broken", participant.getBedMessage()),
Placeholder.parsed("opponent-bed-broken", opponent.getBedMessage()),
Placeholder.parsed("red-bed-broken", red.getBedMessage()),
Placeholder.parsed("blue-bed-broken", blue.getBedMessage()),
Placeholder.parsed("opponent-combo", opponent.getComboMessage()),
Placeholder.unparsed("combo", participant.getComboMessage()),
Placeholder.unparsed("longest-combo", String.valueOf(participant.getLongestCombo())),
Expand All @@ -132,37 +123,45 @@ else if (profile.hasState(ProfileState.IN_GAME, ProfileState.IN_SPECTATOR) && ma
Placeholder.unparsed("opponent-longest-combo", String.valueOf(opponent.getLongestCombo())),
Placeholder.unparsed("opponent-hits", String.valueOf(opponent.getHits())),
Placeholder.unparsed("opponent-hit-difference", String.valueOf(opponent.getHitsDifference(participant))),
Placeholder.unparsed("opponent-points", String.valueOf(opponent.getPoints()))
Placeholder.unparsed("opponent-points", String.valueOf(opponent.getPoints())),
Placeholder.unparsed("opponent-elo", String.valueOf(opponent.getProfile().getGameData().getGlobalStats().getElo())),
Placeholder.unparsed("opponent-kit-elo", String.valueOf(opponent.getProfile().getGameData().get(kit).getElo()))
);
if (opponent.getPlayer() != null) placeholders = TagResolver.resolver(placeholders,
Placeholder.unparsed("opponent-ping", String.valueOf(opponent.getPlayer().getPing())));
}
placeholders = TagResolver.resolver(placeholders,
Placeholder.parsed("red-combo", red.getComboMessage()),
Placeholder.parsed("blue-combo", blue.getComboMessage()),
Placeholder.parsed("red-elo", String.valueOf(red.getProfile().getGameData().getGlobalStats().getElo())),
Placeholder.parsed("blue-elo", String.valueOf(blue.getProfile().getGameData().getGlobalStats().getElo())),
Placeholder.parsed("red-kit-elo", String.valueOf(red.getProfile().getGameData().get(kit).getElo())),
Placeholder.parsed("blue-elo", String.valueOf(blue.getProfile().getGameData().get(kit).getElo())),
Placeholder.parsed("red-bed-broken", red.getBedMessage()),
Placeholder.parsed("blue-bed-broken", blue.getBedMessage()),
Placeholder.unparsed("red-name", red.getName()),
Placeholder.unparsed("red-longest-combo", String.valueOf(red.getLongestCombo())),
Placeholder.unparsed("red-hits", String.valueOf(red.getHits())),
Placeholder.unparsed("red-hit-difference", red.getHitsDifference(sfm.getBlueParticipant())),
Placeholder.unparsed("red-points", String.valueOf(red.getPoints())),
Placeholder.unparsed("red-ping", String.valueOf(red.getPlayer().getPing())),
Placeholder.unparsed("blue-name", blue.getName()),
Placeholder.unparsed("blue-longest-combo", String.valueOf(blue.getLongestCombo())),
Placeholder.unparsed("blue-hits", String.valueOf(blue.getHits())),
Placeholder.unparsed("blue-hit-difference", blue.getHitsDifference(sfm.getRedParticipant())),
Placeholder.unparsed("blue-points", String.valueOf(blue.getPoints())),
Placeholder.unparsed("blue-ping", String.valueOf(blue.getPlayer().getPing()))
Placeholder.unparsed("blue-points", String.valueOf(blue.getPoints()))
);
if (kit.is(KitRule.BED_WARS) && participant != null) placeholders = TagResolver.resolver(placeholders,
Placeholder.parsed("bed-broken", participant.getBedMessage()),
Placeholder.parsed("opponent-bed-broken", participant.getOpponent().getBedMessage())
);
if (red.getPlayer() != null) placeholders = TagResolver.resolver(placeholders,
Placeholder.unparsed("red-ping", String.valueOf(red.getPlayer().getPing())));
if (blue.getPlayer() != null) placeholders = TagResolver.resolver(placeholders,
Placeholder.unparsed("blue-ping", String.valueOf(blue.getPlayer().getPing())));
}
if (match instanceof TeamFightMatch tfm) {
MatchTeam red = tfm.getTeamA();
MatchTeam blue = tfm.getTeamB();
MatchTeam red = tfm.getRedTeam();
MatchTeam blue = tfm.getBlueTeam();
if (participant != null) {
MatchTeam team = tfm.getParticipantTeam(participant);
MatchTeam opponent = team.getOpponentTeam();
Expand Down

This file was deleted.

This file was deleted.

Loading