bug fixes btw

This commit is contained in:
Draycia committed 2020-08-02 02:45:07 -07:00
1 parent b4b5989a23
commit d6972528ab
12 files changed
+60 -56

No files matched your search

@@ -58,6 +58,10 @@ public class CarbonChatChannel extends ChatChannel {
@Override
public void sendMessage(ChatUser user, String message, boolean fromBungee) {
if (user.isOnline()) {
user.asPlayer().setDisplayName(user.getNickname());
}
// Get player's formatting
String messageFormat = getFormat(user);
@@ -66,7 +70,7 @@ public class CarbonChatChannel extends ChatChannel {
Bukkit.getPluginManager().callEvent(formatEvent);
if (formatEvent.isCancelled()) {
if (formatEvent.isCancelled() || formatEvent.getMessage().isEmpty()) {
return;
}
@@ -38,7 +38,7 @@ public class ChannelCommand extends BaseCommand {
@CommandPermission("carbonchat.switch.others")
@Subcommand("other")
@CommandCompletion("@chatchannel @players")
public void baseCommand(CommandSender sender, ChatChannel channel, ChatUser user) {
public void baseCommand(CommandSender sender, @Conditions("exists:true") ChatChannel channel, ChatUser user) {
user.setSelectedChannel(channel);
String message = channel.getSwitchMessage();
@@ -8,10 +8,8 @@ public class UserFormattingListener implements Listener {
@EventHandler
public void onFormat(ChatFormatEvent event) {
if (event.getUser().isOnline() && event.getUser().asPlayer().hasPermission("carbonchat.formatting")) {
event.setFormat(event.getFormat()
.replace("<pre><message></pre>", "<message>")
.replace("<pre><message>", "<message>")
if (!event.getUser().isOnline() || !event.getUser().asPlayer().hasPermission("carbonchat.formatting")) {
event.setFormat(event.getFormat().replace("<message>", "<pre><message></pre>")
);
}
}
+15 -19
View File
@@ -1,26 +1,22 @@
# CarbonChat Docs:
# https://github.com/Draycia/Chat/wiki
# IMPORTANT: Use the <pre> tag around ALL user inputs.
# All <message> placeholders should be prefixed with <pre> and suffixed with </pre>
# Failure to do so may and likely will result in users being able to inject formatting in messages.
# 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.
default:
# switch-message, toggle-off-message and toggle-on-message support PlaceholderAPI
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> </rainbow><gray>is now in <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-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-on: '<gray><player> </rainbow><gray>can now see <color><channel> <gray>chat!'
toggle-other-off: '<gray><player> </rainbow><gray>can no longer see <color><channel> <gray>chat!'
cannot-use-channel: "You cannot use that channel!"
formats:
# Placeholders: <username>, <displayname>, <channel>, <server>, <message>, <primaryrole>, <color>
# Also supports PlaceholderAPI
staff: '<gray>{[%vault_prefix%<gray>]} %player_displayname% <gray>» <color><pre><message>'
default: '<gray>[%vault_prefix%<gray>] %player_displayname%<gray>: <color><pre><message>'
staff: '<gray>{[%vault_prefix%<gray>]} %player_displayname% </rainbow><gray>» <color><message>'
default: '<gray>[%vault_prefix%<gray>] %player_displayname%</rainbow><gray>: <color><message>'
contexts:
# -1 to disable, 0 to set to world, 1+ to fully enable
distance: -1
@@ -59,8 +55,8 @@ channels:
announcements:
name: 'Announcements'
formats:
default: '<gold>Broadcast: <yellow><pre><message></pre>'
staff: '<gold>Broadcast: <yellow><pre><message></pre>'
default: '<gold>Broadcast: <yellow><message>'
staff: '<gold>Broadcast: <yellow><message>'
ignorable: false
should-bungee: false
@@ -75,25 +71,25 @@ formatting:
language:
# The following messages are only compatible with MiniMessage/MineDown
reloaded: '<yellow>Chat config has been reloaded!'
message-to-other: '<green>[<gray>Me <gold>-> <gray><target><green>] <message>'
message-from-other: '<green>[<gray><sender> <gold>-> <gray>Me<green>] <message>'
spy-whispers: '<yellow>Spy [<gray><sender> <gold>-> <gray><target><yellow>] <message>'
message-to-other: '<green>[<gray>Me <gold>-> <gray><target></rainbow><green>] <message>'
message-from-other: '<green>[<gray><sender></rainbow> <gold>-> <gray>Me<green>] <message>'
spy-whispers: '<yellow>Spy [<gray><sender></rainbow> <gold>-> <gray><target></rainbow><yellow>] <message>'
no-reply-target: '<red>You have no one to reply to!'
empty-channel: 'NONE' #<channel>, set to "NONE" to disable
channel-switch-failure: '<red>You cannot use channel <channel>!'
other-nickname-set: '<green><user>''s nickname was set to <nickname><green>!'
other-nickname-set: '<green><user></rainbow>''s nickname was set to <nickname><green>!'
# The following messages are compatible with PlaceholderAPI and MiniMessage/MineDown
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>!'
me: '<italic><dark_purple>*%player_displayname% </rainbow><pre><message></pre>*</dark_purple></italic>'
ignoring-user: '<green>You are now ignoring <gold><player></rainbow><green>!'
not-ignoring-user: '<green>You are no longer ignoring <gold><player></rainbow><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>!"
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-whispers-on: '<gray>You are now spying on whispers!'
spy-whispers-off: '<gray>You are no longer spying on whispers!'
nickname-set: '<green>Your nickname was set to <nickname><green>!'
nickname-set: '<green>Your nickname was set to <nickname></rainbow><green>!'
# Used for <server> placeholder in channel formats
server-name: 'Server'
+1 -1
View File
@@ -10,7 +10,7 @@ repositories {
dependencies {
compileOnly 'com.github.mcMMO-Dev:mcMMO:-SNAPSHOT'
compileOnly project(':CarbonChat')
compileOnly project(path: ':CarbonChat', configuration: 'shadow')
}
description = 'CarbonChatMCMMO'
+1 -1
View File
@@ -9,7 +9,7 @@ repositories {
}
dependencies {
compileOnly project(':CarbonChat')
compileOnly project(path: ':CarbonChat', configuration: 'shadow')
}
description = 'CarbonChatModeration'
@@ -1,6 +1,6 @@
package net.draycia.carbonmoderation;
import co.aikar.commands.CommandManager;
import net.draycia.carbon.libs.co.aikar.commands.CommandManager;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbonmoderation.commands.ClearChatCommand;
import net.draycia.carbonmoderation.commands.MuteCommand;
@@ -18,6 +18,8 @@ public final class CarbonChatModeration extends JavaPlugin {
@Override
public void onEnable() {
saveDefaultConfig();
carbonChat = (CarbonChat)Bukkit.getPluginManager().getPlugin("CarbonChat");
registerCommands();
@@ -1,13 +1,12 @@
package net.draycia.carbonmoderation.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import net.draycia.carbon.libs.co.aikar.commands.BaseCommand;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandAlias;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandPermission;
import net.draycia.carbon.libs.co.aikar.commands.annotation.Default;
import net.draycia.carbon.storage.ChatUser;
import net.draycia.carbonmoderation.CarbonChatModeration;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.text.Component;
import net.draycia.carbon.libs.net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -32,20 +31,20 @@ public class ClearChatCommand extends BaseCommand {
continue;
}
Audience audience = moderation.getCarbonChat().getAdventureManager().getAudiences().player(player);
ChatUser audience = moderation.getCarbonChat().getUserService().wrap(player);
for (int i = 0; i < moderation.getConfig().getInt("clear-chat.message-count", 100); i++) {
audience.sendMessage(component, MessageType.SYSTEM);
audience.sendMessage(component);
}
if (player.hasPermission("carbonchat.clearchat.notify")) {
String message = moderation.getConfig().getString("language.clear-notify");
audience.sendMessage(moderation.getCarbonChat().getAdventureManager().processMessage(message, "player", issuer.getName()), MessageType.SYSTEM);
audience.sendMessage(moderation.getCarbonChat().getAdventureManager().processMessage(message, "player", issuer.getName()));
}
if (player.hasPermission("carbonchat.clearchat.exempt")) {
String message = moderation.getConfig().getString("language.clear-exempt");
audience.sendMessage(moderation.getCarbonChat().getAdventureManager().processMessage(message, "player", issuer.getName()), MessageType.SYSTEM);
audience.sendMessage(moderation.getCarbonChat().getAdventureManager().processMessage(message, "player", issuer.getName()));
}
}
}
@@ -1,14 +1,14 @@
package net.draycia.carbonmoderation.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.carbon.libs.co.aikar.commands.BaseCommand;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandAlias;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandCompletion;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandPermission;
import net.draycia.carbon.libs.co.aikar.commands.annotation.Default;
import net.draycia.carbon.storage.ChatUser;
import net.draycia.carbonmoderation.CarbonChatModeration;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.draycia.carbon.libs.net.kyori.adventure.audience.Audience;
import net.draycia.carbon.libs.net.kyori.adventure.text.Component;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@@ -1,14 +1,14 @@
package net.draycia.carbonmoderation.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.carbon.libs.co.aikar.commands.BaseCommand;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandAlias;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandCompletion;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandPermission;
import net.draycia.carbon.libs.co.aikar.commands.annotation.Default;
import net.draycia.carbon.storage.ChatUser;
import net.draycia.carbonmoderation.CarbonChatModeration;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.draycia.carbon.libs.net.kyori.adventure.audience.Audience;
import net.draycia.carbon.libs.net.kyori.adventure.text.Component;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@@ -37,7 +37,11 @@ public class FilterHandler implements Listener {
List<String> filteredWords = filters.getStringList(replacement);
for (String word : filteredWords) {
event.setMessage(event.getMessage().replaceAll(word, replacement));
if (replacement.equals("_")) {
event.setMessage(event.getMessage().replaceAll(word, ""));
} else {
event.setMessage(event.getMessage().replaceAll(word, replacement));
}
}
}
@@ -11,9 +11,10 @@ filters:
filters:
# In this example, any instance of "lag" or "laggggg" will be replaced with "****"
"****":
- "lag"
- "la[g]+"
"":
- "lag"
# Underscore = blank, empty. The text will basically be removed.
"_":
- "broccoli sucks"
# Anything in blocked-words will prevent the message from being sent at all.
blocked-words: