Aliases and bug fixes

This commit is contained in:
Draycia committed 2020-07-01 07:27:28 -07:00
1 parent 24ec001157
commit a2ec2f50f1
5 files changed
+65 -10

No files matched your search

@@ -0,0 +1,42 @@
package net.draycia.simplechat.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import net.draycia.simplechat.SimpleChat;
import net.draycia.simplechat.channels.ChatChannel;
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
//@CommandAlias("channel %channelName")
public void baseCommand(Player player, @Optional String[] args) {
if (args == null || args.length == 0) {
simpleChat.setPlayerChannel(player, getChatChannel());
simpleChat.getAudiences().player(player).sendMessage(MiniMessage.instance().parse(
getChatChannel().getSwitchMessage(), "color", "<" + getChatChannel().getColor().toString() + ">",
"channel", getChatChannel().getName()));
} else {
Bukkit.getScheduler().scheduleAsyncDelayedTask(simpleChat, () -> {
getChatChannel().sendMessage(player, String.join(" ", args));
});
}
}
public ChatChannel getChatChannel() {
return chatChannel;
}
}