mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-23 04:28:01 +00:00
fix command formatting
This commit is contained in:
parent
17ba11a284
commit
fd5120580d
@ -13,6 +13,7 @@ import net.md_5.bungee.api.ChatColor;
|
|||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
import net.md_5.bungee.api.plugin.Command;
|
||||||
|
|
||||||
@ -53,10 +54,18 @@ public class RedisBungeeCommands {
|
|||||||
if (si != null)
|
if (si != null)
|
||||||
serverToPlayers.put(si.getName(), p);
|
serverToPlayers.put(si.getName(), p);
|
||||||
}
|
}
|
||||||
for (String server : new TreeSet<>(serverToPlayers.keySet()))
|
for (String server : new TreeSet<>(serverToPlayers.keySet())) {
|
||||||
sender.sendMessage(new ComponentBuilder("").color(ChatColor.GREEN).append("[").append(server)
|
TextComponent serverName = new TextComponent();
|
||||||
.append("]").color(ChatColor.YELLOW).append("(").append(String.valueOf(serverToPlayers.get(server).size()))
|
serverName.setColor(ChatColor.GREEN);
|
||||||
.append("): ").color(ChatColor.WHITE).append(Joiner.on(", ").join(serverToPlayers.get(server))).create());
|
serverName.setText("[" + server + "] ");
|
||||||
|
TextComponent serverCount = new TextComponent();
|
||||||
|
serverCount.setColor(ChatColor.YELLOW);
|
||||||
|
serverCount.setText("(" + serverToPlayers.get(server).size() + "): ");
|
||||||
|
TextComponent serverPlayers = new TextComponent();
|
||||||
|
serverPlayers.setColor(ChatColor.WHITE);
|
||||||
|
serverPlayers.setText(Joiner.on(", ").join(serverToPlayers.get(server)));
|
||||||
|
sender.sendMessage(serverName, serverCount, serverPlayers);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(new ComponentBuilder("").color(ChatColor.YELLOW).append("Players: ")
|
sender.sendMessage(new ComponentBuilder("").color(ChatColor.YELLOW).append("Players: ")
|
||||||
.append(Joiner.on(", ").join(RedisBungee.getApi().getPlayersOnline())).create());
|
.append(Joiner.on(", ").join(RedisBungee.getApi().getPlayersOnline())).create());
|
||||||
@ -79,8 +88,10 @@ public class RedisBungeeCommands {
|
|||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
ServerInfo si = RedisBungee.getApi().getServerFor(args[0]);
|
ServerInfo si = RedisBungee.getApi().getServerFor(args[0]);
|
||||||
if (si != null) {
|
if (si != null) {
|
||||||
sender.sendMessage(new ComponentBuilder("").color(ChatColor.BLUE).append(args[0]).append(" is on ")
|
TextComponent message = new TextComponent();
|
||||||
.append(si.getName()).append(".").create());
|
message.setColor(ChatColor.BLUE);
|
||||||
|
message.setText(args[0] + " is on " + si.getName() + ".");
|
||||||
|
sender.sendMessage(message);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
@ -99,13 +110,19 @@ public class RedisBungeeCommands {
|
|||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
long secs = RedisBungee.getApi().getLastOnline(args[0]);
|
long secs = RedisBungee.getApi().getLastOnline(args[0]);
|
||||||
|
TextComponent message = new TextComponent();
|
||||||
if (secs == 0) {
|
if (secs == 0) {
|
||||||
sender.sendMessage(new ComponentBuilder("").color(ChatColor.GREEN).append(args[0]).append(" is currently online.").create());
|
message.setColor(ChatColor.GREEN);
|
||||||
|
message.setText(args[0] + " is currently online.");
|
||||||
|
sender.sendMessage(message);
|
||||||
} else if (secs != -1) {
|
} else if (secs != -1) {
|
||||||
sender.sendMessage(new ComponentBuilder("").color(ChatColor.BLUE).append(args[0]).append(" was last online on ").
|
message.setColor(ChatColor.BLUE);
|
||||||
append(new SimpleDateFormat().format(TimeUnit.SECONDS.toMillis(secs))).append(".").create());
|
message.setText(args[0] + " was last online on " + new SimpleDateFormat().format(TimeUnit.SECONDS.toMillis(secs)) + ".");
|
||||||
|
sender.sendMessage(message);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(new ComponentBuilder("").color(ChatColor.RED).append(args[0]).append(" has never been online.").create());
|
message.setColor(ChatColor.RED);
|
||||||
|
message.setText(args[0] + " has never been online.");
|
||||||
|
sender.sendMessage(message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(NO_PLAYER_SPECIFIED);
|
sender.sendMessage(NO_PLAYER_SPECIFIED);
|
||||||
@ -123,7 +140,9 @@ public class RedisBungeeCommands {
|
|||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
InetAddress ia = RedisBungee.getApi().getPlayerIp(args[0]);
|
InetAddress ia = RedisBungee.getApi().getPlayerIp(args[0]);
|
||||||
if (ia != null) {
|
if (ia != null) {
|
||||||
sender.sendMessage(new ComponentBuilder("").color(ChatColor.GREEN).append(args[0]).append(" is connected from ").append(ia.toString()).append(".").create());
|
TextComponent message = new TextComponent();
|
||||||
|
message.setColor(ChatColor.GREEN);
|
||||||
|
message.setText(args[0] + " is connected from " + ia.toString() + ".");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user