Merge branch 4.9
This commit is contained in:
commit
e6dfd19b84
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
|
|
@ -16,8 +16,3 @@ jobs:
|
|||
run: git config --global user.email "no-reply@github.com" && git config --global user.name "Github Actions"
|
||||
- name: Build
|
||||
run: ./gradlew build --stacktrace
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Chat.jar
|
||||
path: build/libs/Chat*.jar
|
||||
|
|
@ -3,10 +3,7 @@ plugins {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.alttd:Galaxy-API:1.18.1-R0.1-SNAPSHOT") {
|
||||
exclude("net.kyori.adventure.text.minimessage")
|
||||
}
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.10.0-SNAPSHOT") // Minimessage
|
||||
compileOnly("com.alttd:Galaxy-API:1.18.2-R0.1-SNAPSHOT")
|
||||
compileOnly("org.spongepowered:configurate-yaml:4.1.2") // Configurate
|
||||
compileOnly("net.luckperms:api:5.3") // Luckperms
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ public final class Config {
|
|||
public static String MESSAGESENDER = "<hover:show_text:Click to reply><click:suggest_command:/msg <receivername> ><light_purple>(Me -> <gray><receiver></gray>)</hover> <message>";
|
||||
public static String MESSAGERECIEVER = "<hover:show_text:Click to reply><click:suggest_command:/msg <sendername> ><light_purple>(<gray><sender></gray> on <server> -> Me)</hover> <message>";
|
||||
public static String MESSAGESPY = "<gray>(<gray><sendername></gray> -> <receivername>) <message>";
|
||||
public static String RECEIVER_DOES_NOT_EXIST = "<red><player> is not a valid player.</red>";
|
||||
private static void messageCommand() {
|
||||
MESSAGECOMMANDALIASES.clear();
|
||||
REPLYCOMMANDALIASES.clear();
|
||||
|
|
@ -193,6 +194,7 @@ public final class Config {
|
|||
MESSAGESENDER = getString("commands.message.sender-message", MESSAGESENDER);
|
||||
MESSAGERECIEVER = getString("commands.message.reciever-message", MESSAGERECIEVER);
|
||||
MESSAGESPY = getString("commands.message.spy-message", MESSAGESPY);
|
||||
RECEIVER_DOES_NOT_EXIST = getString("commands.message.receiver-does-not-exist", RECEIVER_DOES_NOT_EXIST);
|
||||
}
|
||||
|
||||
public static String GCFORMAT = "<white><light_purple><prefix></light_purple> <gray><sender></gray> <hover:show_text:on <server>><yellow>to Global</yellow></hover><gray>: <message>";
|
||||
|
|
@ -271,6 +273,7 @@ public final class Config {
|
|||
public static String REMOVED_USER_FROM_PARTY = "<green>You removed <player> from the chat party!</green>";
|
||||
public static String NOT_A_PARTY_MEMBER = "<red><player> is not a member of your party!</red>";
|
||||
public static String ALREADY_IN_PARTY = "<red>You're already in a party!</red>";
|
||||
public static String ALREADY_IN_THIS_PARTY = "<red>You're already in <party>!</red>";
|
||||
public static String SENT_PARTY_INV = "<green>You send a chat party invite to <player>!</green>";
|
||||
public static String JOIN_PARTY_CLICK_MESSAGE = "<click:run_command:'/party join <party> <party_password>'>" +
|
||||
"<dark_aqua>You received an invite to join <party>, click this message to accept.</dark_aqua></click>";
|
||||
|
|
@ -317,6 +320,7 @@ public final class Config {
|
|||
DISBAND_PARTY_CONFIRM = getString("party.messages.disband-party-confirm", DISBAND_PARTY_CONFIRM);
|
||||
DISBANDED_PARTY = getString("party.messages.disbanded-party", DISBANDED_PARTY);
|
||||
PARTY_INFO = getString("party.messages.party-info", PARTY_INFO);
|
||||
ALREADY_IN_THIS_PARTY = getString("party.messages.already-in-this-party", ALREADY_IN_THIS_PARTY);
|
||||
}
|
||||
|
||||
public static String PARTY_HELP_WRAPPER = "<gold>ChatParty help:\n<commands></gold>";
|
||||
|
|
@ -410,4 +414,26 @@ public final class Config {
|
|||
mailSent = getString("settings.mail.mail-sent", mailSent);
|
||||
}
|
||||
|
||||
public static HashMap<String, Long> serverChannelId = new HashMap<>();
|
||||
public static String REPORT_SENT = "<green>Your report was sent, staff will contact you asap to help resolve your issue!</green>";
|
||||
private static void loadChannelIds() {
|
||||
serverChannelId.clear();
|
||||
serverChannelId.put("general", getLong("discord-channel-id.general", (long) -1));
|
||||
ConfigurationNode node = config.node("discord-channel-id");
|
||||
Map<Object, ? extends ConfigurationNode> objectMap = node.childrenMap();
|
||||
for (Object o : objectMap.keySet()) {
|
||||
String key = (String) o;
|
||||
if (key.equalsIgnoreCase("general"))
|
||||
continue;
|
||||
ConfigurationNode configurationNode = objectMap.get(o);
|
||||
long channelId = configurationNode.getLong();
|
||||
serverChannelId.put(key.toLowerCase(), channelId);
|
||||
}
|
||||
REPORT_SENT = getString("messages.report-sent", REPORT_SENT);
|
||||
}
|
||||
|
||||
public static String HELP_REPORT = "<red>/report <message></red>";
|
||||
private static void loadMessages() {
|
||||
HELP_REPORT = getString("settings.mail.mail-sent", HELP_REPORT);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,15 +3,14 @@ package com.alttd.chat.managers;
|
|||
import com.alttd.chat.ChatAPI;
|
||||
import com.alttd.chat.config.RegexConfig;
|
||||
import com.alttd.chat.objects.ChatFilter;
|
||||
import com.alttd.chat.objects.ModifiableString;
|
||||
import com.alttd.chat.util.ALogger;
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.cacheddata.CachedPermissionData;
|
||||
import net.luckperms.api.model.user.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class RegexManager {
|
||||
|
|
@ -29,15 +28,15 @@ public class RegexManager {
|
|||
chatFilters.add(filter);
|
||||
}
|
||||
|
||||
public static String replaceText(String playerName, UUID uuid, String text) { // TODO loop all objects in the list and check if they violate based on the MATCHER
|
||||
return replaceText(playerName, uuid, text, true);
|
||||
public static boolean filterText(String playerName, UUID uuid, ModifiableString modifiableString, String channel) { // TODO loop all objects in the list and check if they violate based on the MATCHER
|
||||
return filterText(playerName, uuid, modifiableString, true, channel);
|
||||
}
|
||||
|
||||
public static String replaceText(String playerName, UUID uuid, String text, boolean matcher) {
|
||||
public static boolean filterText(String playerName, UUID uuid, ModifiableString modifiableString, boolean matcher, String channel) {
|
||||
User user = ChatAPI.get().getLuckPerms().getUserManager().getUser(uuid);
|
||||
if (user == null) {
|
||||
ALogger.warn("Tried to check chat filters for a user who doesn't exist in LuckPerms");
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
CachedPermissionData permissionData = user.getCachedData().getPermissionData();
|
||||
for(ChatFilter chatFilter : chatFilters) {
|
||||
|
|
@ -45,22 +44,24 @@ public class RegexManager {
|
|||
case CHAT:
|
||||
break;
|
||||
case REPLACE:
|
||||
text = chatFilter.replaceText(text);
|
||||
chatFilter.replaceText(modifiableString);
|
||||
break;
|
||||
case BLOCK:
|
||||
if(chatFilter.matches(text) && !permissionData.checkPermission("chat.bypass-filter." + chatFilter.getName()).asBoolean()) { // todo find a better way to do this?
|
||||
if(!permissionData.checkPermission("chat.bypass-filter-channel." + channel).asBoolean() &&
|
||||
!permissionData.checkPermission("chat.bypass-filter." + chatFilter.getName()).asBoolean() &&
|
||||
chatFilter.matches(modifiableString)) { // todo find a better way to do this?
|
||||
ALogger.info(playerName + " triggered the chat filter for " + chatFilter.getName() + ".");
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case REPLACEMATCHER:
|
||||
if(matcher) {
|
||||
text = chatFilter.replaceMatcher(text);
|
||||
chatFilter.replaceMatcher(modifiableString);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return text;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,34 +42,57 @@ public class ChatFilter {
|
|||
return this.exclusions;
|
||||
}
|
||||
|
||||
public boolean matches(String input) {
|
||||
public boolean matches(ModifiableString filterableString) {
|
||||
String input = filterableString.string();
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
return (matcher.find() || matcher.matches());
|
||||
while (matcher.find())
|
||||
if (!isException(input, matcher.start())) {
|
||||
filterableString.string(filterableString.string().replaceFirst(matcher.group(), "<gold>" + matcher.group() + "</gold>"));
|
||||
return true;
|
||||
}
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
public String replaceText(String input) {
|
||||
public boolean isException(String string, int start)
|
||||
{
|
||||
char[] chars = string.toCharArray();
|
||||
if (start != 0) { //go to start of word if not at start of string
|
||||
while (chars[start] != ' ' && start > 0)
|
||||
start--;
|
||||
start += 1; //go past the space
|
||||
}
|
||||
|
||||
String match = string.substring(start);
|
||||
for (String s : getExclusions()) {
|
||||
if (match.toLowerCase().startsWith(s.toLowerCase()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void replaceText(ModifiableString modifiableString) {
|
||||
String input = modifiableString.string();
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
while (matcher.find()) {
|
||||
String group = matcher.group(); // todo debug
|
||||
if(getExclusions().stream().noneMatch(s -> s.equalsIgnoreCase(group))) { // idk how heavy this is:/
|
||||
input = input.replace(group, getReplacement());
|
||||
if (getExclusions().stream().noneMatch(s -> s.equalsIgnoreCase(group))) { // idk how heavy this is:/
|
||||
modifiableString.string(input.replace(group, getReplacement()));
|
||||
}
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
public String replaceMatcher(String input) {
|
||||
int lenght;
|
||||
public void replaceMatcher(ModifiableString modifiableString) {
|
||||
String input = modifiableString.string();
|
||||
int length;
|
||||
try {
|
||||
lenght = Integer.parseInt(replacement);
|
||||
length = Integer.parseInt(replacement);
|
||||
} catch (NumberFormatException e) {
|
||||
lenght = 3; // could load this from config and make it cleaner
|
||||
length = 3; // could load this from config and make it cleaner
|
||||
}
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
while (matcher.find()) {
|
||||
String group = matcher.group();
|
||||
input = input.replace(group, group.substring(0, lenght));
|
||||
modifiableString.string(input.replace(group, group.substring(0, length)));
|
||||
}
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package com.alttd.chat.objects;
|
||||
|
||||
public class ModifiableString {
|
||||
private String string;
|
||||
|
||||
public ModifiableString(String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
public void string(String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
public String string() {
|
||||
return string;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,18 +8,18 @@ allprojects {
|
|||
version = "1.0.0-SNAPSHOT"
|
||||
description = "All in one minecraft chat plugin"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://repo.destro.xyz/snapshots") // Altitude - Galaxy
|
||||
maven("https://oss.sonatype.org/content/groups/public/") // Adventure
|
||||
maven("https://oss.sonatype.org/content/repositories/snapshots/") // Minimessage
|
||||
maven("https://oss.sonatype.org/content/repositories/") // Minimessage
|
||||
maven("https://nexus.velocitypowered.com/repository/") // Velocity
|
||||
maven("https://nexus.velocitypowered.com/repository/maven-public/") // Velocity
|
||||
maven("https://repo.spongepowered.org/maven") // Configurate
|
||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") // Papi
|
||||
maven("https://jitpack.io")
|
||||
}
|
||||
// repositories {
|
||||
// mavenCentral()
|
||||
// maven("https://repo.destro.xyz/snapshots") // Altitude - Galaxy
|
||||
// maven("https://oss.sonatype.org/content/groups/public/") // Adventure
|
||||
// maven("https://oss.sonatype.org/content/repositories/snapshots/") // Minimessage
|
||||
// maven("https://oss.sonatype.org/content/repositories/") // Minimessage
|
||||
// maven("https://nexus.velocitypowered.com/repository/") // Velocity
|
||||
// maven("https://nexus.velocitypowered.com/repository/maven-public/") // Velocity
|
||||
// maven("https://repo.spongepowered.org/maven") // Configurate
|
||||
// maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") // Papi
|
||||
// maven("https://jitpack.io")
|
||||
// }
|
||||
}
|
||||
|
||||
subprojects {
|
||||
|
|
|
|||
|
|
@ -5,10 +5,7 @@ plugins {
|
|||
|
||||
dependencies {
|
||||
implementation(project(":api")) // API
|
||||
compileOnly("com.alttd:Galaxy-API:1.18.1-R0.1-SNAPSHOT") { // Galaxy
|
||||
exclude("net.kyori.adventure.text.minimessage")
|
||||
}
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.10.0-SNAPSHOT") // Minimessage
|
||||
compileOnly("com.alttd:Galaxy-API:1.18.2-R0.1-SNAPSHOT") // Galaxy
|
||||
compileOnly("com.gitlab.ruany:LiteBansAPI:0.3.5") // move to proxy
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public class ChatClear implements CommandExecutor {
|
|||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
if (!player.hasPermission("chat.clear-bypass"))
|
||||
player.sendMessage(component);
|
||||
|
||||
Bukkit.getServer().sendMessage(miniMessage.deserialize(
|
||||
"<gold><player> cleared chat.</gold>",
|
||||
Placeholder.component("player",sender.name()))
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.alttd.chat.config.Config;
|
|||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.managers.RegexManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import com.alttd.chat.objects.ModifiableString;
|
||||
import com.alttd.chat.objects.channels.CustomChannel;
|
||||
import com.alttd.chat.util.GalaxyUtility;
|
||||
import com.alttd.chat.util.Utility;
|
||||
|
|
@ -37,11 +38,16 @@ public class ChatHandler {
|
|||
public void privateMessage(Player player, String target, String message) {
|
||||
// ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
||||
// user.setReplyTarget(target);
|
||||
String updatedMessage = RegexManager.replaceText(player.getName(), player.getUniqueId(), message); // todo a better way for this
|
||||
if(updatedMessage == null) {
|
||||
GalaxyUtility.sendBlockedNotification("DM Language", player, message, target);
|
||||
ModifiableString modifiableString = new ModifiableString(message);
|
||||
// todo a better way for this
|
||||
if(!RegexManager.filterText(player.getName(), player.getUniqueId(), modifiableString, "privatemessage")) {
|
||||
GalaxyUtility.sendBlockedNotification("DM Language",
|
||||
player,
|
||||
Utility.parseMiniMessage(Utility.parseColors(modifiableString.string())),
|
||||
target);
|
||||
return; // the message was blocked
|
||||
}
|
||||
String updatedMessage = modifiableString.string();
|
||||
|
||||
if(!player.hasPermission("chat.format")) {
|
||||
updatedMessage = Utility.stripTokens(updatedMessage);
|
||||
|
|
@ -92,12 +98,17 @@ public class ChatHandler {
|
|||
Component senderName = user.getDisplayName();
|
||||
Component prefix = user.getPrefix();
|
||||
|
||||
String updatedMessage = RegexManager.replaceText(player.getName(), player.getUniqueId(), message); // todo a better way for this
|
||||
if(updatedMessage == null) {
|
||||
GalaxyUtility.sendBlockedNotification("GC Language", player, message, "");
|
||||
ModifiableString modifiableString = new ModifiableString(message);
|
||||
// todo a better way for this
|
||||
if (!RegexManager.filterText(player.getName(), player.getUniqueId(), modifiableString, "globalchat")) {
|
||||
GalaxyUtility.sendBlockedNotification("GC Language",
|
||||
player,
|
||||
Utility.parseMiniMessage(Utility.parseColors(modifiableString.string())),
|
||||
"");
|
||||
return; // the message was blocked
|
||||
}
|
||||
|
||||
String updatedMessage = modifiableString.string();
|
||||
if(!player.hasPermission("chat.format")) {
|
||||
updatedMessage = Utility.stripTokens(updatedMessage);
|
||||
} else {
|
||||
|
|
@ -132,12 +143,16 @@ public class ChatHandler {
|
|||
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
||||
Component senderName = user.getDisplayName();
|
||||
|
||||
String updatedMessage = RegexManager.replaceText(player.getName(), player.getUniqueId(), message);
|
||||
if(updatedMessage == null) {
|
||||
GalaxyUtility.sendBlockedNotification(channel.getChannelName() + " Language", player, message, "");
|
||||
ModifiableString modifiableString = new ModifiableString(message);
|
||||
if(!RegexManager.filterText(player.getName(), player.getUniqueId(), modifiableString, channel.getChannelName())) {
|
||||
GalaxyUtility.sendBlockedNotification(channel.getChannelName() + " Language",
|
||||
player,
|
||||
Utility.parseMiniMessage(Utility.parseColors(modifiableString.string())),
|
||||
"");
|
||||
return; // the message was blocked
|
||||
}
|
||||
|
||||
String updatedMessage = modifiableString.string();
|
||||
if(!player.hasPermission("chat.format")) {
|
||||
updatedMessage = Utility.stripTokens(updatedMessage);
|
||||
}
|
||||
|
|
@ -192,7 +207,7 @@ public class ChatHandler {
|
|||
//
|
||||
// updatedMessage = Utility.formatText(updatedMessage);
|
||||
//
|
||||
// List<Template> templates = new ArrayList<>(List.of(
|
||||
// List<Placeholder> Placeholders = new ArrayList<>(List.of(
|
||||
// Placeholder.miniMessage("sender", senderName),
|
||||
// Placeholder.miniMessage("sendername", senderName),
|
||||
// Placeholder.miniMessage("partyname", party.getPartyName()),
|
||||
|
|
@ -200,10 +215,10 @@ public class ChatHandler {
|
|||
// Placeholder.miniMessage("server", Bukkit.getServerName()),
|
||||
// Placeholder.miniMessage("[i]", itemComponent(player.getInventory().getItemInMainHand()))));
|
||||
//
|
||||
// Component component = Utility.parseMiniMessage(Config.PARTY_FORMAT, templates);
|
||||
// Component component = Utility.parseMiniMessage(Config.PARTY_FORMAT, Placeholders);
|
||||
//// sendPartyMessage(player, party.getPartyId(), component);
|
||||
//
|
||||
// Component spyMessage = Utility.parseMiniMessage(Config.PARTY_SPY, templates);
|
||||
// Component spyMessage = Utility.parseMiniMessage(Config.PARTY_SPY, Placeholders);
|
||||
// for(Player pl : Bukkit.getOnlinePlayers()) {
|
||||
// if(pl.hasPermission(Config.SPYPERMISSION) && !party.getPartyUsersUuid().contains(pl.getUniqueId())) {
|
||||
// pl.sendMessage(spyMessage);
|
||||
|
|
@ -253,7 +268,7 @@ public class ChatHandler {
|
|||
if (user == null) return false;
|
||||
if (user.isMuted() || (ChatPlugin.getInstance().serverMuted() && !player.hasPermission("chat.bypass-server-muted"))) {
|
||||
// if (Database.get().isPlayerMuted(player.getUniqueId(), null) || (ChatPlugin.getInstance().serverMuted() && !player.hasPermission("chat.bypass-server-muted"))) {
|
||||
GalaxyUtility.sendBlockedNotification(prefix, player, message, "");
|
||||
GalaxyUtility.sendBlockedNotification(prefix, player, Utility.parseMiniMessage(Utility.stripTokens(message)), "");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.alttd.chat.handler.ChatHandler;
|
|||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.managers.RegexManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import com.alttd.chat.objects.ModifiableString;
|
||||
import com.alttd.chat.util.GalaxyUtility;
|
||||
import com.alttd.chat.util.Utility;
|
||||
import io.papermc.paper.chat.ChatRenderer;
|
||||
|
|
@ -43,14 +44,16 @@ public class ChatListener implements Listener, ChatRenderer {
|
|||
|
||||
Component input = event.message();
|
||||
String message = PlainTextComponentSerializer.plainText().serialize(input);
|
||||
|
||||
message = RegexManager.replaceText(player.getName(), player.getUniqueId(), message); // todo a better way for this
|
||||
if(message == null) {
|
||||
ModifiableString modifiableString = new ModifiableString(message);
|
||||
// todo a better way for this
|
||||
if(!RegexManager.filterText(player.getName(), player.getUniqueId(), modifiableString, "chat")) {
|
||||
event.setCancelled(true);
|
||||
GalaxyUtility.sendBlockedNotification("Language", player, input, "");
|
||||
GalaxyUtility.sendBlockedNotification("Language", player,
|
||||
Utility.parseMiniMessage(Utility.parseColors(modifiableString.string())),
|
||||
"");
|
||||
return; // the message was blocked
|
||||
}
|
||||
|
||||
message = modifiableString.string();
|
||||
if(!player.hasPermission("chat.format")) {
|
||||
message = Utility.stripTokens(message);
|
||||
} else {
|
||||
|
|
@ -62,7 +65,7 @@ public class ChatListener implements Listener, ChatRenderer {
|
|||
|
||||
message = Utility.formatText(message);
|
||||
TagResolver placeholders = TagResolver.resolver(
|
||||
Placeholder.parsed("message", message),
|
||||
Placeholder.unparsed("message", message), // needs to be unparsed because of the placeholders repeating bug
|
||||
Placeholder.component("[i]]", ChatHandler.itemComponent(player.getInventory().getItemInMainHand()))
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ import com.alttd.chat.database.Queries;
|
|||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.managers.RegexManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import com.alttd.chat.objects.ModifiableString;
|
||||
import com.alttd.chat.util.GalaxyUtility;
|
||||
import com.alttd.chat.util.Utility;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
|
@ -48,12 +48,18 @@ public class PlayerListener implements Listener {
|
|||
Component component = event.line(i);
|
||||
if (component != null) {
|
||||
String message = PlainTextComponentSerializer.plainText().serialize(component);
|
||||
Player player = event.getPlayer();
|
||||
message = RegexManager.replaceText(player.getName(), player.getUniqueId(), message, false); // todo a better way for this
|
||||
ModifiableString modifiableString = new ModifiableString(message);
|
||||
|
||||
if (message == null) {
|
||||
GalaxyUtility.sendBlockedNotification("Sign Language" , player, PlainTextComponentSerializer.plainText().serialize(component), "");
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// todo a better way for this
|
||||
if (!RegexManager.filterText(player.getName(), player.getUniqueId(), modifiableString, false, "sign")) {
|
||||
GalaxyUtility.sendBlockedNotification("Sign Language",
|
||||
player,
|
||||
Utility.parseMiniMessage(Utility.parseColors(modifiableString.string())),
|
||||
"");
|
||||
}
|
||||
message = modifiableString.string();
|
||||
|
||||
component = message == null ? Component.empty() : Component.text(message);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GalaxyUtility {
|
||||
|
||||
public static void sendBlockedNotification(String prefix, Player player, String input, String target) {
|
||||
TagResolver placeholders = TagResolver.resolver(
|
||||
Placeholder.parsed("prefix", prefix),
|
||||
|
|
@ -30,4 +31,5 @@ public class GalaxyUtility {
|
|||
public static void sendBlockedNotification(String prefix, Player player, Component input, String target) {
|
||||
sendBlockedNotification(prefix, player, PlainTextComponentSerializer.plainText().serialize(input), target);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,21 +4,21 @@ include(":api")
|
|||
include(":galaxy")
|
||||
include(":velocity")
|
||||
|
||||
//dependencyResolutionManagement {
|
||||
// repositories {
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
// mavenLocal()
|
||||
// mavenCentral()
|
||||
// maven("https://repo.destro.xyz/snapshots") // Altitude - Galaxy
|
||||
// maven("https://oss.sonatype.org/content/groups/public/") // Adventure
|
||||
// maven("https://oss.sonatype.org/content/repositories/snapshots/") // Minimessage
|
||||
// maven("https://nexus.velocitypowered.com/repository/") // Velocity
|
||||
// maven("https://nexus.velocitypowered.com/repository/maven-public/") // Velocity
|
||||
// maven("https://repo.spongepowered.org/maven") // Configurate
|
||||
// maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") // Papi
|
||||
// maven("https://jitpack.io")
|
||||
// }
|
||||
// repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
//}
|
||||
mavenCentral()
|
||||
maven("https://repo.destro.xyz/snapshots") // Altitude - Galaxy
|
||||
maven("https://oss.sonatype.org/content/groups/public/") // Adventure
|
||||
maven("https://oss.sonatype.org/content/repositories/snapshots/") // Minimessage
|
||||
maven("https://nexus.velocitypowered.com/repository/") // Velocity
|
||||
maven("https://nexus.velocitypowered.com/repository/maven-public/") // Velocity
|
||||
maven("https://repo.spongepowered.org/maven") // Configurate
|
||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") // Papi
|
||||
maven("https://jitpack.io")
|
||||
}
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
}
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
|
|
|
|||
|
|
@ -5,15 +5,11 @@ plugins {
|
|||
|
||||
dependencies {
|
||||
implementation(project(":api")) // API
|
||||
compileOnly("com.velocitypowered:velocity-api:3.0.1") // Velocity
|
||||
annotationProcessor("com.velocitypowered:velocity-api:3.0.1")
|
||||
// compileOnly("com.velocitypowered:velocity-brigadier:1.0.0-SNAPSHOT")
|
||||
compileOnly("com.velocitypowered:velocity-api:3.1.0") // Velocity
|
||||
annotationProcessor("com.velocitypowered:velocity-api:3.1.0")
|
||||
implementation("mysql:mysql-connector-java:8.0.27") // mysql
|
||||
implementation("org.spongepowered", "configurate-yaml", "4.1.2")
|
||||
implementation("net.kyori", "adventure-text-minimessage", "4.10.0-SNAPSHOT") {
|
||||
exclude("net.kyori")
|
||||
exclude("net.kyori.examination")
|
||||
}
|
||||
implementation("net.kyori:adventure-text-minimessage:4.10.1")
|
||||
compileOnly("com.gitlab.ruany:LiteBansAPI:0.3.5")
|
||||
compileOnly("com.alttd.proxydiscordlink:ProxyDiscordLink:1.0.0-BETA-SNAPSHOT")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,7 @@ import com.alttd.chat.ChatImplementation;
|
|||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.managers.PartyManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import com.alttd.velocitychat.commands.GlobalAdminChat;
|
||||
import com.alttd.velocitychat.commands.MailCommand;
|
||||
import com.alttd.velocitychat.commands.PartyCommand;
|
||||
import com.alttd.velocitychat.commands.Reload;
|
||||
import com.alttd.velocitychat.commands.*;
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.database.DatabaseConnection;
|
||||
import com.alttd.velocitychat.handlers.ChatHandler;
|
||||
|
|
@ -37,7 +34,7 @@ import java.nio.file.Path;
|
|||
@Plugin(id = "chatplugin", name = "ChatPlugin", version = "1.0.0",
|
||||
description = "A chat plugin for Altitude Minecraft Server",
|
||||
authors = {"destro174", "teri"},
|
||||
dependencies = {@Dependency(id = "luckperms"), @Dependency(id = "litebans")}
|
||||
dependencies = {@Dependency(id = "luckperms"), @Dependency(id = "litebans"), @Dependency(id = "proxydiscordlink")}
|
||||
)
|
||||
public class VelocityChat {
|
||||
|
||||
|
|
@ -114,6 +111,7 @@ public class VelocityChat {
|
|||
new GlobalAdminChat(server);
|
||||
new Reload(server);
|
||||
new MailCommand(server);
|
||||
new Report(server);
|
||||
server.getCommandManager().register("party", new PartyCommand());
|
||||
// all (proxy)commands go here
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public class PartyCommand implements SimpleCommand {
|
|||
List<String> finalValues = new ArrayList<>();
|
||||
|
||||
for (String str : possibleValues) {
|
||||
if (str.toLowerCase().startsWith(remaining)) {
|
||||
if (str.toLowerCase().startsWith(remaining.toLowerCase())) {
|
||||
finalValues.add(StringArgumentType.escapeIfRequired(str));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,15 @@ package com.alttd.velocitychat.commands;
|
|||
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.util.Utility;
|
||||
import com.alttd.velocitychat.VelocityChat;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
|
||||
import com.alttd.proxydiscordlink.DiscordLink;
|
||||
import com.alttd.proxydiscordlink.lib.net.dv8tion.jda.api.EmbedBuilder;
|
||||
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import com.velocitypowered.api.command.BrigadierCommand;
|
||||
import com.velocitypowered.api.command.CommandMeta;
|
||||
|
|
@ -16,8 +20,12 @@ import com.velocitypowered.api.proxy.ProxyServer;
|
|||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class Report {
|
||||
|
|
@ -26,40 +34,43 @@ public class Report {
|
|||
LiteralCommandNode<CommandSource> command = LiteralArgumentBuilder
|
||||
.<CommandSource>literal("report")
|
||||
.requires(ctx -> ctx.hasPermission("command.chat.report"))
|
||||
.then(RequiredArgumentBuilder.<CommandSource, String>argument("username", StringArgumentType.string())
|
||||
.suggests((context, builder) -> {
|
||||
Collection<String> possibleValues = new ArrayList<>();
|
||||
for (Player player : proxyServer.getAllPlayers()) {
|
||||
possibleValues.add(player.getGameProfile().getName());
|
||||
.then(RequiredArgumentBuilder
|
||||
.<CommandSource, String>argument("report", StringArgumentType.greedyString())
|
||||
.executes(context -> {
|
||||
if (!(context.getSource() instanceof Player player)) {
|
||||
context.getSource().sendMessage(Utility.parseMiniMessage(Config.NO_CONSOLE));
|
||||
return 1;
|
||||
}
|
||||
if(possibleValues.isEmpty()) return Suggestions.empty();
|
||||
String remaining = builder.getRemaining().toLowerCase();
|
||||
for (String str : possibleValues) {
|
||||
if (str.toLowerCase().startsWith(remaining)) {
|
||||
builder.suggest(StringArgumentType.escapeIfRequired(str));
|
||||
}
|
||||
Optional<ServerConnection> optionalServerConnection = player.getCurrentServer();
|
||||
if (optionalServerConnection.isEmpty()) {
|
||||
return 1;
|
||||
}
|
||||
return builder.buildFuture();
|
||||
ServerConnection serverConnection = optionalServerConnection.get();
|
||||
String serverName = serverConnection.getServer().getServerInfo().getName();
|
||||
|
||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||
embedBuilder.setAuthor(player.getUsername(), null, "https://crafatar.com/avatars/" + player.getUniqueId() + "?overlay");
|
||||
embedBuilder.setTitle("Player Report");
|
||||
embedBuilder.setColor(Color.CYAN);
|
||||
embedBuilder.addField("Incident",
|
||||
context.getArgument("report", String.class),
|
||||
false);
|
||||
embedBuilder.addField("Server",
|
||||
serverName.substring(0, 1).toUpperCase() + serverName.substring(1),
|
||||
false);
|
||||
|
||||
Long id = Config.serverChannelId.get(serverName.toLowerCase());
|
||||
if (id <= 0)
|
||||
id = Config.serverChannelId.get("general");
|
||||
DiscordLink.getPlugin().getBot().sendEmbedToDiscord(id, embedBuilder, -1);
|
||||
player.sendMessage(Utility.parseMiniMessage(Config.REPORT_SENT));
|
||||
return 1;
|
||||
})
|
||||
.then(RequiredArgumentBuilder
|
||||
.<CommandSource, String>argument("report", StringArgumentType.greedyString())
|
||||
.executes(context -> {
|
||||
if (!(context.getSource() instanceof Player player)) {
|
||||
context.getSource().sendMessage(Utility.parseMiniMessage(Config.NO_CONSOLE));
|
||||
return 1;
|
||||
}
|
||||
Optional<ServerConnection> optionalServerConnection = player.getCurrentServer();
|
||||
if (optionalServerConnection.isEmpty()) {
|
||||
return 1;
|
||||
}
|
||||
ServerConnection serverConnection = optionalServerConnection.get();
|
||||
String serverName = serverConnection.getServer().getServerInfo().getName();
|
||||
//TODO send message to channel with that server name
|
||||
return 1;
|
||||
})
|
||||
)
|
||||
)
|
||||
.executes(context -> 0)
|
||||
.executes(context -> {
|
||||
context.getSource().sendMessage(Utility.parseMiniMessage(Config.HELP_REPORT));
|
||||
return 0;
|
||||
})
|
||||
.build();
|
||||
|
||||
BrigadierCommand brigadierCommand = new BrigadierCommand(command);
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ public class Invite implements SubCommand {
|
|||
Placeholder.unparsed("party", party.getPartyName()),
|
||||
Placeholder.unparsed("party_password", party.getPartyPassword())
|
||||
));
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.SENT_PARTY_INV,
|
||||
Placeholder.unparsed("player", target.getUsername()),
|
||||
Placeholder.unparsed("party", party.getPartyName()),
|
||||
Placeholder.unparsed("party_password", party.getPartyPassword())
|
||||
));
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.SENT_PARTY_INV,
|
||||
Placeholder.unparsed("player", target.getUsername())
|
||||
));
|
||||
|
|
|
|||
|
|
@ -45,12 +45,17 @@ public class Join implements SubCommand {
|
|||
|
||||
// party.addUser(ChatUserManager.getChatUser(player.getUniqueId())); //Removed until we can get nicknames to translate to colors correctly
|
||||
ChatUser chatUser = ChatUserManager.getChatUser(player.getUniqueId());
|
||||
|
||||
if (chatUser.getPartyId() == party.getPartyId()) {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.ALREADY_IN_THIS_PARTY, Placeholder.parsed("party", party.getPartyName())));
|
||||
return;
|
||||
}
|
||||
party.addUser(chatUser, player.getUsername());
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.JOINED_PARTY, Placeholder.unparsed("party_name", party.getPartyName())));
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.JOINED_PARTY, Placeholder.parsed("party_name", party.getPartyName())));
|
||||
VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party,
|
||||
Utility.parseMiniMessage(Config.PLAYER_JOINED_PARTY,
|
||||
Placeholder.component("player_name", chatUser.getDisplayName()),
|
||||
Placeholder.unparsed("party_name", party.getPartyName())
|
||||
Placeholder.parsed("party_name", party.getPartyName())
|
||||
), null);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ChatHandler {
|
||||
|
||||
|
|
@ -39,20 +38,19 @@ public class ChatHandler {
|
|||
Player player2 = optionalPlayer2.get();
|
||||
ChatUser targetUser = ChatUserManager.getChatUser(player2.getUniqueId());
|
||||
|
||||
TagResolver placeholders = TagResolver.resolver(
|
||||
TagResolver Placeholders = TagResolver.resolver(
|
||||
Placeholder.component("sender", senderUser.getDisplayName()),
|
||||
Placeholder.unparsed("sendername", player.getUsername()),
|
||||
Placeholder.component("receiver", targetUser.getDisplayName()),
|
||||
Placeholder.unparsed("receivername", player2.getUsername()),
|
||||
Placeholder.component("message", GsonComponentSerializer.gson().deserialize(message)),
|
||||
Placeholder.unparsed("server", player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "Altitude")
|
||||
);
|
||||
Placeholder.unparsed("server", player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "Altitude"));
|
||||
|
||||
ServerConnection serverConnection;
|
||||
if(player.getCurrentServer().isPresent() && player2.getCurrentServer().isPresent()) {
|
||||
// redirect to the sender
|
||||
serverConnection = player.getCurrentServer().get();
|
||||
Component component = Utility.parseMiniMessage(Config.MESSAGESENDER, placeholders);
|
||||
Component component = Utility.parseMiniMessage(Config.MESSAGESENDER, Placeholders);
|
||||
ByteArrayDataOutput buf = ByteStreams.newDataOutput();
|
||||
buf.writeUTF("privatemessageout");
|
||||
buf.writeUTF(player.getUniqueId().toString());
|
||||
|
|
@ -63,7 +61,7 @@ public class ChatHandler {
|
|||
|
||||
//redirect to the receiver
|
||||
serverConnection = player2.getCurrentServer().get();
|
||||
component = Utility.parseMiniMessage(Config.MESSAGERECIEVER, placeholders);
|
||||
component = Utility.parseMiniMessage(Config.MESSAGERECIEVER, Placeholders);
|
||||
buf = ByteStreams.newDataOutput();
|
||||
buf.writeUTF("privatemessagein");
|
||||
buf.writeUTF(player2.getUniqueId().toString());
|
||||
|
|
@ -76,13 +74,13 @@ public class ChatHandler {
|
|||
}
|
||||
|
||||
public static void sendBlockedNotification(String prefix, Player player, String input, String target, ServerConnection serverConnection) {
|
||||
TagResolver placeholders = TagResolver.resolver(
|
||||
Placeholder.parsed("prefix", prefix),
|
||||
TagResolver Placeholders = TagResolver.resolver(
|
||||
Placeholder.unparsed("prefix", prefix),
|
||||
Placeholder.parsed("displayname", Utility.getDisplayName(player.getUniqueId(), player.getUsername())),
|
||||
Placeholder.parsed("target", (target.isEmpty() ? " tried to say: " : " -> " + target + ": ")),
|
||||
Placeholder.parsed("input", input)
|
||||
Placeholder.unparsed("target", (target.isEmpty() ? " tried to say: " : " -> " + target + ": ")),
|
||||
Placeholder.unparsed("input", input)
|
||||
);
|
||||
Component blockedNotification = Utility.parseMiniMessage(Config.NOTIFICATIONFORMAT, placeholders);
|
||||
Component blockedNotification = Utility.parseMiniMessage(Config.NOTIFICATIONFORMAT, Placeholders);
|
||||
|
||||
serverConnection.getServer().getPlayersConnected().forEach(pl ->{
|
||||
if (pl.hasPermission("chat.alert-blocked")) {
|
||||
|
|
@ -118,7 +116,8 @@ public class ChatHandler {
|
|||
}
|
||||
Component senderName = user.getDisplayName();
|
||||
|
||||
String updatedMessage = RegexManager.replaceText(player.getUsername(), uuid, message);
|
||||
// String updatedMessage = RegexManager.replaceText(player.getUsername(), uuid, message);
|
||||
String updatedMessage = message; // NEEDS FIXING
|
||||
if(updatedMessage == null) {
|
||||
sendBlockedNotification("Party Language", player, message, "", serverConnection);
|
||||
return; // the message was blocked
|
||||
|
|
@ -132,19 +131,19 @@ public class ChatHandler {
|
|||
|
||||
updatedMessage = Utility.formatText(updatedMessage);
|
||||
|
||||
TagResolver placeholders = TagResolver.resolver(
|
||||
TagResolver Placeholders = TagResolver.resolver(
|
||||
Placeholder.component("sender", senderName),
|
||||
Placeholder.unparsed("username", player.getUsername()),
|
||||
Placeholder.unparsed("party", party.getPartyName()),
|
||||
Placeholder.parsed("message", updatedMessage),
|
||||
Placeholder.component("sendername", senderName),
|
||||
Placeholder.unparsed("partyname", party.getPartyName()),
|
||||
Placeholder.unparsed("message", updatedMessage),
|
||||
Placeholder.unparsed("server", serverConnection.getServer().getServerInfo().getName()),
|
||||
Placeholder.component("[i]", item)
|
||||
);
|
||||
|
||||
Component partyMessage = Utility.parseMiniMessage(Config.PARTY_FORMAT, placeholders);
|
||||
Component partyMessage = Utility.parseMiniMessage(Config.PARTY_FORMAT, Placeholders);
|
||||
sendPartyMessage(party, partyMessage, user.getIgnoredBy());
|
||||
|
||||
Component spyMessage = Utility.parseMiniMessage(Config.PARTY_SPY, placeholders);
|
||||
Component spyMessage = Utility.parseMiniMessage(Config.PARTY_SPY, Placeholders);
|
||||
for(Player pl : serverConnection.getServer().getPlayersConnected()) {
|
||||
if(pl.hasPermission(Config.SPYPERMISSION) && !party.getPartyUsersUuid().contains(pl.getUniqueId())) {
|
||||
pl.sendMessage(spyMessage);
|
||||
|
|
@ -171,13 +170,12 @@ public class ChatHandler {
|
|||
serverName = sender.getCurrentServer().isPresent() ? sender.getCurrentServer().get().getServerInfo().getName() : "Altitude";
|
||||
}
|
||||
|
||||
TagResolver placeholders = TagResolver.resolver(
|
||||
Placeholder.parsed("message", Utility.formatText(message)),
|
||||
TagResolver Placeholders = TagResolver.resolver(
|
||||
Placeholder.unparsed("message", message),
|
||||
Placeholder.component("sender", senderName),
|
||||
Placeholder.parsed("server", serverName)
|
||||
);
|
||||
Placeholder.unparsed("server", serverName));
|
||||
|
||||
Component component = Utility.parseMiniMessage(Config.GACFORMAT, placeholders);
|
||||
Component component = Utility.parseMiniMessage(Config.GACFORMAT, Placeholders);
|
||||
|
||||
VelocityChat.getPlugin().getProxy().getAllPlayers().stream().filter(target -> target.hasPermission("command.chat.globaladminchat")/*TODO permission*/).forEach(target -> {
|
||||
target.sendMessage(component);
|
||||
|
|
@ -192,7 +190,6 @@ public class ChatHandler {
|
|||
uuid = player.getUniqueId();
|
||||
senderName = player.getUsername();
|
||||
}
|
||||
|
||||
Optional<Player> optionalPlayer = VelocityChat.getPlugin().getProxy().getPlayer(recipient);
|
||||
if (optionalPlayer.isEmpty()) {
|
||||
targetUUID = ServerHandler.getPlayerUUID(recipient);
|
||||
|
|
@ -203,24 +200,12 @@ public class ChatHandler {
|
|||
} else {
|
||||
targetUUID = optionalPlayer.get().getUniqueId();
|
||||
}
|
||||
|
||||
if (!commandSource.hasPermission("chat.format"))
|
||||
message = Utility.stripTokens(message);
|
||||
else
|
||||
message = Utility.parseColors(message);
|
||||
|
||||
Mail mail = new Mail(targetUUID, uuid, message);
|
||||
Mail mail = new Mail(uuid, targetUUID, message);
|
||||
ChatUser chatUser = ChatUserManager.getChatUser(targetUUID);
|
||||
chatUser.addMail(mail);
|
||||
// TODO load from config
|
||||
TagResolver placeholders = TagResolver.resolver(
|
||||
Placeholder.parsed("sender", senderName)
|
||||
);
|
||||
optionalPlayer.ifPresent(player -> player.sendMessage(Utility.parseMiniMessage(Config.mailReceived, placeholders)));
|
||||
commandSource.sendMessage(Utility.parseMiniMessage(Config.mailSent,
|
||||
Placeholder.component("player_name", chatUser.getDisplayName()),
|
||||
Placeholder.parsed("message", message)
|
||||
));
|
||||
String finalSenderName = senderName;
|
||||
optionalPlayer.ifPresent(player -> player.sendMessage(Utility.parseMiniMessage("<yellow>New mail from " + finalSenderName)));
|
||||
}
|
||||
|
||||
public void readMail(CommandSource commandSource, String targetPlayer) {
|
||||
|
|
@ -248,15 +233,13 @@ public class ChatHandler {
|
|||
Queries.markMailRead(mail);
|
||||
}
|
||||
ChatUser chatUser = ChatUserManager.getChatUser(mail.getSender());
|
||||
Date sentTime = new Date(mail.getSendTime());
|
||||
TagResolver placeholders = TagResolver.resolver(
|
||||
TagResolver Placeholders = TagResolver.resolver(
|
||||
Placeholder.component("staffprefix", chatUser.getStaffPrefix()),
|
||||
Placeholder.component("sender", chatUser.getDisplayName()),
|
||||
Placeholder.parsed("message", mail.getMessage()),
|
||||
Placeholder.parsed("date", sentTime.toString()),
|
||||
Placeholder.parsed("time_ago", String.valueOf(TimeUnit.MILLISECONDS.toDays(new Date().getTime() - sentTime.getTime())))
|
||||
Placeholder.unparsed("message", mail.getMessage()),
|
||||
Placeholder.unparsed("date", new Date(mail.getSendTime()).toString())
|
||||
);
|
||||
Component mailMessage = Utility.parseMiniMessage(Config.mailBody, placeholders);
|
||||
Component mailMessage = Utility.parseMiniMessage(Config.mailBody, Placeholders);
|
||||
component = component.append(Component.newline()).append(mailMessage);
|
||||
}
|
||||
component = component.append(Component.newline()).append(Utility.parseMiniMessage(Config.mailFooter));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user