mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 22:15:45 +00:00
Add reload command
This commit is contained in:
1 parent
c4b90054d1
commit
fb8c773494
4 files changed
+71
-3
No files matched your search
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* CarbonChat
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 Josua Parks (Vicarious)
|
||||||
|
* Contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package net.draycia.carbon.common.command.commands;
|
||||||
|
|
||||||
|
import cloud.commandframework.CommandManager;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import net.draycia.carbon.common.command.Commander;
|
||||||
|
import net.draycia.carbon.common.config.ConfigFactory;
|
||||||
|
import net.draycia.carbon.common.config.PrimaryConfig;
|
||||||
|
import net.draycia.carbon.common.messages.CarbonMessageService;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||||
|
|
||||||
|
// TODO: listen to sponge reload stuff
|
||||||
|
@DefaultQualifier(NonNull.class)
|
||||||
|
public class ReloadCommand {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public ReloadCommand(
|
||||||
|
final CommandManager<Commander> commandManager,
|
||||||
|
final ConfigFactory configFactory,
|
||||||
|
final CarbonMessageService messageService
|
||||||
|
) {
|
||||||
|
final var command = commandManager.commandBuilder("creload", "carbonreload")
|
||||||
|
.permission("carbon.reload")
|
||||||
|
.senderType(Commander.class)
|
||||||
|
.handler(handler -> {
|
||||||
|
final @Nullable PrimaryConfig config = configFactory.reloadPrimaryConfig();
|
||||||
|
|
||||||
|
if (config != null) {
|
||||||
|
messageService.configReloaded(handler.getSender());
|
||||||
|
} else {
|
||||||
|
messageService.configReloadFailed(handler.getSender());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
commandManager.command(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -305,4 +305,10 @@ public interface CarbonMessageService {
|
|||||||
@Message("whisper.ignored_by_target")
|
@Message("whisper.ignored_by_target")
|
||||||
void whisperTargetIgnoring(final Audience audience, final @Placeholder Component target);
|
void whisperTargetIgnoring(final Audience audience, final @Placeholder Component target);
|
||||||
|
|
||||||
|
@Message("config.reload.success")
|
||||||
|
void configReloaded(final Audience audience);
|
||||||
|
|
||||||
|
@Message("config.reload.failed")
|
||||||
|
void configReloadFailed(final Audience audience);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,7 @@ import net.draycia.carbon.common.command.commands.HelpCommand;
|
|||||||
import net.draycia.carbon.common.command.commands.IgnoreCommand;
|
import net.draycia.carbon.common.command.commands.IgnoreCommand;
|
||||||
import net.draycia.carbon.common.command.commands.MuteCommand;
|
import net.draycia.carbon.common.command.commands.MuteCommand;
|
||||||
import net.draycia.carbon.common.command.commands.NicknameCommand;
|
import net.draycia.carbon.common.command.commands.NicknameCommand;
|
||||||
|
import net.draycia.carbon.common.command.commands.ReloadCommand;
|
||||||
import net.draycia.carbon.common.command.commands.ReplyCommand;
|
import net.draycia.carbon.common.command.commands.ReplyCommand;
|
||||||
import net.draycia.carbon.common.command.commands.UnignoreCommand;
|
import net.draycia.carbon.common.command.commands.UnignoreCommand;
|
||||||
import net.draycia.carbon.common.command.commands.UnmuteCommand;
|
import net.draycia.carbon.common.command.commands.UnmuteCommand;
|
||||||
@@ -58,9 +59,9 @@ public final class CloudUtils {
|
|||||||
private static final Component NULL = Component.text("null");
|
private static final Component NULL = Component.text("null");
|
||||||
private static final Pattern SPECIAL_CHARACTERS_PATTERN = Pattern.compile("[^\\s\\w\\-]");
|
private static final Pattern SPECIAL_CHARACTERS_PATTERN = Pattern.compile("[^\\s\\w\\-]");
|
||||||
|
|
||||||
public static final List<Class<?>> COMMAND_CLASSES = List.of(ClearChatCommand.class, ContinueCommand.class, DebugCommand.class,
|
public static final List<Class<?>> COMMAND_CLASSES = List.of(ClearChatCommand.class, ContinueCommand.class,
|
||||||
HelpCommand.class, IgnoreCommand.class, MuteCommand.class, NicknameCommand.class, ReplyCommand.class, UnignoreCommand.class,
|
DebugCommand.class, HelpCommand.class, IgnoreCommand.class, MuteCommand.class, NicknameCommand.class,
|
||||||
UnmuteCommand.class, WhisperCommand.class);
|
ReloadCommand.class, ReplyCommand.class, UnignoreCommand.class, UnmuteCommand.class, WhisperCommand.class);
|
||||||
|
|
||||||
private CloudUtils() {
|
private CloudUtils() {
|
||||||
|
|
||||||
|
|||||||
@@ -57,3 +57,5 @@ ignore.now_ignoring=<green>You are now ignoring <target>
|
|||||||
ignore.no_longer_ignoring=<green>You are no longer ignoring <target>
|
ignore.no_longer_ignoring=<green>You are no longer ignoring <target>
|
||||||
whisper.ignoring_target=<red>You are ignoring <target>
|
whisper.ignoring_target=<red>You are ignoring <target>
|
||||||
whisper.ignored_by_target=<red><target> <red>is ignoring you
|
whisper.ignored_by_target=<red><target> <red>is ignoring you
|
||||||
|
config.reload.success=<green>Config reloaded successfully
|
||||||
|
config.reload.failed=<red>Config failed to reload
|
||||||
Reference in new issue
Block a user