Fix nicknames and prefixes
This commit is contained in:
@@ -16,7 +16,7 @@ public class GlobalAdminChat {
|
||||
public GlobalAdminChat(ProxyServer proxyServer) {
|
||||
LiteralCommandNode<CommandSource> command = LiteralArgumentBuilder
|
||||
.<CommandSource>literal("globaladminchat")
|
||||
.requires(ctx -> ctx.hasPermission("command.proxy.globaladminchat"))// TODO permission system? load permissions from config?
|
||||
.requires(ctx -> ctx.hasPermission("command.proxy.globaladminchat"))
|
||||
.then(RequiredArgumentBuilder
|
||||
.<CommandSource, String>argument("message", StringArgumentType.greedyString())
|
||||
.executes(context -> {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Message {
|
||||
/*public Message(ProxyServer proxyServer) {
|
||||
LiteralCommandNode<CommandSource> command = LiteralArgumentBuilder
|
||||
.<CommandSource>literal("message")
|
||||
.requires(ctx -> ctx.hasPermission("command.proxy.message"))// TODO permission system? load permissions from config?
|
||||
.requires(ctx -> ctx.hasPermission("command.proxy.message"))
|
||||
.then(RequiredArgumentBuilder
|
||||
.<CommandSource, String>argument("player", StringArgumentType.word())
|
||||
.suggests((context, builder) -> {
|
||||
|
||||
@@ -42,7 +42,7 @@ public class SendMail {
|
||||
|
||||
LiteralCommandNode<CommandSource> command = LiteralArgumentBuilder
|
||||
.<CommandSource>literal("mail")
|
||||
.requires(ctx -> ctx.hasPermission("command.proxy.mail"))// TODO permission
|
||||
.requires(ctx -> ctx.hasPermission("command.proxy.mail"))
|
||||
.then(LiteralArgumentBuilder.<CommandSource>literal("send")
|
||||
.then(playerNode
|
||||
.then(RequiredArgumentBuilder
|
||||
|
||||
@@ -53,26 +53,24 @@ public class ChatHandler {
|
||||
}
|
||||
|
||||
public void globalAdminChat(CommandSource commandSource, String message) {
|
||||
String senderName = Config.CONSOLENAME;
|
||||
Component senderName = Component.text(Config.CONSOLENAME);
|
||||
String serverName = "Altitude";
|
||||
if (commandSource instanceof Player) {
|
||||
Player sender = (Player) commandSource;
|
||||
senderName = sender.getUsername();
|
||||
ChatUser user = ChatUserManager.getChatUser(sender.getUniqueId());
|
||||
if(user == null) return;
|
||||
senderName = user.getDisplayName();
|
||||
serverName = sender.getCurrentServer().isPresent() ? sender.getCurrentServer().get().getServerInfo().getName() : "Altitude";
|
||||
}
|
||||
|
||||
MiniMessage miniMessage = MiniMessage.get();
|
||||
|
||||
message = Utility.parseColors(message);
|
||||
List<Template> templates = new ArrayList<>(List.of(
|
||||
Template.of("message", message),
|
||||
Template.of("sender", senderName),
|
||||
Template.of("server", serverName)));
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
|
||||
map.put("sender", senderName);
|
||||
//map.put("message", event.getMessage());
|
||||
map.put("message", Utility.parseColors(message));
|
||||
map.put("server", serverName);
|
||||
|
||||
Component component = miniMessage.parse(Config.GACFORMAT, map);
|
||||
Component component = miniMessage.parse(Config.GACFORMAT, templates);
|
||||
|
||||
VelocityChat.getPlugin().getProxy().getAllPlayers().stream().filter(target -> target.hasPermission("command.proxy.globaladminchat")/*TODO permission*/).forEach(target -> {
|
||||
target.sendMessage(component);
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ChatListener {
|
||||
|
||||
map.put("sender", senderName);
|
||||
//map.put("message", event.getMessage());
|
||||
map.put("message", Utility.parseColors(event.getMessage()));
|
||||
map.put("message", event.getMessage());
|
||||
map.put("server", serverName);
|
||||
|
||||
Component message = miniMessage.parse(Config.GACFORMAT, map);
|
||||
@@ -56,10 +56,4 @@ public class ChatListener {
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(order = PostOrder.FIRST)
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
// do stuff
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user