Add toggle command and feature

This commit is contained in:
Draycia committed 2020-06-13 01:09:36 -07:00
1 parent 225bd6e08e
commit 5e30aed924
5 files changed
+82 -4

No files matched your search

@@ -0,0 +1,36 @@
package net.draycia.simplechat.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import me.minidigger.minimessage.text.MiniMessageParser;
import net.draycia.simplechat.SimpleChat;
import net.draycia.simplechat.channels.ChatChannel;
import net.kyori.text.adapter.bukkit.TextAdapter;
import org.bukkit.entity.Player;
@CommandAlias("tch|togglec|togglechannel|toggle")
public class ToggleCommand extends BaseCommand {
private SimpleChat simpleChat;
public ToggleCommand(SimpleChat simpleChat) {
this.simpleChat = simpleChat;
}
@Default
@CommandCompletion("@chatchannel")
public void baseCommand(Player player, @Conditions("canuse:true") ChatChannel channel) {
String message;
if (simpleChat.togglePlayerChannelMute(player, channel)) {
message = channel.getToggleOnMessage();
} else {
message = channel.getToggleOffMessage();
}
message = MiniMessageParser.handlePlaceholders(message, "color", channel.getColor().toString());
TextAdapter.sendMessage(player, MiniMessageParser.parseFormat(message, "channel", channel.getName()));
}
}