mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
44 lines
1.4 KiB
Java
44 lines
1.4 KiB
Java
package net.draycia.carbon.commands;
|
|
|
|
import dev.jorel.commandapi.CommandAPICommand;
|
|
import dev.jorel.commandapi.CommandPermission;
|
|
import net.draycia.carbon.CarbonChat;
|
|
import net.draycia.carbon.storage.CommandSettings;
|
|
import net.draycia.carbon.util.CommandUtils;
|
|
import net.kyori.adventure.text.Component;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
|
|
|
public class ChatReloadCommand {
|
|
|
|
@NonNull
|
|
private final CarbonChat carbonChat;
|
|
|
|
public ChatReloadCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
|
this.carbonChat = carbonChat;
|
|
|
|
if (!commandSettings.enabled()) {
|
|
return;
|
|
}
|
|
|
|
CommandUtils.handleDuplicateCommands(commandSettings);
|
|
|
|
new CommandAPICommand(commandSettings.name())
|
|
.withAliases(commandSettings.aliases())
|
|
.withPermission(CommandPermission.fromString("carbonchat.reload"))
|
|
.executes(this::execute)
|
|
.register();
|
|
}
|
|
|
|
private void execute(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
|
this.carbonChat.reloadConfig();
|
|
this.carbonChat.reloadFilters();
|
|
|
|
final Component message = this.carbonChat.adventureManager()
|
|
.processMessage(this.carbonChat.language().getString("reloaded"), "br", "\n");
|
|
|
|
this.carbonChat.adventureManager().audiences().sender(sender).sendMessage(message);
|
|
}
|
|
|
|
}
|