mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 01:27:40 +01:00
Add playtime command (#4562)
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
parent
add664441e
commit
edd15132fd
@ -0,0 +1,53 @@
|
|||||||
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.Statistic;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.CommandSource;
|
||||||
|
import com.earth2me.essentials.IUser;
|
||||||
|
import com.earth2me.essentials.utils.DateUtil;
|
||||||
|
import com.earth2me.essentials.utils.EnumUtil;
|
||||||
|
|
||||||
|
public class Commandplaytime extends EssentialsCommand {
|
||||||
|
// For some reason, in 1.13 PLAY_ONE_MINUTE = ticks played = what used to be PLAY_ONE_TICK
|
||||||
|
// https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/b848d8ce633871b52115247b089029749c02f579
|
||||||
|
private static final Statistic PLAY_ONE_TICK = EnumUtil.getStatistic("PLAY_ONE_MINUTE", "PLAY_ONE_TICK");
|
||||||
|
|
||||||
|
public Commandplaytime() {
|
||||||
|
super("playtime");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void run(Server server, CommandSource sender, String commandLabel, String[] args) throws Exception {
|
||||||
|
final IUser target;
|
||||||
|
final String key;
|
||||||
|
|
||||||
|
if (args.length > 0 && sender.isAuthorized("essentials.playtime.others", ess)) {
|
||||||
|
target = getPlayer(server, sender, args, 0);
|
||||||
|
key = "playtimeOther";
|
||||||
|
} else if (sender.isPlayer()) {
|
||||||
|
target = sender.getUser(ess);
|
||||||
|
key = "playtime";
|
||||||
|
} else {
|
||||||
|
throw new NotEnoughArgumentsException();
|
||||||
|
}
|
||||||
|
|
||||||
|
final long playtimeMs = System.currentTimeMillis() - (target.getBase().getStatistic(PLAY_ONE_TICK) * 50);
|
||||||
|
sender.sendMessage(tl(key, DateUtil.formatDateDiff(playtimeMs), target.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||||
|
if (args.length == 1 && sender.isAuthorized("essentials.playtime.others", ess)) {
|
||||||
|
return getPlayers(server, sender);
|
||||||
|
} else {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -884,6 +884,14 @@ playerTempBanned=\u00a76Player \u00a7c{0}\u00a76 temporarily banned \u00a7c{1}\u
|
|||||||
playerUnbanIpAddress=\u00a76Player\u00a7c {0} \u00a76unbanned IP\:\u00a7c {1}
|
playerUnbanIpAddress=\u00a76Player\u00a7c {0} \u00a76unbanned IP\:\u00a7c {1}
|
||||||
playerUnbanned=\u00a76Player\u00a7c {0} \u00a76unbanned\u00a7c {1}
|
playerUnbanned=\u00a76Player\u00a7c {0} \u00a76unbanned\u00a7c {1}
|
||||||
playerUnmuted=\u00a76You have been unmuted.
|
playerUnmuted=\u00a76You have been unmuted.
|
||||||
|
playtimeCommandDescription=Shows a player''s time played in game
|
||||||
|
playtimeCommandUsage=/<command> [player]
|
||||||
|
playtimeCommandUsage1=/<command>
|
||||||
|
playtimeCommandUsage1Description=Shows your time played in game
|
||||||
|
playtimeCommandUsage2=/<command> <player>
|
||||||
|
playtimeCommandUsage2Description=Shows the specified player''s time played in game
|
||||||
|
playtime=\u00a76Playtime\:\u00a7c {0}
|
||||||
|
playtimeOther=\u00a76Playtime of {1}\u00a76\:\u00a7c {0}
|
||||||
pong=Pong\!
|
pong=Pong\!
|
||||||
posPitch=\u00a76Pitch\: {0} (Head angle)
|
posPitch=\u00a76Pitch\: {0} (Head angle)
|
||||||
possibleWorlds=\u00a76Possible worlds are the numbers \u00a7c0\u00a76 through \u00a7c{0}\u00a76.
|
possibleWorlds=\u00a76Possible worlds are the numbers \u00a7c0\u00a76 through \u00a7c{0}\u00a76.
|
||||||
|
@ -344,6 +344,10 @@ commands:
|
|||||||
description: Pong!
|
description: Pong!
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
aliases: [echo,eecho,eping,pong,epong]
|
aliases: [echo,eecho,eping,pong,epong]
|
||||||
|
playtime:
|
||||||
|
description: Shows a player's time played in game
|
||||||
|
usage: /<command> [player]
|
||||||
|
aliases: [eplaytime]
|
||||||
potion:
|
potion:
|
||||||
description: Adds custom potion effects to a potion.
|
description: Adds custom potion effects to a potion.
|
||||||
usage: /<command> <clear|apply|effect:<effect> power:<power> duration:<duration>>
|
usage: /<command> <clear|apply|effect:<effect> power:<power> duration:<duration>>
|
||||||
|
Loading…
Reference in New Issue
Block a user