From f7debb212da47851fe1c48ab1d1b6adb068255a2 Mon Sep 17 00:00:00 2001 From: Savvy Date: Thu, 28 Sep 2017 21:18:32 -0400 Subject: [PATCH] Fixed bug, Optional bug remains --- build.gradle | 4 ++-- .../me/savvy/rixa/commands/admin/ConfigCommand.java | 13 ++++++++----- src/main/java/me/savvy/rixa/guild/RixaGuild.java | 9 ++++++--- .../savvy/rixa/guild/management/GuildSettings.java | 6 ++++-- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index 771a601..d59a109 100644 --- a/build.gradle +++ b/build.gradle @@ -24,9 +24,9 @@ repositories { } dependencies { - compile 'net.dv8tion:JDA:3.1.1_215' + compile 'net.dv8tion:JDA:3.3.1_284' compile 'mysql:mysql-connector-java:5.1.38' - compile 'com.sedmelluq:lavaplayer:1.2.42' + compile 'com.sedmelluq:lavaplayer:1.2.43' compile 'org.twitter4j:twitter4j-core:4.0.3' compile 'org.twitter4j:twitter4j-stream:4.0.6' compile 'org.projectlombok:lombok:1.16.18' diff --git a/src/main/java/me/savvy/rixa/commands/admin/ConfigCommand.java b/src/main/java/me/savvy/rixa/commands/admin/ConfigCommand.java index 4fa834c..a7006ad 100644 --- a/src/main/java/me/savvy/rixa/commands/admin/ConfigCommand.java +++ b/src/main/java/me/savvy/rixa/commands/admin/ConfigCommand.java @@ -14,7 +14,6 @@ import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.core.entities.Role; import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; -import org.apache.commons.lang3.EnumUtils; import java.util.Arrays; import java.util.List; @@ -201,8 +200,10 @@ public class ConfigCommand implements CommandExec { } else if (messages[1].equalsIgnoreCase("addperm") || messages[1].equalsIgnoreCase("addpermission") || messages[1].equalsIgnoreCase("aperm")) { String permission = "notFound"; for (String string : messages) { - if (EnumUtils.isValidEnum(RixaPermission.class, string.toUpperCase())) { - permission = string.toUpperCase(); + for(RixaPermission rixaPermission: RixaPermission.values()) { + if (rixaPermission.name().equalsIgnoreCase(string)) { + permission = string.toUpperCase(); + } } } if (permission.equalsIgnoreCase("notFound")) { @@ -229,8 +230,10 @@ public class ConfigCommand implements CommandExec { || messages[1].equalsIgnoreCase("delperm")) { String permission = "notFound"; for (String string : messages) { - if (EnumUtils.isValidEnum(RixaPermission.class, string.toUpperCase())) { - permission = string.toUpperCase(); + for(RixaPermission rixaPermission: RixaPermission.values()) { + if (rixaPermission.name().equalsIgnoreCase(string)) { + permission = string.toUpperCase(); + } } } if (permission.equalsIgnoreCase("notFound")) { diff --git a/src/main/java/me/savvy/rixa/guild/RixaGuild.java b/src/main/java/me/savvy/rixa/guild/RixaGuild.java index 5d85deb..77289b6 100644 --- a/src/main/java/me/savvy/rixa/guild/RixaGuild.java +++ b/src/main/java/me/savvy/rixa/guild/RixaGuild.java @@ -73,8 +73,12 @@ public class RixaGuild { try { Query query = new Query("SELECT `guild_name` FROM `core` WHERE `guild_id` = '" + guild.getId() + "';"); Optional optional = db.send(query); - if (!optional.isPresent()) r = Result.ERROR; - if (!(optional.get() instanceof ResultSet)) r = Result.ERROR; + if (!optional.isPresent() || !(optional.get() instanceof ResultSet)) { + r = Result.ERROR; + } else { + r = Result.SUCCESS; + } + if (r != Result.ERROR) { ResultSet set = (ResultSet) optional.get(); if (set.next()) { @@ -87,7 +91,6 @@ public class RixaGuild { } catch (SQLException e) { e.printStackTrace(); } - return r == Result.TRUE; } diff --git a/src/main/java/me/savvy/rixa/guild/management/GuildSettings.java b/src/main/java/me/savvy/rixa/guild/management/GuildSettings.java index 5bd6d3f..553b326 100644 --- a/src/main/java/me/savvy/rixa/guild/management/GuildSettings.java +++ b/src/main/java/me/savvy/rixa/guild/management/GuildSettings.java @@ -57,8 +57,10 @@ public class GuildSettings { Query query = new Query("SELECT * FROM `settings` WHERE `guild_id` = ?"); query.setString(guild.getId()); Optional optional = Rixa.getDatabase().send(query); - if (!optional.isPresent()) return; - if (!(optional.get() instanceof ResultSet)) return; + if (!optional.isPresent() || !(optional.get() instanceof ResultSet)) { + Rixa.getInstance().getLogger().severe("Could not find " + guild.getName() + ", GuildSettings:60"); + return; + } ResultSet set = (ResultSet) optional.get(); if (set.next()) { this.prefix = (set.getString("prefix"));