Fixed bug, Optional bug remains

This commit is contained in:
Savvy 2017-09-28 21:18:32 -04:00
parent 7675fe3ec3
commit f7debb212d
4 changed files with 20 additions and 12 deletions

View File

@ -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'

View File

@ -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")) {

View File

@ -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;
}

View File

@ -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"));