[CHANGE] Remove Command Permissions Management from Config in favor of discord permissions

This commit is contained in:
2023-08-05 18:32:35 +02:00
parent 42e8adcfae
commit 95e1dfac70
9 changed files with 14 additions and 26 deletions

View File

@@ -24,7 +24,7 @@ public class SDLinkConfig extends ModuleConfig {
// DO NOT REMOVE TRANSIENT HERE... OTHERWISE, THE STUPID CONFIG LIBRARY // DO NOT REMOVE TRANSIENT HERE... OTHERWISE, THE STUPID CONFIG LIBRARY
// WILL TRY TO WRITE THESE TO THE CONFIG // WILL TRY TO WRITE THESE TO THE CONFIG
public transient static SDLinkConfig INSTANCE; public transient static SDLinkConfig INSTANCE;
public transient static int configVer = 5; public transient static int configVer = 6;
@Path("general") @Path("general")
@SpecComment("General Mod Config") @SpecComment("General Mod Config")

View File

@@ -22,10 +22,6 @@ public class BotConfigSettings {
@SpecComment("How often the Bot Status will update on Discord (in Seconds). Set to 0 to disable") @SpecComment("How often the Bot Status will update on Discord (in Seconds). Set to 0 to disable")
public int statusUpdateInterval = 30; public int statusUpdateInterval = 30;
@Path("staffRole")
@SpecComment("Role Name or ID that is allowed to use Staff Functions. If not defined, it will default back to Admin/Kick Perms")
public String staffRole = "";
@Path("botStatus") @Path("botStatus")
@SpecComment("Control what the Discord Bot will display as it's status message") @SpecComment("Control what the Discord Bot will display as it's status message")
public BotStatus botStatus = new BotStatus(); public BotStatus botStatus = new BotStatus();

View File

@@ -44,10 +44,6 @@ public class LinkAndWhitelistConfigSettings {
@SpecComment("Automatically link Minecraft and Discord Accounts when a user is whitelisted") @SpecComment("Automatically link Minecraft and Discord Accounts when a user is whitelisted")
public boolean linkedWhitelist = false; public boolean linkedWhitelist = false;
@Path("staffOnlyWhitelist")
@SpecComment("Should only staff be allowed to whitelist players")
public boolean staffOnlyWhitelist = false;
@Path("autoWhitelistRole") @Path("autoWhitelistRole")
@SpecComment("If a role ID (or name) is defined here, it will be assigned to players when they are whitelisted") @SpecComment("If a role ID (or name) is defined here, it will be assigned to players when they are whitelisted")
public String autoWhitelistRole = ""; public String autoWhitelistRole = "";

View File

@@ -1,3 +1,7 @@
/*
* This file is part of sdlink-core, licensed under the MIT License (MIT).
* Copyright HypherionSA and Contributors
*/
package com.hypherionmc.sdlink.core.config.impl; package com.hypherionmc.sdlink.core.config.impl;
import me.hypherionmc.moonconfig.core.conversion.Path; import me.hypherionmc.moonconfig.core.conversion.Path;
@@ -14,7 +18,7 @@ public class MessageIgnoreConfig {
@Path("entries") @Path("entries")
@SpecComment("List of entries to process") @SpecComment("List of entries to process")
public List<Ignore> entires = new ArrayList<>(); public List<Ignore> entries = new ArrayList<>();
@Path("ignoredThreads") @Path("ignoredThreads")
@SpecComment("Ignore messages sent from certain threads") @SpecComment("Ignore messages sent from certain threads")

View File

@@ -4,9 +4,7 @@
*/ */
package com.hypherionmc.sdlink.core.discord.commands.slash; package com.hypherionmc.sdlink.core.discord.commands.slash;
import com.hypherionmc.sdlink.core.managers.RoleManager;
import com.jagrosh.jdautilities.command.SlashCommand; import com.jagrosh.jdautilities.command.SlashCommand;
import net.dv8tion.jda.api.Permission;
/** /**
* @author HypherionSA * @author HypherionSA
@@ -15,13 +13,13 @@ import net.dv8tion.jda.api.Permission;
public abstract class SDLinkSlashCommand extends SlashCommand { public abstract class SDLinkSlashCommand extends SlashCommand {
public SDLinkSlashCommand(boolean requiresPerms) { public SDLinkSlashCommand(boolean requiresPerms) {
if (requiresPerms) { /*if (requiresPerms) {
if (RoleManager.getStaffRole() != null) { if (RoleManager.getStaffRole() != null) {
this.requiredRole = RoleManager.getStaffRole().getName(); this.requiredRole = RoleManager.getStaffRole().getName();
} else { } else {
this.userPermissions = new Permission[] { Permission.ADMINISTRATOR, Permission.KICK_MEMBERS }; this.userPermissions = new Permission[] { Permission.ADMINISTRATOR, Permission.KICK_MEMBERS };
} }
} }*/
this.guildOnly = true; this.guildOnly = true;
} }

View File

@@ -5,7 +5,6 @@
package com.hypherionmc.sdlink.core.discord.commands.slash.whitelist; package com.hypherionmc.sdlink.core.discord.commands.slash.whitelist;
import com.hypherionmc.sdlink.core.accounts.MinecraftAccount; import com.hypherionmc.sdlink.core.accounts.MinecraftAccount;
import com.hypherionmc.sdlink.core.config.SDLinkConfig;
import com.hypherionmc.sdlink.core.database.SDLinkAccount; import com.hypherionmc.sdlink.core.database.SDLinkAccount;
import com.hypherionmc.sdlink.core.discord.commands.slash.SDLinkSlashCommand; import com.hypherionmc.sdlink.core.discord.commands.slash.SDLinkSlashCommand;
import com.hypherionmc.sdlink.core.services.SDLinkPlatform; import com.hypherionmc.sdlink.core.services.SDLinkPlatform;
@@ -28,7 +27,7 @@ import static com.hypherionmc.sdlink.core.managers.DatabaseManager.sdlinkDatabas
public class WhitelistAccountCommand extends SDLinkSlashCommand { public class WhitelistAccountCommand extends SDLinkSlashCommand {
public WhitelistAccountCommand() { public WhitelistAccountCommand() {
super(SDLinkConfig.INSTANCE.whitelistingAndLinking.whitelisting.staffOnlyWhitelist); super(false);
this.name = "whitelist"; this.name = "whitelist";
this.help = "Start the process of Whitelisting your Minecraft Account"; this.help = "Start the process of Whitelisting your Minecraft Account";

View File

@@ -1,3 +1,7 @@
/*
* This file is part of sdlink-core, licensed under the MIT License (MIT).
* Copyright HypherionSA and Contributors
*/
package com.hypherionmc.sdlink.core.managers; package com.hypherionmc.sdlink.core.managers;
import com.hypherionmc.sdlink.core.discord.BotController; import com.hypherionmc.sdlink.core.discord.BotController;

View File

@@ -19,7 +19,6 @@ import java.util.concurrent.atomic.AtomicInteger;
*/ */
public class RoleManager { public class RoleManager {
private static Role staffRole;
private static Role whitelistedRole; private static Role whitelistedRole;
private static Role linkedRole; private static Role linkedRole;
private static final HashMap<String, Role> commandRoles = new HashMap<>(); private static final HashMap<String, Role> commandRoles = new HashMap<>();
@@ -30,10 +29,6 @@ public class RoleManager {
* @param builder * @param builder
*/ */
public static void loadRequiredRoles(AtomicInteger errCount, StringBuilder builder) { public static void loadRequiredRoles(AtomicInteger errCount, StringBuilder builder) {
if (!SDLinkConfig.INSTANCE.botConfig.staffRole.isEmpty()) {
staffRole = getRole(errCount, builder, "Staff", SDLinkConfig.INSTANCE.botConfig.staffRole);
}
if (!SDLinkConfig.INSTANCE.whitelistingAndLinking.whitelisting.autoWhitelistRole.isEmpty()) { if (!SDLinkConfig.INSTANCE.whitelistingAndLinking.whitelisting.autoWhitelistRole.isEmpty()) {
whitelistedRole = getRole(errCount, builder, "Whitelist", SDLinkConfig.INSTANCE.whitelistingAndLinking.whitelisting.autoWhitelistRole); whitelistedRole = getRole(errCount, builder, "Whitelist", SDLinkConfig.INSTANCE.whitelistingAndLinking.whitelisting.autoWhitelistRole);
} }
@@ -95,10 +90,6 @@ public class RoleManager {
return linkedRole; return linkedRole;
} }
public static Role getStaffRole() {
return staffRole;
}
public static Role getWhitelistedRole() { public static Role getWhitelistedRole() {
return whitelistedRole; return whitelistedRole;
} }

View File

@@ -55,7 +55,7 @@ public final class DiscordMessageBuilder {
} }
if (SDLinkConfig.INSTANCE.ignoreConfig.enabled) { if (SDLinkConfig.INSTANCE.ignoreConfig.enabled) {
for (MessageIgnoreConfig.Ignore i : SDLinkConfig.INSTANCE.ignoreConfig.entires) { for (MessageIgnoreConfig.Ignore i : SDLinkConfig.INSTANCE.ignoreConfig.entries) {
if (i.searchMode == MessageIgnoreConfig.FilterMode.MATCHES && message.equalsIgnoreCase(i.search)) { if (i.searchMode == MessageIgnoreConfig.FilterMode.MATCHES && message.equalsIgnoreCase(i.search)) {
if (i.action == MessageIgnoreConfig.ActionMode.REPLACE) { if (i.action == MessageIgnoreConfig.ActionMode.REPLACE) {
message = message.replace(i.search, i.replace); message = message.replace(i.search, i.replace);