Compare commits
36
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbd421c423 | ||
|
|
5fe5a305a5 | ||
|
|
bbfc9c407c | ||
|
|
880108d344 | ||
|
|
61e705b088 | ||
|
|
38228ea585 | ||
|
|
b65fcdb1c7 | ||
|
|
e74361a7b7 | ||
|
|
769859a617 | ||
|
|
cb0bda8d5b | ||
|
|
5212954946 | ||
|
|
f1b8af6136 | ||
|
|
bfc9af69d0 | ||
|
|
ea705c879f | ||
|
|
f5c0a0676c | ||
|
|
9bd9e21321 | ||
|
|
1c570fd524 | ||
|
|
131ea6da9d | ||
|
|
3275db13d0 | ||
|
|
a908e32d0b | ||
|
|
8393d12c6d | ||
|
|
782c7df4ef | ||
|
|
a876a9f77b | ||
|
|
f3147b3256 | ||
|
|
65503a02f3 | ||
|
|
7140a0cd78 | ||
|
|
187f71d6c3 | ||
|
|
3b2aa84164 | ||
|
|
0fb497c2f1 | ||
|
|
192fca3a89 | ||
|
|
d6135f2456 | ||
|
|
c057c69653 | ||
|
|
c25767e473 | ||
|
|
37aa9fdf4c | ||
|
|
ed2ba74772 | ||
|
|
44d6e994cc |
Vendored
+4
-1
@@ -1,9 +1,12 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
environment {
|
||||||
|
NEXUS_CREDS = credentials('alttd-snapshot-user')
|
||||||
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('Gradle') {
|
stage('Gradle') {
|
||||||
steps {
|
steps {
|
||||||
sh './gradlew build'
|
sh './gradlew build -PalttdSnapshotUsername=$NEXUS_CREDS_USR -PalttdSnapshotPassword=$NEXUS_CREDS_PSW'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Archive') {
|
stage('Archive') {
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ public abstract interface ChatAPI {
|
|||||||
|
|
||||||
DatabaseConnection getDataBase();
|
DatabaseConnection getDataBase();
|
||||||
|
|
||||||
void ReloadConfig();
|
void reloadConfig();
|
||||||
|
|
||||||
void ReloadChatFilters();
|
void reloadChatFilters();
|
||||||
|
|
||||||
HashMap<String, String> getPrefixes();
|
HashMap<String, String> getPrefixes();
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,12 @@ import com.alttd.chat.config.PrefixConfig;
|
|||||||
import com.alttd.chat.database.DatabaseConnection;
|
import com.alttd.chat.database.DatabaseConnection;
|
||||||
import com.alttd.chat.database.Queries;
|
import com.alttd.chat.database.Queries;
|
||||||
import com.alttd.chat.managers.ChatUserManager;
|
import com.alttd.chat.managers.ChatUserManager;
|
||||||
import com.alttd.chat.managers.PartyManager;
|
|
||||||
import com.alttd.chat.managers.RegexManager;
|
import com.alttd.chat.managers.RegexManager;
|
||||||
import com.alttd.chat.util.ALogger;
|
|
||||||
import net.luckperms.api.LuckPerms;
|
import net.luckperms.api.LuckPerms;
|
||||||
import net.luckperms.api.LuckPermsProvider;
|
import net.luckperms.api.LuckPermsProvider;
|
||||||
import net.luckperms.api.model.group.Group;
|
import net.luckperms.api.model.group.Group;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ChatImplementation implements ChatAPI{
|
public class ChatImplementation implements ChatAPI{
|
||||||
|
|
||||||
@@ -26,7 +23,7 @@ public class ChatImplementation implements ChatAPI{
|
|||||||
|
|
||||||
public ChatImplementation() {
|
public ChatImplementation() {
|
||||||
instance = this;
|
instance = this;
|
||||||
ReloadConfig();
|
reloadConfig();
|
||||||
|
|
||||||
luckPerms = getLuckPerms();
|
luckPerms = getLuckPerms();
|
||||||
databaseConnection = getDataBase();
|
databaseConnection = getDataBase();
|
||||||
@@ -57,13 +54,13 @@ public class ChatImplementation implements ChatAPI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ReloadConfig() {
|
public void reloadConfig() {
|
||||||
Config.init();
|
Config.init();
|
||||||
loadPrefixes();
|
loadPrefixes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ReloadChatFilters() {
|
public void reloadChatFilters() {
|
||||||
RegexManager.initialize();
|
RegexManager.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -368,6 +368,8 @@ public final class Config {
|
|||||||
public static String CUSTOM_CHANNEL_TOGGLED = "<yellow>Toggled <channel> <status>.</yellow>";
|
public static String CUSTOM_CHANNEL_TOGGLED = "<yellow>Toggled <channel> <status>.</yellow>";
|
||||||
public static Component TOGGLED_ON = null;
|
public static Component TOGGLED_ON = null;
|
||||||
public static Component TOGGLED_OFF = null;
|
public static Component TOGGLED_OFF = null;
|
||||||
|
public static double LOCAL_DISTANCE;
|
||||||
|
public static String CHANNEL_SPY = "<i><gray>SPY:</gray> <dark_gray>(<dark_gray><sender> → <channel>) <message></dark_gray>";
|
||||||
private static void chatChannels() {
|
private static void chatChannels() {
|
||||||
ConfigurationNode node = getNode("chat-channels");
|
ConfigurationNode node = getNode("chat-channels");
|
||||||
if (node.empty()) {
|
if (node.empty()) {
|
||||||
@@ -383,12 +385,16 @@ public final class Config {
|
|||||||
new CustomChannel(channelName,
|
new CustomChannel(channelName,
|
||||||
getString(key + "format", ""),
|
getString(key + "format", ""),
|
||||||
getList(key + "servers", Collections.EMPTY_LIST),
|
getList(key + "servers", Collections.EMPTY_LIST),
|
||||||
getBoolean(key + "proxy", false));
|
getBoolean(key + "proxy", false),
|
||||||
|
getBoolean(key + "local", false)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_CHANNEL_TOGGLED = getString("chat-channels-messages.channel-toggled", CUSTOM_CHANNEL_TOGGLED);
|
CUSTOM_CHANNEL_TOGGLED = getString("chat-channels-messages.channel-toggled", CUSTOM_CHANNEL_TOGGLED);
|
||||||
TOGGLED_ON = Utility.parseMiniMessage(getString("chat-channels-messages.channel-on", "<green>on</green><gray>"));
|
TOGGLED_ON = Utility.parseMiniMessage(getString("chat-channels-messages.channel-on", "<green>on</green><gray>"));
|
||||||
TOGGLED_OFF = Utility.parseMiniMessage(getString("chat-channels-messages.channel-off", "<red>off</red><gray>"));
|
TOGGLED_OFF = Utility.parseMiniMessage(getString("chat-channels-messages.channel-off", "<red>off</red><gray>"));
|
||||||
|
LOCAL_DISTANCE = getDouble("chat-channels-messages.local-distance", 200.0);
|
||||||
|
CHANNEL_SPY = getString("chat-channels-messages.spy", CHANNEL_SPY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String SERVERMUTEPERMISSION = "chat.command.mute-server";
|
public static String SERVERMUTEPERMISSION = "chat.command.mute-server";
|
||||||
@@ -424,6 +430,7 @@ public final class Config {
|
|||||||
public static String mailUnread = "<green><click:run_command:/mail list unread>You have <amount> unread mail, click to view it.</click></green>";
|
public static String mailUnread = "<green><click:run_command:/mail list unread>You have <amount> unread mail, click to view it.</click></green>";
|
||||||
public static String mailSent = "<green>Successfully send mail to <player_name></green>: <#2e8b57><message></#2e8b57>";
|
public static String mailSent = "<green>Successfully send mail to <player_name></green>: <#2e8b57><message></#2e8b57>";
|
||||||
public static List<String> mailCommandAlias = new ArrayList<>();
|
public static List<String> mailCommandAlias = new ArrayList<>();
|
||||||
|
public static int mailDisplayDelay = 5;
|
||||||
private static void mailSettings() {
|
private static void mailSettings() {
|
||||||
mailHeader = getString("settings.mail.header", mailHeader);
|
mailHeader = getString("settings.mail.header", mailHeader);
|
||||||
mailBody = getString("settings.mail.message", mailBody);
|
mailBody = getString("settings.mail.message", mailBody);
|
||||||
@@ -432,6 +439,7 @@ public final class Config {
|
|||||||
mailReceived = getString("settings.mail.mail-received", mailReceived);
|
mailReceived = getString("settings.mail.mail-received", mailReceived);
|
||||||
mailUnread = getString("settings.mail.mail-unread", mailUnread);
|
mailUnread = getString("settings.mail.mail-unread", mailUnread);
|
||||||
mailSent = getString("settings.mail.mail-sent", mailSent);
|
mailSent = getString("settings.mail.mail-sent", mailSent);
|
||||||
|
mailDisplayDelay = getInt("settings.mail.delay", mailDisplayDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String, Long> serverChannelId = new HashMap<>();
|
public static HashMap<String, Long> serverChannelId = new HashMap<>();
|
||||||
@@ -503,7 +511,7 @@ public final class Config {
|
|||||||
public static String NICK_TOO_SOON = "<red>Please wait <time><red> until requesting a new nickname";
|
public static String NICK_TOO_SOON = "<red>Please wait <time><red> until requesting a new nickname";
|
||||||
public static String NICK_REQUEST_PLACED = "<green>Replaced your previous request <oldrequestednick><green> with <newrequestednick><green>.";
|
public static String NICK_REQUEST_PLACED = "<green>Replaced your previous request <oldrequestednick><green> with <newrequestednick><green>.";
|
||||||
public static String NICK_REQUEST_NEW = "<green>New nickname request by <player><green>!";
|
public static String NICK_REQUEST_NEW = "<green>New nickname request by <player><green>!";
|
||||||
public static String NICK_TRYOUT = "<white><prefix><white> <nick><gray>: <white>Hi, this is what my new nickname could look like!";
|
public static String NICK_TRYOUT = "<white><prefix><white> <nick><gray>: <white><click:suggest_command:/nick request <nickrequest>>Hi, this is what my new nickname could look like! Click this message to request.";
|
||||||
public static String NICK_REQUESTED = "<green>Your requested to be nicknamed <nick><green> has been received. Staff will accept or deny this request asap!";
|
public static String NICK_REQUESTED = "<green>Your requested to be nicknamed <nick><green> has been received. Staff will accept or deny this request asap!";
|
||||||
public static String NICK_REVIEW_WAITING = "<green>There are <amount> nicknames waiting for review!";
|
public static String NICK_REVIEW_WAITING = "<green>There are <amount> nicknames waiting for review!";
|
||||||
public static String NICK_TAKEN = "<red>Someone else already has this nickname, or has this name as their username.";
|
public static String NICK_TAKEN = "<red>Someone else already has this nickname, or has this name as their username.";
|
||||||
|
|||||||
@@ -10,12 +10,14 @@ public class Channel {
|
|||||||
protected String channelName;
|
protected String channelName;
|
||||||
protected String format;
|
protected String format;
|
||||||
protected boolean proxy;
|
protected boolean proxy;
|
||||||
|
protected boolean local;
|
||||||
|
|
||||||
public Channel(String channelName, String format, boolean proxy) {
|
public Channel(String channelName, String format, boolean proxy, boolean local) {
|
||||||
this.permission = "chat.channel." + channelName.toLowerCase();
|
this.permission = "chat.channel." + channelName.toLowerCase();
|
||||||
this.channelName = channelName;
|
this.channelName = channelName;
|
||||||
this.format = format;
|
this.format = format;
|
||||||
this.proxy = proxy;
|
this.proxy = proxy;
|
||||||
|
this.local = local;
|
||||||
channels.put(channelName.toLowerCase(), this);
|
channels.put(channelName.toLowerCase(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,6 +41,10 @@ public class Channel {
|
|||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLocal() {
|
||||||
|
return local;
|
||||||
|
}
|
||||||
|
|
||||||
public static Channel getChatChannel(String channelName) {
|
public static Channel getChatChannel(String channelName) {
|
||||||
return channels.get(channelName.toLowerCase());
|
return channels.get(channelName.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,13 @@ import java.util.*;
|
|||||||
public class CustomChannel extends Channel {
|
public class CustomChannel extends Channel {
|
||||||
private final List<String> servers;
|
private final List<String> servers;
|
||||||
|
|
||||||
public CustomChannel(String channelName, String format, List<String> servers, boolean proxy) {
|
public CustomChannel(String channelName, String format, List<String> servers, boolean proxy, boolean local) {
|
||||||
super(channelName, format, proxy);
|
super(channelName, format, proxy, local);
|
||||||
this.permission = "chat.channel." + channelName.toLowerCase();
|
this.permission = "chat.channel." + channelName.toLowerCase();
|
||||||
this.channelName = channelName;
|
this.channelName = channelName;
|
||||||
this.format = format;
|
this.format = format;
|
||||||
this.servers = servers;
|
this.servers = servers;
|
||||||
this.proxy = proxy;
|
this.proxy = proxy;
|
||||||
channels.put(channelName.toLowerCase(), this);
|
|
||||||
}
|
}
|
||||||
public List<String> getServers() {
|
public List<String> getServers() {
|
||||||
return servers;
|
return servers;
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ package com.alttd.chat.objects.channels;
|
|||||||
|
|
||||||
public abstract class DefaultChannel extends Channel{
|
public abstract class DefaultChannel extends Channel{
|
||||||
public DefaultChannel(String channelName, String format, boolean proxy) {
|
public DefaultChannel(String channelName, String format, boolean proxy) {
|
||||||
super(channelName, format, proxy);
|
super(channelName, format, proxy, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import net.luckperms.api.LuckPerms;
|
|||||||
import net.luckperms.api.model.group.Group;
|
import net.luckperms.api.model.group.Group;
|
||||||
import net.luckperms.api.model.user.User;
|
import net.luckperms.api.model.user.User;
|
||||||
import net.luckperms.api.node.Node;
|
import net.luckperms.api.node.Node;
|
||||||
import org.bukkit.permissions.Permission;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -22,7 +21,8 @@ import java.util.stream.Collectors;
|
|||||||
public class Utility {
|
public class Utility {
|
||||||
|
|
||||||
private static final List<String> EMPTY_LIST = new ArrayList<>();
|
private static final List<String> EMPTY_LIST = new ArrayList<>();
|
||||||
static final Pattern DEFAULT_URL_PATTERN = Pattern.compile("(?:(https?)://)?([-\\w_.]+\\.\\w{2,})(/\\S*)?");
|
static final Pattern DEFAULT_URL_PATTERN = Pattern.compile("(https?://)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)");
|
||||||
|
static final Pattern URL_SCHEME_PATTERN = Pattern.compile("^[a-z][a-z0-9+\\-.]*:");
|
||||||
|
|
||||||
private static MiniMessage miniMessage = null;
|
private static MiniMessage miniMessage = null;
|
||||||
|
|
||||||
@@ -291,27 +291,25 @@ public class Utility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String formatText(String message) {
|
public static String formatText(String message) {
|
||||||
/*
|
|
||||||
.match(pattern)
|
|
||||||
.replacement(url -> {
|
|
||||||
String clickUrl = url.content();
|
|
||||||
if (!URL_SCHEME_PATTERN.matcher(clickUrl).find()) {
|
|
||||||
clickUrl = "http://" + clickUrl;
|
|
||||||
}
|
|
||||||
return (style == null ? url : url.style(style)).clickEvent(ClickEvent.openUrl(clickUrl));
|
|
||||||
})
|
|
||||||
.build();
|
|
||||||
*/
|
|
||||||
Matcher matcher = DEFAULT_URL_PATTERN.matcher(message);
|
Matcher matcher = DEFAULT_URL_PATTERN.matcher(message);
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
String url = matcher.group();
|
String url = matcher.group();
|
||||||
String clickUrl = url;
|
String displayUrl = url;
|
||||||
String urlFormat = Config.URLFORMAT;
|
String urlFormat = Config.URLFORMAT;
|
||||||
message = message.replace(url, urlFormat.replaceAll("<url>", url).replaceAll("<clickurl>", clickUrl));
|
message = message.replace(url, urlFormat
|
||||||
|
.replaceAll("<url>", "<u>" + displayUrl + "</u>")
|
||||||
|
.replaceAll("<clickurl>", formatUrl(url)));
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String formatUrl(String url) {
|
||||||
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
return "https://" + url;
|
||||||
|
}
|
||||||
|
|
||||||
public static Component parseMiniMessage(String message) {
|
public static Component parseMiniMessage(String message) {
|
||||||
return getMiniMessage().deserialize(message);
|
return getMiniMessage().deserialize(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,16 @@ import com.alttd.chat.objects.channels.Channel;
|
|||||||
import com.alttd.chat.objects.channels.CustomChannel;
|
import com.alttd.chat.objects.channels.CustomChannel;
|
||||||
import com.alttd.chat.objects.chat_log.ChatLogHandler;
|
import com.alttd.chat.objects.chat_log.ChatLogHandler;
|
||||||
import com.alttd.chat.util.ALogger;
|
import com.alttd.chat.util.ALogger;
|
||||||
|
import com.alttd.chat.util.ServerName;
|
||||||
import com.alttd.chat.util.Utility;
|
import com.alttd.chat.util.Utility;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ChatPlugin extends JavaPlugin {
|
public class ChatPlugin extends JavaPlugin {
|
||||||
@@ -38,7 +41,7 @@ public class ChatPlugin extends JavaPlugin {
|
|||||||
chatAPI = new ChatImplementation();
|
chatAPI = new ChatImplementation();
|
||||||
chatHandler = new ChatHandler();
|
chatHandler = new ChatHandler();
|
||||||
DatabaseConnection.initialize();
|
DatabaseConnection.initialize();
|
||||||
serverConfig = new ServerConfig(Bukkit.getServer().getName());
|
serverConfig = new ServerConfig(ServerName.getServerName());
|
||||||
ChatLogHandler chatLogHandler = ChatLogHandler.getInstance(true);
|
ChatLogHandler chatLogHandler = ChatLogHandler.getInstance(true);
|
||||||
registerListener(new PlayerListener(serverConfig), new ChatListener(chatLogHandler), new BookListener(), new ShutdownListener(chatLogHandler, this));
|
registerListener(new PlayerListener(serverConfig), new ChatListener(chatLogHandler), new BookListener(), new ShutdownListener(chatLogHandler, this));
|
||||||
if(serverConfig.GLOBALCHAT) {
|
if(serverConfig.GLOBALCHAT) {
|
||||||
@@ -57,7 +60,9 @@ public class ChatPlugin extends JavaPlugin {
|
|||||||
registerCommand("p", new PartyChat());
|
registerCommand("p", new PartyChat());
|
||||||
registerCommand("emotes", new Emotes());
|
registerCommand("emotes", new Emotes());
|
||||||
for (Channel channel : Channel.getChannels()) {
|
for (Channel channel : Channel.getChannels()) {
|
||||||
if (!(channel instanceof CustomChannel customChannel)) continue;
|
if (!(channel instanceof CustomChannel customChannel)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
this.getServer().getCommandMap().register(channel.getChannelName().toLowerCase(), new ChatChannel(customChannel));
|
this.getServer().getCommandMap().register(channel.getChannelName().toLowerCase(), new ChatChannel(customChannel));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,10 +121,10 @@ public class ChatPlugin extends JavaPlugin {
|
|||||||
serverConfig.MUTED = !serverConfig.MUTED;
|
serverConfig.MUTED = !serverConfig.MUTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReloadConfig() {
|
public void reloadConfig() {
|
||||||
chatAPI.ReloadConfig();
|
chatAPI.reloadConfig();
|
||||||
chatAPI.ReloadChatFilters();
|
chatAPI.reloadChatFilters();
|
||||||
serverConfig = new ServerConfig(Bukkit.getServer().getName());
|
serverConfig = new ServerConfig(ServerName.getServerName());
|
||||||
Bukkit.broadcast(Utility.parseMiniMessage("Reloaded ChatPlugin Config."), "command.chat.reloadchat");
|
Bukkit.broadcast(Utility.parseMiniMessage("Reloaded ChatPlugin Config."), "command.chat.reloadchat");
|
||||||
ALogger.info("Reloaded ChatPlugin config.");
|
ALogger.info("Reloaded ChatPlugin config.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import com.alttd.chat.objects.ChatFilter;
|
|||||||
import com.alttd.chat.objects.ChatUser;
|
import com.alttd.chat.objects.ChatUser;
|
||||||
import com.alttd.chat.objects.ModifiableString;
|
import com.alttd.chat.objects.ModifiableString;
|
||||||
import com.alttd.chat.objects.channels.CustomChannel;
|
import com.alttd.chat.objects.channels.CustomChannel;
|
||||||
|
import com.alttd.chat.util.ALogger;
|
||||||
import com.alttd.chat.util.GalaxyUtility;
|
import com.alttd.chat.util.GalaxyUtility;
|
||||||
|
import com.alttd.chat.util.ServerName;
|
||||||
import com.alttd.chat.util.Utility;
|
import com.alttd.chat.util.Utility;
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
@@ -20,12 +22,15 @@ import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
|||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ChatHandler {
|
public class ChatHandler {
|
||||||
@@ -126,12 +131,11 @@ public class ChatHandler {
|
|||||||
|
|
||||||
Component senderName = user.getDisplayName();
|
Component senderName = user.getDisplayName();
|
||||||
Component prefix = user.getPrefix();
|
Component prefix = user.getPrefix();
|
||||||
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
Placeholder.component("sender", senderName),
|
Placeholder.component("sender", senderName),
|
||||||
Placeholder.component("prefix", prefix),
|
Placeholder.component("prefix", prefix),
|
||||||
Placeholder.component("message", parseMessageContent(player, message)),
|
Placeholder.component("message", parseMessageContent(player, message)),
|
||||||
Placeholder.parsed("server", Bukkit.getServer().getName())
|
Placeholder.parsed("server", ServerName.getServerName())
|
||||||
);
|
);
|
||||||
|
|
||||||
Component component = Utility.parseMiniMessage(Config.GCFORMAT, placeholders);
|
Component component = Utility.parseMiniMessage(Config.GCFORMAT, placeholders);
|
||||||
@@ -157,7 +161,10 @@ public class ChatHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMuted(player, message, "[" + channel.getChannelName() + " Muted] ")) return;
|
if (isMuted(player, message, "[" + channel.getChannelName() + " Muted] ")) {
|
||||||
|
ALogger.info("Refusing to send message by muted user");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
||||||
Component senderName = user.getDisplayName();
|
Component senderName = user.getDisplayName();
|
||||||
@@ -165,7 +172,7 @@ public class ChatHandler {
|
|||||||
TagResolver placeholders = TagResolver.resolver(
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
Placeholder.component("sender", senderName),
|
Placeholder.component("sender", senderName),
|
||||||
Placeholder.component("message", parseMessageContent(player, message)),
|
Placeholder.component("message", parseMessageContent(player, message)),
|
||||||
Placeholder.parsed("server", Bukkit.getServer().getName()),
|
Placeholder.parsed("server", ServerName.getServerName()),
|
||||||
Placeholder.parsed("channel", channel.getChannelName())
|
Placeholder.parsed("channel", channel.getChannelName())
|
||||||
);
|
);
|
||||||
Component component = Utility.parseMiniMessage(channel.getFormat(), placeholders);
|
Component component = Utility.parseMiniMessage(channel.getFormat(), placeholders);
|
||||||
@@ -176,15 +183,16 @@ public class ChatHandler {
|
|||||||
player,
|
player,
|
||||||
Utility.parseMiniMessage(Utility.parseColors(modifiableString.string())),
|
Utility.parseMiniMessage(Utility.parseColors(modifiableString.string())),
|
||||||
"");
|
"");
|
||||||
return; // the message was blocked
|
ALogger.info("Refusing to send blocked chat message");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
component = modifiableString.component();
|
component = modifiableString.component();
|
||||||
|
|
||||||
if (channel.isProxy()) {
|
if (channel.isProxy()) {
|
||||||
sendChatChannelMessage(player, channel.getChannelName(), "chatchannel", component);
|
sendChatChannelMessage(player, channel.getChannelName(), "chatchannel", component, message);
|
||||||
} else {
|
} else {
|
||||||
sendChatChannelMessage(channel, player.getUniqueId(), component);
|
sendChatChannelMessage(channel, player.getUniqueId(), component, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,22 +245,49 @@ public class ChatHandler {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendChatChannelMessage(CustomChannel chatChannel, UUID uuid, Component component) {
|
private void sendChatChannelMessage(CustomChannel chatChannel, UUID uuid, Component component, String message) {
|
||||||
if (!chatChannel.getServers().contains(Bukkit.getServer().getName())) {
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
|
if (player == null) {
|
||||||
|
ALogger.warn("Failed to send chat message from non existent player");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = Bukkit.getPlayer(uuid);
|
if (!chatChannel.getServers().contains(ServerName.getServerName())) {
|
||||||
if (player == null) {
|
player.sendRichMessage("<red>Unable to send messages to <channel> in this server.</red>",
|
||||||
|
Placeholder.parsed("channel", chatChannel.getChannelName()));
|
||||||
|
ALogger.info(String.format("Not sending chat message due to [%s] not being in this channels config",
|
||||||
|
ServerName.getServerName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream<? extends Player> stream = Bukkit.getServer().getOnlinePlayers().stream()
|
Stream<? extends Player> stream = Bukkit.getServer().getOnlinePlayers().stream()
|
||||||
.filter(p -> p.hasPermission(chatChannel.getPermission()));
|
.filter(p -> p.hasPermission(chatChannel.getPermission()));
|
||||||
if (!player.hasPermission("chat.ignorebypass")) {
|
if (!player.hasPermission("chat.ignorebypass")) {
|
||||||
stream = stream.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers().contains(uuid) && !p.hasPermission("chat.ignorebypass"));
|
stream = stream.filter(receiver -> !ChatUserManager.getChatUser(receiver.getUniqueId()).getIgnoredPlayers().contains(uuid)
|
||||||
|
|| receiver.hasPermission("chat.ignorebypass"));
|
||||||
}
|
}
|
||||||
stream.forEach(p -> p.sendMessage(component));
|
if (chatChannel.isLocal()) {
|
||||||
|
Location location = player.getLocation();
|
||||||
|
stream = stream.filter(receiver -> {
|
||||||
|
Player receiverPlayer = Bukkit.getPlayer(receiver.getUniqueId());
|
||||||
|
if (receiverPlayer == null)
|
||||||
|
return false;
|
||||||
|
if (!location.getWorld().getUID().equals(receiverPlayer.getLocation().getWorld().getUID()))
|
||||||
|
return false;
|
||||||
|
return !(receiverPlayer.getLocation().distance(location) > Config.LOCAL_DISTANCE);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
List<? extends Player> recipientPlayers = stream.toList();
|
||||||
|
recipientPlayers.forEach(p -> p.sendMessage(component));
|
||||||
|
|
||||||
|
List<UUID> recipientUUIDs = recipientPlayers.stream().map(Entity::getUniqueId).toList();
|
||||||
|
Bukkit.getServer().getOnlinePlayers().stream()
|
||||||
|
.filter(onlinePlayer -> onlinePlayer.hasPermission(Config.SPYPERMISSION))
|
||||||
|
.filter(onlinePlayer -> !recipientUUIDs.contains(onlinePlayer.getUniqueId()))
|
||||||
|
.forEach(onlinePlayer -> onlinePlayer.sendRichMessage(Config.CHANNEL_SPY,
|
||||||
|
Placeholder.component("sender", player.name()),
|
||||||
|
Placeholder.parsed("channel", chatChannel.getChannelName()),
|
||||||
|
Placeholder.parsed("message", message)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendPluginMessage(Player player, String channel, Component component) {
|
private void sendPluginMessage(Player player, String channel, Component component) {
|
||||||
@@ -272,7 +307,7 @@ public class ChatHandler {
|
|||||||
player.sendPluginMessage(plugin, Config.MESSAGECHANNEL, out.toByteArray());
|
player.sendPluginMessage(plugin, Config.MESSAGECHANNEL, out.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendChatChannelMessage(Player player, String chatChannelName, String channel, Component component) {
|
public void sendChatChannelMessage(Player player, String chatChannelName, String channel, Component component, String ignored) {
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
out.writeUTF(channel);
|
out.writeUTF(channel);
|
||||||
out.writeUTF(chatChannelName);
|
out.writeUTF(chatChannelName);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.alttd.chat.objects.*;
|
|||||||
import com.alttd.chat.objects.chat_log.ChatLogHandler;
|
import com.alttd.chat.objects.chat_log.ChatLogHandler;
|
||||||
import com.alttd.chat.util.ALogger;
|
import com.alttd.chat.util.ALogger;
|
||||||
import com.alttd.chat.util.GalaxyUtility;
|
import com.alttd.chat.util.GalaxyUtility;
|
||||||
|
import com.alttd.chat.util.ServerName;
|
||||||
import com.alttd.chat.util.Utility;
|
import com.alttd.chat.util.Utility;
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
@@ -106,7 +107,7 @@ public class ChatListener implements Listener {
|
|||||||
GalaxyUtility.sendBlockedNotification("Language", player,
|
GalaxyUtility.sendBlockedNotification("Language", player,
|
||||||
modifiableString.component(),
|
modifiableString.component(),
|
||||||
"");
|
"");
|
||||||
chatLogHandler.addChatLog(uuid, player.getServer().getName(), PlainTextComponentSerializer.plainText().serialize(input), true);
|
chatLogHandler.addChatLog(uuid, ServerName.getServerName(), PlainTextComponentSerializer.plainText().serialize(input), true);
|
||||||
return; // the message was blocked
|
return; // the message was blocked
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +116,7 @@ public class ChatListener implements Listener {
|
|||||||
|
|
||||||
if (!player.hasPermission("chat.ignorebypass")) {
|
if (!player.hasPermission("chat.ignorebypass")) {
|
||||||
stream = stream.filter(receiver -> !ChatUserManager.getChatUser(receiver.getUniqueId()).getIgnoredPlayers().contains(uuid)
|
stream = stream.filter(receiver -> !ChatUserManager.getChatUser(receiver.getUniqueId()).getIgnoredPlayers().contains(uuid)
|
||||||
&& !receiver.hasPermission("chat.ignorebypass"));
|
|| receiver.hasPermission("chat.ignorebypass"));
|
||||||
}
|
}
|
||||||
Set<Player> receivers = stream.collect(Collectors.toSet());
|
Set<Player> receivers = stream.collect(Collectors.toSet());
|
||||||
|
|
||||||
@@ -129,7 +130,7 @@ public class ChatListener implements Listener {
|
|||||||
for (Player pingPlayer : playersToPing) {
|
for (Player pingPlayer : playersToPing) {
|
||||||
pingPlayer.playSound(pingPlayer.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 1);
|
pingPlayer.playSound(pingPlayer.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 1);
|
||||||
}
|
}
|
||||||
chatLogHandler.addChatLog(uuid, player.getServer().getName(), modifiableString.string(), false);
|
chatLogHandler.addChatLog(uuid, ServerName.getServerName(), modifiableString.string(), false);
|
||||||
ALogger.info(PlainTextComponentSerializer.plainText().serialize(input));
|
ALogger.info(PlainTextComponentSerializer.plainText().serialize(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,9 +159,11 @@ public class ChatListener implements Listener {
|
|||||||
// String substring = a.group().substring(1);
|
// String substring = a.group().substring(1);
|
||||||
// return ;
|
// return ;
|
||||||
// });
|
// });
|
||||||
|
|
||||||
if (!ChatUserManager.getChatUser(onlinePlayer.getUniqueId()).getIgnoredPlayers().contains(player.getUniqueId())
|
if (!ChatUserManager.getChatUser(onlinePlayer.getUniqueId()).getIgnoredPlayers().contains(player.getUniqueId())
|
||||||
&& !player.hasPermission("chat.ignorebypass"))
|
|| player.hasPermission("chat.ignorebypass")) {
|
||||||
playersToPing.add(onlinePlayer);
|
playersToPing.add(onlinePlayer);
|
||||||
|
}
|
||||||
} else if (nickPattern.matcher(modifiableString.string()).find()) {
|
} else if (nickPattern.matcher(modifiableString.string()).find()) {
|
||||||
modifiableString.replace(TextReplacementConfig.builder()
|
modifiableString.replace(TextReplacementConfig.builder()
|
||||||
.once()
|
.once()
|
||||||
@@ -168,11 +171,12 @@ public class ChatListener implements Listener {
|
|||||||
.replacement(mention.append(onlinePlayerUser.getDisplayName()))
|
.replacement(mention.append(onlinePlayerUser.getDisplayName()))
|
||||||
.build());
|
.build());
|
||||||
if (!ChatUserManager.getChatUser(onlinePlayer.getUniqueId()).getIgnoredPlayers().contains(player.getUniqueId())
|
if (!ChatUserManager.getChatUser(onlinePlayer.getUniqueId()).getIgnoredPlayers().contains(player.getUniqueId())
|
||||||
&& !player.hasPermission("chat.ignorebypass"))
|
|| player.hasPermission("chat.ignorebypass")) {
|
||||||
playersToPing.add(onlinePlayer);
|
playersToPing.add(onlinePlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public @NotNull Component render(@NotNull Player player, @NotNull Component message) {
|
public @NotNull Component render(@NotNull Player player, @NotNull Component message) {
|
||||||
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
||||||
@@ -198,7 +202,7 @@ public class ChatListener implements Listener {
|
|||||||
});
|
});
|
||||||
|
|
||||||
MiniMessage miniMessage = MiniMessage.builder().tags(tagResolver.build()).build();
|
MiniMessage miniMessage = MiniMessage.builder().tags(tagResolver.build()).build();
|
||||||
Component component = miniMessage.deserialize(rawMessage);
|
Component component = miniMessage.deserialize(Utility.formatText(rawMessage));
|
||||||
for(ChatFilter chatFilter : RegexManager.getEmoteFilters()) {
|
for(ChatFilter chatFilter : RegexManager.getEmoteFilters()) {
|
||||||
component = component.replaceText(
|
component = component.replaceText(
|
||||||
TextReplacementConfig.builder()
|
TextReplacementConfig.builder()
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.alttd.chat.objects.channels.Channel;
|
|||||||
import com.alttd.chat.objects.channels.CustomChannel;
|
import com.alttd.chat.objects.channels.CustomChannel;
|
||||||
import com.alttd.chat.objects.ChatUser;
|
import com.alttd.chat.objects.ChatUser;
|
||||||
import com.alttd.chat.util.ALogger;
|
import com.alttd.chat.util.ALogger;
|
||||||
|
import com.alttd.chat.util.ServerName;
|
||||||
import com.alttd.chat.util.Utility;
|
import com.alttd.chat.util.Utility;
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
@@ -164,7 +165,7 @@ public class PluginMessage implements PluginMessageListener {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "reloadconfig":
|
case "reloadconfig":
|
||||||
ChatPlugin.getInstance().ReloadConfig();
|
ChatPlugin.getInstance().reloadConfig();
|
||||||
break;
|
break;
|
||||||
case "chatpunishments":
|
case "chatpunishments":
|
||||||
UUID uuid = UUID.fromString(in.readUTF());
|
UUID uuid = UUID.fromString(in.readUTF());
|
||||||
@@ -194,7 +195,7 @@ public class PluginMessage implements PluginMessageListener {
|
|||||||
ALogger.warn("Received ChatChannel message for non existent channel.");
|
ALogger.warn("Received ChatChannel message for non existent channel.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!chatChannel.getServers().contains(Bukkit.getServer().getName())) {
|
if (!chatChannel.getServers().contains(ServerName.getServerName())) {
|
||||||
ALogger.warn("Received ChatChannel message for the wrong server.");
|
ALogger.warn("Received ChatChannel message for the wrong server.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ public class Nicknames implements CommandExecutor, TabCompleter {
|
|||||||
sender.sendMessage(Utility.parseMiniMessage(Config.NICK_TRYOUT,
|
sender.sendMessage(Utility.parseMiniMessage(Config.NICK_TRYOUT,
|
||||||
Placeholder.component("prefix", Utility.applyColor(api.getUserManager().getUser(player.getUniqueId())
|
Placeholder.component("prefix", Utility.applyColor(api.getUserManager().getUser(player.getUniqueId())
|
||||||
.getCachedData().getMetaData().getPrefix())), // TODO pull this from chatuser?
|
.getCachedData().getMetaData().getPrefix())), // TODO pull this from chatuser?
|
||||||
Placeholder.component("nick", Utility.applyColor(args[1]))));
|
Placeholder.component("nick", Utility.applyColor(args[1])),
|
||||||
|
Placeholder.unparsed("nickrequest", args[1])));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(Utility.parseMiniMessage(Config.NICK_NO_LUCKPERMS));
|
sender.sendMessage(Utility.parseMiniMessage(Config.NICK_NO_LUCKPERMS));
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.alttd.chat.util;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class ServerName {
|
||||||
|
|
||||||
|
private static final String serverName = loadServerName();
|
||||||
|
|
||||||
|
private static String loadServerName() {
|
||||||
|
String serverName = "unknown";
|
||||||
|
try {
|
||||||
|
File serverPropertiesFile = new File(Bukkit.getWorldContainer().getParentFile(), "server.properties");
|
||||||
|
if (!serverPropertiesFile.exists()) {
|
||||||
|
ALogger.warn(String.format("server.properties file not found in %s!", serverPropertiesFile.getAbsolutePath()));
|
||||||
|
return serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
Properties properties = new Properties();
|
||||||
|
FileInputStream fis = new FileInputStream(serverPropertiesFile);
|
||||||
|
properties.load(fis);
|
||||||
|
fis.close();
|
||||||
|
|
||||||
|
serverName = properties.getProperty("server-name", serverName);
|
||||||
|
|
||||||
|
ALogger.info(String.format("Found server name [%s]", serverName));
|
||||||
|
} catch (IOException e) {
|
||||||
|
ALogger.error("Failed to read server.properties", e);
|
||||||
|
}
|
||||||
|
return serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getServerName() {
|
||||||
|
return serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -24,7 +24,6 @@ import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
|||||||
import com.velocitypowered.api.plugin.Dependency;
|
import com.velocitypowered.api.plugin.Dependency;
|
||||||
import com.velocitypowered.api.plugin.Plugin;
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||||
import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||||
@@ -83,9 +82,9 @@ public class VelocityChat {
|
|||||||
ChatUserManager.addUser(console);
|
ChatUserManager.addUser(console);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReloadConfig() {
|
public void reloadConfig() {
|
||||||
chatAPI.ReloadConfig();
|
chatAPI.reloadConfig();
|
||||||
chatAPI.ReloadChatFilters();
|
chatAPI.reloadChatFilters();
|
||||||
serverHandler.cleanup();
|
serverHandler.cleanup();
|
||||||
ByteArrayDataOutput buf = ByteStreams.newDataOutput();
|
ByteArrayDataOutput buf = ByteStreams.newDataOutput();
|
||||||
buf.writeUTF("reloadconfig");
|
buf.writeUTF("reloadconfig");
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class Reload {
|
|||||||
.<CommandSource>literal("reloadchat")
|
.<CommandSource>literal("reloadchat")
|
||||||
.requires(ctx -> ctx.hasPermission("command.chat.reloadchat"))
|
.requires(ctx -> ctx.hasPermission("command.chat.reloadchat"))
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
VelocityChat.getPlugin().ReloadConfig();
|
VelocityChat.getPlugin().reloadConfig();
|
||||||
return 1;
|
return 1;
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -205,6 +205,10 @@ public class ChatHandler {
|
|||||||
}
|
}
|
||||||
Mail mail = new Mail(targetUUID, uuid, message);
|
Mail mail = new Mail(targetUUID, uuid, message);
|
||||||
ChatUser chatUser = ChatUserManager.getChatUser(targetUUID);
|
ChatUser chatUser = ChatUserManager.getChatUser(targetUUID);
|
||||||
|
if (chatUser.getIgnoredPlayers().contains(uuid)) {
|
||||||
|
commandSource.sendMessage(Utility.parseMiniMessage("<red>You cannot mail this player</red>"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
chatUser.addMail(mail);
|
chatUser.addMail(mail);
|
||||||
// TODO load from config
|
// TODO load from config
|
||||||
String finalSenderName = senderName;
|
String finalSenderName = senderName;
|
||||||
|
|||||||
@@ -23,8 +23,10 @@ import com.velocitypowered.api.proxy.server.RegisteredServer;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import net.kyori.adventure.title.Title;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class ProxyPlayerListener {
|
public class ProxyPlayerListener {
|
||||||
|
|
||||||
@@ -68,9 +70,17 @@ public class ProxyPlayerListener {
|
|||||||
List<Mail> unReadMail = chatUser.getUnReadMail();
|
List<Mail> unReadMail = chatUser.getUnReadMail();
|
||||||
if (unReadMail.isEmpty())
|
if (unReadMail.isEmpty())
|
||||||
return;
|
return;
|
||||||
player.sendMessage(Utility.parseMiniMessage(Config.mailUnread,
|
VelocityChat plugin = VelocityChat.getPlugin();
|
||||||
Placeholder.unparsed("amount", String.valueOf(unReadMail.size()))
|
plugin.getProxy().getScheduler().buildTask(plugin, () -> {
|
||||||
));
|
if (!player.isActive())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Component message = Utility.parseMiniMessage(Config.mailUnread,
|
||||||
|
Placeholder.unparsed("amount", String.valueOf(unReadMail.size())));
|
||||||
|
player.sendMessage(message);
|
||||||
|
player.showTitle(Title.title(message, Component.empty()));
|
||||||
|
}).delay(Config.mailDisplayDelay * 50L, TimeUnit.MILLISECONDS).schedule();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|||||||
Reference in New Issue
Block a user