Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.
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 @@ -14,6 +14,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

@RequiredArgsConstructor
public class MineBlocksPlaceholders extends PlaceholderExpansion {
Expand Down Expand Up @@ -72,8 +73,19 @@ private Optional<MineBlock> getBlock(List<String> params) {
BlockCoolDown coolDown = block.getCoolDown();
if (!coolDown.isActive()) return "";
return block.getPlugin().getConfiguration().getLangConfig().getTimeoutFormatted(coolDown.getActive().getEnd());
case "rank":
return getPlayerRank(block, player.getUniqueId()).map(String::valueOf).orElse(getNotRankedMessage());
default: return null;
}
}

private Optional<Integer> getPlayerRank(MineBlock block, UUID playerUUID) {
List<PlayerData> topPlayers = block.getTop().getPlayers();
for (int i = 0; i < topPlayers.size(); i++) {
if (topPlayers.get(i).getUuid().equals(playerUUID)) {
return Optional.of(i + 1); // Rank is 1-based
}
}
return Optional.empty();
}
}
4 changes: 3 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
messages:
not_ranked: "not ranked" # nebo jakákoli jiná zpráva, kterou chcete použít
lang:
top:
nobody: "&cNobody"
Expand Down Expand Up @@ -110,4 +112,4 @@ blocks:
from: 10
to: 50
commands:
- "100;give %player% iron_nugget"
- "100;give %player% iron_nugget"