[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
// WILL TRY TO WRITE THESE TO THE CONFIG
public transient static SDLinkConfig INSTANCE;
public transient static int configVer = 5;
public transient static int configVer = 6;
@Path("general")
@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")
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")
@SpecComment("Control what the Discord Bot will display as it's status message")
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")
public boolean linkedWhitelist = false;
@Path("staffOnlyWhitelist")
@SpecComment("Should only staff be allowed to whitelist players")
public boolean staffOnlyWhitelist = false;
@Path("autoWhitelistRole")
@SpecComment("If a role ID (or name) is defined here, it will be assigned to players when they are whitelisted")
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;
import me.hypherionmc.moonconfig.core.conversion.Path;
@@ -14,7 +18,7 @@ public class MessageIgnoreConfig {
@Path("entries")
@SpecComment("List of entries to process")
public List<Ignore> entires = new ArrayList<>();
public List<Ignore> entries = new ArrayList<>();
@Path("ignoredThreads")
@SpecComment("Ignore messages sent from certain threads")

View File

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

View File

@@ -5,7 +5,6 @@
package com.hypherionmc.sdlink.core.discord.commands.slash.whitelist;
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.discord.commands.slash.SDLinkSlashCommand;
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 WhitelistAccountCommand() {
super(SDLinkConfig.INSTANCE.whitelistingAndLinking.whitelisting.staffOnlyWhitelist);
super(false);
this.name = "whitelist";
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;
import com.hypherionmc.sdlink.core.discord.BotController;

View File

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

View File

@@ -55,7 +55,7 @@ public final class DiscordMessageBuilder {
}
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.action == MessageIgnoreConfig.ActionMode.REPLACE) {
message = message.replace(i.search, i.replace);