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
2 changes: 2 additions & 0 deletions API/src/main/java/dev/lrxh/api/data/IGlobalStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ public interface IGlobalStats {
void setDivision(IDivision division);

double getWinRatio();

double getKdr();
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public enum MenusLocale implements IDataAccessor {
" &f&7* &fWins: &b<wins>",
" &f&7* &fElo: &b<elo>",
" &f&7* &fLosses: &b<losses>",
" &f&7* &fCurrent Streak: &b<win_streak_current>",
" &f&7* &fBest Streak: &b<win_streak_best>",
" &f&7* &fCurrent Streak: &b<currentStreak>",
" &f&7* &fBest Streak: &b<bestStreak>",
" &f&7* &fDivision: &b<division>",
" &f&7* &fK/D &b<kill_death_ratio>"),
" &f&7* &fK/D &b<kdr>"),
MATCH_LIST_TITLE("MATCH.LIST.TITLE", DataType.STRING, "&7Select Match"),
MATCH_LIST_SIZE("MATCH_LIST.SIZE", DataType.INT, "36"),
MATCH_LIST_STARTING_SLOT("MATCH_LIST.STARTING-SLOT", DataType.INT, "10"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public enum ScoreboardLocale implements IDataAccessor {
"&aYour Ping: &f<ping>ms",
"&cTheir Ping: &f<opponent-ping>ms",
" ",
"&fYou: &b<points>/<maxPoints>",
"&fThem: &b<opponent-points>/<maxPoints>",
"&fYou: &b<points>/<rounds>",
"&fThem: &b<opponent-points>/<rounds>",
" ",
"&bserver.net"),
IN_GAME_BOXING("SCOREBOARDS.IN_GAME.BOXING", DataType.STRING_LIST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dev.lrxh.neptune.game.kit.KitService;
import dev.lrxh.neptune.game.kit.impl.KitRule;
import dev.lrxh.neptune.game.kit.menu.button.StatButton;
import dev.lrxh.neptune.providers.placeholder.PlaceholderUtil;
import dev.lrxh.neptune.utils.menu.Button;
import dev.lrxh.neptune.utils.menu.Filter;
import dev.lrxh.neptune.utils.menu.Menu;
Expand All @@ -29,7 +30,7 @@ public StatsMenu(Player player) {

@Override
public String getTitle(Player player) {
return MenusLocale.STAT_TITLE.getString().replace("<player>", target.getName());
return PlaceholderUtil.format(MenusLocale.STAT_TITLE.getString(), player);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
import dev.lrxh.neptune.game.kit.Kit;
import dev.lrxh.neptune.profile.data.KitData;
import dev.lrxh.neptune.providers.clickable.Replacement;
import dev.lrxh.neptune.providers.placeholder.PlaceholderUtil;
import dev.lrxh.neptune.utils.ItemBuilder;
import dev.lrxh.neptune.utils.ItemUtils;
import dev.lrxh.neptune.utils.menu.Button;
import me.clip.placeholderapi.PlaceholderAPI;

import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

Expand All @@ -23,22 +26,9 @@ public StatButton(int slot, Kit kit, Player target) {

@Override
public ItemStack getItemStack(Player player) {
KitData data = API.getProfile(target).getGameData().get(kit);

return new ItemBuilder(kit.getIcon())
.name(MenusLocale.STAT_KIT_NAME.getString().replace("<kit>", kit.getDisplayName()))
.lore(ItemUtils.getLore(MenusLocale.STAT_LORE.getStringList(), new Replacement("<kit>", kit.getDisplayName()),
new Replacement("<wins>", String.valueOf(data.getWins())),
new Replacement("<elo>", String.valueOf(data.getElo())),
new Replacement("<losses>", String.valueOf(data.getLosses())),
new Replacement("<kills>", String.valueOf(data.getKills())),
new Replacement("<deaths>", String.valueOf(data.getDeaths())),
new Replacement("<win_streak_current>", String.valueOf(data.getCurrentStreak())),
new Replacement("<win_streak_best>", String.valueOf(data.getBestStreak())),
new Replacement("<division>", data.getDivision() == null ? "None" : String.valueOf(data.getDivision().getDisplayName())),
new Replacement("<played>", String.valueOf(data.getWins() + data.getLosses())),
new Replacement("<kill_death_ratio>", String.valueOf(data.getKdr()))), player)

.lore(PlaceholderUtil.format(MenusLocale.STAT_LORE.getStringList(), player))
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package dev.lrxh.neptune.profile.data;

import java.math.BigDecimal;
import java.math.RoundingMode;

import dev.lrxh.api.data.IDivision;
import dev.lrxh.api.data.IGlobalStats;
import dev.lrxh.neptune.feature.divisions.DivisionService;
Expand Down Expand Up @@ -48,15 +51,24 @@ public void update() {
this.elo += kitData.getElo();
}
int kitData = profile.getGameData().getKitDataInternal().size();
if (kitData != 0) this.elo = this.elo / kitData;
if (kitData != 0)
this.elo = this.elo / kitData;

this.division = DivisionService.get().getDivisionByElo(elo);
}

@Override
public double getWinRatio() {
int totalGames = wins + losses;
if (totalGames == 0) return 0.0;
return Math.round(((double) wins / totalGames) * 100);
return getRatio(wins, wins + losses);
}

public double getKdr() {
return getRatio(kills, deaths);
}
private double getRatio(int num1, int num2) {
if (num1 == 0 || num2 == 0) return 0.0;
return BigDecimal.valueOf(num1)
.divide(BigDecimal.valueOf(num2), 1, RoundingMode.HALF_UP)
.doubleValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,15 @@ public String format(String line, Player player) {
line = line.replaceAll("<wins>", String.valueOf(globalStats.getWins()));
line = line.replaceAll("<losses>", String.valueOf(globalStats.getLosses()));
line = line.replaceAll("<currentStreak>", String.valueOf(globalStats.getCurrentStreak()));
line = line.replaceAll("<bestStreak>", String.valueOf(globalStats.getBestStreak()));
line = line.replaceAll("<kills>", String.valueOf(globalStats.getKills()));
line = line.replaceAll("<deaths>", String.valueOf(globalStats.getDeaths()));
line = line.replaceAll("<elo>", String.valueOf(globalStats.getElo()));
line = line.replaceAll("<played>", String.valueOf(globalStats.getWins() + globalStats.getLosses()));
line = line.replaceAll("<kdr>", String.valueOf(globalStats.getKdr()));
line = line.replaceAll("<win_streak_current>", String.valueOf(globalStats.getCurrentStreak())); // to be removed
line = line.replaceAll("<kill_death_ratio>", String.valueOf(globalStats.getKdr())); // to be removed
line = line.replaceAll("<win_streak_best>", String.valueOf(globalStats.getBestStreak())); // to be removed

if (state.equals(ProfileState.IN_QUEUE)) {
QueueEntry queueEntry = QueueService.get().get(player.getUniqueId());
Expand All @@ -81,9 +88,11 @@ public String format(String line, Player player) {
line = line.replaceAll("<kit>", queueEntry.getKit().getDisplayName());
line = line.replaceAll("<maxPing>", String.valueOf(profile.getSettingData().getMaxPing()));
line = line.replaceAll("<time>", String.valueOf(queueEntry.getTime().formatTime()));
line = line.replaceAll("<rounds>", String.valueOf(queueEntry.getKit().is(KitRule.BEST_OF_THREE) ? 3 : 1));
Division kitDivision = profile.getGameData().get(queueEntry.getKit()).getDivision();
if (kitDivision != null) line = line.replaceAll("<kit_division>",
kitDivision.getDisplayName());
if (kitDivision != null)
line = line.replaceAll("<kit_division>",
kitDivision.getDisplayName());
}

if (state.equals(ProfileState.IN_KIT_EDITOR)) {
Expand All @@ -101,7 +110,8 @@ public String format(String line, Player player) {
Match match = profile.getMatch();
Participant participant = match.getParticipant(player.getUniqueId());

line = line.replaceAll("<maxPoints>", String.valueOf(match.getRounds()));
line = line.replaceAll("<maxPoints>", String.valueOf(match.getRounds())); // to be removed
line = line.replaceAll("<rounds>", String.valueOf(match.getRounds()));
Division kitDivision = profile.getGameData().get(match.getKit()).getDivision();
line = line.replaceAll("<kit_division>",
kitDivision == null ? "None" : kitDivision.getDisplayName());
Expand Down Expand Up @@ -142,8 +152,7 @@ public String format(String line, Player player) {
line = line.replaceAll("<opponent-combo>",
opponent.getCombo() > 1 ? "&e(" + opponent.getCombo() + " Combo)" : "");
line = line.replaceAll("<opponent-hits>", String.valueOf(opponent.getHits()));
line = line.replaceAll("<diffrence>", participant.getHitsDifference(opponent));
// fixes the typo
line = line.replaceAll("<diffrence>", participant.getHitsDifference(opponent)); // to be removed
line = line.replaceAll("<difference>", participant.getHitsDifference(opponent));
line = line.replaceAll("<points>", String.valueOf(participant.getPoints()));
line = line.replaceAll("<opponent-points>", String.valueOf(opponent.getPoints()));
Expand Down
25 changes: 13 additions & 12 deletions docs/placeholders.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,26 @@
## Globally Available

| Plugin | PlaceholderAPI | Description |
|------------------|-----------------------------------------------------------------------------|------------------------------------------------------------------------|
| ---------------- | --------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| \<online> | None<sup style="color: red">\*</sup> | Use server expansion for PAPI |
| \<queued> | %neptune_queued% | Get the number of players in queue |
| \<in-match> | %neptune_in-match% | Get the number of players in matches |
| \<player> | None<sup style="color: red">\*</sup> | The name of the player |
| \<ping> | %neptune_ping% | The ping of the player in milliseconds |
| \<wins> | %neptune_wins% | The number of wins a player has accumulated |
| \<losses> | %neptune_losses% | The number of losses a player has accumulated |
| \<kills> | %neptune_kills% | The number of kills a player has accumulated |
| \<kills> | %neptune_kills% | The number of kills a player has accumulated |
| \<deaths> | %neptune_deaths% | The number of deaths a player has accumulated |
| \<currentStreak> | %neptune_currentStreak% | The current win streak of the player |
| \<bestStreak> | %neptune_bestStreak% | The best win streak the player has achieved |
| \<division> | %neptune_division% | The global division name of the player |
| None | %neptune*recent_match*(num)\_(opponent/arena/kit/date/time/unix_timestamp)% | Get details about a recent match. Unix timestamp is in seconds, not ms |
| None | %neptune_recent_match_(num)\_(opponent/arena/kit/date/time/unix_timestamp)% | Get details about a recent match. Unix timestamp is in seconds, not ms |
| None | %neptune_state% | Get the current state of the player |

## In Queue

| Plugin | PlaceholderAPI | Description |
|-----------------|----------------------------|-----------------------------------------------------------------------|
| --------------- | -------------------------- | --------------------------------------------------------------------- |
| \<kit> | %neptune_kit% | The display name of the kit the player is playing on |
| \<maxPing> | %neptune_maxPing% | The maximum ping allowed by the player in their settings |
| \<time> | %neptune_time% | The time in minutes and seconds that the player has been queueing for |
Expand All @@ -36,21 +37,21 @@
## Kit Editor

| Plugin | PlaceholderAPI | Description |
|--------|----------------|---------------------------------------------------|
| ------ | -------------- | ------------------------------------------------- |
| \<kit> | %neptune_kit% | The display name of the kit the player is editing |

## Party

| Plugin | PlaceholderAPI | Description |
|--------------|---------------------|--------------------------------------------------------|
| ------------ | ------------------- | ------------------------------------------------------ |
| \<leader> | %neptune_leader% | The name of the leader of the party |
| \<size> | %neptune_size% | The number of members in the party |
| \<party-max> | %neptune_party-max% | The maximum number of players that can be in the party |

## Any Match

| Plugin | PlaceholderAPI | Description |
|------------------------------------------------------|----------------------------------------------------------|------------------------------------------------------------|
| ---------------------------------------------------- | -------------------------------------------------------- | ---------------------------------------------------------- |
| \<red-bed-status><sup style="color: red">\*\*</sup> | %neptune_red-bed-broken%<sup style="color: red">$</sup> | The ping of the player in the red team |
| \<blue-bed-status><sup style="color: red">\*\*</sup> | %neptune_blue-bed-broken%<sup style="color: red">$</sup> | The ping of the player in the blue team |
| \<time> | %neptune_time% | The time the match has been active for |
Expand All @@ -61,7 +62,7 @@
## Solo Match

| Plugin | PlaceholderAPI | Description |
|----------------------------------------------------------|--------------------------------------------------------------|----------------------------------------------------------------------|
| -------------------------------------------------------- | ------------------------------------------------------------ | -------------------------------------------------------------------- |
| \<opponent> | %neptune_opponent% | The name of the opponent |
| \<opponent-ping> | %neptune_opponent-ping% | The ping of the opponent in milliseconds |
| \<red-hits> | None | Hits of the red player |
Expand Down Expand Up @@ -91,7 +92,7 @@
## Team Match

| Plugin | PlaceholderAPI | Description |
|---------------------------------------------------------------|--------------------------------------------------------------|--------------------------------------------------|
| ------------------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------ |
| \<alive> | %neptune_alive% | The number of players alive on the player's team |
| \<max> | %neptune_max% | The total number of players on the player's team |
| \<alive-opponent> | %neptune_opponent-alive% | The number of players alive on the opposing team |
Expand All @@ -113,16 +114,16 @@
## FFA Match

| Plugin | PlaceholderAPI | Description |
|----------|-----------------|------------------------------------------------------------|
| -------- | --------------- | ---------------------------------------------------------- |
| \<alive> | %neptune_alive% | The number of players alive in the match |
| \<max> | %neptune_max% | The total number of players that participated in the match |

|

## Leaderboards

| PlaceholderAPI | Description |
|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|
| PlaceholderAPI | Description |
| --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| %neptune*\<KILLS\|BEST_WIN_STREAK\|DEATHS\|ELO\|WINS\|LOSSES\>*\<kit name\>\_\<1-10\>\_name% | Returns the player's name with the most kills/win streak/deaths/elo in the select kit. |
| %neptune*\<KILLS\|BEST_WIN_STREAK\|DEATHS\|ELO\|WINS\|LOSSES\>*\<kit name\>\_\<1-10\>\_value% | Returns the kills/win streak/deaths/elo from the player on the selected kit. |

Expand Down