More work on gc
This commit is contained in:
parent
6cfa890923
commit
80afee0f2f
|
|
@ -140,7 +140,6 @@ public final class Config {
|
|||
|
||||
public static List<String> MESSAGECOMMANDALIASES = new ArrayList<>();
|
||||
public static List<String> REPLYCOMMANDALIASES = new ArrayList<>();
|
||||
public static List<String> GCCOMMANDALIASES = new ArrayList<>();
|
||||
public static String MESSAGESENDER = "<hover:show_text:'Click to reply'><click:suggest_command:'/msg <receiver> '><light_purple>(Me -> <gray><receiver></gray>) <message></light_purple>";
|
||||
public static String MESSAGERECIEVER = "<hover:show_text:'Click to reply'><click:suggest_command:'/msg <receiver> '><light_purple>(<gray><receiver></gray> on <server> -> Me) <message></light_purple>";
|
||||
private static void messageCommand() {
|
||||
|
|
@ -158,12 +157,18 @@ public final class Config {
|
|||
}}).forEach(key -> {
|
||||
REPLYCOMMANDALIASES.add(key.toString());
|
||||
});
|
||||
MESSAGESENDER = getString("commands.message.sender-message", MESSAGESENDER);
|
||||
MESSAGERECIEVER = getString("commands.message.reciever-message", MESSAGERECIEVER);
|
||||
}
|
||||
|
||||
public static List<String> GCCOMMANDALIASES = new ArrayList<>();
|
||||
public static String GCFORMAT = "[&d{luckperms_prefix_element_highest}&f] &7{cmi_user_display_name} &eto Global&7: {message}";
|
||||
private static void globalChat() {
|
||||
MESSAGERECIEVER = getString("commands.globalchat.format", MESSAGERECIEVER);
|
||||
getList("commands.globalchat.aliases", new ArrayList<String>(){{
|
||||
add("gc");
|
||||
}}).forEach(key -> {
|
||||
GCCOMMANDALIASES.add(key.toString());
|
||||
});
|
||||
MESSAGESENDER = getString("commands.message.sender-message", MESSAGESENDER);
|
||||
MESSAGERECIEVER = getString("commands.message.reciever-message", MESSAGERECIEVER);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
package com.alttd.chat.handlers;
|
||||
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class ChatHandler {
|
||||
|
||||
|
|
@ -41,8 +42,24 @@ public class ChatHandler {
|
|||
}
|
||||
|
||||
public void globalChat(CommandSource source, String message) {
|
||||
String senderName, serverName;
|
||||
Map<String, String> map = new HashMap<>();
|
||||
|
||||
if (source instanceof Player) {
|
||||
Player sender = (Player) source;
|
||||
senderName = sender.getUsername();
|
||||
serverName = sender.getCurrentServer().isPresent() ? sender.getCurrentServer().get().getServerInfo().getName() : "Altitude";
|
||||
} else {
|
||||
senderName = "Console"; // TODO console name from config
|
||||
serverName = "Altitude";
|
||||
}
|
||||
map.put("sender", senderName);
|
||||
map.put("message", message);
|
||||
map.put("server", serverName);
|
||||
|
||||
for(ChatPlayer p: chatPlayers) {
|
||||
if(p.isGlobalChatEnabled());
|
||||
p.getPlayer().sendMessage(MiniMessage.get().parse(Config.GCFORMAT, map));
|
||||
//TODO send global chat with format from config
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,30 @@
|
|||
package com.alttd.chat.handlers;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatPlayer {
|
||||
|
||||
private UUID uuid;
|
||||
private Player player;
|
||||
private UUID replyTarget;
|
||||
private boolean globalChatEnabled;
|
||||
|
||||
public ChatPlayer(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
this.replyTarget = null;
|
||||
public ChatPlayer(Player p) {
|
||||
player = p;
|
||||
uuid = p.getUniqueId();
|
||||
replyTarget = null;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public boolean isGlobalChatEnabled() {
|
||||
return globalChatEnabled;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public class PlayerListener {
|
|||
|
||||
@Subscribe(order = PostOrder.FIRST)
|
||||
public void onPlayerLogin(LoginEvent event) {
|
||||
ChatPlugin.getPlugin().getChatHandler().addPlayer(new ChatPlayer(event.getPlayer().getUniqueId()));
|
||||
ChatPlugin.getPlugin().getChatHandler().addPlayer(new ChatPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user