Merge branch 4.9
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user