Add staff chat channels
This commit is contained in:
parent
f054c00147
commit
912be12976
1 changed files with 4 additions and 2 deletions
|
@ -9,6 +9,7 @@ import net.kyori.text.format.TextColor;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CommandStaffChat implements Command {
|
public class CommandStaffChat implements Command {
|
||||||
|
@ -22,9 +23,10 @@ public class CommandStaffChat implements Command {
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource commandSource, @NonNull String[] strings) {
|
public void execute(CommandSource commandSource, @NonNull String[] strings) {
|
||||||
if (strings.length > 0) {
|
if (strings.length > 0) {
|
||||||
String message = "§4[Staff]§r " + (commandSource instanceof Player ? ((Player) commandSource).getUsername() : "Console") + " > " + String.join(" ", strings).replace("&", "§");
|
String channel = strings[0].startsWith("c:") && !strings[0].equals("c:") ? strings[0].split(":")[1] : null;
|
||||||
|
String message = "§4[Staff]§r " + (commandSource instanceof Player ? ((Player) commandSource).getUsername() : "Console") + (channel != null ? " (" + channel + ")" : "")+ " > " + String.join(" ", Arrays.copyOfRange(strings, channel == null ? 0 : 1, strings.length)).replace("&", "§");
|
||||||
for (Player player : server.getAllPlayers()) {
|
for (Player player : server.getAllPlayers()) {
|
||||||
if (player.hasPermission("vtools.staffchat")) {
|
if (player.hasPermission("vtools.staffchat" + (channel != null ? "." + channel : ""))) {
|
||||||
player.sendMessage(TextComponent.of(message));
|
player.sendMessage(TextComponent.of(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue