diff --git a/src/main/java/com/alttd/fishingevent/commands/FishCommand.java b/src/main/java/com/alttd/fishingevent/commands/FishCommand.java index 060fcef..e0e8c07 100644 --- a/src/main/java/com/alttd/fishingevent/commands/FishCommand.java +++ b/src/main/java/com/alttd/fishingevent/commands/FishCommand.java @@ -1,10 +1,7 @@ package com.alttd.fishingevent.commands; import com.alttd.fishingevent.FishingEvent; -import com.alttd.fishingevent.commands.fish_subcommands.End; -import com.alttd.fishingevent.commands.fish_subcommands.Leaderboard; -import com.alttd.fishingevent.commands.fish_subcommands.Points; -import com.alttd.fishingevent.commands.fish_subcommands.Start; +import com.alttd.fishingevent.commands.fish_subcommands.*; import com.alttd.fishingevent.config.Messages; import com.alttd.fishingevent.util.Logger; import org.bukkit.command.*; @@ -34,7 +31,8 @@ public class FishCommand implements CommandExecutor, TabExecutor { new Points(), new Leaderboard(), new Start(), - new End() + new End(), + new Time() ); } diff --git a/src/main/java/com/alttd/fishingevent/commands/fish_subcommands/Time.java b/src/main/java/com/alttd/fishingevent/commands/fish_subcommands/Time.java new file mode 100644 index 0000000..eb67ac7 --- /dev/null +++ b/src/main/java/com/alttd/fishingevent/commands/fish_subcommands/Time.java @@ -0,0 +1,43 @@ +package com.alttd.fishingevent.commands.fish_subcommands; + +import com.alttd.fishingevent.commands.SubCommand; +import com.alttd.fishingevent.timer.EventManager; +import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; +import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; +import org.bukkit.command.CommandSender; + +import java.time.Duration; +import java.util.List; + +public class Time extends SubCommand { + @Override + public boolean onCommand(CommandSender commandSender, String[] args) { + if (!EventManager.getInstance().isRunning()) { + commandSender.sendMiniMessage("The event is not running...", null); + return true; + } + Duration timeRemaining = EventManager.getInstance().getTimeRemaining(); + //TODO move message to config + commandSender.sendMiniMessage("There is hour(s), minute(s), and second(s) remaining.", TagResolver.resolver( + Placeholder.parsed("hour", String.valueOf(timeRemaining.toHoursPart())), + Placeholder.parsed("minute", String.valueOf(timeRemaining.toMinutesPart())), + Placeholder.parsed("second", String.valueOf(timeRemaining.toSecondsPart())) + )); + return true; + } + + @Override + public String getName() { + return "time"; + } + + @Override + public List getTabComplete(CommandSender commandSender, String[] args) { + return List.of(); + } + + @Override + public String getHelpMessage() { + return "Invalid command use"; + } +}