MySQL data fix

This commit is contained in:
Esophose 2019-06-04 03:22:53 -06:00
parent 0dff6dabb3
commit 1e298e4f75
3 changed files with 8 additions and 3 deletions

View File

@ -54,6 +54,7 @@ public class StorageItem {
public boolean asBoolean() {
if (object == null) return false;
if (object instanceof Integer) return (Integer) object == 1;
return (boolean) object;
}
@ -63,6 +64,8 @@ public class StorageItem {
}
public Object asObject() {
if (object == null) return null;
if (object instanceof Boolean) return (Boolean) object ? 1 : 0;
return object;
}

View File

@ -105,8 +105,10 @@ public class StorageMysql extends Storage {
continue;
toSave.remove(to.getKey());
for (int i = 0; i < to.getValue().length; i ++) {
if (!to.getValue()[i].asObject().toString()
.equals(last.getValue()[i].asObject().toString())) {
if ((to.getValue()[i].asObject() != null && last.getValue()[i].asObject() == null)
|| (last.getValue()[i].asObject() == null && to.getValue()[i].asObject() != null)
|| (last.getValue()[i].asObject() != null && to.getValue()[i].asObject() != null
&& !to.getValue()[i].asObject().toString().equals(last.getValue()[i].asObject().toString()))) {
//Update
StorageItem[] items = to.getValue();
StringBuilder sql = new StringBuilder(String.format("UPDATE `" + instance.getConfig().getString("Database.Prefix") + "%s`", toKey));

View File

@ -35,7 +35,7 @@ public class MySQLDatabase {
"\t`blacklist` TEXT NULL,\n" +
"\t`void` TEXT NULL,\n" +
"\t`black` TEXT NULL,\n" +
"\t`autobreak` TEXT NULL\n" +
"\t`autobreak` TINYINT(1) NULL\n" +
")");
connection.createStatement().execute("CREATE TABLE IF NOT EXISTS `" + instance.getConfig().getString("Database.Prefix") + "boosts` (\n" +