Dieser Commit ist enthalten in:
Ursprung
8a21d5c93d
Commit
4766e0ab96
@ -23,6 +23,10 @@ import de.steamwar.bungeecore.Message;
|
|||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.Team;
|
import de.steamwar.bungeecore.sql.Team;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.SWCommandUtils;
|
||||||
|
import de.steamwar.command.TypeMapper;
|
||||||
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -32,52 +36,46 @@ import java.text.DecimalFormat;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WhoisCommand extends BasicCommand {
|
public class WhoisCommand extends SWCommand {
|
||||||
public WhoisCommand(){
|
public WhoisCommand() {
|
||||||
super("whois", "bungeecore.teamchat");
|
super("whois", "bungeecore.teamchat");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register("WHOIS_USAGE")
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void genericCommand(ProxiedPlayer player, @Mapper("player") String target, @OptionalValue("") @StaticValue({"-all", "-a", ""}) String displayAll) {
|
||||||
if(!(sender instanceof ProxiedPlayer))
|
SteamwarUser user = SteamwarUser.get(target);
|
||||||
return;
|
if (user == null) {
|
||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
|
||||||
|
|
||||||
if(args.length == 0){
|
|
||||||
Message.send("WHOIS_USAGE", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(args[0]);
|
|
||||||
if(user == null){
|
|
||||||
try {
|
try {
|
||||||
int id = Integer.parseInt(args[0]);
|
int id = Integer.parseInt(target);
|
||||||
user = SteamwarUser.get(id);
|
user = SteamwarUser.get(id);
|
||||||
}catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
try {
|
try {
|
||||||
long id = Long.parseLong(args[0]);
|
long id = Long.parseLong(target);
|
||||||
user = SteamwarUser.get(id);
|
user = SteamwarUser.get(id);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
// Ignored
|
// Ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(user == null) {
|
if (user == null) {
|
||||||
Message.send("UNKNOWN_PLAYER", player);
|
Message.send("UNKNOWN_PLAYER", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean all = false;
|
boolean all = displayAll.contains("-");
|
||||||
if(args.length > 1 && args[1].startsWith("-")) {
|
|
||||||
all = args[1].contains("a");
|
|
||||||
}
|
|
||||||
|
|
||||||
sendUserinfo(player, user, all);
|
sendUserinfo(player, user, all);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Mapper(value = "player", local = true)
|
||||||
|
public TypeMapper<String> playerTypeMapper() {
|
||||||
|
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, boolean all) {
|
private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, boolean all) {
|
||||||
Message.send("WHOIS_USERNAME", player, user.getUserName());
|
Message.send("WHOIS_USERNAME", player, user.getUserName());
|
||||||
Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUuid().toString()), user.getUuid().toString());
|
Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUuid().toString()), user.getUuid().toString());
|
||||||
@ -86,7 +84,7 @@ public class WhoisCommand extends BasicCommand {
|
|||||||
Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId());
|
Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId());
|
||||||
}
|
}
|
||||||
Timestamp firstJoin = user.getFirstjoin();
|
Timestamp firstJoin = user.getFirstjoin();
|
||||||
if(firstJoin == null)
|
if (firstJoin == null)
|
||||||
Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00");
|
Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00");
|
||||||
else
|
else
|
||||||
Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString());
|
Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString());
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren