Skip to content

Commit

Permalink
feat(msg): 为其他玩家显示完成信息
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmJos committed Jul 4, 2022
1 parent 4d1a24e commit 4ba3e35
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ public static final class GAME {
.build();

public static final ConfiguredMessageList<BaseComponent[]> FINISH = list()
.defaults("&e&l恭喜!&f您完成了本次跑酷比赛,总耗时 &6%(time)秒 &f,排名为 &6#%(index) &f!")
.defaults("&e&l恭喜!&f您完成了本次跑酷比赛,总用时 &6%(time)秒 &f,排名为 &6#%(index) &f!")
.params("time", "index").build();

public static final ConfiguredMessageList<BaseComponent[]> FINISH_OTHER = list()
.defaults("&f恭喜 &e&l%(player) &f作为 &6第%(index)名 &f完成了本次跑酷比赛,用时 &6%(time)秒 &f!")
.params("player", "time", "index").build();


public static final ConfiguredMessageList<BaseComponent[]> END = list()
.defaults(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import cc.carm.outsource.plugin.parkourcompetition.util.FireworkUtils;
import me.block2block.hubparkour.api.events.player.ParkourPlayerFinishEvent;
import org.bukkit.Location;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.plugin.Plugin;

import java.text.NumberFormat;
Expand All @@ -19,6 +21,13 @@ public class GameListener extends EasyListener {

public GameListener(Plugin plugin) {
super(plugin);

handleEvent(ServerCommandEvent.class)
.filter(e -> e.getSender() instanceof BlockCommandSender)
.handle(e -> {
BlockCommandSender sender = (BlockCommandSender) e.getSender();
Main.getInstance().log(sender.getBlock().getLocation().toString());
});
}

@EventHandler
Expand Down Expand Up @@ -51,8 +60,8 @@ public void onFinish(ParkourPlayerFinishEvent event) {

PluginConfig.GAME.FINISH.SOUND.playTo(player);
PluginConfig.GAME.FINISH.TITLE.send(player, seconds);
PluginMessages.GAME.FINISH_OTHER.broadcast(player.getName(), seconds, parkour.getFinishTime().size());
PluginMessages.GAME.FINISH.send(player, seconds, parkour.getFinishTime().size());

}

}

0 comments on commit 4ba3e35

Please sign in to comment.