mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 06:28:54 +00:00
Refactor format handler
This commit is contained in:
1 parent
84c5c67674
commit
305e9162fa
28 files changed
+221
-190
No files matched your search
+1
-1
@@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
|
||||
@CommandPermission("carbonchat.clearchat.clear")
|
||||
public class ClearChatCommand extends BaseCommand {
|
||||
|
||||
private CarbonChatModeration moderation;
|
||||
private final CarbonChatModeration moderation;
|
||||
|
||||
public ClearChatCommand(CarbonChatModeration moderation) {
|
||||
this.moderation = moderation;
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ import org.bukkit.command.CommandSender;
|
||||
@CommandPermission("carbonchat.mute")
|
||||
public class MuteCommand extends BaseCommand {
|
||||
|
||||
private CarbonChatModeration moderation;
|
||||
private final CarbonChatModeration moderation;
|
||||
|
||||
public MuteCommand(CarbonChatModeration moderation) {
|
||||
this.moderation = moderation;
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ import org.bukkit.command.CommandSender;
|
||||
@CommandPermission("carbonchat.shadowmute")
|
||||
public class ShadowMuteCommand extends BaseCommand {
|
||||
|
||||
private CarbonChatModeration moderation;
|
||||
private final CarbonChatModeration moderation;
|
||||
|
||||
public ShadowMuteCommand(CarbonChatModeration moderation) {
|
||||
this.moderation = moderation;
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbonmoderation.listeners;
|
||||
|
||||
import net.draycia.carbon.events.ChatFormatEvent;
|
||||
import net.draycia.carbon.events.PreChatFormatEvent;
|
||||
import net.draycia.carbonmoderation.CarbonChatModeration;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -8,14 +8,14 @@ import org.bukkit.event.Listener;
|
||||
|
||||
public class CapsHandler implements Listener {
|
||||
|
||||
private CarbonChatModeration moderation;
|
||||
private final CarbonChatModeration moderation;
|
||||
|
||||
public CapsHandler(CarbonChatModeration moderation) {
|
||||
this.moderation = moderation;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onMessage(ChatFormatEvent event) {
|
||||
public void onMessage(PreChatFormatEvent event) {
|
||||
if (!moderation.getConfig().getBoolean("caps-protection.enabled")) {
|
||||
return;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package net.draycia.carbonmoderation.listeners;
|
||||
|
||||
import net.draycia.carbon.channels.ChatChannel;
|
||||
import net.draycia.carbon.events.ChatFormatEvent;
|
||||
import net.draycia.carbon.events.PreChatFormatEvent;
|
||||
import net.draycia.carbonmoderation.CarbonChatModeration;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -15,14 +15,14 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class FilterHandler implements Listener {
|
||||
|
||||
private CarbonChatModeration moderation;
|
||||
private final CarbonChatModeration moderation;
|
||||
|
||||
public FilterHandler(CarbonChatModeration moderation) {
|
||||
this.moderation = moderation;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onFilter(ChatFormatEvent event) {
|
||||
public void onFilter(PreChatFormatEvent event) {
|
||||
if (!moderation.getConfig().getBoolean("filters.enabled")) {
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
package net.draycia.carbonmoderation.listeners;
|
||||
|
||||
import net.draycia.carbon.events.ChatFormatEvent;
|
||||
import net.draycia.carbon.events.PreChatFormatEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class MuteHandler implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onMute(ChatFormatEvent event) {
|
||||
public void onMute(PreChatFormatEvent event) {
|
||||
if (event.getUser().isMuted()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
+3
-8
@@ -9,15 +9,10 @@ public class ShadowMuteHandler implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onComponent(ChatComponentEvent event) {
|
||||
if (event.getUser().isShadowMuted()) {
|
||||
if (event.getRecipients().size() == 1 && event.getUser().equals(event.getRecipients().get(0))) {
|
||||
return;
|
||||
if (event.getSender().isShadowMuted()) {
|
||||
if (!event.getSender().equals(event.getTarget())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
try {
|
||||
event.getRecipients().clear();
|
||||
event.getRecipients().add(event.getUser());
|
||||
} catch (UnsupportedOperationException e) {}
|
||||
}
|
||||
|
||||
// TODO: figure out a way to add the console "[SM]" prefix for shadow muted players
|
||||
|
||||
Reference in new issue
Block a user