Update minimessage to 4.10.0
This commit is contained in:
parent
575c788d10
commit
448d9ac8aa
|
|
@ -4,7 +4,7 @@ plugins {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("com.alttd:Galaxy-API:1.18.1-R0.1-SNAPSHOT")
|
compileOnly("com.alttd:Galaxy-API:1.18.1-R0.1-SNAPSHOT")
|
||||||
compileOnly("net.kyori:adventure-text-minimessage:4.2.0-SNAPSHOT") // Minimessage
|
compileOnly("net.kyori:adventure-text-minimessage:4.10.0-SNAPSHOT") // Minimessage
|
||||||
compileOnly("org.spongepowered:configurate-yaml:4.1.2") // Configurate
|
compileOnly("org.spongepowered:configurate-yaml:4.1.2") // Configurate
|
||||||
compileOnly("net.luckperms:api:5.3") // Luckperms
|
compileOnly("net.luckperms:api:5.3") // Luckperms
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,15 @@ package com.alttd.chat.util;
|
||||||
import com.alttd.chat.ChatAPI;
|
import com.alttd.chat.ChatAPI;
|
||||||
import com.alttd.chat.config.Config;
|
import com.alttd.chat.config.Config;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
|
||||||
import net.kyori.adventure.text.format.Style;
|
|
||||||
import net.kyori.adventure.text.format.TextDecoration;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.template.TemplateResolver;
|
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
|
||||||
|
import net.kyori.adventure.text.minimessage.placeholder.Replacement;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import net.luckperms.api.LuckPerms;
|
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 net.md_5.bungee.api.ChatColor;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
@ -245,14 +241,22 @@ public class Utility {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component parseMiniMessage(String message) {
|
public static Component parseMiniMessage(String message) {
|
||||||
return parseMiniMessage(message, null);
|
return getMiniMessage().deserialize(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component parseMiniMessage(String message, List<Template> templates) {
|
public static Component parseMiniMessage(String message, Map<String, Replacement<?>> placeholders) {
|
||||||
if (templates == null) {
|
if (placeholders == null) {
|
||||||
return getMiniMessage().deserialize(message);
|
return getMiniMessage().deserialize(message);
|
||||||
} else {
|
} else {
|
||||||
return getMiniMessage().deserialize(message, TemplateResolver.templates(templates));
|
return getMiniMessage().deserialize(message, PlaceholderResolver.map(placeholders));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Component parseMiniMessage(String message, Placeholder<?> ... placeholders) {
|
||||||
|
if (placeholders == null) {
|
||||||
|
return getMiniMessage().deserialize(message);
|
||||||
|
} else {
|
||||||
|
return getMiniMessage().deserialize(message, PlaceholderResolver.placeholders(placeholders));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ dependencies {
|
||||||
// implementation(project(":api"))
|
// implementation(project(":api"))
|
||||||
implementation(project(":galaxy"))
|
implementation(project(":galaxy"))
|
||||||
implementation(project(":velocity"))
|
implementation(project(":velocity"))
|
||||||
// implementation("net.kyori", "adventure-text-minimessage", "4.2.0-SNAPSHOT") {
|
// implementation("net.kyori", "adventure-text-minimessage", "4.10.0-SNAPSHOT") {
|
||||||
// exclude("net.kyori")
|
// exclude("net.kyori")
|
||||||
// exclude("net.kyori.examination")
|
// exclude("net.kyori.examination")
|
||||||
// }
|
// }
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ plugins {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":api")) // API
|
implementation(project(":api")) // API
|
||||||
compileOnly("com.alttd:Galaxy-API:1.18.1-R0.1-SNAPSHOT") // Galaxy
|
compileOnly("com.alttd:Galaxy-API:1.18.1-R0.1-SNAPSHOT") // Galaxy
|
||||||
|
compileOnly("net.kyori:adventure-text-minimessage:4.10.0-SNAPSHOT") // Minimessage
|
||||||
compileOnly("com.gitlab.ruany:LiteBansAPI:0.3.5") // move to proxy
|
compileOnly("com.gitlab.ruany:LiteBansAPI:0.3.5") // move to proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,7 @@ import com.alttd.chat.listeners.PluginMessage;
|
||||||
import com.alttd.chat.objects.channels.Channel;
|
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.util.ALogger;
|
import com.alttd.chat.util.ALogger;
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.alttd.chat.util.Utility;
|
||||||
import com.google.common.io.ByteStreams;
|
|
||||||
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;
|
||||||
|
|
@ -111,7 +110,7 @@ public class ChatPlugin extends JavaPlugin {
|
||||||
chatAPI.ReloadConfig();
|
chatAPI.ReloadConfig();
|
||||||
chatAPI.ReloadChatFilters();
|
chatAPI.ReloadChatFilters();
|
||||||
serverConfig = new ServerConfig(Bukkit.getServerName());
|
serverConfig = new ServerConfig(Bukkit.getServerName());
|
||||||
Bukkit.broadcast("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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,14 @@ import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.placeholder.Replacement;
|
||||||
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.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class ChatHandler {
|
public class ChatHandler {
|
||||||
|
|
@ -55,16 +53,16 @@ public class ChatHandler {
|
||||||
|
|
||||||
updatedMessage = Utility.formatText(updatedMessage);
|
updatedMessage = Utility.formatText(updatedMessage);
|
||||||
|
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
Template.template("message", updatedMessage),
|
placeholders.put("message", Replacement.miniMessage(updatedMessage));
|
||||||
Template.template("sendername", player.getName()),
|
placeholders.put("sendername", Replacement.miniMessage(player.getName()));
|
||||||
Template.template("receivername", target),
|
placeholders.put("receivername", Replacement.miniMessage(target));
|
||||||
Template.template("[i]", itemComponent(player.getInventory().getItemInMainHand()))));
|
placeholders.put("[i]", Replacement.component(itemComponent(player.getInventory().getItemInMainHand())));
|
||||||
|
|
||||||
Component component = Utility.parseMiniMessage("<message>", templates);
|
Component component = Utility.parseMiniMessage("<message>", placeholders);
|
||||||
|
|
||||||
sendPrivateMessage(player, target, "privatemessage", component);
|
sendPrivateMessage(player, target, "privatemessage", component);
|
||||||
Component spymessage = Utility.parseMiniMessage(Config.MESSAGESPY, templates);
|
Component spymessage = Utility.parseMiniMessage(Config.MESSAGESPY, placeholders);
|
||||||
for(Player pl : Bukkit.getOnlinePlayers()) {
|
for(Player pl : Bukkit.getOnlinePlayers()) {
|
||||||
if(pl.hasPermission(Config.SPYPERMISSION) && ChatUserManager.getChatUser(pl.getUniqueId()).isSpy() && !pl.equals(player) && !pl.getName().equalsIgnoreCase(target)) {
|
if(pl.hasPermission(Config.SPYPERMISSION) && ChatUserManager.getChatUser(pl.getUniqueId()).isSpy() && !pl.equals(player) && !pl.getName().equalsIgnoreCase(target)) {
|
||||||
pl.sendMessage(spymessage);
|
pl.sendMessage(spymessage);
|
||||||
|
|
@ -85,7 +83,9 @@ public class ChatHandler {
|
||||||
|
|
||||||
long timeLeft = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - user.getGcCooldown());
|
long timeLeft = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - user.getGcCooldown());
|
||||||
if(timeLeft <= Config.GCCOOLDOWN && !player.hasPermission("chat.globalchat.cooldownbypass")) { // player is on cooldown and should wait x seconds
|
if(timeLeft <= Config.GCCOOLDOWN && !player.hasPermission("chat.globalchat.cooldownbypass")) { // player is on cooldown and should wait x seconds
|
||||||
player.sendMessage(Utility.parseMiniMessage(Config.GCONCOOLDOWN, List.of(Template.template("cooldown", Config.GCCOOLDOWN-timeLeft+""))));
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
|
placeholders.put("cooldown", Replacement.miniMessage(Config.GCCOOLDOWN-timeLeft+""));
|
||||||
|
player.sendMessage(Utility.parseMiniMessage(Config.GCONCOOLDOWN, placeholders));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,14 +109,14 @@ public class ChatHandler {
|
||||||
|
|
||||||
updatedMessage = Utility.formatText(updatedMessage);
|
updatedMessage = Utility.formatText(updatedMessage);
|
||||||
|
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
Template.template("sender", senderName),
|
placeholders.put("sender", Replacement.component(senderName));
|
||||||
Template.template("prefix", prefix),
|
placeholders.put("prefix", Replacement.component(prefix));
|
||||||
Template.template("message", updatedMessage),
|
placeholders.put("message", Replacement.miniMessage(updatedMessage));
|
||||||
Template.template("server", Bukkit.getServerName()),
|
placeholders.put("server", Replacement.miniMessage(Bukkit.getServerName()));
|
||||||
Template.template("[i]", itemComponent(player.getInventory().getItemInMainHand()))));
|
placeholders.put("[i]", Replacement.component(itemComponent(player.getInventory().getItemInMainHand())));
|
||||||
|
|
||||||
Component component = Utility.parseMiniMessage(Config.GCFORMAT, templates);
|
Component component = Utility.parseMiniMessage(Config.GCFORMAT, placeholders);
|
||||||
user.setGcCooldown(System.currentTimeMillis());
|
user.setGcCooldown(System.currentTimeMillis());
|
||||||
sendPluginMessage(player, "globalchat", component);
|
sendPluginMessage(player, "globalchat", component);
|
||||||
}
|
}
|
||||||
|
|
@ -146,14 +146,14 @@ public class ChatHandler {
|
||||||
|
|
||||||
updatedMessage = Utility.formatText(updatedMessage);
|
updatedMessage = Utility.formatText(updatedMessage);
|
||||||
|
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
Template.template("sender", senderName),
|
placeholders.put("sender", Replacement.component(senderName));
|
||||||
Template.template("message", updatedMessage),
|
placeholders.put("message", Replacement.miniMessage(updatedMessage));
|
||||||
Template.template("server", Bukkit.getServerName()),
|
placeholders.put("server", Replacement.miniMessage(Bukkit.getServerName()));
|
||||||
Template.template("channel", channel.getChannelName()),
|
placeholders.put("channel", Replacement.miniMessage(channel.getChannelName()));
|
||||||
Template.template("[i]", itemComponent(player.getInventory().getItemInMainHand()))));
|
placeholders.put("[i]", Replacement.component(itemComponent(player.getInventory().getItemInMainHand())));
|
||||||
|
|
||||||
Component component = Utility.parseMiniMessage(channel.getFormat(), templates);
|
Component component = Utility.parseMiniMessage(channel.getFormat(), placeholders);
|
||||||
|
|
||||||
if (channel.isProxy()) {
|
if (channel.isProxy()) {
|
||||||
sendChatChannelMessage(player, channel.getChannelName(), "chatchannel", component);
|
sendChatChannelMessage(player, channel.getChannelName(), "chatchannel", component);
|
||||||
|
|
@ -193,12 +193,12 @@ public class ChatHandler {
|
||||||
// updatedMessage = Utility.formatText(updatedMessage);
|
// updatedMessage = Utility.formatText(updatedMessage);
|
||||||
//
|
//
|
||||||
// List<Template> templates = new ArrayList<>(List.of(
|
// List<Template> templates = new ArrayList<>(List.of(
|
||||||
// Template.template("sender", senderName),
|
// Placeholder.miniMessage("sender", senderName),
|
||||||
// Template.template("sendername", senderName),
|
// Placeholder.miniMessage("sendername", senderName),
|
||||||
// Template.template("partyname", party.getPartyName()),
|
// Placeholder.miniMessage("partyname", party.getPartyName()),
|
||||||
// Template.template("message", updatedMessage),
|
// Placeholder.miniMessage("message", updatedMessage),
|
||||||
// Template.template("server", Bukkit.getServerName()),
|
// Placeholder.miniMessage("server", Bukkit.getServerName()),
|
||||||
// Template.template("[i]", itemComponent(player.getInventory().getItemInMainHand()))));
|
// Placeholder.miniMessage("[i]", itemComponent(player.getInventory().getItemInMainHand()))));
|
||||||
//
|
//
|
||||||
// Component component = Utility.parseMiniMessage(Config.PARTY_FORMAT, templates);
|
// Component component = Utility.parseMiniMessage(Config.PARTY_FORMAT, templates);
|
||||||
//// sendPartyMessage(player, party.getPartyId(), component);
|
//// sendPartyMessage(player, party.getPartyId(), component);
|
||||||
|
|
|
||||||
|
|
@ -10,20 +10,18 @@ import com.alttd.chat.util.GalaxyUtility;
|
||||||
import com.alttd.chat.util.Utility;
|
import com.alttd.chat.util.Utility;
|
||||||
import io.papermc.paper.chat.ChatRenderer;
|
import io.papermc.paper.chat.ChatRenderer;
|
||||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
import litebans.api.Database;
|
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.placeholder.Replacement;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||||
import org.bukkit.Bukkit;
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ChatListener implements Listener, ChatRenderer {
|
public class ChatListener implements Listener, ChatRenderer {
|
||||||
|
|
||||||
|
|
@ -45,7 +43,7 @@ public class ChatListener implements Listener, ChatRenderer {
|
||||||
&& ChatUserManager.getChatUser(receiver.getUniqueId()).getIgnoredPlayers().contains(player.getUniqueId()));
|
&& ChatUserManager.getChatUser(receiver.getUniqueId()).getIgnoredPlayers().contains(player.getUniqueId()));
|
||||||
|
|
||||||
Component input = event.message();
|
Component input = event.message();
|
||||||
String message = PlainComponentSerializer.plain().serialize(input);
|
String message = PlainTextComponentSerializer.plainText().serialize(input);
|
||||||
|
|
||||||
message = RegexManager.replaceText(player.getName(), player.getUniqueId(), message); // todo a better way for this
|
message = RegexManager.replaceText(player.getName(), player.getUniqueId(), message); // todo a better way for this
|
||||||
if(message == null) {
|
if(message == null) {
|
||||||
|
|
@ -65,12 +63,11 @@ public class ChatListener implements Listener, ChatRenderer {
|
||||||
|
|
||||||
message = Utility.formatText(message);
|
message = Utility.formatText(message);
|
||||||
|
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
Template.template("message", message),
|
placeholders.put("message", Replacement.miniMessage(message));
|
||||||
Template.template("[i]", ChatHandler.itemComponent(player.getInventory().getItemInMainHand()))
|
placeholders.put("[i]", Replacement.component(ChatHandler.itemComponent(player.getInventory().getItemInMainHand())));
|
||||||
));
|
|
||||||
|
|
||||||
Component component = Utility.parseMiniMessage("<message>", templates);
|
Component component = Utility.parseMiniMessage("<message>", placeholders);
|
||||||
|
|
||||||
event.message(component);
|
event.message(component);
|
||||||
event.renderer(this);
|
event.renderer(this);
|
||||||
|
|
@ -80,16 +77,15 @@ public class ChatListener implements Listener, ChatRenderer {
|
||||||
public @NotNull Component render(@NotNull Player player, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer) {
|
public @NotNull Component render(@NotNull Player player, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer) {
|
||||||
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
||||||
|
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
Template.template("sender", user.getDisplayName()),
|
placeholders.put("sender", Replacement.component(user.getDisplayName()));
|
||||||
Template.template("sendername", player.getName()),
|
placeholders.put("sendername", Replacement.component(player.name()));
|
||||||
Template.template("prefix", user.getPrefix()),
|
placeholders.put("prefix", Replacement.component(user.getPrefix()));
|
||||||
Template.template("prefixall", user.getPrefixAll()),
|
placeholders.put("prefixall", Replacement.component(user.getPrefixAll()));
|
||||||
Template.template("staffprefix", user.getStaffPrefix()),
|
placeholders.put("staffprefix", Replacement.component(user.getStaffPrefix()));
|
||||||
Template.template("message", message)
|
placeholders.put("message", Replacement.component(message));
|
||||||
));
|
|
||||||
|
|
||||||
return Utility.parseMiniMessage(Config.CHATFORMAT, templates);
|
return Utility.parseMiniMessage(Config.CHATFORMAT, placeholders);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -8,6 +8,7 @@ import com.alttd.chat.util.GalaxyUtility;
|
||||||
import com.alttd.chat.util.Utility;
|
import com.alttd.chat.util.Utility;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||||
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
@ -46,12 +47,12 @@ public class PlayerListener implements Listener {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
Component component = event.line(i);
|
Component component = event.line(i);
|
||||||
if (component != null) {
|
if (component != null) {
|
||||||
String message = PlainComponentSerializer.plain().serialize(component);
|
String message = PlainTextComponentSerializer.plainText().serialize(component);
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
message = RegexManager.replaceText(player.getName(), player.getUniqueId(), message, false); // todo a better way for this
|
message = RegexManager.replaceText(player.getName(), player.getUniqueId(), message, false); // todo a better way for this
|
||||||
|
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
GalaxyUtility.sendBlockedNotification("Sign Language" , player, PlainComponentSerializer.plain().serialize(component), "");
|
GalaxyUtility.sendBlockedNotification("Sign Language" , player, PlainTextComponentSerializer.plainText().serialize(component), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
component = message == null ? Component.empty() : Component.text(message);
|
component = message == null ? Component.empty() : Component.text(message);
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,23 @@ package com.alttd.chat.util;
|
||||||
|
|
||||||
import com.alttd.chat.config.Config;
|
import com.alttd.chat.config.Config;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.placeholder.Replacement;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||||
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.Map;
|
||||||
|
|
||||||
public class GalaxyUtility {
|
public class GalaxyUtility {
|
||||||
public static void sendBlockedNotification(String prefix, Player player, String input, String target) {
|
public static void sendBlockedNotification(String prefix, Player player, String input, String target) {
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
Template.template("prefix", prefix),
|
placeholders.put("prefix", Replacement.miniMessage(prefix));
|
||||||
Template.template("displayname", Utility.getDisplayName(player.getUniqueId(), player.getName())),
|
placeholders.put("displayname", Replacement.miniMessage(Utility.getDisplayName(player.getUniqueId(), player.getName())));
|
||||||
Template.template("target", (target.isEmpty() ? " tried to say: " : " -> " + target + ": ")),
|
placeholders.put("target", Replacement.miniMessage((target.isEmpty() ? " tried to say: " : " -> " + target + ": ")));
|
||||||
Template.template("input", input)
|
placeholders.put("input", Replacement.miniMessage(input));
|
||||||
));
|
Component blockedNotification = Utility.parseMiniMessage(Config.NOTIFICATIONFORMAT, placeholders);
|
||||||
Component blockedNotification = Utility.parseMiniMessage(Config.NOTIFICATIONFORMAT, templates);
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(a ->{
|
Bukkit.getOnlinePlayers().forEach(a ->{
|
||||||
if (a.hasPermission("chat.alert-blocked")) {
|
if (a.hasPermission("chat.alert-blocked")) {
|
||||||
|
|
@ -31,6 +30,6 @@ public class GalaxyUtility {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendBlockedNotification(String prefix, Player player, Component input, String target) {
|
public static void sendBlockedNotification(String prefix, Player player, Component input, String target) {
|
||||||
sendBlockedNotification(prefix, player, PlainComponentSerializer.plain().serialize(input), target);
|
sendBlockedNotification(prefix, player, PlainTextComponentSerializer.plainText().serialize(input), target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ dependencies {
|
||||||
annotationProcessor("com.velocitypowered:velocity-api:3.0.0")
|
annotationProcessor("com.velocitypowered:velocity-api:3.0.0")
|
||||||
implementation("mysql:mysql-connector-java:8.0.27") // mysql
|
implementation("mysql:mysql-connector-java:8.0.27") // mysql
|
||||||
implementation("org.spongepowered", "configurate-yaml", "4.1.2")
|
implementation("org.spongepowered", "configurate-yaml", "4.1.2")
|
||||||
implementation("net.kyori", "adventure-text-minimessage", "4.2.0-SNAPSHOT") {
|
implementation("net.kyori", "adventure-text-minimessage", "4.10.0-SNAPSHOT") {
|
||||||
exclude("net.kyori")
|
exclude("net.kyori")
|
||||||
exclude("net.kyori.examination")
|
exclude("net.kyori.examination")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.command.SimpleCommand;
|
import com.velocitypowered.api.command.SimpleCommand;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -112,8 +112,8 @@ public class PartyCommand implements SimpleCommand {
|
||||||
if (stringBuilder.length() != 0)
|
if (stringBuilder.length() != 0)
|
||||||
stringBuilder.replace(stringBuilder.length() - 1, stringBuilder.length(), "");
|
stringBuilder.replace(stringBuilder.length() - 1, stringBuilder.length(), "");
|
||||||
|
|
||||||
return Utility.parseMiniMessage(Config.PARTY_HELP_WRAPPER, List.of(
|
return Utility.parseMiniMessage(Config.PARTY_HELP_WRAPPER,
|
||||||
Template.template("commands", Utility.parseMiniMessage(stringBuilder.toString()))
|
Placeholder.component("commands", Utility.parseMiniMessage(stringBuilder.toString()))
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9,8 +9,7 @@ import com.alttd.chat.util.Utility;
|
||||||
import com.alttd.velocitychat.commands.SubCommand;
|
import com.alttd.velocitychat.commands.SubCommand;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -38,9 +37,9 @@ public class Create implements SubCommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PartyManager.getParty(args[1]) != null) {
|
if (PartyManager.getParty(args[1]) != null) {
|
||||||
source.sendMessage(Utility.parseMiniMessage(Config.PARTY_EXISTS, List.of(
|
source.sendMessage(Utility.parseMiniMessage(Config.PARTY_EXISTS,
|
||||||
Template.template("party", args[1])
|
Placeholder.miniMessage("party", args[1])
|
||||||
)));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Party party = Queries.addParty(player.getUniqueId(), args[1], args[2]);
|
Party party = Queries.addParty(player.getUniqueId(), args[1], args[2]);
|
||||||
|
|
@ -48,8 +47,8 @@ public class Create implements SubCommand {
|
||||||
party.addUser(ChatUserManager.getChatUser(player.getUniqueId()), player.getUsername());
|
party.addUser(ChatUserManager.getChatUser(player.getUniqueId()), player.getUsername());
|
||||||
PartyManager.addParty(party);
|
PartyManager.addParty(party);
|
||||||
source.sendMessage(Utility.parseMiniMessage(Config.CREATED_PARTY,
|
source.sendMessage(Utility.parseMiniMessage(Config.CREATED_PARTY,
|
||||||
List.of(Template.template("party_name", party.getPartyName()),
|
Placeholder.miniMessage("party_name", party.getPartyName()),
|
||||||
Template.template("party_password", party.getPartyPassword()))));
|
Placeholder.miniMessage("party_password", party.getPartyPassword())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import com.alttd.velocitychat.VelocityChat;
|
||||||
import com.alttd.velocitychat.commands.SubCommand;
|
import com.alttd.velocitychat.commands.SubCommand;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -39,9 +39,7 @@ public class Disband implements SubCommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
source.sendMessage(Utility.parseMiniMessage(Config.DISBAND_PARTY_CONFIRM, List.of(
|
source.sendMessage(Utility.parseMiniMessage(Config.DISBAND_PARTY_CONFIRM, Placeholder.miniMessage("party", party.getPartyName())));
|
||||||
Template.template("party", party.getPartyName())
|
|
||||||
)));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!args[1].equalsIgnoreCase("confirm") || !args[2].equals(party.getPartyName())) {
|
if (!args[1].equalsIgnoreCase("confirm") || !args[2].equals(party.getPartyName())) {
|
||||||
|
|
@ -49,10 +47,10 @@ public class Disband implements SubCommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party,
|
VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party,
|
||||||
Utility.parseMiniMessage(Config.DISBANDED_PARTY, List.of(
|
Utility.parseMiniMessage(Config.DISBANDED_PARTY,
|
||||||
Template.template("owner", player.getUsername()),
|
Placeholder.miniMessage("owner", player.getUsername()),
|
||||||
Template.template("party", party.getPartyName())
|
Placeholder.miniMessage("party", party.getPartyName())
|
||||||
)), null);
|
), null);
|
||||||
party.delete();
|
party.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import com.alttd.velocitychat.commands.SubCommand;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -37,14 +37,12 @@ public class Info implements SubCommand {
|
||||||
displayNames.add(partyUser.getDisplayName());
|
displayNames.add(partyUser.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
source.sendMessage(Utility.parseMiniMessage(Config.PARTY_INFO,
|
||||||
Template.template("party", party.getPartyName()),
|
Placeholder.miniMessage("party", party.getPartyName()),
|
||||||
Template.template("password", party.getPartyPassword()),
|
Placeholder.miniMessage("password", party.getPartyPassword()),
|
||||||
Template.template("owner", party.getPartyUser(party.getOwnerUuid()).getDisplayName()),
|
Placeholder.component("owner", party.getPartyUser(party.getOwnerUuid()).getDisplayName()),
|
||||||
Template.template("members", Component.join(Component.text(", "), displayNames))
|
Placeholder.component("members", Component.join(Component.text(", "), displayNames))
|
||||||
));
|
));
|
||||||
|
|
||||||
source.sendMessage(Utility.parseMiniMessage(Config.PARTY_INFO, templates));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import com.alttd.velocitychat.VelocityChat;
|
||||||
import com.alttd.velocitychat.commands.SubCommand;
|
import com.alttd.velocitychat.commands.SubCommand;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -49,19 +49,19 @@ public class Invite implements SubCommand {
|
||||||
Player target = optional.get();
|
Player target = optional.get();
|
||||||
|
|
||||||
if (!target.isActive()) {
|
if (!target.isActive()) {
|
||||||
source.sendMessage(Utility.parseMiniMessage(Config.NOT_ONLINE, List.of(
|
source.sendMessage(Utility.parseMiniMessage(Config.NOT_ONLINE,
|
||||||
Template.template("player", target.getUsername())
|
Placeholder.miniMessage("player", target.getUsername())
|
||||||
)));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.sendMessage(Utility.parseMiniMessage(Config.JOIN_PARTY_CLICK_MESSAGE, List.of(
|
target.sendMessage(Utility.parseMiniMessage(Config.JOIN_PARTY_CLICK_MESSAGE,
|
||||||
Template.template("party", party.getPartyName()),
|
Placeholder.miniMessage("party", party.getPartyName()),
|
||||||
Template.template("party_password", party.getPartyPassword())
|
Placeholder.miniMessage("party_password", party.getPartyPassword())
|
||||||
)));
|
));
|
||||||
source.sendMessage(Utility.parseMiniMessage(Config.SENT_PARTY_INV, List.of(
|
source.sendMessage(Utility.parseMiniMessage(Config.SENT_PARTY_INV,
|
||||||
Template.template("player", target.getUsername())
|
Placeholder.miniMessage("player", target.getUsername())
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import com.alttd.chat.util.Utility;
|
||||||
import com.alttd.velocitychat.commands.SubCommand;
|
import com.alttd.velocitychat.commands.SubCommand;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -43,8 +43,7 @@ public class Join implements SubCommand {
|
||||||
|
|
||||||
// party.addUser(ChatUserManager.getChatUser(player.getUniqueId())); //Removed until we can get nicknames to translate to colors correctly
|
// party.addUser(ChatUserManager.getChatUser(player.getUniqueId())); //Removed until we can get nicknames to translate to colors correctly
|
||||||
party.addUser(ChatUserManager.getChatUser(player.getUniqueId()), player.getUsername());
|
party.addUser(ChatUserManager.getChatUser(player.getUniqueId()), player.getUsername());
|
||||||
source.sendMessage(Utility.parseMiniMessage(Config.JOINED_PARTY, List.of(
|
source.sendMessage(Utility.parseMiniMessage(Config.JOINED_PARTY, Placeholder.miniMessage("party_name", party.getPartyName())));
|
||||||
Template.template("party_name", party.getPartyName()))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import com.alttd.velocitychat.commands.SubCommand;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -44,10 +44,10 @@ public class Leave implements SubCommand {
|
||||||
UUID uuid = party.setNewOwner();
|
UUID uuid = party.setNewOwner();
|
||||||
source.sendMessage(Utility.parseMiniMessage(Config.NOTIFY_FINDING_NEW_OWNER));
|
source.sendMessage(Utility.parseMiniMessage(Config.NOTIFY_FINDING_NEW_OWNER));
|
||||||
VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party,
|
VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party,
|
||||||
Utility.parseMiniMessage(Config.OWNER_LEFT_PARTY, List.of(
|
Utility.parseMiniMessage(Config.OWNER_LEFT_PARTY,
|
||||||
Template.template("old_owner", player.getUsername()),
|
Placeholder.miniMessage("old_owner", player.getUsername()),
|
||||||
Template.template("new_owner", party.getPartyUser(uuid).getPlayerName())
|
Placeholder.miniMessage("new_owner", party.getPartyUser(uuid).getPlayerName())
|
||||||
)), null);
|
), null);
|
||||||
} else {
|
} else {
|
||||||
party.delete();
|
party.delete();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,7 @@ import com.alttd.velocitychat.VelocityChat;
|
||||||
import com.alttd.velocitychat.commands.SubCommand;
|
import com.alttd.velocitychat.commands.SubCommand;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||||
import org.checkerframework.checker.units.qual.A;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -44,9 +43,9 @@ public class Name implements SubCommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PartyManager.getParty(args[1]) != null) {
|
if (PartyManager.getParty(args[1]) != null) {
|
||||||
source.sendMessage(Utility.parseMiniMessage(Config.PARTY_EXISTS, List.of(
|
source.sendMessage(Utility.parseMiniMessage(Config.PARTY_EXISTS,
|
||||||
Template.template("party", args[1])
|
Placeholder.miniMessage("party", args[1])
|
||||||
)));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
party.setPartyName(args[1]);
|
party.setPartyName(args[1]);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import com.alttd.velocitychat.VelocityChat;
|
||||||
import com.alttd.velocitychat.commands.SubCommand;
|
import com.alttd.velocitychat.commands.SubCommand;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -43,17 +43,17 @@ public class Owner implements SubCommand {
|
||||||
}
|
}
|
||||||
PartyUser partyUser = party.getPartyUser(args[1]);
|
PartyUser partyUser = party.getPartyUser(args[1]);
|
||||||
if (partyUser == null) {
|
if (partyUser == null) {
|
||||||
source.sendMessage(Utility.parseMiniMessage(Config.NOT_A_PARTY_MEMBER, List.of(
|
source.sendMessage(Utility.parseMiniMessage(Config.NOT_A_PARTY_MEMBER,
|
||||||
Template.template("player", args[1])
|
Placeholder.miniMessage("player", args[1])
|
||||||
)));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
party.setNewOwner(partyUser.getUuid());
|
party.setNewOwner(partyUser.getUuid());
|
||||||
VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party,
|
VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party,
|
||||||
Utility.parseMiniMessage(Config.NEW_PARTY_OWNER, List.of(
|
Utility.parseMiniMessage(Config.NEW_PARTY_OWNER,
|
||||||
Template.template("old_owner", player.getUsername()),
|
Placeholder.miniMessage("old_owner", player.getUsername()),
|
||||||
Template.template("new_owner", partyUser.getPlayerName())
|
Placeholder.miniMessage("new_owner", partyUser.getPlayerName())
|
||||||
)), null);
|
), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import com.alttd.velocitychat.VelocityChat;
|
||||||
import com.alttd.velocitychat.commands.SubCommand;
|
import com.alttd.velocitychat.commands.SubCommand;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -49,18 +49,18 @@ public class Remove implements SubCommand {
|
||||||
if (optionalPlayer.isEmpty()) {
|
if (optionalPlayer.isEmpty()) {
|
||||||
partyUser = party.getPartyUser(args[1]);
|
partyUser = party.getPartyUser(args[1]);
|
||||||
if (partyUser == null) {
|
if (partyUser == null) {
|
||||||
source.sendMessage(Utility.parseMiniMessage(Config.NOT_A_PARTY_MEMBER, List.of(
|
source.sendMessage(Utility.parseMiniMessage(Config.NOT_A_PARTY_MEMBER,
|
||||||
Template.template("player", args[1])
|
Placeholder.miniMessage("player", args[1])
|
||||||
)));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
onlinePlayer = optionalPlayer.get();
|
onlinePlayer = optionalPlayer.get();
|
||||||
partyUser = party.getPartyUser(onlinePlayer.getUniqueId());
|
partyUser = party.getPartyUser(onlinePlayer.getUniqueId());
|
||||||
if (partyUser == null) {
|
if (partyUser == null) {
|
||||||
source.sendMessage(Utility.parseMiniMessage(Config.NOT_A_PARTY_MEMBER, List.of(
|
source.sendMessage(Utility.parseMiniMessage(Config.NOT_A_PARTY_MEMBER,
|
||||||
Template.template("player", onlinePlayer.getUsername())
|
Placeholder.miniMessage("player", onlinePlayer.getUsername())
|
||||||
)));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -72,14 +72,14 @@ public class Remove implements SubCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onlinePlayer != null && onlinePlayer.isActive()) {
|
if (onlinePlayer != null && onlinePlayer.isActive()) {
|
||||||
onlinePlayer.sendMessage(Utility.parseMiniMessage(Config.REMOVED_FROM_PARTY, List.of(
|
onlinePlayer.sendMessage(Utility.parseMiniMessage(Config.REMOVED_FROM_PARTY,
|
||||||
Template.template("party", party.getPartyName())
|
Placeholder.miniMessage("party", party.getPartyName())
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
source.sendMessage(Utility.parseMiniMessage(Config.REMOVED_USER_FROM_PARTY, List.of(
|
source.sendMessage(Utility.parseMiniMessage(Config.REMOVED_USER_FROM_PARTY,
|
||||||
Template.template("player", onlinePlayer == null ? partyUser.getPlayerName() : onlinePlayer.getUsername())
|
Placeholder.miniMessage("player", onlinePlayer == null ? partyUser.getPlayerName() : onlinePlayer.getUsername())
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.placeholder.Replacement;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
|
@ -38,19 +38,19 @@ public class ChatHandler {
|
||||||
Player player2 = optionalPlayer2.get();
|
Player player2 = optionalPlayer2.get();
|
||||||
ChatUser targetUser = ChatUserManager.getChatUser(player2.getUniqueId());
|
ChatUser targetUser = ChatUserManager.getChatUser(player2.getUniqueId());
|
||||||
|
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
Template.template("sender", senderUser.getDisplayName()),
|
placeholders.put("sender", Replacement.component(senderUser.getDisplayName()));
|
||||||
Template.template("sendername", player.getUsername()),
|
placeholders.put("sendername", Replacement.miniMessage(player.getUsername()));
|
||||||
Template.template("receiver", targetUser.getDisplayName()),
|
placeholders.put("receiver", Replacement.component(targetUser.getDisplayName()));
|
||||||
Template.template("receivername", player2.getUsername()),
|
placeholders.put("receivername", Replacement.miniMessage(player2.getUsername()));
|
||||||
Template.template("message", GsonComponentSerializer.gson().deserialize(message)),
|
placeholders.put("message", Replacement.component(GsonComponentSerializer.gson().deserialize(message)));
|
||||||
Template.template("server", player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "Altitude")));
|
placeholders.put("server", Replacement.miniMessage(player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "Altitude"));
|
||||||
|
|
||||||
ServerConnection serverConnection;
|
ServerConnection serverConnection;
|
||||||
if(player.getCurrentServer().isPresent() && player2.getCurrentServer().isPresent()) {
|
if(player.getCurrentServer().isPresent() && player2.getCurrentServer().isPresent()) {
|
||||||
// redirect to the sender
|
// redirect to the sender
|
||||||
serverConnection = player.getCurrentServer().get();
|
serverConnection = player.getCurrentServer().get();
|
||||||
Component component = Utility.parseMiniMessage(Config.MESSAGESENDER, templates);
|
Component component = Utility.parseMiniMessage(Config.MESSAGESENDER, placeholders);
|
||||||
ByteArrayDataOutput buf = ByteStreams.newDataOutput();
|
ByteArrayDataOutput buf = ByteStreams.newDataOutput();
|
||||||
buf.writeUTF("privatemessageout");
|
buf.writeUTF("privatemessageout");
|
||||||
buf.writeUTF(player.getUniqueId().toString());
|
buf.writeUTF(player.getUniqueId().toString());
|
||||||
|
|
@ -61,7 +61,7 @@ public class ChatHandler {
|
||||||
|
|
||||||
//redirect to the receiver
|
//redirect to the receiver
|
||||||
serverConnection = player2.getCurrentServer().get();
|
serverConnection = player2.getCurrentServer().get();
|
||||||
component = Utility.parseMiniMessage(Config.MESSAGERECIEVER, templates);
|
component = Utility.parseMiniMessage(Config.MESSAGERECIEVER, placeholders);
|
||||||
buf = ByteStreams.newDataOutput();
|
buf = ByteStreams.newDataOutput();
|
||||||
buf.writeUTF("privatemessagein");
|
buf.writeUTF("privatemessagein");
|
||||||
buf.writeUTF(player2.getUniqueId().toString());
|
buf.writeUTF(player2.getUniqueId().toString());
|
||||||
|
|
@ -71,29 +71,15 @@ public class ChatHandler {
|
||||||
serverConnection.sendPluginMessage(VelocityChat.getPlugin().getChannelIdentifier(), buf.toByteArray());
|
serverConnection.sendPluginMessage(VelocityChat.getPlugin().getChannelIdentifier(), buf.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChatUser targetUser = ChatUserManager.getChatUser(player2.getUniqueId());
|
|
||||||
//
|
|
||||||
// List<Template> templates = new ArrayList<>(List.of(
|
|
||||||
// Template.template("sender", senderUser.getDisplayName()),
|
|
||||||
// Template.template("receiver", targetUser.getDisplayName()),
|
|
||||||
// Template.template("message", message),
|
|
||||||
// Template.template("server", player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "Altitude")));
|
|
||||||
//
|
|
||||||
// Component senderMessage = Utility.parseMiniMessage(Config.MESSAGESENDER, templates);
|
|
||||||
// Component receiverMessage = Utility.parseMiniMessage(Config.MESSAGERECIEVER, templates);
|
|
||||||
//
|
|
||||||
// player.sendMessage(senderMessage);
|
|
||||||
// player2.sendMessage(receiverMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendBlockedNotification(String prefix, Player player, String input, String target, ServerConnection serverConnection) {
|
public static void sendBlockedNotification(String prefix, Player player, String input, String target, ServerConnection serverConnection) {
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
Template.template("prefix", prefix),
|
placeholders.put("prefix", Replacement.miniMessage(prefix));
|
||||||
Template.template("displayname", Utility.getDisplayName(player.getUniqueId(), player.getUsername())),
|
placeholders.put("displayname", Replacement.miniMessage(Utility.getDisplayName(player.getUniqueId(), player.getUsername())));
|
||||||
Template.template("target", (target.isEmpty() ? " tried to say: " : " -> " + target + ": ")),
|
placeholders.put("target", Replacement.miniMessage((target.isEmpty() ? " tried to say: " : " -> " + target + ": ")));
|
||||||
Template.template("input", input)
|
placeholders.put("input", Replacement.miniMessage(input));
|
||||||
));
|
Component blockedNotification = Utility.parseMiniMessage(Config.NOTIFICATIONFORMAT, placeholders);
|
||||||
Component blockedNotification = Utility.parseMiniMessage(Config.NOTIFICATIONFORMAT, templates);
|
|
||||||
|
|
||||||
serverConnection.getServer().getPlayersConnected().forEach(pl ->{
|
serverConnection.getServer().getPlayersConnected().forEach(pl ->{
|
||||||
if (pl.hasPermission("chat.alert-blocked")) {
|
if (pl.hasPermission("chat.alert-blocked")) {
|
||||||
|
|
@ -143,18 +129,17 @@ public class ChatHandler {
|
||||||
|
|
||||||
updatedMessage = Utility.formatText(updatedMessage);
|
updatedMessage = Utility.formatText(updatedMessage);
|
||||||
|
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
Template.template("sender", senderName),
|
placeholders.put("sender", Replacement.component(senderName));
|
||||||
Template.template("party", party.getPartyName()),
|
placeholders.put("party", Replacement.miniMessage(party.getPartyName()));
|
||||||
Template.template("message", updatedMessage),
|
placeholders.put("message", Replacement.miniMessage(updatedMessage));
|
||||||
Template.template("server", serverConnection.getServer().getServerInfo().getName()),
|
placeholders.put("server", Replacement.miniMessage(serverConnection.getServer().getServerInfo().getName()));
|
||||||
Template.template("[i]", item)
|
placeholders.put("[i]", Replacement.component(item));
|
||||||
));
|
|
||||||
|
|
||||||
Component partyMessage = Utility.parseMiniMessage(Config.PARTY_FORMAT, templates);
|
Component partyMessage = Utility.parseMiniMessage(Config.PARTY_FORMAT, placeholders);
|
||||||
sendPartyMessage(party, partyMessage, user.getIgnoredBy());
|
sendPartyMessage(party, partyMessage, user.getIgnoredBy());
|
||||||
|
|
||||||
Component spyMessage = Utility.parseMiniMessage(Config.PARTY_SPY, templates);
|
Component spyMessage = Utility.parseMiniMessage(Config.PARTY_SPY, placeholders);
|
||||||
for(Player pl : serverConnection.getServer().getPlayersConnected()) {
|
for(Player pl : serverConnection.getServer().getPlayersConnected()) {
|
||||||
if(pl.hasPermission(Config.SPYPERMISSION) && !party.getPartyUsersUuid().contains(pl.getUniqueId())) {
|
if(pl.hasPermission(Config.SPYPERMISSION) && !party.getPartyUsersUuid().contains(pl.getUniqueId())) {
|
||||||
pl.sendMessage(spyMessage);
|
pl.sendMessage(spyMessage);
|
||||||
|
|
@ -181,12 +166,12 @@ public class ChatHandler {
|
||||||
serverName = sender.getCurrentServer().isPresent() ? sender.getCurrentServer().get().getServerInfo().getName() : "Altitude";
|
serverName = sender.getCurrentServer().isPresent() ? sender.getCurrentServer().get().getServerInfo().getName() : "Altitude";
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
Template.template("message", Utility.formatText(message)),
|
placeholders.put("message", Replacement.miniMessage(Utility.formatText(message)));
|
||||||
Template.template("sender", senderName),
|
placeholders.put("sender", Replacement.component(senderName));
|
||||||
Template.template("server", serverName)));
|
placeholders.put("server", Replacement.miniMessage(serverName));
|
||||||
|
|
||||||
Component component = Utility.parseMiniMessage(Config.GACFORMAT, templates);
|
Component component = Utility.parseMiniMessage(Config.GACFORMAT, placeholders);
|
||||||
|
|
||||||
VelocityChat.getPlugin().getProxy().getAllPlayers().stream().filter(target -> target.hasPermission("command.chat.globaladminchat")/*TODO permission*/).forEach(target -> {
|
VelocityChat.getPlugin().getProxy().getAllPlayers().stream().filter(target -> target.hasPermission("command.chat.globaladminchat")/*TODO permission*/).forEach(target -> {
|
||||||
target.sendMessage(component);
|
target.sendMessage(component);
|
||||||
|
|
@ -215,10 +200,9 @@ public class ChatHandler {
|
||||||
ChatUser chatUser = ChatUserManager.getChatUser(targetUUID);
|
ChatUser chatUser = ChatUserManager.getChatUser(targetUUID);
|
||||||
chatUser.addMail(mail);
|
chatUser.addMail(mail);
|
||||||
// TODO load from config
|
// TODO load from config
|
||||||
String finalSenderName = senderName;
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
optionalPlayer.ifPresent(player -> player.sendMessage(Utility.parseMiniMessage(Config.mailReceived, List.of(
|
placeholders.put("sender", Replacement.miniMessage(senderName));
|
||||||
Template.template("sender", finalSenderName))
|
optionalPlayer.ifPresent(player -> player.sendMessage(Utility.parseMiniMessage(Config.mailReceived, placeholders)));
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readMail(CommandSource commandSource, String targetPlayer) {
|
public void readMail(CommandSource commandSource, String targetPlayer) {
|
||||||
|
|
@ -247,14 +231,13 @@ public class ChatHandler {
|
||||||
}
|
}
|
||||||
ChatUser chatUser = ChatUserManager.getChatUser(mail.getSender());
|
ChatUser chatUser = ChatUserManager.getChatUser(mail.getSender());
|
||||||
Date sentTime = new Date(mail.getSendTime());
|
Date sentTime = new Date(mail.getSendTime());
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
Template.template("staffprefix", chatUser.getStaffPrefix()),
|
placeholders.put("staffprefix", Replacement.component(chatUser.getStaffPrefix()));
|
||||||
Template.template("sender", chatUser.getDisplayName()),
|
placeholders.put("sender", Replacement.component(chatUser.getDisplayName()));
|
||||||
Template.template("message", mail.getMessage()),
|
placeholders.put("message", Replacement.miniMessage(mail.getMessage()));
|
||||||
Template.template("date", sentTime.toString()),
|
placeholders.put("date", Replacement.miniMessage(sentTime.toString()));
|
||||||
Template.template("time_ago", String.valueOf(TimeUnit.MILLISECONDS.toDays(new Date().getTime() - sentTime.getTime())))
|
placeholders.put("time_ago", Replacement.miniMessage(String.valueOf(TimeUnit.MILLISECONDS.toDays(new Date().getTime() - sentTime.getTime()))));
|
||||||
));
|
Component mailMessage = Utility.parseMiniMessage(Config.mailBody, placeholders);
|
||||||
Component mailMessage = Utility.parseMiniMessage(Config.mailBody, templates);
|
|
||||||
component = component.append(Component.newline()).append(mailMessage);
|
component = component.append(Component.newline()).append(mailMessage);
|
||||||
}
|
}
|
||||||
component = component.append(Component.newline()).append(Utility.parseMiniMessage(Config.mailFooter));
|
component = component.append(Component.newline()).append(Utility.parseMiniMessage(Config.mailFooter));
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,18 @@
|
||||||
package com.alttd.velocitychat.listeners;
|
package com.alttd.velocitychat.listeners;
|
||||||
|
|
||||||
|
import com.alttd.chat.config.Config;
|
||||||
import com.alttd.chat.util.Utility;
|
import com.alttd.chat.util.Utility;
|
||||||
import com.alttd.velocitychat.VelocityChat;
|
import com.alttd.velocitychat.VelocityChat;
|
||||||
import com.alttd.velocitychat.events.GlobalAdminChatEvent;
|
import com.alttd.velocitychat.events.GlobalAdminChatEvent;
|
||||||
import com.alttd.chat.config.Config;
|
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
// TODO code CLEANUP
|
// TODO code CLEANUP
|
||||||
public class ChatListener {
|
public class ChatListener {
|
||||||
|
|
||||||
|
|
@ -36,13 +33,11 @@ public class ChatListener {
|
||||||
serverName = sender.getCurrentServer().isPresent() ? sender.getCurrentServer().get().getServerInfo().getName() : "Altitude";
|
serverName = sender.getCurrentServer().isPresent() ? sender.getCurrentServer().get().getServerInfo().getName() : "Altitude";
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
Component message = Utility.parseMiniMessage(Config.GACFORMAT,
|
||||||
Template.template("sender", senderName),
|
Placeholder.miniMessage("sender", senderName),
|
||||||
Template.template("message", event.getMessage()),
|
Placeholder.miniMessage("message", event.getMessage()),
|
||||||
Template.template("server", serverName)
|
Placeholder.miniMessage("server", serverName)
|
||||||
));
|
);
|
||||||
|
|
||||||
Component message = Utility.parseMiniMessage(Config.GACFORMAT, templates);
|
|
||||||
|
|
||||||
plugin.getProxy().getAllPlayers().stream().filter(target -> target.hasPermission("command.chat.globaladminchat")).forEach(target -> {
|
plugin.getProxy().getAllPlayers().stream().filter(target -> target.hasPermission("command.chat.globaladminchat")).forEach(target -> {
|
||||||
target.sendMessage(message);
|
target.sendMessage(message);
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,10 @@ import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
||||||
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
|
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||||
|
import net.kyori.adventure.text.minimessage.placeholder.Replacement;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ProxyPlayerListener {
|
public class ProxyPlayerListener {
|
||||||
|
|
||||||
|
|
@ -36,9 +35,9 @@ public class ProxyPlayerListener {
|
||||||
if (chatUser == null)
|
if (chatUser == null)
|
||||||
return;
|
return;
|
||||||
VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party,
|
VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party,
|
||||||
Utility.parseMiniMessage(Config.PARTY_MEMBER_LOGGED_ON, List.of(
|
Utility.parseMiniMessage(Config.PARTY_MEMBER_LOGGED_ON,
|
||||||
Template.template("player", chatUser.getDisplayName())
|
Placeholder.component("player", chatUser.getDisplayName())
|
||||||
)),
|
),
|
||||||
chatUser.getIgnoredPlayers());
|
chatUser.getIgnoredPlayers());
|
||||||
// TODO setup ChatUser on Proxy
|
// TODO setup ChatUser on Proxy
|
||||||
//VelocityChat.getPlugin().getChatHandler().addPlayer(new ChatPlayer(event.getPlayer().getUniqueId()));
|
//VelocityChat.getPlugin().getChatHandler().addPlayer(new ChatPlayer(event.getPlayer().getUniqueId()));
|
||||||
|
|
@ -55,9 +54,9 @@ 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, List.of(
|
player.sendMessage(Utility.parseMiniMessage(Config.mailUnread,
|
||||||
Template.template("amount", String.valueOf(unReadMail.size()))
|
Placeholder.miniMessage("amount", String.valueOf(unReadMail.size()))
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
@ -69,9 +68,9 @@ public class ProxyPlayerListener {
|
||||||
if (chatUser == null)
|
if (chatUser == null)
|
||||||
return;
|
return;
|
||||||
VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party,
|
VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party,
|
||||||
Utility.parseMiniMessage(Config.PARTY_MEMBER_LOGGED_OFF, List.of(
|
Utility.parseMiniMessage(Config.PARTY_MEMBER_LOGGED_OFF,
|
||||||
Template.template("player", chatUser.getDisplayName())
|
Placeholder.component("player", chatUser.getDisplayName())
|
||||||
)),
|
),
|
||||||
chatUser.getIgnoredPlayers());
|
chatUser.getIgnoredPlayers());
|
||||||
// TODO setup ChatUser on Proxy
|
// TODO setup ChatUser on Proxy
|
||||||
//VelocityChat.getPlugin().getChatHandler().removePlayer(event.getPlayer().getUniqueId());
|
//VelocityChat.getPlugin().getChatHandler().removePlayer(event.getPlayer().getUniqueId());
|
||||||
|
|
@ -86,25 +85,23 @@ public class ProxyPlayerListener {
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
||||||
Template.template("player", player.getUsername()),
|
placeholders.put("player", Replacement.miniMessage(player.getUsername()));
|
||||||
Template.template("from_server", previousServer.getServerInfo().getName()),
|
placeholders.put("from_server", Replacement.miniMessage(previousServer.getServerInfo().getName()));
|
||||||
Template.template("to_server", event.getServer().getServerInfo().getName())));
|
placeholders.put("to_server", Replacement.miniMessage(event.getServer().getServerInfo().getName()));
|
||||||
|
|
||||||
ServerWrapper wrapper = serverHandler.getWrapper(previousServer.getServerInfo().getName());
|
ServerWrapper wrapper = serverHandler.getWrapper(previousServer.getServerInfo().getName());
|
||||||
if(wrapper != null) {
|
if(wrapper != null) {
|
||||||
wrapper.sendJoinLeaveMessage(event.getPlayer().getUniqueId(), Utility.parseMiniMessage(Config.SERVERSWTICHMESSAGETO, templates));
|
wrapper.sendJoinLeaveMessage(event.getPlayer().getUniqueId(), Utility.parseMiniMessage(Config.SERVERSWTICHMESSAGETO, placeholders));
|
||||||
}
|
}
|
||||||
wrapper = serverHandler.getWrapper(event.getServer().getServerInfo().getName());
|
wrapper = serverHandler.getWrapper(event.getServer().getServerInfo().getName());
|
||||||
if(wrapper != null) {
|
if(wrapper != null) {
|
||||||
wrapper.sendJoinLeaveMessage(event.getPlayer().getUniqueId(), Utility.parseMiniMessage(Config.SERVERSWTICHMESSAGEFROM, templates));
|
wrapper.sendJoinLeaveMessage(event.getPlayer().getUniqueId(), Utility.parseMiniMessage(Config.SERVERSWTICHMESSAGEFROM, placeholders));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
|
||||||
Template.template("player", event.getPlayer().getUsername())
|
|
||||||
));
|
|
||||||
ServerWrapper wrapper = serverHandler.getWrapper(event.getServer().getServerInfo().getName());
|
ServerWrapper wrapper = serverHandler.getWrapper(event.getServer().getServerInfo().getName());
|
||||||
if(wrapper != null) {
|
if(wrapper != null) {
|
||||||
wrapper.sendJoinLeaveMessage(event.getPlayer().getUniqueId(), Utility.parseMiniMessage(Config.SERVERJOINMESSAGE, templates));
|
wrapper.sendJoinLeaveMessage(event.getPlayer().getUniqueId(), Utility.parseMiniMessage(Config.SERVERJOINMESSAGE, Placeholder.miniMessage("player", event.getPlayer().getUsername())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -115,13 +112,12 @@ public class ProxyPlayerListener {
|
||||||
if (event.getLoginStatus().equals(DisconnectEvent.LoginStatus.SUCCESSFUL_LOGIN) && event.getPlayer().getCurrentServer().isPresent()) {
|
if (event.getLoginStatus().equals(DisconnectEvent.LoginStatus.SUCCESSFUL_LOGIN) && event.getPlayer().getCurrentServer().isPresent()) {
|
||||||
RegisteredServer registeredServer = event.getPlayer().getCurrentServer().get().getServer();
|
RegisteredServer registeredServer = event.getPlayer().getCurrentServer().get().getServer();
|
||||||
|
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
|
||||||
Template.template("player", event.getPlayer().getUsername()),
|
|
||||||
Template.template("from_server", registeredServer.getServerInfo().getName())));
|
|
||||||
|
|
||||||
ServerWrapper wrapper = serverHandler.getWrapper(registeredServer.getServerInfo().getName());
|
ServerWrapper wrapper = serverHandler.getWrapper(registeredServer.getServerInfo().getName());
|
||||||
if(wrapper != null) {
|
if(wrapper != null) {
|
||||||
wrapper.sendJoinLeaveMessage(event.getPlayer().getUniqueId(), Utility.parseMiniMessage(Config.SERVERLEAVEMESSAGE, templates));
|
wrapper.sendJoinLeaveMessage(event.getPlayer().getUniqueId(), Utility.parseMiniMessage(Config.SERVERLEAVEMESSAGE,
|
||||||
|
Placeholder.miniMessage("player", event.getPlayer().getUsername()),
|
||||||
|
Placeholder.miniMessage("from_server", registeredServer.getServerInfo().getName())
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user