Force flag names to be 64 characters or less

- A few people seem to be on interesting SQL installs. This should fix the issues they have with 767 bytes,
This commit is contained in:
dordsor21 2020-04-30 11:52:39 +01:00
parent b56d4d0fea
commit 5e842f1572
2 changed files with 4 additions and 2 deletions

View File

@ -1211,7 +1211,7 @@ public class SQLManager implements AbstractDB {
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_flags`("
+ "`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,"
+ "`plot_id` INT(11) NOT NULL," + " `flag` VARCHAR(256),"
+ "`plot_id` INT(11) NOT NULL," + " `flag` VARCHAR(64),"
+ " `value` VARCHAR(512)," + "FOREIGN KEY (plot_id) REFERENCES `" + this.prefix
+ "plot` (id) ON DELETE CASCADE, " + "UNIQUE (plot_id, flag)"
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
@ -1270,7 +1270,7 @@ public class SQLManager implements AbstractDB {
+ " `value` blob NOT NULL" + ')');
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_flags`("
+ "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`plot_id` INTEGER NOT NULL,"
+ " `flag` VARCHAR(256)," + " `value` VARCHAR(512),"
+ " `flag` VARCHAR(64)," + " `value` VARCHAR(512),"
+ "FOREIGN KEY (plot_id) REFERENCES `" + this.prefix
+ "plot` (id) ON DELETE CASCADE, " + "UNIQUE (plot_id, flag))");
}

View File

@ -75,6 +75,8 @@ public abstract class PlotFlag<T, F extends PlotFlag<T, F>> {
flagName.append(chars[i]);
}
}
Preconditions.checkState(flagName.length() <= 64,
"flag name may not be more than 64 characters. Check: " + flagName.toString());
this.flagName = flagName.toString();
}