Fixed MysqlDataTruncation error when logging custom skull data

This commit is contained in:
Intelli 2024-05-11 15:08:16 -06:00
parent 377a6f55b9
commit d18a023e73
3 changed files with 41 additions and 2 deletions

View File

@ -372,7 +372,7 @@ public class Database extends Queue {
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "session(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int, user int, wid int, x int, y int (3), z int, action tinyint" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(wid,x,z,time), INDEX(user,time), INDEX(time)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "sign(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int, user int, wid int, x int, y int, z int, action tinyint, color int, color_secondary int, data tinyint, waxed tinyint, face tinyint, line_1 varchar(100), line_2 varchar(100), line_3 varchar(100), line_4 varchar(100), line_5 varchar(100), line_6 varchar(100), line_7 varchar(100), line_8 varchar(100)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "skull(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, owner varchar(64)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "skull(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, owner varchar(255)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(user), INDEX(uuid)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "user(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int,user varchar(100),uuid varchar(64)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(uuid,user)";

View File

@ -22,7 +22,15 @@ public class Paper_v1_20 extends Paper_v1_17 implements PaperInterface {
@Override
public String getSkullOwner(Skull skull) {
return skull.getPlayerProfile().getName();
String owner = skull.getPlayerProfile().getName();
if (owner.length() > 255 && skull.getPlayerProfile().getId() != null) {
return skull.getPlayerProfile().getId().toString();
}
else if (owner.length() > 255) {
return owner.substring(0, 255);
}
return owner;
}
@Override

View File

@ -0,0 +1,31 @@
package net.coreprotect.patch.script;
import java.sql.Statement;
import net.coreprotect.config.Config;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.language.Phrase;
import net.coreprotect.language.Selector;
import net.coreprotect.utility.Chat;
public class __2_23_0 {
protected static boolean patch(Statement statement) {
try {
if (Config.getGlobal().MYSQL) {
try {
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "skull MODIFY owner VARCHAR(255);");
}
catch (Exception e) {
Chat.console(Phrase.build(Phrase.PATCH_SKIP_UPDATE, ConfigHandler.prefix + "skull", Selector.FIRST, Selector.FIRST));
}
}
}
catch (Exception e) {
e.printStackTrace();
}
return true;
}
}