Finish user settings feature

This commit is contained in:
Draycia authored and Josh (Vicarious) committed 2020-07-07 05:05:11 -07:00
1 parent 6530c8d026
commit 36672f8ed3
10 files changed
+116 -19

No files matched your search

@@ -9,6 +9,7 @@ import net.draycia.simplechat.SimpleChat;
import net.draycia.simplechat.channels.ChatChannel;
import net.draycia.simplechat.storage.ChatUser;
import net.kyori.adventure.text.format.TextColor;
import org.bukkit.entity.Player;
@CommandAlias("chcolor|channelcolor")
@CommandPermission("simplechat.setcolor")
@@ -22,7 +23,9 @@ public class ChannelColorCommand extends BaseCommand {
@Default
@CommandCompletion("@chatchannel @chatcolors")
public void baseCommand(ChatUser user, ChatChannel chatChannel, String color) {
public void baseCommand(Player player, ChatChannel chatChannel, String color) {
ChatUser user = simpleChat.getUserService().wrap(player);
user.getChannelSettings(chatChannel).setColor(TextColor.fromHexString(color));
}
@@ -14,11 +14,11 @@ import org.bukkit.entity.Player;
@CommandAlias("clearchat|cc")
@CommandPermission("simplechat.clearchat")
public class CommandClearChat extends BaseCommand {
public class ClearChatCommand extends BaseCommand {
private SimpleChat simpleChat;
public CommandClearChat(SimpleChat simpleChat) {
public ClearChatCommand(SimpleChat simpleChat) {
this.simpleChat = simpleChat;
}
@@ -0,0 +1,48 @@
package net.draycia.simplechat.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.ConditionFailedException;
import co.aikar.commands.annotation.*;
import net.draycia.simplechat.SimpleChat;
import net.draycia.simplechat.channels.ChatChannel;
import net.draycia.simplechat.storage.ChatUser;
import net.draycia.simplechat.storage.UserChannelSettings;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.entity.Player;
@CommandAlias("setcolor")
@CommandPermission("simplechat.setcolor")
public class SetColorCommand extends BaseCommand {
private SimpleChat simpleChat;
public SetColorCommand(SimpleChat simpleChat) {
this.simpleChat = simpleChat;
}
@Default
@CommandCompletion("@chatchannel")
public void baseCommand(Player player, @Conditions("canuse:true") ChatChannel channel, String color) {
// TODO: condition for ChatChannel existing
if (channel == null || color == null) {
throw new ConditionFailedException("Channel or Color not supplied!");
}
ChatUser user = simpleChat.getUserService().wrap(player);
// TODO: move into conditions
if (!player.hasPermission("simplechat.setcolor." + channel.getName())) {
throw new ConditionFailedException("You can't set colors for this channel!");
}
UserChannelSettings settings = user.getChannelSettings(channel);
settings.setColor(TextColor.fromHexString(color));
user.sendMessage(MiniMessage.get().parse(simpleChat.getConfig().getString("language.channel-color-set"),
"color", "<color:" + color + ">", "channel", channel.getName(), "hex", color));
}
}