From 5e842f1572ffb01fb8a5d8101d5e6e1eef0398ce Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 30 Apr 2020 11:52:39 +0100 Subject: [PATCH] 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, --- .../main/java/com/plotsquared/core/database/SQLManager.java | 4 ++-- .../main/java/com/plotsquared/core/plot/flag/PlotFlag.java | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/database/SQLManager.java b/Core/src/main/java/com/plotsquared/core/database/SQLManager.java index b0608291b..124814d63 100644 --- a/Core/src/main/java/com/plotsquared/core/database/SQLManager.java +++ b/Core/src/main/java/com/plotsquared/core/database/SQLManager.java @@ -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))"); } diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java index 513398a39..53830c8ae 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java @@ -75,6 +75,8 @@ public abstract class PlotFlag> { 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(); }