mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 14:38:49 +00:00
Merge branch 'feature/modules'
This commit is contained in:
commit
6f28851211
64 files changed
+1147
-1216
No files matched your search
@@ -0,0 +1,99 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>SimpleChatParent</artifactId>
|
||||||
|
<groupId>net.draycia</groupId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>SimpleChatModeration</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>SimpleChatModeration</name>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<defaultGoal>clean package</defaultGoal>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.1.1</version>
|
||||||
|
<configuration>
|
||||||
|
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.7.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>testCompile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>testCompile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.draycia</groupId>
|
||||||
|
<artifactId>SimpleChat</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.MilkBowl</groupId>
|
||||||
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
package net.draycia.simplechatmoderation;
|
||||||
|
|
||||||
|
import co.aikar.commands.CommandManager;
|
||||||
|
import net.draycia.simplechat.SimpleChat;
|
||||||
|
import net.draycia.simplechatmoderation.commands.ClearChatCommand;
|
||||||
|
import net.draycia.simplechatmoderation.commands.MuteCommand;
|
||||||
|
import net.draycia.simplechatmoderation.commands.ShadowMuteCommand;
|
||||||
|
import net.draycia.simplechatmoderation.listeners.CapsHandler;
|
||||||
|
import net.draycia.simplechatmoderation.listeners.FilterHandler;
|
||||||
|
import net.draycia.simplechatmoderation.listeners.MuteHandler;
|
||||||
|
import net.draycia.simplechatmoderation.listeners.ShadowMuteHandler;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public final class SimpleChatModeration extends JavaPlugin {
|
||||||
|
|
||||||
|
private SimpleChat simpleChat;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
simpleChat = (SimpleChat)Bukkit.getPluginManager().getPlugin("SimpleChat");
|
||||||
|
|
||||||
|
registerCommands();
|
||||||
|
registerListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerCommands() {
|
||||||
|
CommandManager commandManager = simpleChat.getCommandManager().getCommandManager();
|
||||||
|
|
||||||
|
commandManager.registerCommand(new ClearChatCommand(this));
|
||||||
|
commandManager.registerCommand(new MuteCommand(this));
|
||||||
|
commandManager.registerCommand(new ShadowMuteCommand(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerListeners() {
|
||||||
|
Bukkit.getPluginManager().registerEvents(new CapsHandler(this), this);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new FilterHandler(this), this);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new MuteHandler(), this);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new ShadowMuteHandler(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleChat getSimpleChat() {
|
||||||
|
return simpleChat;
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
-14
@@ -1,14 +1,13 @@
|
|||||||
package net.draycia.simplechat.commands;
|
package net.draycia.simplechatmoderation.commands;
|
||||||
|
|
||||||
import co.aikar.commands.BaseCommand;
|
import co.aikar.commands.BaseCommand;
|
||||||
import co.aikar.commands.CommandIssuer;
|
import co.aikar.commands.CommandIssuer;
|
||||||
import co.aikar.commands.annotation.CommandAlias;
|
import co.aikar.commands.annotation.CommandAlias;
|
||||||
import co.aikar.commands.annotation.CommandPermission;
|
import co.aikar.commands.annotation.CommandPermission;
|
||||||
import co.aikar.commands.annotation.Default;
|
import co.aikar.commands.annotation.Default;
|
||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechatmoderation.SimpleChatModeration;
|
||||||
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 org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -16,38 +15,38 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandPermission("simplechat.clearchat.clear")
|
@CommandPermission("simplechat.clearchat.clear")
|
||||||
public class ClearChatCommand extends BaseCommand {
|
public class ClearChatCommand extends BaseCommand {
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
private SimpleChatModeration moderation;
|
||||||
|
|
||||||
public ClearChatCommand(SimpleChat simpleChat) {
|
public ClearChatCommand(SimpleChatModeration moderation) {
|
||||||
this.simpleChat = simpleChat;
|
this.moderation = moderation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Default
|
@Default
|
||||||
public void baseCommand(CommandIssuer issuer) {
|
public void baseCommand(CommandIssuer issuer) {
|
||||||
String format = simpleChat.getConfig().getString("clear-chat-message", "");
|
String format = moderation.getConfig().getString("clear-chat.message", "");
|
||||||
Component component = MiniMessage.get().parse(format, "br", "\n");
|
Component component = moderation.getSimpleChat().processMessage(format, "br", "\n");
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (player.hasPermission("simplechat.clearchat.exempt")) {
|
if (player.hasPermission("simplechat.clearchat.exempt")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Audience audience = simpleChat.getAudiences().player(player);
|
Audience audience = moderation.getSimpleChat().getAudiences().player(player);
|
||||||
|
|
||||||
for (int i = 0; i < simpleChat.getConfig().getInt("clear-chat-amount", 100); i++) {
|
for (int i = 0; i < moderation.getConfig().getInt("clear-chat.message-count", 100); i++) {
|
||||||
audience.sendMessage(component);
|
audience.sendMessage(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = issuer.isPlayer() ? ((Player)issuer).getName() : "Console";
|
String name = issuer.isPlayer() ? ((Player)issuer).getName() : "Console";
|
||||||
|
|
||||||
if (player.hasPermission("simplechat.clearchat.notify")) {
|
if (player.hasPermission("simplechat.clearchat.notify")) {
|
||||||
String message = simpleChat.getConfig().getString("language.clear-notify");
|
String message = moderation.getConfig().getString("language.clear-notify");
|
||||||
audience.sendMessage(MiniMessage.get().parse(message, "player", name));
|
audience.sendMessage(moderation.getSimpleChat().processMessage(message, "player", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.hasPermission("simplechat.clearchat.exempt")) {
|
if (player.hasPermission("simplechat.clearchat.exempt")) {
|
||||||
String message = simpleChat.getConfig().getString("language.clear-exempt");
|
String message = moderation.getConfig().getString("language.clear-exempt");
|
||||||
audience.sendMessage(MiniMessage.get().parse(message, "player", name));
|
audience.sendMessage(moderation.getSimpleChat().processMessage(message, "player", name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package net.draycia.simplechatmoderation.commands;
|
||||||
|
|
||||||
|
import co.aikar.commands.BaseCommand;
|
||||||
|
import co.aikar.commands.annotation.CommandAlias;
|
||||||
|
import co.aikar.commands.annotation.CommandCompletion;
|
||||||
|
import co.aikar.commands.annotation.CommandPermission;
|
||||||
|
import co.aikar.commands.annotation.Default;
|
||||||
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
|
import net.draycia.simplechatmoderation.SimpleChatModeration;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
@CommandAlias("mute")
|
||||||
|
@CommandPermission("simplechat.mute")
|
||||||
|
public class MuteCommand extends BaseCommand {
|
||||||
|
|
||||||
|
private SimpleChatModeration moderation;
|
||||||
|
|
||||||
|
public MuteCommand(SimpleChatModeration moderation) {
|
||||||
|
this.moderation = moderation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Default
|
||||||
|
@CommandCompletion("@players")
|
||||||
|
public void baseCommand(CommandSender sender, ChatUser targetUser) {
|
||||||
|
String format;
|
||||||
|
|
||||||
|
if (targetUser.isMuted()) {
|
||||||
|
targetUser.setMuted(false);
|
||||||
|
format = moderation.getConfig().getString("language.no-longer-muted");
|
||||||
|
} else {
|
||||||
|
Permission permission = moderation.getSimpleChat().getPermission();
|
||||||
|
|
||||||
|
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "simplechat.mute.exempt")) {
|
||||||
|
format = moderation.getConfig().getString("language.mute-exempt");
|
||||||
|
} else {
|
||||||
|
targetUser.setMuted(true);
|
||||||
|
format = moderation.getConfig().getString("language.is-now-muted");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component message = moderation.getSimpleChat().processMessage(format, "br", "\n",
|
||||||
|
"player", targetUser.asOfflinePlayer().getName());
|
||||||
|
|
||||||
|
moderation.getSimpleChat().getAudiences().audience(sender).sendMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package net.draycia.simplechatmoderation.commands;
|
||||||
|
|
||||||
|
import co.aikar.commands.BaseCommand;
|
||||||
|
import co.aikar.commands.annotation.CommandAlias;
|
||||||
|
import co.aikar.commands.annotation.CommandCompletion;
|
||||||
|
import co.aikar.commands.annotation.CommandPermission;
|
||||||
|
import co.aikar.commands.annotation.Default;
|
||||||
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
|
import net.draycia.simplechatmoderation.SimpleChatModeration;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
@CommandAlias("shadowmute|sm|smute")
|
||||||
|
@CommandPermission("simplechat.shadowmute")
|
||||||
|
public class ShadowMuteCommand extends BaseCommand {
|
||||||
|
|
||||||
|
private SimpleChatModeration moderation;
|
||||||
|
|
||||||
|
public ShadowMuteCommand(SimpleChatModeration moderation) {
|
||||||
|
this.moderation = moderation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Default
|
||||||
|
@CommandCompletion("@players")
|
||||||
|
public void baseCommand(CommandSender sender, ChatUser targetUser) {
|
||||||
|
String format;
|
||||||
|
|
||||||
|
if (targetUser.isShadowMuted()) {
|
||||||
|
targetUser.setShadowMuted(false);
|
||||||
|
format = moderation.getConfig().getString("language.no-longer-shadow-muted");
|
||||||
|
} else {
|
||||||
|
Permission permission = moderation.getSimpleChat().getPermission();
|
||||||
|
|
||||||
|
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "simplechat.shadowmute.exempt")) {
|
||||||
|
format = moderation.getConfig().getString("language.shadow-mute-exempt");
|
||||||
|
} else {
|
||||||
|
targetUser.setShadowMuted(true);
|
||||||
|
format = moderation.getConfig().getString("language.is-now-shadow-muted");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component message = moderation.getSimpleChat().processMessage(format, "br", "\n",
|
||||||
|
"player", targetUser.asOfflinePlayer().getName());
|
||||||
|
|
||||||
|
moderation.getSimpleChat().getAudiences().audience(sender).sendMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+9
-9
@@ -1,26 +1,26 @@
|
|||||||
package net.draycia.simplechat.listeners;
|
package net.draycia.simplechatmoderation.listeners;
|
||||||
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.events.ChatFormatEvent;
|
import net.draycia.simplechat.events.ChatFormatEvent;
|
||||||
|
import net.draycia.simplechatmoderation.SimpleChatModeration;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
public class CapsHandler implements Listener {
|
public class CapsHandler implements Listener {
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
private SimpleChatModeration moderation;
|
||||||
|
|
||||||
public CapsHandler(SimpleChat simpleChat) {
|
public CapsHandler(SimpleChatModeration moderation) {
|
||||||
this.simpleChat = simpleChat;
|
this.moderation = moderation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onMessage(ChatFormatEvent event) {
|
public void onMessage(ChatFormatEvent event) {
|
||||||
if (!simpleChat.getConfig().getBoolean("caps-protection.enabled")) {
|
if (!moderation.getConfig().getBoolean("caps-protection.enabled")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(event.getMessage().length() >= simpleChat.getConfig().getInt("caps-protection.minimum-length"))) {
|
if (!(event.getMessage().length() >= moderation.getConfig().getInt("caps-protection.minimum-length"))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,11 +34,11 @@ public class CapsHandler implements Listener {
|
|||||||
|
|
||||||
double capsPercentage = (amountOfCaps * 100.0) / event.getMessage().length();
|
double capsPercentage = (amountOfCaps * 100.0) / event.getMessage().length();
|
||||||
|
|
||||||
if (!(capsPercentage >= simpleChat.getConfig().getDouble("caps-protection.percent-caps"))) {
|
if (!(capsPercentage >= moderation.getConfig().getDouble("caps-protection.percent-caps"))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (simpleChat.getConfig().getBoolean("block-message")) {
|
if (moderation.getConfig().getBoolean("block-message")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else {
|
} else {
|
||||||
event.setMessage(event.getMessage().toLowerCase());
|
event.setMessage(event.getMessage().toLowerCase());
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package net.draycia.simplechatmoderation.listeners;
|
||||||
|
|
||||||
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
|
import net.draycia.simplechat.events.ChatFormatEvent;
|
||||||
|
import net.draycia.simplechatmoderation.SimpleChatModeration;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FilterHandler implements Listener {
|
||||||
|
|
||||||
|
private SimpleChatModeration moderation;
|
||||||
|
|
||||||
|
public FilterHandler(SimpleChatModeration moderation) {
|
||||||
|
this.moderation = moderation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onFilter(ChatFormatEvent event) {
|
||||||
|
if (!moderation.getConfig().getBoolean("filters.enabled")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String filterText = moderation.getConfig().getString("filters.filter-text", "****");
|
||||||
|
|
||||||
|
if (channelUsesFilter(event.getChatChannel())) {
|
||||||
|
for (String entry : moderation.getConfig().getStringList("filters.filtered-words")) {
|
||||||
|
event.setMessage(event.getMessage().replaceAll(entry, filterText));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean channelUsesFilter(ChatChannel chatChannel) {
|
||||||
|
List<String> channels = moderation.getConfig().getStringList("filters.channels");
|
||||||
|
|
||||||
|
return channels.contains("*") || channels.contains(chatChannel.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package net.draycia.simplechat.listeners;
|
package net.draycia.simplechatmoderation.listeners;
|
||||||
|
|
||||||
import net.draycia.simplechat.events.ChatFormatEvent;
|
import net.draycia.simplechat.events.ChatFormatEvent;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package net.draycia.simplechat.listeners;
|
package net.draycia.simplechatmoderation.listeners;
|
||||||
|
|
||||||
import net.draycia.simplechat.events.ChatComponentEvent;
|
import net.draycia.simplechat.events.ChatComponentEvent;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
caps-protection:
|
||||||
|
enabled: true
|
||||||
|
minimum-length: 10
|
||||||
|
percent-caps: 80
|
||||||
|
block-message: false
|
||||||
|
|
||||||
|
filters:
|
||||||
|
enabled: true
|
||||||
|
filter-text: '****'
|
||||||
|
filtered-words:
|
||||||
|
- 'lag'
|
||||||
|
- 'la[g]+'
|
||||||
|
channels:
|
||||||
|
- '*' # Use '*' to mean all channels
|
||||||
|
|
||||||
|
clear-chat:
|
||||||
|
# The message sent to clear chat, you probably want to leave this blank
|
||||||
|
message: ""
|
||||||
|
# How many messages will be sent in order to clear chat
|
||||||
|
message-count: 100
|
||||||
|
|
||||||
|
language:
|
||||||
|
is-now-shadow-muted: '<yellow>Player <player> is now shadow muted!'
|
||||||
|
no-longer-shadow-muted: '<yellow>Player <player> is no longer shadow muted!'
|
||||||
|
shadow-mute-exempt: '<red>Player <player> is exempt from being shadow muted!'
|
||||||
|
is-now-muted: '<yellow>Player <player> is now muted!'
|
||||||
|
no-longer-muted: '<yellow>Player <player> is no longer muted!'
|
||||||
|
mute-exempt: '<red>Player <player> is exempt from being muted!'
|
||||||
|
reloaded: '<yellow>ChatModeration config has been reloaded!'
|
||||||
|
clear-notify: '<yellow>Chat has been cleared by <player>.'
|
||||||
|
clear-exempt: '<yellow>You were exempt from the clear due to your permissions!'
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
name: SimpleChatModeration
|
||||||
|
version: ${project.version}
|
||||||
|
main: net.draycia.simplechatmoderation.SimpleChatModeration
|
||||||
|
api-version: 1.16
|
||||||
|
depend: [SimpleChat]
|
||||||
@@ -0,0 +1,255 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>SimpleChatParent</artifactId>
|
||||||
|
<groupId>net.draycia</groupId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>SimpleChat</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>SimpleChat</name>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<defaultGoal>clean package</defaultGoal>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.1.1</version>
|
||||||
|
<configuration>
|
||||||
|
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.7.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>testCompile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>testCompile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<!-- Spigot API -->
|
||||||
|
<repository>
|
||||||
|
<id>spigotmc-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<!-- Kyori -->
|
||||||
|
<repository>
|
||||||
|
<id>sonatype</id>
|
||||||
|
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<!-- PlaceholderAPI -->
|
||||||
|
<repository>
|
||||||
|
<id>placeholderapi</id>
|
||||||
|
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<!-- Towny, VaultAPI -->
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<!-- ACF -->
|
||||||
|
<repository>
|
||||||
|
<id>aikar</id>
|
||||||
|
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<!-- NuVotifier -->
|
||||||
|
<repository>
|
||||||
|
<id>bintray-repo</id>
|
||||||
|
<url>https://dl.bintray.com/ichbinjoe/public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<!-- BungeeChannelAPI -->
|
||||||
|
<repository>
|
||||||
|
<id>codemc-repo</id>
|
||||||
|
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<!-- MineDown -->
|
||||||
|
<repository>
|
||||||
|
<id>minebench-repo</id>
|
||||||
|
<url>http://repo.minebench.de/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<!-- mcMMO and MiniMessage must be compiled locally -->
|
||||||
|
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- ACF - command framework -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>co.aikar</groupId>
|
||||||
|
<artifactId>acf-bukkit</artifactId>
|
||||||
|
<version>0.5.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Components and formatting -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-api</artifactId>
|
||||||
|
<version>4.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-nbt</artifactId>
|
||||||
|
<version>4.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-platform-bukkit</artifactId>
|
||||||
|
<version>4.0.0-SNAPSHOT</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<!-- Must be built locally for the time being -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-text-minimessage</artifactId>
|
||||||
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MineDown, alternative to MiniMessage -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.themoep</groupId>
|
||||||
|
<artifactId>minedown</artifactId>
|
||||||
|
<version>1.6.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Database stuff -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>co.aikar</groupId>
|
||||||
|
<artifactId>idb-bukkit</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zaxxer</groupId>
|
||||||
|
<artifactId>HikariCP</artifactId>
|
||||||
|
<version>2.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Easier bungee handling -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.leonardosnt</groupId>
|
||||||
|
<artifactId>bungeechannelapi</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Redis -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.lettuce</groupId>
|
||||||
|
<artifactId>lettuce-core</artifactId>
|
||||||
|
<version>6.0.0.M1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Placeholders -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.clip</groupId>
|
||||||
|
<artifactId>placeholderapi</artifactId>
|
||||||
|
<version>2.10.6</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Towny chats - nation & town -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TownyAdvanced</groupId>
|
||||||
|
<artifactId>Towny</artifactId>
|
||||||
|
<version>0.96.1.11</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mcMMO - no repository, add to maven local -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||||
|
<artifactId>mcMMO</artifactId>
|
||||||
|
<version>2.1.130</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Vault for permissions / groups -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.MilkBowl</groupId>
|
||||||
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- NuVotifier for vote messages in discord bridge -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vexsoftware</groupId>
|
||||||
|
<artifactId>nuvotifier-universal</artifactId>
|
||||||
|
<version>2.6.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- LuckPerms for custom contexts -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.luckperms</groupId>
|
||||||
|
<artifactId>api</artifactId>
|
||||||
|
<version>5.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
+24
-31
@@ -1,6 +1,7 @@
|
|||||||
package net.draycia.simplechat;
|
package net.draycia.simplechat;
|
||||||
|
|
||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import de.themoep.minedown.MineDown;
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import net.draycia.simplechat.listeners.*;
|
import net.draycia.simplechat.listeners.*;
|
||||||
import net.draycia.simplechat.managers.*;
|
import net.draycia.simplechat.managers.*;
|
||||||
import net.draycia.simplechat.storage.UserService;
|
import net.draycia.simplechat.storage.UserService;
|
||||||
@@ -8,7 +9,11 @@ import net.draycia.simplechat.storage.impl.JSONUserService;
|
|||||||
import net.draycia.simplechat.storage.impl.MySQLUserService;
|
import net.draycia.simplechat.storage.impl.MySQLUserService;
|
||||||
import net.draycia.simplechat.util.ItemStackUtils;
|
import net.draycia.simplechat.util.ItemStackUtils;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
import net.kyori.adventure.text.serializer.bungeecord.BungeeCordComponentSerializer;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@@ -17,7 +22,6 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public final class SimpleChat extends JavaPlugin {
|
public final class SimpleChat extends JavaPlugin {
|
||||||
|
|
||||||
private ArrayList<ChatChannel> channels = new ArrayList<>();
|
|
||||||
private ArrayList<Pattern> itemPatterns = new ArrayList<>();
|
private ArrayList<Pattern> itemPatterns = new ArrayList<>();
|
||||||
|
|
||||||
private Permission permission;
|
private Permission permission;
|
||||||
@@ -85,16 +89,13 @@ public final class SimpleChat extends JavaPlugin {
|
|||||||
|
|
||||||
// Register chat listeners
|
// Register chat listeners
|
||||||
pluginManager.registerEvents(new BukkitChatListener(this), this);
|
pluginManager.registerEvents(new BukkitChatListener(this), this);
|
||||||
pluginManager.registerEvents(new FilterHandler(this), this);
|
|
||||||
pluginManager.registerEvents(new ItemLinkHandler(this), this);
|
pluginManager.registerEvents(new ItemLinkHandler(this), this);
|
||||||
pluginManager.registerEvents(new LegacyFormatHandler(), this);
|
pluginManager.registerEvents(new LegacyFormatHandler(), this);
|
||||||
pluginManager.registerEvents(new MuteHandler(), this);
|
|
||||||
pluginManager.registerEvents(new OfflineNameHandler(), this);
|
pluginManager.registerEvents(new OfflineNameHandler(), this);
|
||||||
pluginManager.registerEvents(new PingHandler(this), this);
|
pluginManager.registerEvents(new PingHandler(this), this);
|
||||||
pluginManager.registerEvents(new PlaceholderHandler(this), this);
|
pluginManager.registerEvents(new PlaceholderHandler(this), this);
|
||||||
pluginManager.registerEvents(new ShadowMuteHandler(), this);
|
|
||||||
pluginManager.registerEvents(new EmptyChatHandler(this), this);
|
pluginManager.registerEvents(new EmptyChatHandler(this), this);
|
||||||
pluginManager.registerEvents(new CapsHandler(this), this);
|
pluginManager.registerEvents(new UserFormattingListener(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadPatterns() {
|
public void reloadPatterns() {
|
||||||
@@ -105,32 +106,24 @@ public final class SimpleChat extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatChannel getDefaultChannel() {
|
public Component processMessageWithPapi(Player player, String input, String... placeholders) {
|
||||||
for (ChatChannel channel : channels) {
|
return processMessage(PlaceholderAPI.setPlaceholders(player, input), placeholders);
|
||||||
if (channel.isDefault()) {
|
|
||||||
return channel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return channels.get(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatChannel getChannel(String name) {
|
public Component processMessage(String input, String... placeholders) {
|
||||||
if (name == null) {
|
switch (getConfig().getString("formatting.type", "minimessage").toLowerCase()) {
|
||||||
return getDefaultChannel();
|
case "minedown":
|
||||||
|
return processMineDown(input, placeholders);
|
||||||
|
case "minimessage-markdown":
|
||||||
|
return MiniMessage.markdown().parse(input, placeholders);
|
||||||
|
case "minimessage":
|
||||||
|
default:
|
||||||
|
return MiniMessage.get().parse(input, placeholders);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ChatChannel chatChannel : channels) {
|
|
||||||
if (chatChannel.getName().equalsIgnoreCase(name)) {
|
|
||||||
return chatChannel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return getDefaultChannel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ChatChannel> getChannels() {
|
private Component processMineDown(String input, String... placeholders) {
|
||||||
return channels;
|
return BungeeCordComponentSerializer.get().deserialize(MineDown.parse(input, placeholders));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Permission getPermission() {
|
public Permission getPermission() {
|
||||||
@@ -149,6 +142,10 @@ public final class SimpleChat extends JavaPlugin {
|
|||||||
return pluginMessageManager;
|
return pluginMessageManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RedisManager getRedisManager() {
|
||||||
|
return redisManager;
|
||||||
|
}
|
||||||
|
|
||||||
public UserService getUserService() {
|
public UserService getUserService() {
|
||||||
return userService;
|
return userService;
|
||||||
}
|
}
|
||||||
@@ -160,8 +157,4 @@ public final class SimpleChat extends JavaPlugin {
|
|||||||
public ItemStackUtils getItemStackUtils() {
|
public ItemStackUtils getItemStackUtils() {
|
||||||
return itemStackUtils;
|
return itemStackUtils;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RedisManager getRedisManager() {
|
|
||||||
return redisManager;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package net.draycia.simplechat.channels;
|
||||||
|
|
||||||
|
import co.aikar.commands.CommandManager;
|
||||||
|
import net.draycia.simplechat.SimpleChat;
|
||||||
|
import net.draycia.simplechat.commands.AliasedChannelCommand;
|
||||||
|
import net.draycia.simplechat.util.Registry;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ChannelRegistry implements Registry<ChatChannel> {
|
||||||
|
|
||||||
|
private Map<String, ChatChannel> registry = new HashMap<>();
|
||||||
|
private SimpleChat simpleChat;
|
||||||
|
|
||||||
|
public ChannelRegistry(SimpleChat simpleChat) {
|
||||||
|
this.simpleChat = simpleChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean register(@NotNull String key, @NotNull ChatChannel value) {
|
||||||
|
boolean registerSuccessful = registry.putIfAbsent(key, value) == null;
|
||||||
|
|
||||||
|
if (registerSuccessful) {
|
||||||
|
CommandManager commandManager = simpleChat.getCommandManager().getCommandManager();
|
||||||
|
|
||||||
|
commandManager.getCommandReplacements().addReplacement("channelName", value.getAliases());
|
||||||
|
commandManager.registerCommand(new AliasedChannelCommand(simpleChat, value));
|
||||||
|
|
||||||
|
if (value instanceof Listener) {
|
||||||
|
Bukkit.getPluginManager().registerEvents((Listener)value, simpleChat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return registerSuccessful;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public Collection<ChatChannel> values() {
|
||||||
|
return registry.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public ChatChannel get(String key) {
|
||||||
|
return registry.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+13
-39
@@ -1,13 +1,11 @@
|
|||||||
package net.draycia.simplechat.channels;
|
package net.draycia.simplechat.channels;
|
||||||
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.events.ChatFormatEvent;
|
import net.draycia.simplechat.events.ChatFormatEvent;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public abstract class ChatChannel {
|
public abstract class ChatChannel {
|
||||||
@@ -25,24 +23,28 @@ public abstract class ChatChannel {
|
|||||||
/**
|
/**
|
||||||
* @return If this is the default (typically Global) channel players use when they're in no other channel.
|
* @return If this is the default (typically Global) channel players use when they're in no other channel.
|
||||||
*/
|
*/
|
||||||
public abstract boolean isDefault();
|
public abstract Boolean isDefault();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return If this channel can be toggled off and if players can ignore player messages in this channel.
|
* @return If this channel can be toggled off and if players can ignore player messages in this channel.
|
||||||
*/
|
*/
|
||||||
public abstract boolean isIgnorable();
|
public abstract Boolean isIgnorable();
|
||||||
|
|
||||||
public abstract boolean shouldBungee();
|
public abstract Boolean shouldBungee();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The name of this channel.
|
* @return The name of this channel.
|
||||||
*/
|
*/
|
||||||
public abstract String getName();
|
public abstract String getName();
|
||||||
|
|
||||||
|
public abstract String getKey();
|
||||||
|
|
||||||
|
public abstract String getAliases();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The distance other players must be within to the sender to see messages in this channel.
|
* @return The distance other players must be within to the sender to see messages in this channel.
|
||||||
*/
|
*/
|
||||||
public abstract double getDistance();
|
public abstract Double getDistance();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The message to be sent to the player when switching to this channel.
|
* @return The message to be sent to the player when switching to this channel.
|
||||||
@@ -67,51 +69,23 @@ public abstract class ChatChannel {
|
|||||||
|
|
||||||
public abstract String getToggleOtherOffMessage();
|
public abstract String getToggleOtherOffMessage();
|
||||||
|
|
||||||
public abstract boolean filterEnabled();
|
public abstract String getCannotUseMessage();
|
||||||
|
|
||||||
/**
|
public abstract Boolean firstMatchingGroup();
|
||||||
* @return If this channel is Towny's town chat.
|
|
||||||
*/
|
|
||||||
public boolean isTownChat() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return If this channel is Towny's nation chat.
|
|
||||||
*/
|
|
||||||
public boolean isNationChat() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return If this channel is a Towny alliance chat.
|
|
||||||
*/
|
|
||||||
public boolean isAllianceChat() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return If this channel is mcMMO's party chat.
|
|
||||||
*/
|
|
||||||
public boolean isPartyChat() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract boolean firstMatchingGroup();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return If the player can use this channel.
|
* @return If the player can use this channel.
|
||||||
*/
|
*/
|
||||||
public abstract boolean canPlayerUse(ChatUser user);
|
public abstract Boolean canPlayerUse(ChatUser user);
|
||||||
|
|
||||||
public abstract boolean canPlayerSee(ChatUser sender, ChatUser target, boolean checkSpying);
|
public abstract Boolean canPlayerSee(ChatUser sender, ChatUser target, boolean checkSpying);
|
||||||
|
|
||||||
public abstract List<ChatUser> getAudience(ChatUser user);
|
public abstract List<ChatUser> getAudience(ChatUser user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return If the channel should forward its formatting / formatted message to other servers
|
* @return If the channel should forward its formatting / formatted message to other servers
|
||||||
*/
|
*/
|
||||||
public boolean shouldForwardFormatting() {
|
public Boolean shouldForwardFormatting() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
+98
-58
@@ -5,10 +5,10 @@ import net.draycia.simplechat.channels.ChatChannel;
|
|||||||
import net.draycia.simplechat.events.ChatComponentEvent;
|
import net.draycia.simplechat.events.ChatComponentEvent;
|
||||||
import net.draycia.simplechat.events.ChatFormatEvent;
|
import net.draycia.simplechat.events.ChatFormatEvent;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
|
import net.kyori.adventure.audience.MessageType;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -36,11 +36,12 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getDiscordFormatting() {
|
private String getDiscordFormatting() {
|
||||||
return getFormats().getOrDefault("discord-to-mc", "<gray>[<blue>Discord<gray>] <username><white>: <message>");
|
return getFormats().getOrDefault("discord-to-mc",
|
||||||
|
"<gray>[<blue>Discord<gray>] <username><white>: <message>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayerUse(ChatUser user) {
|
public Boolean canPlayerUse(ChatUser user) {
|
||||||
return user.asPlayer().hasPermission("simplechat.channels." + getName() + ".use");
|
return user.asPlayer().hasPermission("simplechat.channels." + getName() + ".use");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +73,7 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get formatted message
|
// Get formatted message
|
||||||
TextComponent formattedMessage = (TextComponent)MiniMessage.get().parse(formatEvent.getFormat(),
|
TextComponent formattedMessage = (TextComponent)simpleChat.processMessage(formatEvent.getFormat(),
|
||||||
"br", "\n",
|
"br", "\n",
|
||||||
"color", "<color:" + getColor().toString() + ">",
|
"color", "<color:" + getColor().toString() + ">",
|
||||||
"phase", Long.toString(System.currentTimeMillis() % 25),
|
"phase", Long.toString(System.currentTimeMillis() % 25),
|
||||||
@@ -80,7 +81,8 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
"message", formatEvent.getMessage());
|
"message", formatEvent.getMessage());
|
||||||
|
|
||||||
// Call custom chat event
|
// Call custom chat event
|
||||||
ChatComponentEvent componentEvent = new ChatComponentEvent(user, this, formattedMessage, formatEvent.getMessage(), getAudience(user));
|
ChatComponentEvent componentEvent = new ChatComponentEvent(user, this, formattedMessage,
|
||||||
|
formatEvent.getMessage(), getAudience(user));
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(componentEvent);
|
Bukkit.getPluginManager().callEvent(componentEvent);
|
||||||
|
|
||||||
@@ -90,33 +92,22 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
|
|
||||||
TextColor userColor = chatUser.getChannelSettings(this).getColor();
|
TextColor userColor = chatUser.getChannelSettings(this).getColor();
|
||||||
|
|
||||||
String prefix;
|
String prefix = processPlaceholders(user, simpleChat.getConfig().getString("spy-prefix"));
|
||||||
|
|
||||||
if (isNationChat()) {
|
|
||||||
prefix = simpleChat.getConfig().getString("spy-prefix-nation");
|
|
||||||
} else if (isTownChat()) {
|
|
||||||
prefix = simpleChat.getConfig().getString("spy-prefix-town");
|
|
||||||
} else if (isPartyChat()) {
|
|
||||||
prefix = simpleChat.getConfig().getString("spy-prefix-mcmmo");
|
|
||||||
} else {
|
|
||||||
prefix = simpleChat.getConfig().getString("spy-prefix");
|
|
||||||
}
|
|
||||||
|
|
||||||
prefix = processPlaceholders(user, prefix);
|
|
||||||
|
|
||||||
if (userColor == null) {
|
if (userColor == null) {
|
||||||
if (isUserSpying(user, chatUser)) {
|
if (isUserSpying(user, chatUser)) {
|
||||||
prefix = prefix.replace("<color>", "<color:" + getColor() + ">");
|
prefix = prefix.replace("<color>", "<color:" + getColor() + ">");
|
||||||
|
|
||||||
chatUser.sendMessage(MiniMessage.get().parse(prefix).append(componentEvent.getComponent()));
|
chatUser.sendMessage(simpleChat.processMessage(prefix).append(componentEvent.getComponent()), MessageType.CHAT);
|
||||||
} else if (componentEvent.getRecipients().contains(chatUser)) {
|
} else if (componentEvent.getRecipients().contains(chatUser)) {
|
||||||
chatUser.sendMessage(componentEvent.getComponent());
|
chatUser.sendMessage(componentEvent.getComponent(), MessageType.CHAT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
prefix = prefix.replace("<color>", "<color:" + chatUser.getChannelSettings(this).getColor().asHexString() + ">");
|
prefix = prefix.replace("<color>", "<color:" +
|
||||||
|
chatUser.getChannelSettings(this).getColor().asHexString() + ">");
|
||||||
String format = formatEvent.getFormat();
|
String format = formatEvent.getFormat();
|
||||||
|
|
||||||
TextComponent newFormat = (TextComponent)MiniMessage.get().parse(format,
|
TextComponent newFormat = (TextComponent)simpleChat.processMessage(format,
|
||||||
"br", "\n",
|
"br", "\n",
|
||||||
"color", "<color:" + userColor.toString() + ">",
|
"color", "<color:" + userColor.toString() + ">",
|
||||||
"phase", Long.toString(System.currentTimeMillis() % 25),
|
"phase", Long.toString(System.currentTimeMillis() % 25),
|
||||||
@@ -124,17 +115,18 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
"message", formatEvent.getMessage());
|
"message", formatEvent.getMessage());
|
||||||
|
|
||||||
if (isUserSpying(user, chatUser)) {
|
if (isUserSpying(user, chatUser)) {
|
||||||
newFormat = (TextComponent)MiniMessage.get().parse(prefix, "br", "\n")
|
newFormat = (TextComponent)simpleChat.processMessage(prefix, "br", "\n")
|
||||||
.append(newFormat);
|
.append(newFormat);
|
||||||
} else if (!componentEvent.getRecipients().contains(chatUser)) {
|
} else if (!componentEvent.getRecipients().contains(chatUser)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatComponentEvent newEvent = new ChatComponentEvent(user, this, newFormat, formatEvent.getMessage(), Collections.singletonList(chatUser));
|
ChatComponentEvent newEvent = new ChatComponentEvent(user, this, newFormat,
|
||||||
|
formatEvent.getMessage(), Collections.singletonList(chatUser), true);
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(newEvent);
|
Bukkit.getPluginManager().callEvent(newEvent);
|
||||||
|
|
||||||
chatUser.sendMessage(newEvent.getComponent());
|
chatUser.sendMessage(newEvent.getComponent(), MessageType.CHAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +202,7 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
return getFormat(group);
|
return getFormat(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canPlayerSee(ChatUser sender, ChatUser target, boolean checkSpying) {
|
public Boolean canPlayerSee(ChatUser sender, ChatUser target, boolean checkSpying) {
|
||||||
Player targetPlayer = target.asPlayer();
|
Player targetPlayer = target.asPlayer();
|
||||||
|
|
||||||
if (checkSpying && targetPlayer.hasPermission("simplechat.spy." + getName())) {
|
if (checkSpying && targetPlayer.hasPermission("simplechat.spy." + getName())) {
|
||||||
@@ -258,7 +250,8 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
public Map<String, String> getFormats() {
|
public Map<String, String> getFormats() {
|
||||||
HashMap<String, String> formats = new HashMap<>();
|
HashMap<String, String> formats = new HashMap<>();
|
||||||
|
|
||||||
ConfigurationSection section = simpleChat.getConfig().getConfigurationSection("channels").getConfigurationSection(getKey());
|
ConfigurationSection channelsSection = simpleChat.getConfig().getConfigurationSection("channels");
|
||||||
|
ConfigurationSection section = channelsSection.getConfigurationSection(getKey());
|
||||||
ConfigurationSection formatSection = section.getConfigurationSection("formats");
|
ConfigurationSection formatSection = section.getConfigurationSection("formats");
|
||||||
|
|
||||||
if (formatSection == null) {
|
if (formatSection == null) {
|
||||||
@@ -274,84 +267,84 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextColor getColor() {
|
public TextColor getColor() {
|
||||||
return TextColor.fromHexString((String) getSetting("color"));
|
return TextColor.fromHexString(getString("color"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFormat(String group) {
|
public String getFormat(String group) {
|
||||||
return getFormats().getOrDefault(group, getFormats().getOrDefault("default", "<white><%player_displayname%<white>> <message>"));
|
return getFormats().getOrDefault(group, getFormats().getOrDefault("default",
|
||||||
|
"<white><%player_displayname%<white>> <message>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDefault() {
|
public Boolean isDefault() {
|
||||||
return (Boolean) getSetting("default");
|
return getBoolean("default");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isIgnorable() {
|
public Boolean isIgnorable() {
|
||||||
return (Boolean)getSetting("ignorable");
|
return getBoolean("ignorable");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldBungee() {
|
public Boolean shouldBungee() {
|
||||||
return (Boolean) getSetting("should-bungee");
|
return getBoolean("should-bungee");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
String name = (String) getSetting("name");
|
String name = getString("name");
|
||||||
return name == null ? key : name;
|
return name == null ? key : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getDistance() {
|
public Double getDistance() {
|
||||||
return (Integer) getSetting("distance");
|
return getDouble("distance");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSwitchMessage() {
|
public String getSwitchMessage() {
|
||||||
return (String) getSetting("switch-message");
|
return getString("switch-message");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSwitchOtherMessage() {
|
public String getSwitchOtherMessage() {
|
||||||
return (String) getSetting("switch-other-message");
|
return getString("switch-other-message");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getToggleOffMessage() {
|
public String getToggleOffMessage() {
|
||||||
return (String) getSetting("toggle-off-message");
|
return getString("toggle-off-message");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getToggleOnMessage() {
|
public String getToggleOnMessage() {
|
||||||
return (String) getSetting("toggle-on-message");
|
return getString("toggle-on-message");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getToggleOtherOnMessage() {
|
public String getToggleOtherOnMessage() {
|
||||||
return (String) getSetting("toggle-other-on");
|
return getString("toggle-other-on");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getToggleOtherOffMessage() {
|
public String getToggleOtherOffMessage() {
|
||||||
return (String) getSetting("toggle-other-off");
|
return getString("toggle-other-off");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldForwardFormatting() {
|
public String getCannotUseMessage() {
|
||||||
return (Boolean) getSetting("forward-format");
|
return getString("cannot-use-channel");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean filterEnabled() {
|
public Boolean shouldForwardFormatting() {
|
||||||
return (Boolean) getSetting("filter-enabled");
|
return getBoolean("forward-format");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean firstMatchingGroup() {
|
public Boolean firstMatchingGroup() {
|
||||||
return (Boolean) getSetting("first-matching-group");
|
return getBoolean("first-matching-group");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -365,24 +358,71 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
return itemPatterns;
|
return itemPatterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getSetting(String key) {
|
private String getString(String key) {
|
||||||
ConfigurationSection section = simpleChat.getConfig().getConfigurationSection("channels").getConfigurationSection(getKey());
|
ConfigurationSection channelsSection = simpleChat.getConfig().getConfigurationSection("channels");
|
||||||
|
ConfigurationSection section = channelsSection.getConfigurationSection(getKey());
|
||||||
|
|
||||||
if (section.contains(key)) {
|
if (section != null && section.contains(key)) {
|
||||||
return section.get(key);
|
return section.getString(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationSection defaultSection = simpleChat.getConfig().getConfigurationSection("default");
|
ConfigurationSection defaultSection = simpleChat.getConfig().getConfigurationSection("default");
|
||||||
|
|
||||||
if (defaultSection.contains(key)) {
|
if (defaultSection != null && defaultSection.contains(key)) {
|
||||||
return defaultSection.get(key);
|
return defaultSection.getString(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getBoolean(String key) {
|
||||||
|
ConfigurationSection channelsSection = simpleChat.getConfig().getConfigurationSection("channels");
|
||||||
|
ConfigurationSection section = channelsSection.getConfigurationSection(getKey());
|
||||||
|
|
||||||
|
if (section != null && section.contains(key)) {
|
||||||
|
return section.getBoolean(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigurationSection defaultSection = simpleChat.getConfig().getConfigurationSection("default");
|
||||||
|
|
||||||
|
if (defaultSection != null && defaultSection.contains(key)) {
|
||||||
|
return defaultSection.getBoolean(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getKey() {
|
private double getDouble(String key) {
|
||||||
|
ConfigurationSection channelsSection = simpleChat.getConfig().getConfigurationSection("channels");
|
||||||
|
ConfigurationSection section = channelsSection.getConfigurationSection(getKey());
|
||||||
|
|
||||||
|
if (section != null && section.contains(key)) {
|
||||||
|
return section.getDouble(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigurationSection defaultSection = simpleChat.getConfig().getConfigurationSection("default");
|
||||||
|
|
||||||
|
if (defaultSection != null && defaultSection.contains(key)) {
|
||||||
|
return defaultSection.getDouble(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAliases() {
|
||||||
|
String aliases = getString("aliases");
|
||||||
|
|
||||||
|
if (aliases == null) {
|
||||||
|
return getKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
package net.draycia.simplechat.commands;
|
||||||
|
|
||||||
|
import co.aikar.commands.BaseCommand;
|
||||||
|
import co.aikar.commands.ConditionFailedException;
|
||||||
|
import co.aikar.commands.annotation.*;
|
||||||
|
import net.draycia.simplechat.SimpleChat;
|
||||||
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandAlias("%channelName")
|
||||||
|
@CommandPermission("simplechat.switch")
|
||||||
|
public class AliasedChannelCommand extends BaseCommand {
|
||||||
|
|
||||||
|
private SimpleChat simpleChat;
|
||||||
|
private ChatChannel chatChannel;
|
||||||
|
|
||||||
|
public AliasedChannelCommand(SimpleChat simpleChat, ChatChannel chatChannel) {
|
||||||
|
this.simpleChat = simpleChat;
|
||||||
|
this.chatChannel = chatChannel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Default
|
||||||
|
public void baseCommand(Player player, @Optional String[] args) {
|
||||||
|
ChatUser user = simpleChat.getUserService().wrap(player);
|
||||||
|
|
||||||
|
if (!chatChannel.canPlayerUse(user)) {
|
||||||
|
throw new ConditionFailedException(chatChannel.getCannotUseMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args == null || args.length == 0) {
|
||||||
|
user.setSelectedChannel(getChatChannel());
|
||||||
|
|
||||||
|
user.sendMessage(simpleChat.processMessage(getChatChannel().getSwitchMessage(),
|
||||||
|
"color", "<" + getChatChannel().getColor().toString() + ">",
|
||||||
|
"channel", getChatChannel().getName()));
|
||||||
|
} else {
|
||||||
|
Bukkit.getScheduler().scheduleAsyncDelayedTask(simpleChat, () -> {
|
||||||
|
getChatChannel().sendMessage(user, String.join(" ", args), false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatChannel getChatChannel() {
|
||||||
|
return chatChannel;
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-5
@@ -5,8 +5,6 @@ import co.aikar.commands.annotation.*;
|
|||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.draycia.simplechat.storage.UserChannelSettings;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -29,7 +27,7 @@ public class ChannelCommand extends BaseCommand {
|
|||||||
if (args == null || args.length == 0) {
|
if (args == null || args.length == 0) {
|
||||||
user.setSelectedChannel(channel);
|
user.setSelectedChannel(channel);
|
||||||
|
|
||||||
user.sendMessage(MiniMessage.get().parse(channel.getSwitchMessage(),
|
user.sendMessage(simpleChat.processMessageWithPapi(player, channel.getSwitchMessage(),
|
||||||
"br", "\n",
|
"br", "\n",
|
||||||
"color", "<" + channel.getColor().toString() + ">",
|
"color", "<" + channel.getColor().toString() + ">",
|
||||||
"channel", channel.getName()));
|
"channel", channel.getName()));
|
||||||
@@ -49,10 +47,10 @@ public class ChannelCommand extends BaseCommand {
|
|||||||
String message = channel.getSwitchMessage();
|
String message = channel.getSwitchMessage();
|
||||||
String otherMessage = channel.getSwitchOtherMessage();
|
String otherMessage = channel.getSwitchOtherMessage();
|
||||||
|
|
||||||
user.sendMessage(MiniMessage.get().parse(message, "br", "\n",
|
user.sendMessage(simpleChat.processMessage(message, "br", "\n",
|
||||||
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
||||||
|
|
||||||
simpleChat.getAudiences().audience(sender).sendMessage(MiniMessage.get().parse(otherMessage, "br", "\n",
|
simpleChat.getAudiences().audience(sender).sendMessage(simpleChat.processMessage(otherMessage, "br", "\n",
|
||||||
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName(),
|
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName(),
|
||||||
"player", user.asOfflinePlayer().getName()));
|
"player", user.asOfflinePlayer().getName()));
|
||||||
}
|
}
|
||||||
+1
-3
@@ -6,7 +6,6 @@ import co.aikar.commands.annotation.CommandPermission;
|
|||||||
import co.aikar.commands.annotation.Default;
|
import co.aikar.commands.annotation.Default;
|
||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@CommandAlias("chatreload|creload")
|
@CommandAlias("chatreload|creload")
|
||||||
@@ -22,10 +21,9 @@ public class ChatReloadCommand extends BaseCommand {
|
|||||||
@Default
|
@Default
|
||||||
public void baseCommand(CommandSender sender) {
|
public void baseCommand(CommandSender sender) {
|
||||||
simpleChat.reloadConfig();
|
simpleChat.reloadConfig();
|
||||||
simpleChat.getChannelManager().reloadChannels();
|
|
||||||
simpleChat.reloadPatterns();
|
simpleChat.reloadPatterns();
|
||||||
|
|
||||||
Component message = MiniMessage.get().parse(simpleChat.getConfig().getString("language.reloaded"),
|
Component message = simpleChat.processMessage(simpleChat.getConfig().getString("language.reloaded"),
|
||||||
"br", "\n");
|
"br", "\n");
|
||||||
|
|
||||||
simpleChat.getAudiences().audience(sender).sendMessage(message);
|
simpleChat.getAudiences().audience(sender).sendMessage(message);
|
||||||
+10
-4
@@ -7,7 +7,7 @@ import co.aikar.commands.annotation.CommandPermission;
|
|||||||
import co.aikar.commands.annotation.Default;
|
import co.aikar.commands.annotation.Default;
|
||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandAlias("ignore")
|
@CommandAlias("ignore")
|
||||||
@@ -31,11 +31,17 @@ public class IgnoreCommand extends BaseCommand {
|
|||||||
user.setIgnoringUser(targetUser, false);
|
user.setIgnoringUser(targetUser, false);
|
||||||
message = simpleChat.getConfig().getString("language.not-ignoring-user");
|
message = simpleChat.getConfig().getString("language.not-ignoring-user");
|
||||||
} else {
|
} else {
|
||||||
user.setIgnoringUser(targetUser, true);
|
Permission permission = simpleChat.getPermission();
|
||||||
message = simpleChat.getConfig().getString("language.ignoring-user");
|
|
||||||
|
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "simplechat.ignore.exempt")) {
|
||||||
|
message = simpleChat.getConfig().getString("language.ignore-exempt");
|
||||||
|
} else {
|
||||||
|
user.setIgnoringUser(targetUser, true);
|
||||||
|
message = simpleChat.getConfig().getString("language.ignoring-user");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendMessage(MiniMessage.get().parse(message, "br", "\n"));
|
user.sendMessage(simpleChat.processMessageWithPapi(player, message, "br", "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-2
@@ -8,7 +8,6 @@ import me.clip.placeholderapi.PlaceholderAPI;
|
|||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -26,7 +25,7 @@ public class MeCommand extends BaseCommand {
|
|||||||
public void baseCommand(Player player, String... args) {
|
public void baseCommand(Player player, String... args) {
|
||||||
String message = String.join(" ", args).replace("</pre>", "");
|
String message = String.join(" ", args).replace("</pre>", "");
|
||||||
String format = PlaceholderAPI.setPlaceholders(player, simpleChat.getConfig().getString("language.me"));
|
String format = PlaceholderAPI.setPlaceholders(player, simpleChat.getConfig().getString("language.me"));
|
||||||
Component component = MiniMessage.get().parse(format, "br", "\n", "message", message);
|
Component component = simpleChat.processMessage(format, "br", "\n", "message", message);
|
||||||
|
|
||||||
ChatUser user = simpleChat.getUserService().wrap(player);
|
ChatUser user = simpleChat.getUserService().wrap(player);
|
||||||
|
|
||||||
File renamed without changes.
+1
-2
@@ -7,7 +7,6 @@ import co.aikar.commands.annotation.Default;
|
|||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandAlias("reply|r")
|
@CommandAlias("reply|r")
|
||||||
@@ -31,7 +30,7 @@ public class ReplyCommand extends BaseCommand {
|
|||||||
|
|
||||||
if (user.getReplyTarget() == null) {
|
if (user.getReplyTarget() == null) {
|
||||||
String message = simpleChat.getConfig().getString("language.no-reply-target");
|
String message = simpleChat.getConfig().getString("language.no-reply-target");
|
||||||
Component component = MiniMessage.get().parse(message, "br", "\n");
|
Component component = simpleChat.processMessage(message, "br", "\n");
|
||||||
user.sendMessage(component);
|
user.sendMessage(component);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
+1
-2
@@ -8,7 +8,6 @@ import net.draycia.simplechat.channels.ChatChannel;
|
|||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.draycia.simplechat.storage.UserChannelSettings;
|
import net.draycia.simplechat.storage.UserChannelSettings;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandAlias("setcolor")
|
@CommandAlias("setcolor")
|
||||||
@@ -40,7 +39,7 @@ public class SetColorCommand extends BaseCommand {
|
|||||||
|
|
||||||
settings.setColor(TextColor.fromHexString(color));
|
settings.setColor(TextColor.fromHexString(color));
|
||||||
|
|
||||||
user.sendMessage(MiniMessage.get().parse(simpleChat.getConfig().getString("language.channel-color-set"),
|
user.sendMessage(simpleChat.processMessageWithPapi(player, simpleChat.getConfig().getString("language.channel-color-set"),
|
||||||
"br", "\n", "color", "<color:" + color + ">", "channel", channel.getName(), "hex", color));
|
"br", "\n", "color", "<color:" + color + ">", "channel", channel.getName(), "hex", color));
|
||||||
}
|
}
|
||||||
|
|
||||||
+2
-3
@@ -6,7 +6,6 @@ import net.draycia.simplechat.SimpleChat;
|
|||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.draycia.simplechat.storage.UserChannelSettings;
|
import net.draycia.simplechat.storage.UserChannelSettings;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandAlias("spych|spychannel|spy")
|
@CommandAlias("spych|spychannel|spy")
|
||||||
@@ -36,7 +35,7 @@ public class SpyChannelCommand extends BaseCommand {
|
|||||||
message = simpleChat.getConfig().getString("language.spy-toggled-on");
|
message = simpleChat.getConfig().getString("language.spy-toggled-on");
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendMessage(MiniMessage.get().parse(message, "br", "\n",
|
user.sendMessage(simpleChat.processMessageWithPapi(player, message, "br", "\n",
|
||||||
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +53,7 @@ public class SpyChannelCommand extends BaseCommand {
|
|||||||
message = simpleChat.getConfig().getString("language.spy-whispers-on");
|
message = simpleChat.getConfig().getString("language.spy-whispers-on");
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendMessage(MiniMessage.get().parse(message, "br", "\n"));
|
user.sendMessage(simpleChat.processMessageWithPapi(player, message, "br", "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+3
-4
@@ -6,7 +6,6 @@ import net.draycia.simplechat.SimpleChat;
|
|||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.draycia.simplechat.storage.UserChannelSettings;
|
import net.draycia.simplechat.storage.UserChannelSettings;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -37,7 +36,7 @@ public class ToggleCommand extends BaseCommand {
|
|||||||
message = channel.getToggleOnMessage();
|
message = channel.getToggleOnMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendMessage(MiniMessage.get().parse(message, "br", "\n",
|
user.sendMessage(simpleChat.processMessageWithPapi(player, message, "br", "\n",
|
||||||
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,10 +59,10 @@ public class ToggleCommand extends BaseCommand {
|
|||||||
otherMessage = channel.getToggleOtherOnMessage();
|
otherMessage = channel.getToggleOtherOnMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendMessage(MiniMessage.get().parse(message, "br", "\n",
|
user.sendMessage(simpleChat.processMessage(message, "br", "\n",
|
||||||
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
||||||
|
|
||||||
simpleChat.getAudiences().audience(sender).sendMessage(MiniMessage.get().parse(otherMessage,
|
simpleChat.getAudiences().audience(sender).sendMessage(simpleChat.processMessage(otherMessage,
|
||||||
"br", "\n", "color", "<color:" + channel.getColor().toString() + ">",
|
"br", "\n", "color", "<color:" + channel.getColor().toString() + ">",
|
||||||
"channel", channel.getName(), "player", user.asOfflinePlayer().getName()));
|
"channel", channel.getName(), "player", user.asOfflinePlayer().getName()));
|
||||||
}
|
}
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
package net.draycia.simplechat.events;
|
||||||
|
|
||||||
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
|
import net.draycia.simplechat.util.Registry;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ChannelRegisterEvent extends Event {
|
||||||
|
|
||||||
|
/** Bukkit event stuff **/
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Relevant stuff **/
|
||||||
|
private List<ChatChannel> registeredChannels;
|
||||||
|
private Registry<ChatChannel> registry;
|
||||||
|
|
||||||
|
public ChannelRegisterEvent(List<ChatChannel> registeredChannels, Registry<ChatChannel> registry) {
|
||||||
|
super(!Bukkit.isPrimaryThread());
|
||||||
|
|
||||||
|
this.registeredChannels = registeredChannels;
|
||||||
|
this.registry = registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(ChatChannel chatChannel) {
|
||||||
|
registry.register(chatChannel.getKey(), chatChannel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ChatChannel> getRegisteredChannels() {
|
||||||
|
return registeredChannels;
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
@@ -2,6 +2,7 @@ package net.draycia.simplechat.events;
|
|||||||
|
|
||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
@@ -24,6 +25,8 @@ public class ChannelSwitchEvent extends Event {
|
|||||||
private ChatUser user;
|
private ChatUser user;
|
||||||
|
|
||||||
public ChannelSwitchEvent(ChatChannel channel, ChatUser user) {
|
public ChannelSwitchEvent(ChatChannel channel, ChatUser user) {
|
||||||
|
super(!Bukkit.isPrimaryThread());
|
||||||
|
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
+12
-1
@@ -3,6 +3,7 @@ package net.draycia.simplechat.events;
|
|||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
@@ -20,15 +21,21 @@ public class ChatComponentEvent extends Event implements Cancellable {
|
|||||||
private TextComponent component;
|
private TextComponent component;
|
||||||
private String originalMessage;
|
private String originalMessage;
|
||||||
private List<ChatUser> recipients;
|
private List<ChatUser> recipients;
|
||||||
|
private boolean customPlayerFormat;
|
||||||
|
|
||||||
public ChatComponentEvent(ChatUser user, ChatChannel chatChannel, TextComponent component, String originalMessage, List<ChatUser> recipients) {
|
public ChatComponentEvent(ChatUser user, ChatChannel chatChannel, TextComponent component, String originalMessage, List<ChatUser> recipients) {
|
||||||
super(true);
|
this(user, chatChannel, component, originalMessage, recipients, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatComponentEvent(ChatUser user, ChatChannel chatChannel, TextComponent component, String originalMessage, List<ChatUser> recipients, boolean customPlayerFormat) {
|
||||||
|
super(!Bukkit.isPrimaryThread());
|
||||||
|
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.chatChannel = chatChannel;
|
this.chatChannel = chatChannel;
|
||||||
this.component = component;
|
this.component = component;
|
||||||
this.originalMessage = originalMessage;
|
this.originalMessage = originalMessage;
|
||||||
this.recipients = recipients;
|
this.recipients = recipients;
|
||||||
|
this.customPlayerFormat = customPlayerFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -78,4 +85,8 @@ public class ChatComponentEvent extends Event implements Cancellable {
|
|||||||
public String getOriginalMessage() {
|
public String getOriginalMessage() {
|
||||||
return originalMessage;
|
return originalMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCustomPlayerFormat() {
|
||||||
|
return customPlayerFormat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -2,6 +2,7 @@ package net.draycia.simplechat.events;
|
|||||||
|
|
||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
@@ -18,7 +19,7 @@ public class ChatFormatEvent extends Event implements Cancellable {
|
|||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
public ChatFormatEvent(ChatUser user, ChatChannel chatChannel, String format, String message) {
|
public ChatFormatEvent(ChatUser user, ChatChannel chatChannel, String format, String message) {
|
||||||
super(true);
|
super(!Bukkit.isPrimaryThread());
|
||||||
|
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.chatChannel = chatChannel;
|
this.chatChannel = chatChannel;
|
||||||
+3
@@ -2,6 +2,7 @@ package net.draycia.simplechat.events;
|
|||||||
|
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
@@ -27,6 +28,8 @@ public class PrivateMessageEvent extends Event {
|
|||||||
private final String message;
|
private final String message;
|
||||||
|
|
||||||
public PrivateMessageEvent(ChatUser sender, ChatUser target, Component senderComponent, Component targetComponent, String message) {
|
public PrivateMessageEvent(ChatUser sender, ChatUser target, Component senderComponent, Component targetComponent, String message) {
|
||||||
|
super(!Bukkit.isPrimaryThread());
|
||||||
|
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.senderComponent = senderComponent;
|
this.senderComponent = senderComponent;
|
||||||
+1
-1
@@ -19,7 +19,7 @@ public class BukkitChatListener implements Listener {
|
|||||||
// Chat messages
|
// Chat messages
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onPlayerchat(AsyncPlayerChatEvent event) {
|
public void onPlayerchat(AsyncPlayerChatEvent event) {
|
||||||
event.setCancelled(true);
|
event.getRecipients().clear();
|
||||||
|
|
||||||
ChatUser user = simpleChat.getUserService().wrap(event.getPlayer());
|
ChatUser user = simpleChat.getUserService().wrap(event.getPlayer());
|
||||||
|
|
||||||
+5
-2
@@ -2,7 +2,6 @@ package net.draycia.simplechat.listeners;
|
|||||||
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
import net.draycia.simplechat.events.ChatComponentEvent;
|
import net.draycia.simplechat.events.ChatComponentEvent;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -17,6 +16,10 @@ public class EmptyChatHandler implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onComponent(ChatComponentEvent event) {
|
public void onComponent(ChatComponentEvent event) {
|
||||||
|
if (event.isCustomPlayerFormat()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.getRecipients().size() == 1 && event.getUser().equals(event.getRecipients().get(0))) {
|
if (event.getRecipients().size() == 1 && event.getUser().equals(event.getRecipients().get(0))) {
|
||||||
String message = simpleChat.getConfig().getString("language.empty-channel");
|
String message = simpleChat.getConfig().getString("language.empty-channel");
|
||||||
|
|
||||||
@@ -24,7 +27,7 @@ public class EmptyChatHandler implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.getUser().sendMessage(MiniMessage.get().parse(message));
|
event.getUser().sendMessage(simpleChat.processMessage(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package net.draycia.simplechat.listeners;
|
||||||
|
|
||||||
|
import net.draycia.simplechat.events.ChatFormatEvent;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public class UserFormattingListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onFormat(ChatFormatEvent event) {
|
||||||
|
if (event.getUser().isOnline()) {
|
||||||
|
if (event.getUser().asPlayer().hasPermission("simplechat.formatting")) {
|
||||||
|
event.setFormat(event.getFormat()
|
||||||
|
.replace("<pre><message></pre>", "<message>")
|
||||||
|
.replace("<pre><message>", "<message>")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package net.draycia.simplechat.managers;
|
||||||
|
|
||||||
|
import net.draycia.simplechat.SimpleChat;
|
||||||
|
import net.draycia.simplechat.channels.ChannelRegistry;
|
||||||
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
|
import net.draycia.simplechat.channels.impls.*;
|
||||||
|
import net.draycia.simplechat.events.ChannelRegisterEvent;
|
||||||
|
import net.draycia.simplechat.util.Registry;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ChannelManager {
|
||||||
|
|
||||||
|
private ChannelRegistry registry;
|
||||||
|
private String defaultChannelKey = null;
|
||||||
|
|
||||||
|
public ChannelManager(SimpleChat simpleChat) {
|
||||||
|
registry = new ChannelRegistry(simpleChat);
|
||||||
|
List<ChatChannel> channels = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String key : simpleChat.getConfig().getConfigurationSection("channels").getKeys(false)) {
|
||||||
|
ChatChannel channel = new SimpleChatChannel(key, simpleChat);
|
||||||
|
|
||||||
|
ConfigurationSection section = simpleChat.getConfig().getConfigurationSection("channels").getConfigurationSection(key);
|
||||||
|
|
||||||
|
String name = section.getString("name");
|
||||||
|
|
||||||
|
if (name != null && name.length() > 16) {
|
||||||
|
simpleChat.getLogger().warning("Channel name [" + name + "] too long! Max length: 16.");
|
||||||
|
simpleChat.getLogger().warning("Skipping channel, please check your settings!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
channels.add(channel);
|
||||||
|
|
||||||
|
if (channel.isDefault()) {
|
||||||
|
simpleChat.getLogger().info("Default channel found: " + channel.getName());
|
||||||
|
defaultChannelKey = channel.getKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ChatChannel channel : channels) {
|
||||||
|
simpleChat.getLogger().info("Registering channel: " + channel.getName());
|
||||||
|
getRegistry().register(channel.getKey(), channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getPluginManager().callEvent(new ChannelRegisterEvent(channels, getRegistry()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Registry<ChatChannel> getRegistry() {
|
||||||
|
return registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatChannel getDefaultChannel() {
|
||||||
|
if (defaultChannelKey != null) {
|
||||||
|
return registry.get(defaultChannelKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatChannel getChannelOrDefault(String key) {
|
||||||
|
if (key == null) {
|
||||||
|
return getDefaultChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatChannel channel = registry.get(key);
|
||||||
|
|
||||||
|
if (channel == null) {
|
||||||
|
return getDefaultChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+4
-21
@@ -3,10 +3,6 @@ package net.draycia.simplechat.managers;
|
|||||||
import co.aikar.commands.*;
|
import co.aikar.commands.*;
|
||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.channels.impls.AllianceChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.NationChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.PartyChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.TownChatChannel;
|
|
||||||
import net.draycia.simplechat.commands.*;
|
import net.draycia.simplechat.commands.*;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -30,7 +26,7 @@ public class CommandManager {
|
|||||||
|
|
||||||
ArrayList<String> completions = new ArrayList<>();
|
ArrayList<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
for (ChatChannel chatChannel : simpleChat.getChannels()) {
|
for (ChatChannel chatChannel : simpleChat.getChannelManager().getRegistry().values()) {
|
||||||
if (chatChannel.canPlayerUse(user)) {
|
if (chatChannel.canPlayerUse(user)) {
|
||||||
completions.add(chatChannel.getName());
|
completions.add(chatChannel.getName());
|
||||||
}
|
}
|
||||||
@@ -42,7 +38,7 @@ public class CommandManager {
|
|||||||
commandManager.getCommandCompletions().registerCompletion("channel", (context) -> {
|
commandManager.getCommandCompletions().registerCompletion("channel", (context) -> {
|
||||||
ArrayList<String> completions = new ArrayList<>();
|
ArrayList<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
for (ChatChannel chatChannel : simpleChat.getChannels()) {
|
for (ChatChannel chatChannel : simpleChat.getChannelManager().getRegistry().values()) {
|
||||||
completions.add(chatChannel.getName());
|
completions.add(chatChannel.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +48,7 @@ public class CommandManager {
|
|||||||
commandManager.getCommandContexts().registerContext(ChatChannel.class, (context) -> {
|
commandManager.getCommandContexts().registerContext(ChatChannel.class, (context) -> {
|
||||||
String name = context.popFirstArg();
|
String name = context.popFirstArg();
|
||||||
|
|
||||||
for (ChatChannel chatChannel : simpleChat.getChannels()) {
|
for (ChatChannel chatChannel : simpleChat.getChannelManager().getRegistry().values()) {
|
||||||
if (chatChannel.getName().equalsIgnoreCase(name)) {
|
if (chatChannel.getName().equalsIgnoreCase(name)) {
|
||||||
return chatChannel;
|
return chatChannel;
|
||||||
}
|
}
|
||||||
@@ -73,17 +69,7 @@ public class CommandManager {
|
|||||||
ChatUser user = simpleChat.getUserService().wrap(context.getIssuer().getPlayer());
|
ChatUser user = simpleChat.getUserService().wrap(context.getIssuer().getPlayer());
|
||||||
|
|
||||||
if (!value.canPlayerUse(user)) {
|
if (!value.canPlayerUse(user)) {
|
||||||
if (value.isTownChat() && !((TownChatChannel)value).isInTown(user)) {
|
throw new ConditionFailedException(value.getCannotUseMessage());
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.town-cannot-use"));
|
|
||||||
} else if (value.isNationChat() && !((NationChatChannel)value).isInNation(user)) {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.nation-cannot-use"));
|
|
||||||
} else if (value.isAllianceChat() && !((AllianceChatChannel)value).isInNation(user)) {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.alliance-cannot-use"));
|
|
||||||
} else if (value.isPartyChat() && !((PartyChatChannel)value).isInParty(user)) {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.party-cannot-use"));
|
|
||||||
} else {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.cannot-use-channel"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -100,13 +86,10 @@ public class CommandManager {
|
|||||||
manager.registerCommand(new ToggleCommand(simpleChat));
|
manager.registerCommand(new ToggleCommand(simpleChat));
|
||||||
manager.registerCommand(new ChannelCommand(simpleChat));
|
manager.registerCommand(new ChannelCommand(simpleChat));
|
||||||
manager.registerCommand(new IgnoreCommand(simpleChat));
|
manager.registerCommand(new IgnoreCommand(simpleChat));
|
||||||
manager.registerCommand(new ClearChatCommand(simpleChat));
|
|
||||||
manager.registerCommand(new ShadowMuteCommand(simpleChat));
|
|
||||||
manager.registerCommand(new ChatReloadCommand(simpleChat));
|
manager.registerCommand(new ChatReloadCommand(simpleChat));
|
||||||
manager.registerCommand(new MeCommand(simpleChat));
|
manager.registerCommand(new MeCommand(simpleChat));
|
||||||
manager.registerCommand(new MessageCommand(simpleChat));
|
manager.registerCommand(new MessageCommand(simpleChat));
|
||||||
manager.registerCommand(new ReplyCommand(simpleChat));
|
manager.registerCommand(new ReplyCommand(simpleChat));
|
||||||
manager.registerCommand(new MuteCommand(simpleChat));
|
|
||||||
manager.registerCommand(new SetColorCommand(simpleChat));
|
manager.registerCommand(new SetColorCommand(simpleChat));
|
||||||
manager.registerCommand(new SpyChannelCommand(simpleChat));
|
manager.registerCommand(new SpyChannelCommand(simpleChat));
|
||||||
}
|
}
|
||||||
+4
-4
@@ -57,7 +57,7 @@ public class PluginMessageManager implements PluginMessageListener {
|
|||||||
private void onMessageReceived(ByteArrayDataInput in) {
|
private void onMessageReceived(ByteArrayDataInput in) {
|
||||||
String chatChannelName = in.readUTF();
|
String chatChannelName = in.readUTF();
|
||||||
|
|
||||||
ChatChannel chatChannel = simpleChat.getChannel(chatChannelName);
|
ChatChannel chatChannel = simpleChat.getChannelManager().getRegistry().get(chatChannelName);
|
||||||
|
|
||||||
if (chatChannel == null) {
|
if (chatChannel == null) {
|
||||||
return;
|
return;
|
||||||
@@ -84,7 +84,7 @@ public class PluginMessageManager implements PluginMessageListener {
|
|||||||
public void onComponentReceived(ByteArrayDataInput in) {
|
public void onComponentReceived(ByteArrayDataInput in) {
|
||||||
String chatChannelName = in.readUTF();
|
String chatChannelName = in.readUTF();
|
||||||
|
|
||||||
ChatChannel chatChannel = simpleChat.getChannel(chatChannelName);
|
ChatChannel chatChannel = simpleChat.getChannelManager().getRegistry().get(chatChannelName);
|
||||||
|
|
||||||
if (chatChannel == null) {
|
if (chatChannel == null) {
|
||||||
return;
|
return;
|
||||||
@@ -104,7 +104,7 @@ public class PluginMessageManager implements PluginMessageListener {
|
|||||||
String chatMessage = in.readUTF();
|
String chatMessage = in.readUTF();
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(simpleChat, () -> {
|
Bukkit.getScheduler().scheduleAsyncDelayedTask(simpleChat, () -> {
|
||||||
chatChannel.sendComponent(user, MiniMessage.get().parse(chatMessage, "br", "\n"));
|
chatChannel.sendComponent(user, simpleChat.processMessage(chatMessage, "br", "\n"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ public class PluginMessageManager implements PluginMessageListener {
|
|||||||
String chatMessage = in.readUTF();
|
String chatMessage = in.readUTF();
|
||||||
|
|
||||||
ChatUser target = simpleChat.getUserService().wrap(targetUUID);
|
ChatUser target = simpleChat.getUserService().wrap(targetUUID);
|
||||||
target.sendMessage(MiniMessage.get().parse(chatMessage, "br", "\n"));
|
target.sendMessage(simpleChat.processMessage(chatMessage, "br", "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(ChatChannel chatChannel, Player player, String message) {
|
public void sendMessage(ChatChannel chatChannel, Player player, String message) {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+22
-9
@@ -16,6 +16,7 @@ import org.bukkit.OfflinePlayer;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.SQLSyntaxErrorException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -52,6 +53,11 @@ public class MySQLUserService extends UserService {
|
|||||||
database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_users (uuid CHAR(36) PRIMARY KEY," +
|
database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_users (uuid CHAR(36) PRIMARY KEY," +
|
||||||
"channel VARCHAR(16), muted BOOLEAN, shadowmuted BOOLEAN, spyingwhispers BOOLEAN)");
|
"channel VARCHAR(16), muted BOOLEAN, shadowmuted BOOLEAN, spyingwhispers BOOLEAN)");
|
||||||
|
|
||||||
|
// Ignore the exception, it's just saying the column already exists
|
||||||
|
try {
|
||||||
|
database.executeUpdate("ALTER TABLE sc_users ADD COLUMN spyingwhispers BOOLEAN DEFAULT false");
|
||||||
|
} catch (SQLSyntaxErrorException syntaxErrorException) {}
|
||||||
|
|
||||||
database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_channel_settings (uuid CHAR(36), channel CHAR(16), spying BOOLEAN, ignored BOOLEAN, color TINYTEXT, PRIMARY KEY (uuid, channel))");
|
database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_channel_settings (uuid CHAR(36), channel CHAR(16), spying BOOLEAN, ignored BOOLEAN, color TINYTEXT, PRIMARY KEY (uuid, channel))");
|
||||||
|
|
||||||
database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_ignored_users (uuid CHAR(36), user CHAR(36), PRIMARY KEY (uuid, user))");
|
database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_ignored_users (uuid CHAR(36), user CHAR(36), PRIMARY KEY (uuid, user))");
|
||||||
@@ -100,7 +106,6 @@ public class MySQLUserService extends UserService {
|
|||||||
|
|
||||||
SimpleChatUser user = new SimpleChatUser(uuid);
|
SimpleChatUser user = new SimpleChatUser(uuid);
|
||||||
|
|
||||||
|
|
||||||
try (DbStatement statement = database.query("SELECT * from sc_users WHERE uuid = ?;")) {
|
try (DbStatement statement = database.query("SELECT * from sc_users WHERE uuid = ?;")) {
|
||||||
statement.execute(uuid.toString());
|
statement.execute(uuid.toString());
|
||||||
|
|
||||||
@@ -113,22 +118,30 @@ public class MySQLUserService extends UserService {
|
|||||||
List<DbRow> channelSettings = database.getResults("SELECT * from sc_channel_settings WHERE uuid = ?;", uuid.toString());
|
List<DbRow> channelSettings = database.getResults("SELECT * from sc_channel_settings WHERE uuid = ?;", uuid.toString());
|
||||||
List<DbRow> ignoredUsers = database.getResults("SELECT * from sc_ignored_users WHERE uuid = ?;", uuid.toString());
|
List<DbRow> ignoredUsers = database.getResults("SELECT * from sc_ignored_users WHERE uuid = ?;", uuid.toString());
|
||||||
|
|
||||||
user.setSelectedChannel(simpleChat.getChannel(users.getString("channel")));
|
ChatChannel channel = simpleChat.getChannelManager().getChannelOrDefault(users.getString("channel"));
|
||||||
|
|
||||||
|
if (channel != null) {
|
||||||
|
user.setSelectedChannel(channel);
|
||||||
|
}
|
||||||
|
|
||||||
user.setMuted(users.<Boolean>get("muted"));
|
user.setMuted(users.<Boolean>get("muted"));
|
||||||
user.setShadowMuted(users.<Boolean>get("shadowmuted"));
|
user.setShadowMuted(users.<Boolean>get("shadowmuted"));
|
||||||
user.setSpyingWhispers(users.<Boolean>get("spyingwhispers"));
|
user.setSpyingWhispers(users.<Boolean>get("spyingwhispers"));
|
||||||
|
|
||||||
for (DbRow channelSetting : channelSettings) {
|
for (DbRow channelSetting : channelSettings) {
|
||||||
ChatChannel chatChannel = simpleChat.getChannel(channelSetting.getString("channel"));
|
ChatChannel chatChannel = simpleChat.getChannelManager().getRegistry().get(channelSetting.getString("channel"));
|
||||||
UserChannelSettings settings = user.getChannelSettings(chatChannel);
|
|
||||||
|
|
||||||
settings.setSpying(channelSetting.<Boolean>get("spying"));
|
if (chatChannel != null) {
|
||||||
settings.setIgnoring(channelSetting.<Boolean>get("ignored"));
|
UserChannelSettings settings = user.getChannelSettings(chatChannel);
|
||||||
|
|
||||||
String color = channelSetting.getString("color");
|
settings.setSpying(channelSetting.<Boolean>get("spying"));
|
||||||
|
settings.setIgnoring(channelSetting.<Boolean>get("ignored"));
|
||||||
|
|
||||||
if (color != null) {
|
String color = channelSetting.getString("color");
|
||||||
settings.setColor(TextColor.fromHexString(color));
|
|
||||||
|
if (color != null) {
|
||||||
|
settings.setColor(TextColor.fromHexString(color));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+6
-7
@@ -11,7 +11,6 @@ import net.kyori.adventure.audience.ForwardingAudience;
|
|||||||
import net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.sound.Sound;
|
import net.kyori.adventure.sound.Sound;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -71,12 +70,12 @@ public class SimpleChatUser implements ChatUser, ForwardingAudience {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChatChannel getSelectedChannel() {
|
public ChatChannel getSelectedChannel() {
|
||||||
return selectedChannel == null ? simpleChat.getDefaultChannel() : simpleChat.getChannel(selectedChannel);
|
return simpleChat.getChannelManager().getChannelOrDefault(selectedChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSelectedChannel(ChatChannel chatChannel) {
|
public void setSelectedChannel(ChatChannel chatChannel) {
|
||||||
this.selectedChannel = chatChannel.getName();
|
this.selectedChannel = chatChannel.getKey();
|
||||||
syncToRedis();
|
syncToRedis();
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(new ChannelSwitchEvent(chatChannel, this));
|
Bukkit.getPluginManager().callEvent(new ChannelSwitchEvent(chatChannel, this));
|
||||||
@@ -84,7 +83,7 @@ public class SimpleChatUser implements ChatUser, ForwardingAudience {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearSelectedChannel() {
|
public void clearSelectedChannel() {
|
||||||
setSelectedChannel(simpleChat.getDefaultChannel());
|
setSelectedChannel(simpleChat.getChannelManager().getDefaultChannel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -200,12 +199,12 @@ public class SimpleChatUser implements ChatUser, ForwardingAudience {
|
|||||||
targetName = this.asPlayer().getDisplayName();
|
targetName = this.asPlayer().getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
Component toPlayerComponent = MiniMessage.get().parse(toPlayerFormat, "br", "\n",
|
Component toPlayerComponent = simpleChat.processMessage(toPlayerFormat, "br", "\n",
|
||||||
"message", message,
|
"message", message,
|
||||||
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||||
"target", targetName, "sender", senderName);
|
"target", targetName, "sender", senderName);
|
||||||
|
|
||||||
Component fromPlayerComponent = MiniMessage.get().parse(fromPlayerFormat, "br", "\n",
|
Component fromPlayerComponent = simpleChat.processMessage(fromPlayerFormat, "br", "\n",
|
||||||
"message", message,
|
"message", message,
|
||||||
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||||
"target", targetName, "sender", senderName);
|
"target", targetName, "sender", senderName);
|
||||||
@@ -243,7 +242,7 @@ public class SimpleChatUser implements ChatUser, ForwardingAudience {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendMessage(MiniMessage.get().parse(simpleChat.getConfig().getString("language.spy-whispers"), "br", "\n",
|
user.sendMessage(simpleChat.processMessage(simpleChat.getConfig().getString("language.spy-whispers"), "br", "\n",
|
||||||
"message", message,
|
"message", message,
|
||||||
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||||
"target", targetName, "sender", senderName));
|
"target", targetName, "sender", senderName));
|
||||||
File renamed without changes.
+7
-6
@@ -1,6 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
Simple channel based chat plugin for Spigot
|
Simple channel based chat plugin for Spigot
|
||||||
Copyright (C) 2020 Alexander Söderberg
|
Copyright (C) 2020 Alexander Söderberg
|
||||||
|
Copyright (C) 2020 Josua Parks (Draycia)
|
||||||
|
|
||||||
|
Modifications made to work with Kyori/Adventure
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -30,19 +33,17 @@ import java.lang.reflect.Method;
|
|||||||
|
|
||||||
public final class ItemStackUtils {
|
public final class ItemStackUtils {
|
||||||
|
|
||||||
private final Class<?> craftItemStackClass;
|
|
||||||
private final Method asNMSCopyMethod;
|
private final Method asNMSCopyMethod;
|
||||||
private final Class<?> itemStackClass;
|
|
||||||
private final Method cMethod;
|
private final Method cMethod;
|
||||||
|
|
||||||
public ItemStackUtils() throws NoSuchMethodException, ClassNotFoundException {
|
public ItemStackUtils() throws NoSuchMethodException, ClassNotFoundException {
|
||||||
final String version = Bukkit.getServer().getClass().getPackage().getName()
|
final String version = Bukkit.getServer().getClass().getPackage().getName()
|
||||||
.substring("org.bukkit.craftbukkit.".length());
|
.substring("org.bukkit.craftbukkit.".length());
|
||||||
|
|
||||||
this.craftItemStackClass = Class.forName("org.bukkit.craftbukkit." + version + ".inventory.CraftItemStack");
|
Class<?> craftItemStackClass = Class.forName("org.bukkit.craftbukkit." + version + ".inventory.CraftItemStack");
|
||||||
this.asNMSCopyMethod = this.craftItemStackClass.getMethod("asNMSCopy", ItemStack.class);
|
this.asNMSCopyMethod = craftItemStackClass.getMethod("asNMSCopy", ItemStack.class);
|
||||||
this.itemStackClass = Class.forName("net.minecraft.server." + version + ".ItemStack");
|
Class<?> itemStackClass = Class.forName("net.minecraft.server." + version + ".ItemStack");
|
||||||
this.cMethod = this.itemStackClass.getMethod("C");
|
this.cMethod = itemStackClass.getMethod("C");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component createComponent(final Player player) {
|
public Component createComponent(final Player player) {
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package net.draycia.simplechat.util;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public interface Registry<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the specified key and value to the registry
|
||||||
|
* @param key The entry's key
|
||||||
|
* @param value The value to insert
|
||||||
|
* @return If successfully registered
|
||||||
|
*/
|
||||||
|
boolean register(@NotNull String key, @NotNull T value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the list of registered values
|
||||||
|
* @return The list of registered values
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
Collection<T> values();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains an entry associated with the specified key
|
||||||
|
* @param key The key for the entry
|
||||||
|
* @return The entry associated with the key
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
T get(String key);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
# MiniMessage Docs:
|
|
||||||
# https://github.com/KyoriPowered/adventure-docs/blob/feature/minimessage/source/minimessage.rst#the-components
|
|
||||||
|
|
||||||
# SimpleChat Docs:
|
# SimpleChat Docs:
|
||||||
# https://github.com/Draycia/Chat/wiki
|
# https://github.com/Draycia/Chat/wiki
|
||||||
|
|
||||||
@@ -11,18 +8,19 @@
|
|||||||
# All of the settings under this 'default' section can be applied to each channel individually to override these.
|
# All of the settings under this 'default' section can be applied to each channel individually to override these.
|
||||||
# These are provided as a way to configure default channel settings.
|
# These are provided as a way to configure default channel settings.
|
||||||
default:
|
default:
|
||||||
|
# switch-message, toggle-off-message and toggle-on-message support PlaceholderAPI
|
||||||
switch-message: '<gray>You are now in <color><channel> <gray>chat!'
|
switch-message: '<gray>You are now in <color><channel> <gray>chat!'
|
||||||
switch-other-message: '<gray><player> is now in <color><channel> <gray>chat!'
|
switch-other-message: '<gray><player> is now in <color><channel> <gray>chat!'
|
||||||
toggle-on-message: '<gray>You can now see <color><channel> <gray>chat!'
|
toggle-on-message: '<gray>You can now see <color><channel> <gray>chat!'
|
||||||
toggle-off-message: '<gray>You can no longer see <color><channel> <gray>chat!'
|
toggle-off-message: '<gray>You can no longer see <color><channel> <gray>chat!'
|
||||||
toggle-other-on: '<gray><player> can now see <color><channel> <gray>chat!'
|
toggle-other-on: '<gray><player> can now see <color><channel> <gray>chat!'
|
||||||
toggle-other-off: '<gray><player> can no longer see <color><channel> <gray>chat!'
|
toggle-other-off: '<gray><player> can no longer see <color><channel> <gray>chat!'
|
||||||
|
cannot-use-channel: "You cannot use that channel!"
|
||||||
formats:
|
formats:
|
||||||
# Placeholders: username, displayname, channel, server, message, primaryrole
|
# Placeholders: <username>, <displayname>, <channel>, <server>, <message>, <primaryrole>, <color>
|
||||||
# Also supports PlaceholderAPI
|
# Also supports PlaceholderAPI
|
||||||
discord-to-mc: '<gray>[<blue>Discord<gray>] <username><white>: <pre><message>'
|
staff: '<gray>{[%vault_prefix%<gray>]} %player_displayname% <gray>» <color><pre><message>'
|
||||||
staff: '<gray>{[%vault_prefix%<gray>]} %player_displayname% <gray>» <white><pre><message>'
|
default: '<gray>[%vault_prefix%<gray>] %player_displayname%<gray>: <color><pre><message>'
|
||||||
default: '<gray>[%vault_prefix%<gray>] %player_displayname%<gray>: <white><pre><message>'
|
|
||||||
color: '#FFFFFF'
|
color: '#FFFFFF'
|
||||||
# Can players /toggle this channel and hide its messages?
|
# Can players /toggle this channel and hide its messages?
|
||||||
ignorable: true
|
ignorable: true
|
||||||
@@ -34,10 +32,6 @@ default:
|
|||||||
should-bungee: true
|
should-bungee: true
|
||||||
# Determines if this channel should use the highest matching vault group found for formatting
|
# Determines if this channel should use the highest matching vault group found for formatting
|
||||||
first-matching-group: false
|
first-matching-group: false
|
||||||
# Determines if the chat filter is enabled for this channel
|
|
||||||
filter-enabled: true
|
|
||||||
# Towny, Nation, Alliance, Party, Normal
|
|
||||||
type: 'normal'
|
|
||||||
|
|
||||||
channels:
|
channels:
|
||||||
global:
|
global:
|
||||||
@@ -52,61 +46,44 @@ channels:
|
|||||||
ignorable: false
|
ignorable: false
|
||||||
should-bungee: false
|
should-bungee: false
|
||||||
|
|
||||||
filters:
|
|
||||||
- 'lag'
|
|
||||||
- 'la[g]+'
|
|
||||||
|
|
||||||
filter-text: '****'
|
|
||||||
|
|
||||||
replacements:
|
replacements:
|
||||||
'%shrug%': '¯\_(ツ)_/¯'
|
'%shrug%': '¯\_(ツ)_/¯'
|
||||||
|
|
||||||
|
# Options:
|
||||||
|
# 'MiniMessage': https://github.com/KyoriPowered/adventure-docs/blob/feature/minimessage/source/minimessage.rst#the-components
|
||||||
|
# 'MiniMessage-Markdown': https://github.com/KyoriPowered/adventure-docs/blob/feature/minimessage/source/minimessage.rst#markdown
|
||||||
|
# 'MineDown': https://github.com/Phoenix616/MineDown#syntax
|
||||||
|
# Note that the messages provided in the default config utilise MiniMessage, and need to be changed if you're using MineDown
|
||||||
|
formatting:
|
||||||
|
type: 'MiniMessage'
|
||||||
|
|
||||||
language:
|
language:
|
||||||
ignoring-user: '<green>You are now ignoring <gold><player><green>!'
|
# The following messages are only compatible with MiniMessage
|
||||||
not-ignoring-user: '<green>You are no longer ignoring <gold><player><green>!'
|
reloaded: '<yellow>Chat config has been reloaded!'
|
||||||
is-now-shadow-muted: '<yellow>User <user> is now shadow muted!'
|
|
||||||
no-longer-shadow-muted: '<yellow>User <user> is no longer shadow muted!'
|
|
||||||
is-now-muted: '<yellow>User <user> is now muted!'
|
|
||||||
no-longer-muted: '<yellow>User <user> is no longer muted!'
|
|
||||||
reloaded: '<yellow>Chat config has been reloaded! Note that this does not reload channel configs!'
|
|
||||||
me: '<italic><dark_purple>*%player_displayname% <pre><message></pre>*</dark_purple></italic>'
|
|
||||||
message-to-other: '<green>[<gray>Me <gold>-> <gray><target><green>] <message>'
|
message-to-other: '<green>[<gray>Me <gold>-> <gray><target><green>] <message>'
|
||||||
message-from-other: '<green>[<gray><sender> <gold>-> <gray>Me<green>] <message>'
|
message-from-other: '<green>[<gray><sender> <gold>-> <gray>Me<green>] <message>'
|
||||||
spy-whispers: '<yellow>Spy [<gray><sender> <gold>-> <gray><target><yellow>] <message>'
|
spy-whispers: '<yellow>Spy [<gray><sender> <gold>-> <gray><target><yellow>] <message>'
|
||||||
spy-whispers-on: '<gray>You are now spying on whispers!'
|
|
||||||
spy-whispers-off: '<gray>You are no longer spying on whispers!'
|
|
||||||
no-reply-target: '<red>You have no one to reply to!'
|
no-reply-target: '<red>You have no one to reply to!'
|
||||||
|
empty-channel: '<green>Nobody is around to hear you!' #<channel>
|
||||||
|
|
||||||
|
# The following messages are compatible with PlaceholderAPI and MiniMessage
|
||||||
|
me: '<italic><dark_purple>*%player_displayname% <pre><message></pre>*</dark_purple></italic>'
|
||||||
|
ignoring-user: '<green>You are now ignoring <gold><player><green>!'
|
||||||
|
not-ignoring-user: '<green>You are no longer ignoring <gold><player><green>!'
|
||||||
|
ignore-exempt: '<red>User <player> <red>is exempt from being ignored!'
|
||||||
channel-color-set: "<green>You have set <color><channel> <green>color to <hex>!"
|
channel-color-set: "<green>You have set <color><channel> <green>color to <hex>!"
|
||||||
spy-toggled-on: '<gray>You are now spying on <color><channel> <gray>chat!'
|
spy-toggled-on: '<gray>You are now spying on <color><channel> <gray>chat!'
|
||||||
spy-toggled-off: '<gray>You are no longer spying on <color><channel> <gray>chat!'
|
spy-toggled-off: '<gray>You are no longer spying on <color><channel> <gray>chat!'
|
||||||
clear-notify: '<yellow>Chat has been cleared by <player>.'
|
spy-whispers-on: '<gray>You are now spying on whispers!'
|
||||||
clear-exempt: '<yellow>You were exempt from the clear due to your permissions!'
|
spy-whispers-off: '<gray>You are no longer spying on whispers!'
|
||||||
empty-channel: '<green>Nobody is around to hear you!' #<channel>
|
|
||||||
# The following messages are not MiniMessage compatible
|
|
||||||
player-left: '%player_displayname% has left <server>!'
|
|
||||||
player-joined: '%player_displayname% has joined <server>!'
|
|
||||||
vote-received: '<name> has voted on <service>!'
|
|
||||||
cannot-use-channel: "You cannot use that channel!"
|
|
||||||
town-cannot-use: 'You are not in a town!'
|
|
||||||
nation-cannot-use: 'You are not in a nation!'
|
|
||||||
alliance-cannot-use: 'You do not have any alliances!'
|
|
||||||
party-cannot-use: 'You are not in a party!'
|
|
||||||
|
|
||||||
|
# Used for <server> placeholder in channel formats
|
||||||
server-name: 'Server'
|
server-name: 'Server'
|
||||||
|
|
||||||
clear-chat-message: ""
|
|
||||||
clear-chat-amount: 100
|
|
||||||
|
|
||||||
item-link-placeholders:
|
item-link-placeholders:
|
||||||
- '[item]' # cursed placeholder do not use
|
- '[item]' # cursed placeholder do not use
|
||||||
- '%item%'
|
- '%item%'
|
||||||
|
|
||||||
caps-protection:
|
|
||||||
enabled: true
|
|
||||||
minimum-length: 10
|
|
||||||
percent-caps: 80
|
|
||||||
block-message: false
|
|
||||||
|
|
||||||
spy-prefix: '<color>[SPY] '
|
spy-prefix: '<color>[SPY] '
|
||||||
spy-prefix-nation: '<color>[SPY <nation>] '
|
spy-prefix-nation: '<color>[SPY <nation>] '
|
||||||
spy-prefix-town: '<color>[SPY <town>] '
|
spy-prefix-town: '<color>[SPY <town>] '
|
||||||
@@ -121,12 +98,6 @@ pings:
|
|||||||
highlight: true # independent of the "enabled" option!
|
highlight: true # independent of the "enabled" option!
|
||||||
on-whisper: true # independent of the "enabled" option!
|
on-whisper: true # independent of the "enabled" option!
|
||||||
|
|
||||||
listeners:
|
|
||||||
join: true # sends join messages in discord
|
|
||||||
leave: true # sends leave messages in discord
|
|
||||||
death: true # sends death messages in discord
|
|
||||||
vote: false # sends vote messages in discord
|
|
||||||
|
|
||||||
storage:
|
storage:
|
||||||
type: JSON # JSON, MySQL
|
type: JSON # JSON, MySQL
|
||||||
username: 'username'
|
username: 'username'
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
name: SimpleChat
|
name: SimpleChat
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
main: net.draycia.simplechat.SimpleChat
|
main: net.draycia.simplechat.SimpleChat
|
||||||
api-version: 1.13
|
api-version: 1.16
|
||||||
depend: [PlaceholderAPI, Vault]
|
depend: [PlaceholderAPI, Vault]
|
||||||
softdepend: [Towny, mcMMO, Votifier]
|
softdepend: [LuckPerms]
|
||||||
@@ -5,272 +5,20 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>net.draycia</groupId>
|
<groupId>net.draycia</groupId>
|
||||||
<artifactId>SimpleChat</artifactId>
|
<artifactId>SimpleChatParent</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0</version>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>SimpleChat</name>
|
<modules>
|
||||||
|
<module>SimpleChatPlugin</module>
|
||||||
|
<module>SimpleChatModeration</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<name>SimpleChatParent</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
|
||||||
<defaultGoal>clean package</defaultGoal>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.1.1</version>
|
|
||||||
<configuration>
|
|
||||||
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
|
|
||||||
<relocations>
|
|
||||||
<relocation>
|
|
||||||
<pattern>co.aikar.commands</pattern>
|
|
||||||
<shadedPattern>net.draycia.simplechat.libs.acf</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>co.aikar.locales</pattern>
|
|
||||||
<shadedPattern>net.draycia.simplechat.libs.locales</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>co.aikar.idb</pattern>
|
|
||||||
<shadedPattern>net.draycia.simplechat.libs.idb</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>net.kyori</pattern>
|
|
||||||
<shadedPattern>net.draycia.simplechat.libs.kyori</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>io.papermc.lib</pattern>
|
|
||||||
<shadedPattern>net.draycia.simplechat.libs.paperlib</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>com.fasterxml</pattern>
|
|
||||||
<shadedPattern>net.draycia.simplechat.libs.fasterxml</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>com.neovisionaries</pattern>
|
|
||||||
<shadedPattern>net.draycia.simplechat.libs.neovisionaries</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>okio</pattern>
|
|
||||||
<shadedPattern>net.draycia.simplechat.libs.okio</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>okhttp3</pattern>
|
|
||||||
<shadedPattern>net.draycia.simplechat.libs.okhttp3</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.checkerframework</pattern>
|
|
||||||
<shadedPattern>net.draycia.simplechat.libs.checkerframework</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
</relocations>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.7.0</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>compile</id>
|
|
||||||
<phase>compile</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>compile</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>testCompile</id>
|
|
||||||
<phase>test-compile</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>testCompile</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<source>${java.version}</source>
|
|
||||||
<target>${java.version}</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<!-- Spigot API -->
|
|
||||||
<repository>
|
|
||||||
<id>spigotmc-repo</id>
|
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<!-- Kyori -->
|
|
||||||
<repository>
|
|
||||||
<id>sonatype</id>
|
|
||||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<!-- PlaceholderAPI -->
|
|
||||||
<repository>
|
|
||||||
<id>placeholderapi</id>
|
|
||||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<!-- Towny, VaultAPI -->
|
|
||||||
<repository>
|
|
||||||
<id>jitpack.io</id>
|
|
||||||
<url>https://jitpack.io</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<!-- ACF -->
|
|
||||||
<repository>
|
|
||||||
<id>aikar</id>
|
|
||||||
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<!-- NuVotifier -->
|
|
||||||
<repository>
|
|
||||||
<id>bintray-repo</id>
|
|
||||||
<url>https://dl.bintray.com/ichbinjoe/public/</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<!-- BungeeChannelAPI -->
|
|
||||||
<repository>
|
|
||||||
<id>codemc-repo</id>
|
|
||||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
|
||||||
<releases>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<!-- mcMMO and MiniMessage must be compiled locally -->
|
|
||||||
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot-api</artifactId>
|
|
||||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- ACF - command framework -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>co.aikar</groupId>
|
|
||||||
<artifactId>acf-bukkit</artifactId>
|
|
||||||
<version>0.5.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Components and formatting -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kyori</groupId>
|
|
||||||
<artifactId>adventure-api</artifactId>
|
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kyori</groupId>
|
|
||||||
<artifactId>adventure-nbt</artifactId>
|
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kyori</groupId>
|
|
||||||
<artifactId>adventure-platform-bukkit</artifactId>
|
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.google.code.gson</groupId>
|
|
||||||
<artifactId>gson</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<!-- Must be built locally for the time being -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kyori</groupId>
|
|
||||||
<artifactId>adventure-text-minimessage</artifactId>
|
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Placeholders -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>me.clip</groupId>
|
|
||||||
<artifactId>placeholderapi</artifactId>
|
|
||||||
<version>2.10.6</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Towny chats - nation & town -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.TownyAdvanced</groupId>
|
|
||||||
<artifactId>Towny</artifactId>
|
|
||||||
<version>0.96.1.11</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- mcMMO - no repository, add to maven local -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
|
||||||
<artifactId>mcMMO</artifactId>
|
|
||||||
<version>2.1.130</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Vault for permissions / groups -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.MilkBowl</groupId>
|
|
||||||
<artifactId>VaultAPI</artifactId>
|
|
||||||
<version>1.7</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- NuVotifier for vote messages in discord bridge -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.vexsoftware</groupId>
|
|
||||||
<artifactId>nuvotifier-universal</artifactId>
|
|
||||||
<version>2.6.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>co.aikar</groupId>
|
|
||||||
<artifactId>idb-bukkit</artifactId>
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zaxxer</groupId>
|
|
||||||
<artifactId>HikariCP</artifactId>
|
|
||||||
<version>2.4.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Easier bungee handling -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.github.leonardosnt</groupId>
|
|
||||||
<artifactId>bungeechannelapi</artifactId>
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Redis -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.lettuce</groupId>
|
|
||||||
<artifactId>lettuce-core</artifactId>
|
|
||||||
<version>6.0.0.M1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
</project>
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package net.draycia.simplechat.channels.impls;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
|
||||||
import com.palmergames.bukkit.towny.event.NationRemoveTownEvent;
|
|
||||||
import com.palmergames.bukkit.towny.event.TownRemoveResidentEvent;
|
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
public class AllianceChatChannel extends NationChatChannel implements Listener {
|
|
||||||
|
|
||||||
public AllianceChatChannel(String name, SimpleChat simpleChat) {
|
|
||||||
super(name, simpleChat);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerSee(ChatUser sender, ChatUser target, boolean checkSpying) {
|
|
||||||
if (checkSpying && target.asPlayer().hasPermission("simplechat.spy." + getName())) {
|
|
||||||
if (target.getChannelSettings(this).isSpying()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (super.canPlayerSee(sender, target, false) && sender != null) {
|
|
||||||
try {
|
|
||||||
Resident resident = TownyAPI.getInstance().getDataSource().getResident(target.asPlayer().getName());
|
|
||||||
Resident targetResident = TownyAPI.getInstance().getDataSource().getResident(sender.asPlayer().getName());
|
|
||||||
|
|
||||||
if (resident.isAlliedWith(targetResident)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAllianceChat() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isNationChat() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
package net.draycia.simplechat.channels.impls;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
|
||||||
import com.palmergames.bukkit.towny.event.NationRemoveTownEvent;
|
|
||||||
import com.palmergames.bukkit.towny.event.TownRemoveResidentEvent;
|
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
|
||||||
import com.palmergames.bukkit.towny.object.Nation;
|
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
public class NationChatChannel extends SimpleChatChannel implements Listener {
|
|
||||||
|
|
||||||
public NationChatChannel(String name, SimpleChat simpleChat) {
|
|
||||||
super(name, simpleChat);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String processPlaceholders(ChatUser user, String input) {
|
|
||||||
return input.replace("<nation>", getNation(user));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getNation(ChatUser user) {
|
|
||||||
try {
|
|
||||||
Resident resident = TownyAPI.getInstance().getDataSource().getResident(user.asPlayer().getName());
|
|
||||||
|
|
||||||
if (resident.hasNation()) {
|
|
||||||
return resident.getTown().getNation().getFormattedName();
|
|
||||||
}
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerSee(ChatUser sender, ChatUser target, boolean checkSpying) {
|
|
||||||
if (checkSpying && target.asPlayer().hasPermission("simplechat.spy." + getName())) {
|
|
||||||
if (target.getChannelSettings(this).isSpying()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (super.canPlayerSee(sender, target, false) && sender != null) {
|
|
||||||
try {
|
|
||||||
Resident resident = TownyAPI.getInstance().getDataSource().getResident(sender.asPlayer().getName());
|
|
||||||
|
|
||||||
if (resident.hasNation()) {
|
|
||||||
Nation nation = resident.getTown().getNation();
|
|
||||||
|
|
||||||
if (nation.hasResident(target.asPlayer().getName())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerUse(ChatUser user) {
|
|
||||||
return super.canPlayerUse(user) && isInNation(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInNation(ChatUser user) {
|
|
||||||
try {
|
|
||||||
return TownyAPI.getInstance().getDataSource().getResident(user.asPlayer().getName()).hasNation();
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onResidentRemove(TownRemoveResidentEvent event) {
|
|
||||||
String name = event.getResident().getName();
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(Bukkit.getOfflinePlayer(name));
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isAllianceChat()) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onNationRemoveTown(NationRemoveTownEvent event) {
|
|
||||||
for (Resident resident : event.getTown().getResidents()) {
|
|
||||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(resident.getName());
|
|
||||||
|
|
||||||
if (!offlinePlayer.isOnline()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(offlinePlayer);
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isAllianceChat()) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(event.getPlayer());
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isAllianceChat() && !isInNation(user)) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isNationChat() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
package net.draycia.simplechat.channels.impls;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.api.PartyAPI;
|
|
||||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
public class PartyChatChannel extends SimpleChatChannel implements Listener {
|
|
||||||
|
|
||||||
public PartyChatChannel(String name, SimpleChat simpleChat) {
|
|
||||||
super(name, simpleChat);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String processPlaceholders(ChatUser user, String input) {
|
|
||||||
String partyName = PartyAPI.getPartyName(user.asPlayer());
|
|
||||||
|
|
||||||
if (partyName == null) {
|
|
||||||
partyName = "NotLoaded";
|
|
||||||
}
|
|
||||||
|
|
||||||
return input.replace("<party>", partyName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerSee(ChatUser sender, ChatUser target, boolean checkSpying) {
|
|
||||||
if (checkSpying && target.asPlayer().hasPermission("simplechat.spy." + getName())) {
|
|
||||||
if (target.getChannelSettings(this).isSpying()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (super.canPlayerSee(sender, target, false) && sender != null) {
|
|
||||||
return PartyAPI.inSameParty(sender.asPlayer(), target.asPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerUse(ChatUser user) {
|
|
||||||
return super.canPlayerUse(user) && isInParty(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
private McMMOPartyChangeEvent.EventReason LEFT = McMMOPartyChangeEvent.EventReason.LEFT_PARTY;
|
|
||||||
private McMMOPartyChangeEvent.EventReason KICKED = McMMOPartyChangeEvent.EventReason.KICKED_FROM_PARTY;
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPartyLeave(McMMOPartyChangeEvent event) {
|
|
||||||
if (event.getReason() != LEFT && event.getReason() != KICKED) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(event.getPlayer());
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isPartyChat()) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(event.getPlayer());
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isPartyChat() && !isInParty(user)) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInParty(ChatUser user) {
|
|
||||||
return PartyAPI.inParty(user.asPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPartyChat() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
package net.draycia.simplechat.channels.impls;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
|
||||||
import com.palmergames.bukkit.towny.event.TownAddResidentEvent;
|
|
||||||
import com.palmergames.bukkit.towny.event.TownRemoveResidentEvent;
|
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
public class TownChatChannel extends SimpleChatChannel implements Listener {
|
|
||||||
|
|
||||||
public TownChatChannel(String name, SimpleChat simpleChat) {
|
|
||||||
super(name, simpleChat);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String processPlaceholders(ChatUser user, String input) {
|
|
||||||
return input.replace("<town>", getTown(user));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTown(ChatUser user) {
|
|
||||||
try {
|
|
||||||
Resident resident = TownyAPI.getInstance().getDataSource().getResident(user.asPlayer().getName());
|
|
||||||
|
|
||||||
if (resident.hasTown()) {
|
|
||||||
return resident.getTown().getFormattedName();
|
|
||||||
}
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerSee(ChatUser sender, ChatUser target, boolean checkSpying) {
|
|
||||||
if (checkSpying && target.asPlayer().hasPermission("simplechat.spy." + getName())) {
|
|
||||||
if (target.getChannelSettings(this).isSpying()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (super.canPlayerSee(sender, target, false) && sender != null) {
|
|
||||||
try {
|
|
||||||
Resident resident = TownyAPI.getInstance().getDataSource().getResident(target.asPlayer().getName());
|
|
||||||
|
|
||||||
if (resident.hasTown()) {
|
|
||||||
return resident.getTown().hasResident(sender.asPlayer().getName());
|
|
||||||
}
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerUse(ChatUser user) {
|
|
||||||
if (super.canPlayerUse(user)) {
|
|
||||||
try {
|
|
||||||
return TownyAPI.getInstance().getDataSource().getResident(user.asPlayer().getName()).hasTown();
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInTown(ChatUser user) {
|
|
||||||
try {
|
|
||||||
return TownyAPI.getInstance().getDataSource().getResident(user.asPlayer().getName()).hasTown();
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onResidentRemove(TownRemoveResidentEvent event) {
|
|
||||||
String name = event.getResident().getName();
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(Bukkit.getOfflinePlayer(name));
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isTownChat()) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(event.getPlayer());
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isTownChat() && !isInTown(user)) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isTownChat() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package net.draycia.simplechat.commands;
|
|
||||||
|
|
||||||
import co.aikar.commands.BaseCommand;
|
|
||||||
import co.aikar.commands.ConditionFailedException;
|
|
||||||
import co.aikar.commands.annotation.*;
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.channels.ChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.AllianceChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.NationChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.PartyChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.TownChatChannel;
|
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
@CommandAlias("%channelName")
|
|
||||||
@CommandPermission("simplechat.switch")
|
|
||||||
public class AliasedChannelCommand extends BaseCommand {
|
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
|
||||||
private ChatChannel chatChannel;
|
|
||||||
|
|
||||||
public AliasedChannelCommand(SimpleChat simpleChat, ChatChannel chatChannel) {
|
|
||||||
this.simpleChat = simpleChat;
|
|
||||||
this.chatChannel = chatChannel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Default
|
|
||||||
public void baseCommand(Player player, @Optional String[] args) {
|
|
||||||
ChatUser user = simpleChat.getUserService().wrap(player);
|
|
||||||
|
|
||||||
if (!chatChannel.canPlayerUse(user)) {
|
|
||||||
if (chatChannel.isTownChat() && !((TownChatChannel)chatChannel).isInTown(user)) {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.town-cannot-use"));
|
|
||||||
} else if (chatChannel.isNationChat() && !((NationChatChannel)chatChannel).isInNation(user)) {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.nation-cannot-use"));
|
|
||||||
} else if (chatChannel.isAllianceChat() && !((AllianceChatChannel)chatChannel).isInNation(user)) {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("alliance-cannot-use"));
|
|
||||||
} else if (chatChannel.isPartyChat() && !((PartyChatChannel)chatChannel).isInParty(user)) {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("party-cannot-use"));
|
|
||||||
} else {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("cannot-use-channel"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args == null || args.length == 0) {
|
|
||||||
user.setSelectedChannel(getChatChannel());
|
|
||||||
|
|
||||||
user.sendMessage(MiniMessage.get().parse(
|
|
||||||
getChatChannel().getSwitchMessage(), "color", "<" + getChatChannel().getColor().toString() + ">",
|
|
||||||
"channel", getChatChannel().getName()));
|
|
||||||
} else {
|
|
||||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(simpleChat, () -> {
|
|
||||||
getChatChannel().sendMessage(user, String.join(" ", args), false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatChannel getChatChannel() {
|
|
||||||
return chatChannel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package net.draycia.simplechat.commands;
|
|
||||||
|
|
||||||
import co.aikar.commands.BaseCommand;
|
|
||||||
import co.aikar.commands.annotation.CommandAlias;
|
|
||||||
import co.aikar.commands.annotation.CommandCompletion;
|
|
||||||
import co.aikar.commands.annotation.CommandPermission;
|
|
||||||
import co.aikar.commands.annotation.Default;
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
@CommandAlias("mute")
|
|
||||||
@CommandPermission("simplechat.mute")
|
|
||||||
public class MuteCommand extends BaseCommand {
|
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
|
||||||
|
|
||||||
public MuteCommand(SimpleChat simpleChat) {
|
|
||||||
this.simpleChat = simpleChat;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Default
|
|
||||||
@CommandCompletion("@players")
|
|
||||||
public void baseCommand(CommandSender sender, ChatUser targetUser) {
|
|
||||||
String format;
|
|
||||||
|
|
||||||
if (targetUser.isMuted()) {
|
|
||||||
targetUser.setMuted(true);
|
|
||||||
format = simpleChat.getConfig().getString("language.no-longer-muted");
|
|
||||||
} else {
|
|
||||||
targetUser.setMuted(false);
|
|
||||||
format = simpleChat.getConfig().getString("language.is-now-muted");
|
|
||||||
}
|
|
||||||
|
|
||||||
Component message = MiniMessage.get().parse(format, "br", "\n",
|
|
||||||
"user", targetUser.asOfflinePlayer().getName());
|
|
||||||
|
|
||||||
simpleChat.getAudiences().audience(sender).sendMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package net.draycia.simplechat.commands;
|
|
||||||
|
|
||||||
import co.aikar.commands.BaseCommand;
|
|
||||||
import co.aikar.commands.annotation.CommandAlias;
|
|
||||||
import co.aikar.commands.annotation.CommandCompletion;
|
|
||||||
import co.aikar.commands.annotation.CommandPermission;
|
|
||||||
import co.aikar.commands.annotation.Default;
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
@CommandAlias("shadowmute|sm|smute")
|
|
||||||
@CommandPermission("simplechat.shadowmute")
|
|
||||||
public class ShadowMuteCommand extends BaseCommand {
|
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
|
||||||
|
|
||||||
public ShadowMuteCommand(SimpleChat simpleChat) {
|
|
||||||
this.simpleChat = simpleChat;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Default
|
|
||||||
@CommandCompletion("@players")
|
|
||||||
public void baseCommand(CommandSender sender, ChatUser targetUser) {
|
|
||||||
String format;
|
|
||||||
|
|
||||||
if (targetUser.isShadowMuted()) {
|
|
||||||
targetUser.setShadowMuted(false);
|
|
||||||
format = simpleChat.getConfig().getString("language.no-longer-shadow-muted");
|
|
||||||
} else {
|
|
||||||
targetUser.setShadowMuted(true);
|
|
||||||
format = simpleChat.getConfig().getString("language.is-now-shadow-muted");
|
|
||||||
}
|
|
||||||
|
|
||||||
Component message = MiniMessage.get().parse(format, "br", "\n",
|
|
||||||
"user", targetUser.asOfflinePlayer().getName());
|
|
||||||
|
|
||||||
simpleChat.getAudiences().audience(sender).sendMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package net.draycia.simplechat.listeners;
|
|
||||||
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.channels.ChatChannel;
|
|
||||||
import net.draycia.simplechat.events.ChatFormatEvent;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
public class FilterHandler implements Listener {
|
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
|
||||||
|
|
||||||
public FilterHandler(SimpleChat simpleChat) {
|
|
||||||
this.simpleChat = simpleChat;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void onFilter(ChatFormatEvent event) {
|
|
||||||
ChatChannel channel = event.getChatChannel();
|
|
||||||
String filterText = simpleChat.getConfig().getString("filter-text", "****");
|
|
||||||
|
|
||||||
if (channel.filterEnabled() && simpleChat.getConfig().contains("filters")) {
|
|
||||||
for (String entry : simpleChat.getConfig().getStringList("filters")) {
|
|
||||||
event.setMessage(event.getMessage().replaceAll(entry, filterText));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
package net.draycia.simplechat.managers;
|
|
||||||
|
|
||||||
import co.aikar.commands.CommandManager;
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.channels.ChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.*;
|
|
||||||
import net.draycia.simplechat.commands.AliasedChannelCommand;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
public class ChannelManager {
|
|
||||||
|
|
||||||
public ChannelManager(SimpleChat simpleChat) {
|
|
||||||
boolean hasTownChat = false;
|
|
||||||
boolean hasNationChat = false;
|
|
||||||
boolean hasAllianceChat = false;
|
|
||||||
boolean hasPartyChat = false;
|
|
||||||
|
|
||||||
for (String key : simpleChat.getConfig().getConfigurationSection("channels").getKeys(false)) {
|
|
||||||
ChatChannel channel;
|
|
||||||
|
|
||||||
ConfigurationSection section = simpleChat.getConfig().getConfigurationSection("channels").getConfigurationSection(key);
|
|
||||||
|
|
||||||
String name = section.getString("name");
|
|
||||||
|
|
||||||
if (name != null && name.length() > 16) {
|
|
||||||
simpleChat.getLogger().warning("Channel name [" + name + "] too long! Max length: 16.");
|
|
||||||
simpleChat.getLogger().warning("Skipping channel, please check your settings!");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String type = section.getString("type");
|
|
||||||
|
|
||||||
if (type == null) {
|
|
||||||
type = "normal";
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type.toLowerCase()) {
|
|
||||||
case "towny":
|
|
||||||
channel = new TownChatChannel(key, simpleChat);
|
|
||||||
hasTownChat = true;
|
|
||||||
break;
|
|
||||||
case "nation":
|
|
||||||
channel = new NationChatChannel(key, simpleChat);
|
|
||||||
hasNationChat = true;
|
|
||||||
break;
|
|
||||||
case "alliance":
|
|
||||||
channel = new AllianceChatChannel(key, simpleChat);
|
|
||||||
hasAllianceChat = true;
|
|
||||||
break;
|
|
||||||
case "party":
|
|
||||||
channel = new PartyChatChannel(key, simpleChat);
|
|
||||||
hasPartyChat = true;
|
|
||||||
break;
|
|
||||||
case "normal":
|
|
||||||
channel = new SimpleChatChannel(key, simpleChat);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
simpleChat.getLogger().warning("Invalid channel type for channel [" + key + "]. Skipping channel.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channel.isTownChat() || channel.isNationChat() || channel.isAllianceChat()) {
|
|
||||||
if (!Bukkit.getPluginManager().isPluginEnabled("Towny")) {
|
|
||||||
simpleChat.getLogger().warning("Towny related channel with key [" + key + "] found, but Towny isn't installed. Skipping channel.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channel.isPartyChat()) {
|
|
||||||
if (!Bukkit.getPluginManager().isPluginEnabled("mcMMO")) {
|
|
||||||
simpleChat.getLogger().warning("mcMMO related channel with key [" + key + "] found, but mcMMO isn't installed. Skipping channel.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
simpleChat.getChannels().add(channel);
|
|
||||||
|
|
||||||
CommandManager commandManager = simpleChat.getCommandManager().getCommandManager();
|
|
||||||
|
|
||||||
String commandName = section.contains("aliases") ? section.getString("aliases") : key;
|
|
||||||
|
|
||||||
commandManager.getCommandReplacements().addReplacement("channelName", commandName);
|
|
||||||
commandManager.registerCommand(new AliasedChannelCommand(simpleChat, channel));
|
|
||||||
|
|
||||||
if (channel instanceof Listener) {
|
|
||||||
Bukkit.getPluginManager().registerEvents((Listener)channel, simpleChat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean townyInstalled = Bukkit.getPluginManager().isPluginEnabled("Towny");
|
|
||||||
boolean mcmmoInstalled = Bukkit.getPluginManager().isPluginEnabled("mcMMO");
|
|
||||||
|
|
||||||
if (!hasTownChat && townyInstalled) {
|
|
||||||
simpleChat.getLogger().info("Towny installed but no Town channel is setup!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasNationChat && townyInstalled) {
|
|
||||||
simpleChat.getLogger().info("Towny installed but no Nation channel is setup!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasAllianceChat && townyInstalled) {
|
|
||||||
simpleChat.getLogger().info("Towny installed but no Alliance channel is setup!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasPartyChat && mcmmoInstalled) {
|
|
||||||
simpleChat.getLogger().info("mcMMO installed but no Party channel is setup!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reloadChannels() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user