[CHORE] Code Cleanup and Bug Fixes
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
version_major=0
|
||||
version_minor=0
|
||||
version_patch=18
|
||||
version_patch=19
|
||||
|
||||
shade_group=com.hypherionmc.sdlink.shaded.
|
||||
|
||||
# Core Dependencies
|
||||
jda=5.0.0-beta.12
|
||||
jda=5.0.0-beta.13
|
||||
chewtils=2.0-SNAPSHOT
|
||||
webhooks=0.7.5
|
||||
commons4=4.4
|
||||
|
@@ -134,17 +134,13 @@ public class MinecraftAccount {
|
||||
|
||||
String finalnickname = SDLinkConfig.INSTANCE.whitelistingAndLinking.accountLinking.nicknameFormat.replace("%nick%", nickname).replace("%mcname%", suffix);
|
||||
|
||||
if (finalnickname.length() > 32) {
|
||||
finalnickname = finalnickname.substring(0, 28) + "...";
|
||||
}
|
||||
|
||||
if (SDLinkConfig.INSTANCE.whitelistingAndLinking.accountLinking.changeNickname && updateNick) {
|
||||
try {
|
||||
member.modifyNickname(finalnickname).queue();
|
||||
|
||||
try {
|
||||
if (RoleManager.getLinkedRole() != null) {
|
||||
guild.addRoleToMember(UserSnowflake.fromId(member.getId()), RoleManager.getLinkedRole()).queue();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (SDLinkConfig.INSTANCE.generalConfig.debugging) {
|
||||
e.printStackTrace();
|
||||
@@ -152,6 +148,14 @@ public class MinecraftAccount {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (RoleManager.getLinkedRole() != null) {
|
||||
guild.addRoleToMember(UserSnowflake.fromId(member.getId()), RoleManager.getLinkedRole()).queue();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return Result.success("Your Discord and MC accounts have been linked");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@@ -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 = 9;
|
||||
public transient static int configVer = 10;
|
||||
|
||||
@Path("general")
|
||||
@SpecComment("General Mod Config")
|
||||
|
@@ -39,7 +39,7 @@ public class ChannelWebhookConfig {
|
||||
public long eventsChannelID = 0;
|
||||
|
||||
@Path("consoleChannelID")
|
||||
@SpecComment("If this ID is set, console messages sent after the bot started will be relayed here, and you can execute minecraft commands here")
|
||||
@SpecComment("If this ID is set, console messages sent after the bot started will be relayed here")
|
||||
public long consoleChannelID = 0;
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ public class ChannelWebhookConfig {
|
||||
public String chatWebhook = "";
|
||||
|
||||
@Path("eventsWebhook")
|
||||
@SpecComment("The URL of the channel webhook to use for Server Messages Will be encrypted on first run")
|
||||
@SpecComment("The URL of the channel webhook to use for Server Messages. Will be encrypted on first run")
|
||||
public String eventsWebhook = "";
|
||||
|
||||
@Path("consoleWebhook")
|
||||
@SpecComment("The URL of the channel webhook to use for Console Messages Will be encrypted on first run")
|
||||
@SpecComment("The URL of the channel webhook to use for Console Messages. DOES NOT WORK FOR CONSOLE RELAY! Will be encrypted on first run")
|
||||
public String consoleWebhook = "";
|
||||
}
|
||||
|
||||
|
@@ -90,7 +90,7 @@ public class ChatSettingsConfig {
|
||||
public boolean broadcastCommands = true;
|
||||
|
||||
@Path("ignoredCommands")
|
||||
@SpecComment("Commands that should not be broadcasted to discord")
|
||||
@SpecComment("Commands that should not be broadcast to discord")
|
||||
public List<String> ignoredCommands = new ArrayList<String>() {{ add("particle"); add("login"); add("execute"); }};
|
||||
|
||||
@Path("allowMentionsFromChat")
|
||||
|
@@ -56,7 +56,7 @@ public class LinkAndWhitelistConfigSettings {
|
||||
public boolean linkedWhitelist = false;
|
||||
|
||||
@Path("autoWhitelist")
|
||||
@SpecComment("Allow automatically whitelisting and de-whitelisting users with autoWhitelistRoles")
|
||||
@SpecComment("Allow automatically whitelisting and de-whitelisting users with autoWhitelistRoles. WARNING: You cannot use the regular whitelist commands if this is enabled")
|
||||
public boolean autoWhitelist = false;
|
||||
|
||||
@Path("autoWhitelistRoles")
|
||||
|
@@ -5,6 +5,7 @@
|
||||
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.messaging.Result;
|
||||
@@ -33,6 +34,11 @@ public class ConfirmWhitelistSlashCommand extends SDLinkSlashCommand {
|
||||
|
||||
@Override
|
||||
protected void execute(SlashCommandEvent event) {
|
||||
if (SDLinkConfig.INSTANCE.whitelistingAndLinking.whitelisting.autoWhitelist) {
|
||||
event.reply("Sorry, but this server uses auto-whitelisting based on roles. This command cannot be used").setEphemeral(true).queue();
|
||||
return;
|
||||
}
|
||||
|
||||
int mcCode = event.getOption("code") != null ? event.getOption("code").getAsInt() : 0;
|
||||
|
||||
if (mcCode == 0) {
|
||||
|
@@ -5,6 +5,7 @@
|
||||
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.messaging.Result;
|
||||
@@ -29,6 +30,11 @@ public class UnWhitelistAccountSlashCommand extends SDLinkSlashCommand {
|
||||
|
||||
@Override
|
||||
protected void execute(SlashCommandEvent event) {
|
||||
if (SDLinkConfig.INSTANCE.whitelistingAndLinking.whitelisting.autoWhitelist) {
|
||||
event.reply("Sorry, but this server uses auto-whitelisting based on roles. This command cannot be used").setEphemeral(true).queue();
|
||||
return;
|
||||
}
|
||||
|
||||
sdlinkDatabase.reloadCollection("accounts");
|
||||
List<SDLinkAccount> accounts = sdlinkDatabase.findAll(SDLinkAccount.class);
|
||||
|
||||
|
@@ -5,6 +5,7 @@
|
||||
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;
|
||||
@@ -37,6 +38,11 @@ public class WhitelistAccountCommand extends SDLinkSlashCommand {
|
||||
|
||||
@Override
|
||||
protected void execute(SlashCommandEvent event) {
|
||||
if (SDLinkConfig.INSTANCE.whitelistingAndLinking.whitelisting.autoWhitelist) {
|
||||
event.reply("Sorry, but this server uses auto-whitelisting based on roles. This command cannot be used").setEphemeral(true).queue();
|
||||
return;
|
||||
}
|
||||
|
||||
String mcName = event.getOption("mcname") != null ? event.getOption("mcname").getAsString() : "";
|
||||
|
||||
if (mcName.isEmpty()) {
|
||||
|
@@ -94,12 +94,12 @@ public class LogReader extends AbstractAppender {
|
||||
if (!BotController.INSTANCE.isBotReady())
|
||||
return;
|
||||
if (System.currentTimeMillis() - time > 250) {
|
||||
logs = logs.replaceAll("\\b(?:(?:2(?:[0-4][0-9]|5[0-5])|[0-1]?[0-9]?[0-9])\\.){3}(?:(?:2([0-4][0-9]|5[0-5])|[0-1]?[0-9]?[0-9]))\\b", "[REDACTED]");
|
||||
|
||||
if (logs.length() > 2000) {
|
||||
logs = logs.substring(0, 1999);
|
||||
}
|
||||
|
||||
logs = logs.replaceAll("\\b(?:(?:2(?:[0-4][0-9]|5[0-5])|[0-1]?[0-9]?[0-9])\\.){3}(?:(?:2([0-4][0-9]|5[0-5])|[0-1]?[0-9]?[0-9]))\\b", "[REDACTED]");
|
||||
|
||||
DiscordMessage discordMessage = new DiscordMessageBuilder(MessageType.CONSOLE)
|
||||
.message(logs)
|
||||
.author(DiscordAuthor.SERVER)
|
||||
|
Reference in New Issue
Block a user