Fix nicknames and prefixes
This commit is contained in:
@@ -51,6 +51,12 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alttd</groupId>
|
||||
@@ -58,6 +64,18 @@
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.30</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.10</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
|
||||
+16
-2
@@ -67,7 +67,10 @@
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@@ -77,7 +80,7 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency><!--TODO update to version 4.0.0-->
|
||||
<dependency>
|
||||
<groupId>org.spongepowered</groupId>
|
||||
<artifactId>configurate-yaml</artifactId>
|
||||
<version>3.7.1</version>
|
||||
@@ -87,5 +90,16 @@
|
||||
<artifactId>galaxy-api</artifactId>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.10</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -22,5 +22,4 @@ public class Message implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Teri, is Tabcompleter needed here? we already have spigot setup to complete playernames on tab, doesn't work for crossserver stuff and offline players
|
||||
}
|
||||
|
||||
@@ -42,8 +42,6 @@ public class ChatHandler {
|
||||
|
||||
if(!player.hasPermission("chat.format")) {
|
||||
message = miniMessage.stripTokens(message);
|
||||
} else {
|
||||
message = Utility.parseColors(message);
|
||||
}
|
||||
|
||||
if(message.contains("[i]"))
|
||||
@@ -71,16 +69,14 @@ public class ChatHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
Component senderName = player.displayName();
|
||||
String prefix = user.getPrefix();
|
||||
Component senderName = user.getDisplayName();
|
||||
Component prefix = user.getPrefix();
|
||||
|
||||
message = RegexManager.replaceText(message); // todo a better way for this
|
||||
if(message == null) return; // the message was blocked
|
||||
|
||||
if(!player.hasPermission("chat.format")) {
|
||||
message = miniMessage.stripTokens(message);
|
||||
} else {
|
||||
message = Utility.parseColors(message);
|
||||
}
|
||||
|
||||
if(message.contains("[i]"))
|
||||
|
||||
@@ -5,9 +5,9 @@ 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.util.Utility;
|
||||
import io.papermc.paper.chat.ChatRenderer;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
@@ -24,25 +24,12 @@ import java.util.List;
|
||||
public class ChatListener implements Listener, ChatRenderer {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerChat(AsyncChatEvent event) { // this should also include a way to prevent a player from seeing chat
|
||||
// @teri what about mutes?
|
||||
public void onPlayerChat(AsyncChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
||||
|
||||
// tweak this to make this slightly better:/
|
||||
event.viewers().removeIf(audience -> audience instanceof Player
|
||||
&& user.getIgnoredPlayers().contains(((Player) audience).getUniqueId()));
|
||||
/* Set<Audience> viewers = event.viewers();
|
||||
Set<Audience> ignores = new HashSet<>();
|
||||
for(Audience audience : viewers) { // I don't like this setup, might alter this API to expose players...
|
||||
if(audience instanceof Player) { // the player option is removed in 1.17=/ bad paper devs
|
||||
UUID uuid = ((Player) audience).getUniqueId();
|
||||
if(user.getIgnoredPlayers().contains(uuid)) {
|
||||
ignores.add(audience);
|
||||
}
|
||||
}
|
||||
}
|
||||
event.viewers().removeAll(ignores);*/
|
||||
|
||||
Component input = event.message();
|
||||
String message = PlainComponentSerializer.plain().serialize(input);
|
||||
@@ -53,8 +40,6 @@ public class ChatListener implements Listener, ChatRenderer {
|
||||
MiniMessage miniMessage = MiniMessage.get();
|
||||
if(!player.hasPermission("chat.format")) {
|
||||
message = miniMessage.stripTokens(message);
|
||||
} else {
|
||||
message = Utility.parseColors(message);
|
||||
}
|
||||
|
||||
if(message.contains("[i]"))
|
||||
|
||||
@@ -3,7 +3,7 @@ version: ${project.version}
|
||||
main: com.alttd.chat.ChatPlugin
|
||||
api-version: 1.16
|
||||
authors: [Destro, Teriuihi]
|
||||
depend: [LuckPerms]
|
||||
depend: [LuckPerms, PlaceholderAPI]
|
||||
commands:
|
||||
globalchat:
|
||||
permission: command.globalchat
|
||||
|
||||
Reference in New Issue
Block a user