mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 14:38:49 +00:00
Mute support
This commit is contained in:
1 parent
7ee51f0a86
commit
06470f46da
5 files changed
+65
No files matched your search
@@ -78,6 +78,7 @@ public final class SimpleChat extends JavaPlugin {
|
|||||||
pluginManager.registerEvents(new FilterHandler(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);
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
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.OfflinePlayer;
|
||||||
|
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, OfflinePlayer target) { // TODO: ChatUser support in ACF
|
||||||
|
ChatUser targetUser = simpleChat.getUserService().wrap(target.getUniqueId());
|
||||||
|
|
||||||
|
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.instance().parse(format, "user", target.getName());
|
||||||
|
|
||||||
|
simpleChat.getAudiences().audience(sender).sendMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package net.draycia.simplechat.listeners.chat;
|
||||||
|
|
||||||
|
import net.draycia.simplechat.events.ChatFormatEvent;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public class MuteHandler implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onMute(ChatFormatEvent event) {
|
||||||
|
if (event.getUser().isMuted()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -65,6 +65,7 @@ public class CommandManager {
|
|||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
public co.aikar.commands.CommandManager getCommandManager() {
|
public co.aikar.commands.CommandManager getCommandManager() {
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ language:
|
|||||||
not-ignoring-user: '<green>You are no longer ignoring <gold><player><green>!'
|
not-ignoring-user: '<green>You are no longer ignoring <gold><player><green>!'
|
||||||
is-now-shadow-muted: '<yellow>User <user> is now shadow muted!'
|
is-now-shadow-muted: '<yellow>User <user> is now shadow muted!'
|
||||||
no-longer-shadow-muted: '<yellow>User <user> is no longer 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!'
|
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>'
|
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>'
|
||||||
|
|||||||
Reference in new issue
Block a user