From 5ccf8f7cb7513004d2d9daef447b461c89a527b0 Mon Sep 17 00:00:00 2001 From: Vankka Date: Tue, 26 Apr 2022 15:37:41 +0300 Subject: [PATCH] Rename Shutdown Behaviour to Channel Locking --- .../discordsrv/common/AbstractDiscordSRV.java | 4 +-- ...rModule.java => ChannelLockingModule.java} | 20 +++++++------- ...rConfig.java => ChannelLockingConfig.java} | 2 +- .../main/channels/base/BaseChannelConfig.java | 2 +- .../common/discord/api/DiscordAPIImpl.java | 2 +- .../discord/api/ThreadChannelLookup.java | 27 ++++++++----------- 6 files changed, 26 insertions(+), 31 deletions(-) rename common/src/main/java/com/discordsrv/common/channel/{ChannelShutdownBehaviourModule.java => ChannelLockingModule.java} (86%) rename common/src/main/java/com/discordsrv/common/config/main/channels/{ShutdownBehaviourConfig.java => ChannelLockingConfig.java} (98%) diff --git a/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java b/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java index a84708d1..37a2c5a7 100644 --- a/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java +++ b/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java @@ -27,7 +27,7 @@ import com.discordsrv.api.module.type.Module; import com.discordsrv.common.api.util.ApiInstanceUtil; import com.discordsrv.common.bootstrap.IBootstrap; import com.discordsrv.common.channel.ChannelConfigHelper; -import com.discordsrv.common.channel.ChannelShutdownBehaviourModule; +import com.discordsrv.common.channel.ChannelLockingModule; import com.discordsrv.common.channel.ChannelUpdaterModule; import com.discordsrv.common.channel.GlobalChannelLookupModule; import com.discordsrv.common.command.game.GameCommandModule; @@ -493,7 +493,7 @@ public abstract class AbstractDiscordSRV { +public class ChannelLockingModule extends AbstractModule { - public ChannelShutdownBehaviourModule(DiscordSRV discordSRV) { + public ChannelLockingModule(DiscordSRV discordSRV) { super(discordSRV); } @@ -49,9 +49,9 @@ public class ChannelShutdownBehaviourModule extends AbstractModule { @Override public void enable() { doForAllChannels((config, channelConfig) -> { - OrDefault shutdownConfig = config.map(cfg -> cfg.shutdownBehaviour); - OrDefault channels = shutdownConfig.map(cfg -> cfg.channels); - OrDefault threads = shutdownConfig.map(cfg -> cfg.threads); + OrDefault shutdownConfig = config.map(cfg -> cfg.channelLocking); + OrDefault channels = shutdownConfig.map(cfg -> cfg.channels); + OrDefault threads = shutdownConfig.map(cfg -> cfg.threads); if (threads.get(cfg -> cfg.unarchive, true)) { discordSRV.discordAPI().findOrCreateThreads(config, channelConfig, __ -> {}, new ArrayList<>(), false); @@ -63,9 +63,9 @@ public class ChannelShutdownBehaviourModule extends AbstractModule { @Override public void disable() { doForAllChannels((config, channelConfig) -> { - OrDefault shutdownConfig = config.map(cfg -> cfg.shutdownBehaviour); - OrDefault channels = shutdownConfig.map(cfg -> cfg.channels); - OrDefault threads = shutdownConfig.map(cfg -> cfg.threads); + OrDefault shutdownConfig = config.map(cfg -> cfg.channelLocking); + OrDefault channels = shutdownConfig.map(cfg -> cfg.channels); + OrDefault threads = shutdownConfig.map(cfg -> cfg.threads); if (threads.get(cfg -> cfg.archive, true)) { for (DiscordThreadChannel thread : discordSRV.discordAPI().findThreads(config, channelConfig)) { @@ -81,7 +81,7 @@ public class ChannelShutdownBehaviourModule extends AbstractModule { private void channelPermissions( IChannelConfig channelConfig, - OrDefault shutdownConfig, + OrDefault shutdownConfig, boolean state ) { JDA jda = discordSRV.jda().orElse(null); diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/ShutdownBehaviourConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/ChannelLockingConfig.java similarity index 98% rename from common/src/main/java/com/discordsrv/common/config/main/channels/ShutdownBehaviourConfig.java rename to common/src/main/java/com/discordsrv/common/config/main/channels/ChannelLockingConfig.java index 1f808797..6b2e5a6d 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/ShutdownBehaviourConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/ChannelLockingConfig.java @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.List; @ConfigSerializable -public class ShutdownBehaviourConfig { +public class ChannelLockingConfig { public Channels channels = new Channels(); public Threads threads = new Threads(); diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/base/BaseChannelConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/base/BaseChannelConfig.java index 36e5c2b6..87aa3278 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/base/BaseChannelConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/base/BaseChannelConfig.java @@ -53,5 +53,5 @@ public class BaseChannelConfig { public MirroringConfig mirroring = new MirroringConfig(); @Order(50) - public ShutdownBehaviourConfig shutdownBehaviour = new ShutdownBehaviourConfig(); + public ChannelLockingConfig channelLocking = new ChannelLockingConfig(); } diff --git a/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIImpl.java index e9cf5187..6aa2e221 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIImpl.java @@ -187,7 +187,7 @@ public class DiscordAPIImpl implements DiscordAPI { ThreadConfig threadConfig, DiscordTextChannel textChannel ) { - if (!config.map(cfg -> cfg.shutdownBehaviour).map(cfg -> cfg.threads).get(cfg -> cfg.unarchive, true)) { + if (!config.map(cfg -> cfg.channelLocking).map(cfg -> cfg.threads).get(cfg -> cfg.unarchive, true)) { return textChannel.createThread(threadConfig.threadName, threadConfig.privateThread); } diff --git a/common/src/main/java/com/discordsrv/common/discord/api/ThreadChannelLookup.java b/common/src/main/java/com/discordsrv/common/discord/api/ThreadChannelLookup.java index 592c8f7f..f915f20f 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/ThreadChannelLookup.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/ThreadChannelLookup.java @@ -1,24 +1,19 @@ /* - * This file is part of the DiscordSRV API, licensed under the MIT License + * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2022 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * 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. * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * 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. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.discordsrv.common.discord.api;