From cc7e1e4999fc192ff752e3c23e0b292ae26ce3ff Mon Sep 17 00:00:00 2001 From: ByteDream Date: Sat, 5 Dec 2020 00:46:54 +0100 Subject: [PATCH] Code cleanup --- .../bytedream/untisbot/discord/Discord.java | 2 +- .../discord/DiscordCommandListener.java | 21 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/org/bytedream/untisbot/discord/Discord.java b/src/org/bytedream/untisbot/discord/Discord.java index a087c4e..bbd412a 100755 --- a/src/org/bytedream/untisbot/discord/Discord.java +++ b/src/org/bytedream/untisbot/discord/Discord.java @@ -12,7 +12,6 @@ import org.json.JSONTokener; import javax.security.auth.login.LoginException; import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; @@ -50,6 +49,7 @@ public class Discord { /** * Show rich presence if a bot update was released within then last 24 hours + * * @since 1.1 */ private void updateRichPresence() { diff --git a/src/org/bytedream/untisbot/discord/DiscordCommandListener.java b/src/org/bytedream/untisbot/discord/DiscordCommandListener.java index f74276b..0ac4213 100755 --- a/src/org/bytedream/untisbot/discord/DiscordCommandListener.java +++ b/src/org/bytedream/untisbot/discord/DiscordCommandListener.java @@ -89,12 +89,11 @@ public class DiscordCommandListener extends ListenerAdapter { /** * Runs a command * - * @param guild guild from which the command came - * @param channel channel from which the command came + * @param guild guild from which the command came + * @param channel channel from which the command came * @param permission if true, commands which needs (admin) permission to run, can be executed - * @param command command to execute - * @param args extra arguments for the command - * + * @param command command to execute + * @param args extra arguments for the command * @since 1.1 */ private void runCommand(Guild guild, TextChannel channel, boolean permission, String command, String[] args) { @@ -174,7 +173,8 @@ public class DiscordCommandListener extends ListenerAdapter { try { session.reconnect(); className = session.getKlassen().findById(classId).getName(); - } catch (IOException ignore) {} + } catch (IOException ignore) { + } String finalClassName = className; // yea java... LocalDate finalDate = date; // yea java part two... @@ -195,7 +195,7 @@ public class DiscordCommandListener extends ListenerAdapter { } for (int i = 0; i < lessons.size(); i++) { ArrayList listLessons = (ArrayList) lessons.values().toArray()[i]; - for (Timetable.Lesson lesson: (ArrayList) lessons.values().toArray()[i]) { + for (Timetable.Lesson lesson : (ArrayList) lessons.values().toArray()[i]) { String additional = ""; if (lesson.getCode() == UntisUtils.LessonCode.CANCELLED) { additional = "~~"; @@ -293,8 +293,7 @@ public class DiscordCommandListener extends ListenerAdapter { if (!data.isCheckActive()) { embedBuilder.setFooter("The timetable checker is deactivated. Type `" + data.getPrefix() + "start` to re-enable it - use `" + data.getPrefix() + "help start` for more details"); } - } - else { + } else { dataSet = "❌ Not set"; embedBuilder.setFooter("To set your data, type `" + data.getPrefix() + "set-data ` - use `" + data.getPrefix() + "help data` for more details"); } @@ -681,7 +680,7 @@ public class DiscordCommandListener extends ListenerAdapter { error = false; } } else if (lastChecked == null || lastChecked.isBefore(now.plusDays(i))) { - guildDataConnector.update(guildId, null, null, null, null, null, null, null, null, null, null, now.plusDays(i)); + guildDataConnector.update(guildId, null, null, null, null, null, null, null, null, null, null, now.plusDays(i)); } } catch (Exception e) { logger.warn(guildName + " ran into an exception while trying to check the timetable for the " + localDate.format(DateTimeFormatter.ofPattern("dd.MM.yyyy")), e); @@ -777,7 +776,7 @@ public class DiscordCommandListener extends ListenerAdapter { String command = ""; String[] args = null; - for (String cmd: commands) { + for (String cmd : commands) { if (message.contains(cmd)) { if (event.isFromGuild()) { prefix = guildDataConnector.get(event.getGuild().getIdLong()).getPrefix();