[CHORE] Code Cleanup and Bug Fixes
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
version_major=0
|
version_major=0
|
||||||
version_minor=0
|
version_minor=0
|
||||||
version_patch=18
|
version_patch=19
|
||||||
|
|
||||||
shade_group=com.hypherionmc.sdlink.shaded.
|
shade_group=com.hypherionmc.sdlink.shaded.
|
||||||
|
|
||||||
# Core Dependencies
|
# Core Dependencies
|
||||||
jda=5.0.0-beta.12
|
jda=5.0.0-beta.13
|
||||||
chewtils=2.0-SNAPSHOT
|
chewtils=2.0-SNAPSHOT
|
||||||
webhooks=0.7.5
|
webhooks=0.7.5
|
||||||
commons4=4.4
|
commons4=4.4
|
||||||
|
@@ -134,9 +134,19 @@ public class MinecraftAccount {
|
|||||||
|
|
||||||
String finalnickname = SDLinkConfig.INSTANCE.whitelistingAndLinking.accountLinking.nicknameFormat.replace("%nick%", nickname).replace("%mcname%", suffix);
|
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) {
|
if (SDLinkConfig.INSTANCE.whitelistingAndLinking.accountLinking.changeNickname && updateNick) {
|
||||||
try {
|
try {
|
||||||
member.modifyNickname(finalnickname).queue();
|
member.modifyNickname(finalnickname).queue();
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (SDLinkConfig.INSTANCE.generalConfig.debugging) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (RoleManager.getLinkedRole() != null) {
|
if (RoleManager.getLinkedRole() != null) {
|
||||||
@@ -145,12 +155,6 @@ public class MinecraftAccount {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
if (SDLinkConfig.INSTANCE.generalConfig.debugging) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result.success("Your Discord and MC accounts have been linked");
|
return Result.success("Your Discord and MC accounts have been linked");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@@ -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 = 9;
|
public transient static int configVer = 10;
|
||||||
|
|
||||||
@Path("general")
|
@Path("general")
|
||||||
@SpecComment("General Mod Config")
|
@SpecComment("General Mod Config")
|
||||||
|
@@ -39,7 +39,7 @@ public class ChannelWebhookConfig {
|
|||||||
public long eventsChannelID = 0;
|
public long eventsChannelID = 0;
|
||||||
|
|
||||||
@Path("consoleChannelID")
|
@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;
|
public long consoleChannelID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,11 +53,11 @@ public class ChannelWebhookConfig {
|
|||||||
public String chatWebhook = "";
|
public String chatWebhook = "";
|
||||||
|
|
||||||
@Path("eventsWebhook")
|
@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 = "";
|
public String eventsWebhook = "";
|
||||||
|
|
||||||
@Path("consoleWebhook")
|
@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 = "";
|
public String consoleWebhook = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -90,7 +90,7 @@ public class ChatSettingsConfig {
|
|||||||
public boolean broadcastCommands = true;
|
public boolean broadcastCommands = true;
|
||||||
|
|
||||||
@Path("ignoredCommands")
|
@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"); }};
|
public List<String> ignoredCommands = new ArrayList<String>() {{ add("particle"); add("login"); add("execute"); }};
|
||||||
|
|
||||||
@Path("allowMentionsFromChat")
|
@Path("allowMentionsFromChat")
|
||||||
|
@@ -56,7 +56,7 @@ public class LinkAndWhitelistConfigSettings {
|
|||||||
public boolean linkedWhitelist = false;
|
public boolean linkedWhitelist = false;
|
||||||
|
|
||||||
@Path("autoWhitelist")
|
@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;
|
public boolean autoWhitelist = false;
|
||||||
|
|
||||||
@Path("autoWhitelistRoles")
|
@Path("autoWhitelistRoles")
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
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.messaging.Result;
|
import com.hypherionmc.sdlink.core.messaging.Result;
|
||||||
@@ -33,6 +34,11 @@ public class ConfirmWhitelistSlashCommand extends SDLinkSlashCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute(SlashCommandEvent event) {
|
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;
|
int mcCode = event.getOption("code") != null ? event.getOption("code").getAsInt() : 0;
|
||||||
|
|
||||||
if (mcCode == 0) {
|
if (mcCode == 0) {
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
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.messaging.Result;
|
import com.hypherionmc.sdlink.core.messaging.Result;
|
||||||
@@ -29,6 +30,11 @@ public class UnWhitelistAccountSlashCommand extends SDLinkSlashCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute(SlashCommandEvent event) {
|
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");
|
sdlinkDatabase.reloadCollection("accounts");
|
||||||
List<SDLinkAccount> accounts = sdlinkDatabase.findAll(SDLinkAccount.class);
|
List<SDLinkAccount> accounts = sdlinkDatabase.findAll(SDLinkAccount.class);
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
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;
|
||||||
@@ -37,6 +38,11 @@ public class WhitelistAccountCommand extends SDLinkSlashCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute(SlashCommandEvent event) {
|
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() : "";
|
String mcName = event.getOption("mcname") != null ? event.getOption("mcname").getAsString() : "";
|
||||||
|
|
||||||
if (mcName.isEmpty()) {
|
if (mcName.isEmpty()) {
|
||||||
|
@@ -94,12 +94,12 @@ public class LogReader extends AbstractAppender {
|
|||||||
if (!BotController.INSTANCE.isBotReady())
|
if (!BotController.INSTANCE.isBotReady())
|
||||||
return;
|
return;
|
||||||
if (System.currentTimeMillis() - time > 250) {
|
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) {
|
if (logs.length() > 2000) {
|
||||||
logs = logs.substring(0, 1999);
|
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)
|
DiscordMessage discordMessage = new DiscordMessageBuilder(MessageType.CONSOLE)
|
||||||
.message(logs)
|
.message(logs)
|
||||||
.author(DiscordAuthor.SERVER)
|
.author(DiscordAuthor.SERVER)
|
||||||
|
Reference in New Issue
Block a user