Truncated some other Strings

This commit is contained in:
Rsl1122 2020-01-06 13:29:33 +02:00
parent 5bd325c2a7
commit 6e4dce2553
4 changed files with 10 additions and 6 deletions

View File

@ -125,10 +125,11 @@ public class RegisterCommand extends CommandNode {
private void consoleRegister(String[] args, Sender sender, String notEnoughArgsMsg) throws PassEncryptUtil.CannotPerformOperationException {
Verify.isTrue(args.length >= 3, () -> new IllegalArgumentException(notEnoughArgsMsg));
int permLevel;
permLevel = Integer.parseInt(args[2]);
String userName = args[1];
Verify.isTrue(userName.length() <= 100, () -> new IllegalArgumentException("Username can only be 100 characters long."));
int permLevel = Integer.parseInt(args[2]);
String passHash = PassEncryptUtil.createHash(args[0]);
registerUser(new WebUser(args[1], passHash, permLevel), sender);
registerUser(new WebUser(userName, passHash, permLevel), sender);
}
private void playerRegister(String[] args, Sender sender) throws PassEncryptUtil.CannotPerformOperationException {

View File

@ -24,6 +24,7 @@ import com.djrapitops.plan.storage.database.transactions.ExecBatchStatement;
import com.djrapitops.plan.storage.database.transactions.ExecStatement;
import com.djrapitops.plan.storage.database.transactions.Executable;
import com.djrapitops.plugin.utilities.Verify;
import org.apache.commons.lang3.StringUtils;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@ -86,7 +87,7 @@ public class DataStoreQueries {
return new ExecStatement(WorldTable.INSERT_STATEMENT) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, worldName);
statement.setString(1, StringUtils.truncate(worldName, 100));
statement.setString(2, serverUUID.toString());
}
};

View File

@ -25,6 +25,7 @@ import com.djrapitops.plan.storage.database.sql.tables.*;
import com.djrapitops.plan.storage.database.transactions.ExecBatchStatement;
import com.djrapitops.plan.storage.database.transactions.Executable;
import com.djrapitops.plugin.utilities.Verify;
import org.apache.commons.lang3.StringUtils;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@ -258,7 +259,7 @@ public class LargeStoreQueries {
for (Map.Entry<UUID, Collection<String>> entry : ofServers.entrySet()) {
UUID serverUUID = entry.getKey();
for (String world : entry.getValue()) {
statement.setString(1, world);
statement.setString(1, StringUtils.truncate(world, 100));
statement.setString(2, serverUUID.toString());
statement.addBatch();
}

View File

@ -20,6 +20,7 @@ import com.djrapitops.plan.storage.database.queries.DataStoreQueries;
import com.djrapitops.plan.storage.database.queries.HasMoreThanZeroQueryStatement;
import com.djrapitops.plan.storage.database.sql.tables.WorldTable;
import com.djrapitops.plan.storage.database.transactions.Transaction;
import org.apache.commons.lang3.StringUtils;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@ -55,7 +56,7 @@ public class WorldNameStoreTransaction extends Transaction {
return !query(new HasMoreThanZeroQueryStatement(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, worldName);
statement.setString(1, StringUtils.truncate(worldName, 100));
statement.setString(2, serverUUID.toString());
}
});