Added a command to display remaining time
This commit is contained in:
parent
13e01bff91
commit
e83b811d34
|
|
@ -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()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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("<red>The event is not running...</red>", null);
|
||||
return true;
|
||||
}
|
||||
Duration timeRemaining = EventManager.getInstance().getTimeRemaining();
|
||||
//TODO move message to config
|
||||
commandSender.sendMiniMessage("There is <gold><hour></gold> hour(s), <gold><minute></gold> minute(s), and <gold><second></gold> 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<String> getTabComplete(CommandSender commandSender, String[] args) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpMessage() {
|
||||
return "<red>Invalid command use</red>";
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user