Code cleanup

This commit is contained in:
ByteDream 2020-12-05 00:46:54 +01:00
parent 992accf51e
commit cc7e1e4999
2 changed files with 11 additions and 12 deletions

View File

@ -12,7 +12,6 @@ import org.json.JSONTokener;
import javax.security.auth.login.LoginException; import javax.security.auth.login.LoginException;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; 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 * Show rich presence if a bot update was released within then last 24 hours
*
* @since 1.1 * @since 1.1
*/ */
private void updateRichPresence() { private void updateRichPresence() {

View File

@ -89,12 +89,11 @@ public class DiscordCommandListener extends ListenerAdapter {
/** /**
* Runs a command * Runs a command
* *
* @param guild guild from which the command came * @param guild guild from which the command came
* @param channel channel 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 permission if true, commands which needs (admin) permission to run, can be executed
* @param command command to execute * @param command command to execute
* @param args extra arguments for the command * @param args extra arguments for the command
*
* @since 1.1 * @since 1.1
*/ */
private void runCommand(Guild guild, TextChannel channel, boolean permission, String command, String[] args) { private void runCommand(Guild guild, TextChannel channel, boolean permission, String command, String[] args) {
@ -174,7 +173,8 @@ public class DiscordCommandListener extends ListenerAdapter {
try { try {
session.reconnect(); session.reconnect();
className = session.getKlassen().findById(classId).getName(); className = session.getKlassen().findById(classId).getName();
} catch (IOException ignore) {} } catch (IOException ignore) {
}
String finalClassName = className; // yea java... String finalClassName = className; // yea java...
LocalDate finalDate = date; // yea java part two... LocalDate finalDate = date; // yea java part two...
@ -195,7 +195,7 @@ public class DiscordCommandListener extends ListenerAdapter {
} }
for (int i = 0; i < lessons.size(); i++) { for (int i = 0; i < lessons.size(); i++) {
ArrayList<Timetable.Lesson> listLessons = (ArrayList<Timetable.Lesson>) lessons.values().toArray()[i]; ArrayList<Timetable.Lesson> listLessons = (ArrayList<Timetable.Lesson>) lessons.values().toArray()[i];
for (Timetable.Lesson lesson: (ArrayList<Timetable.Lesson>) lessons.values().toArray()[i]) { for (Timetable.Lesson lesson : (ArrayList<Timetable.Lesson>) lessons.values().toArray()[i]) {
String additional = ""; String additional = "";
if (lesson.getCode() == UntisUtils.LessonCode.CANCELLED) { if (lesson.getCode() == UntisUtils.LessonCode.CANCELLED) {
additional = "~~"; additional = "~~";
@ -293,8 +293,7 @@ public class DiscordCommandListener extends ListenerAdapter {
if (!data.isCheckActive()) { 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"); 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"; dataSet = "❌ Not set";
embedBuilder.setFooter("To set your data, type `" + data.getPrefix() + "set-data <username> <password> <loginpage url>` - use `" + data.getPrefix() + "help data` for more details"); embedBuilder.setFooter("To set your data, type `" + data.getPrefix() + "set-data <username> <password> <loginpage url>` - use `" + data.getPrefix() + "help data` for more details");
} }
@ -681,7 +680,7 @@ public class DiscordCommandListener extends ListenerAdapter {
error = false; error = false;
} }
} else if (lastChecked == null || lastChecked.isBefore(now.plusDays(i))) { } 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) { } 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); 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 command = "";
String[] args = null; String[] args = null;
for (String cmd: commands) { for (String cmd : commands) {
if (message.contains(cmd)) { if (message.contains(cmd)) {
if (event.isFromGuild()) { if (event.isFromGuild()) {
prefix = guildDataConnector.get(event.getGuild().getIdLong()).getPrefix(); prefix = guildDataConnector.get(event.getGuild().getIdLong()).getPrefix();