Skip to content

Commit 68a0427

Browse files
committed
/pit data <PlayerID>コマンドで<playerID>の戦績確認
1 parent 8b3b6ce commit 68a0427

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/main/java/com/github/elic0de/thejpspit/command/PitCommand.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import co.aikar.commands.BaseCommand;
44
import co.aikar.commands.annotation.CommandAlias;
55
import co.aikar.commands.annotation.CommandPermission;
6+
import co.aikar.commands.annotation.Optional;
67
import co.aikar.commands.annotation.Subcommand;
8+
import co.aikar.commands.bukkit.contexts.OnlinePlayer;
79
import com.github.elic0de.thejpspit.TheJpsPit;
810
import com.github.elic0de.thejpspit.player.PitPlayer;
911
import com.github.elic0de.thejpspit.player.PitPlayerManager;
@@ -16,10 +18,15 @@ public class PitCommand extends BaseCommand {
1618

1719
@Subcommand("data")
1820
@CommandPermission("tjp.data")
19-
public void onCommand(Player player) {
21+
public void onCommand(Player player, @Optional OnlinePlayer onlinePlayer) {
2022
final PitPlayer pitPlayer = PitPlayerManager.getPitPlayer(player);
2123

22-
pitPlayer.sendStatus();
24+
if (onlinePlayer == null) {
25+
pitPlayer.sendStatus();
26+
return;
27+
}
28+
29+
pitPlayer.sendStatus(PitPlayerManager.getPitPlayer(onlinePlayer.getPlayer()));
2330
}
2431

2532
@Subcommand("reset")

src/main/java/com/github/elic0de/thejpspit/player/PitPlayer.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,30 @@ public void sendMessage(String message) {
108108
}
109109

110110
public void sendStatus() {
111+
sendStatus(this);
112+
}
113+
114+
public void sendStatus(PitPlayer player) {
111115
final TheJpsPit pit = TheJpsPit.getInstance();
112116
Stream.of(
113117
"+ -----< %playerName% >----- +",
114118
"Kills >> &e%kills% (#%kills_ranking%)",
119+
"Best Kill Streaks >> &e%best_streaks%",
115120
"Deaths >> &c%deaths% (#%deaths_ranking%)",
116-
"Rating >> &a%rating% (#%rating_ranking%)"
121+
"Rating >> &a%rating% (#%rating_ranking%)",
122+
"Best Rating >> &e%best_rating%"
117123
).map(s ->
118124
s.replaceAll("%playerName%", getName())
119125
.replaceAll("%kills%",
120126
kills + "")
127+
.replaceAll("%best_streaks%",
128+
bestStreaks + "")
121129
.replaceAll("%deaths%",
122130
deaths + "")
123131
.replaceAll("%rating%",
124132
rating + "%")
133+
.replaceAll("%best_rating%",
134+
bestRating + "")
125135
.replaceAll("%kills_ranking%",
126136
pit.getDatabase().getPlayerRanking(this, Database.RankType.KILLS).join()
127137
.orElse(0)
@@ -134,7 +144,7 @@ public void sendStatus() {
134144
pit.getDatabase().getPlayerRanking(this, Database.RankType.RATING).join()
135145
.orElse(0)
136146
+ "")
137-
).forEach(this::sendMessage);
147+
).forEach(player::sendMessage);
138148
}
139149

140150
private void updateXpBar() {

0 commit comments

Comments
 (0)