Merge pull request #2473 from plan-player-analytics/update-extensions

Move extensions to different packages
This commit is contained in:
Aurora Lahtela 2022-07-14 08:36:22 +03:00 committed by GitHub
commit a82bcbff0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 112 additions and 57 deletions

View File

@ -142,6 +142,10 @@ public class DBOpException extends IllegalStateException implements ExceptionWit
context.related(CONSTRAINT_VIOLATION)
.whatToDo("Report this error. NOT NULL constraint violation occurred.");
break;
case 1071:
context.related("column byte length exceeded")
.whatToDo("Update your MySQL, column key size was exceeded (max key length is 767 bytes in 5.6) - MySQL 5.7 increases the limit.");
break;
default:
context.related("Unknown SQL Error code");
}

View File

@ -196,7 +196,7 @@ public class DataStoreQueries {
statement.setLong(2, registered);
statement.setString(3, serverUUID.toString());
statement.setBoolean(4, false); // Banned
statement.setString(5, joinAddress);
statement.setString(5, StringUtils.truncate(joinAddress, JoinAddressTable.JOIN_ADDRESS_MAX_LENGTH));
statement.setBoolean(6, false); // Operator
}
};

View File

@ -27,6 +27,8 @@ public class JoinAddressTable {
public static final String TABLE_NAME = "plan_join_address";
public static final String ID = "id";
public static final String JOIN_ADDRESS = "join_address";
public static final int JOIN_ADDRESS_MAX_LENGTH = 250;
public static final String SELECT_ID = '(' + SELECT + ID + FROM + TABLE_NAME + WHERE + JOIN_ADDRESS + "=LOWER(?))";
public static final String INSERT_STATEMENT = "INSERT INTO " + TABLE_NAME +
" (" + JOIN_ADDRESS + ") VALUES (LOWER(?))";
@ -37,7 +39,7 @@ public class JoinAddressTable {
public static String createTableSQL(DBType dbType) {
return CreateTableBuilder.create(TABLE_NAME, dbType)
.column(ID, Sql.INT).primaryKey()
.column(JOIN_ADDRESS, Sql.varchar(255)).unique()
.column(JOIN_ADDRESS, Sql.varchar(JOIN_ADDRESS_MAX_LENGTH)).unique()
.toString();
}

View File

@ -66,7 +66,7 @@ public class UserInfoTable {
.column(ID, Sql.INT).primaryKey()
.column(USER_ID, Sql.INT).notNull()
.column(SERVER_ID, Sql.INT).notNull()
.column(JOIN_ADDRESS, Sql.varchar(255))
.column(JOIN_ADDRESS, Sql.varchar(JoinAddressTable.JOIN_ADDRESS_MAX_LENGTH))
.column(REGISTERED, Sql.LONG).notNull()
.column(OP, Sql.BOOL).notNull().defaultValue(false)
.column(BANNED, Sql.BOOL).notNull().defaultValue(false)

View File

@ -22,6 +22,7 @@ import com.djrapitops.plan.storage.database.queries.Query;
import com.djrapitops.plan.storage.database.sql.tables.JoinAddressTable;
import com.djrapitops.plan.storage.database.transactions.ExecStatement;
import com.djrapitops.plan.storage.database.transactions.Transaction;
import org.apache.commons.lang3.StringUtils;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@ -53,18 +54,22 @@ public class StoreJoinAddressTransaction extends Transaction {
return new HasMoreThanZeroQueryStatement(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
String address = joinAddress.get();
statement.setString(1, address.toLowerCase());
String address = getAddress();
statement.setString(1, address);
}
};
}
private String getAddress() {
return StringUtils.truncate(joinAddress.get().toLowerCase(), JoinAddressTable.JOIN_ADDRESS_MAX_LENGTH);
}
@Override
protected void performOperations() {
execute(new ExecStatement(JoinAddressTable.INSERT_STATEMENT) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, joinAddress.get().toLowerCase());
statement.setString(1, getAddress());
}
});
}

View File

@ -24,6 +24,7 @@ import com.djrapitops.plan.storage.database.sql.tables.JoinAddressTable;
import com.djrapitops.plan.storage.database.sql.tables.SessionsTable;
import com.djrapitops.plan.storage.database.sql.tables.UserInfoTable;
import com.djrapitops.plan.storage.database.transactions.ExecBatchStatement;
import org.apache.commons.lang3.StringUtils;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -98,7 +99,7 @@ public class SessionJoinAddressPatch extends Patch {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
for (String joinAddress : joinAddresses) {
statement.setString(1, joinAddress.toLowerCase());
statement.setString(1, StringUtils.truncate(joinAddress.toLowerCase(), JoinAddressTable.JOIN_ADDRESS_MAX_LENGTH));
statement.addBatch();
}
}

View File

@ -17,6 +17,7 @@
package com.djrapitops.plan.storage.database.transactions.patches;
import com.djrapitops.plan.storage.database.sql.building.Sql;
import com.djrapitops.plan.storage.database.sql.tables.JoinAddressTable;
import com.djrapitops.plan.storage.database.sql.tables.UserInfoTable;
/**
@ -34,6 +35,6 @@ public class UserInfoHostnamePatch extends Patch {
@Override
protected void applyPatch() {
addColumn(UserInfoTable.TABLE_NAME, UserInfoTable.JOIN_ADDRESS + ' '
+ Sql.varchar(255));
+ Sql.varchar(JoinAddressTable.JOIN_ADDRESS_MAX_LENGTH));
}
}

View File

@ -1,51 +1,51 @@
dependencies {
implementation project(path: ":api")
shadow 'com.djrapitops:Extension-AAC:4.4.2-R0.1'
shadow 'com.djrapitops:Extension-AdvancedAchievements:6.4.0-R0.1'
shadow 'com.djrapitops:Extension-AdvancedBan:2.1.5-R1.0'
shadow 'com.djrapitops:Extension-ASkyBlock:3.0.9.4-R0.5'
shadow 'com.djrapitops:Extension-AuthMe:5.6.0-R0.2'
shadow 'com.djrapitops:Extension-BanManager:7.3.1-R0.2'
shadow 'com.djrapitops:Extension-BentoBox:1.15.5-R1.0'
shadow 'com.djrapitops:Extension-CoreProtect:2.16.0-R0.4'
shadow 'com.djrapitops:Extension-DiscordSRV:1.18.0-R0.4'
shadow 'com.djrapitops:Extension-DKBans:2.1.2-R0.3'
shadow 'com.djrapitops:Extension-DKCoins:3.0.5-R0.1'
shadow 'com.djrapitops:Extension-EssentialsX:2.15.0-R1.0'
shadow 'com.djrapitops:Extension-Factions:2.14.0-R0.1'
shadow 'com.djrapitops:Extension-FactionsUUID:1.6.9.5-U0.5.25-R0.1'
shadow 'com.djrapitops:Extension-FastLogin:R0.1'
shadow 'com.djrapitops:Extension-Floodgate:2.0-R0.2'
shadow 'com.djrapitops:Extension-GriefDefender:2.1.0-R0.1'
shadow 'com.djrapitops:Extension-GriefPrevention:16.11.6-R0.2'
shadow 'com.djrapitops:Extension-GriefPrevention-Sponge:4.0.1-R0.2'
shadow 'com.djrapitops:Extension-Heroes:R0.2'
shadow 'com.djrapitops:Extension-Jobs:4.16.3-R0.1'
shadow 'com.djrapitops:Extension-KingdomsX:1.12.6.3.1-R0.4'
shadow 'com.djrapitops:Extension-Lands:5.4.12-R0.1'
shadow 'net.playeranalytics:Extension-LibertyBans:0.8.0-R0.2'
shadow 'com.djrapitops:Extension-Litebans:0.3.4-R0.4'
shadow 'com.djrapitops:Extension-LogBlock:1.16.1.2-R0.9'
shadow 'com.djrapitops:Extension-LuckPerms:5.0-R0.5'
shadow 'com.djrapitops:Extension-MarriageMaster:2.3-R0.3'
shadow 'com.djrapitops:Extension-McMMO:2.1.149-R1.5'
shadow 'com.djrapitops:Extension-MinigamesLib:1.14.17-R0.2'
shadow 'com.djrapitops:Extension-MyPet:3.10-R0.2'
shadow 'com.djrapitops:Extension-Nucleus:2.3.0-R0.1'
shadow 'com.djrapitops:Extension-nuVotifier:2.3.4-R0.3'
shadow 'com.djrapitops:Extension-PlaceholderAPI:2.10.9-R0.5'
shadow 'com.djrapitops:Extension-PlotSquared:5.13.11-R0.2'
shadow 'com.djrapitops:Extension-ProtectionStones:2.8.2-R0.2'
shadow 'com.djrapitops:Extension-ProtocolSupport:1.16.4-R0.3'
shadow 'com.djrapitops:Extension-Quests:4.0.5-R0.1'
shadow 'com.djrapitops:Extension-React:6.651-R0.1'
shadow 'com.djrapitops:Extension-RedProtect:7.7.3-R0.1'
shadow 'com.djrapitops:Extension-Sponge-Economy:8.0.0-R0.3'
shadow 'com.djrapitops:Extension-SuperbVote:0.5.4-R0.1'
shadow 'com.djrapitops:Extension-Tebex:R1.3'
shadow 'com.djrapitops:Extension-Towny:0.96.7.4-R0.2'
shadow 'com.djrapitops:Extension-Vault:1.7-R0.3'
shadow 'com.djrapitops:Extension-ViaVersion:4.0.1-R0.3'
shadow 'net.playeranalytics:Extension-AAC:4.4.2-R1.1'
shadow 'net.playeranalytics:Extension-AdvancedAchievements:6.4.0-R1.1'
shadow 'net.playeranalytics:Extension-AdvancedBan:2.1.5-R2.0'
shadow 'net.playeranalytics:Extension-ASkyBlock:3.0.9.4-R1.5'
shadow 'net.playeranalytics:Extension-AuthMe:5.6.0-R1.2'
shadow 'net.playeranalytics:Extension-BanManager:7.3.1-R1.2'
shadow 'net.playeranalytics:Extension-BentoBox:1.15.5-R2.0'
// shadow 'net.playeranalytics:Extension-CoreProtect:2.16.0-R1.4' // unable to compile new version
shadow 'net.playeranalytics:Extension-DiscordSRV:1.25.1-R1.4'
shadow 'net.playeranalytics:Extension-DKBans:2.1.2-R1.3'
shadow 'net.playeranalytics:Extension-DKCoins:3.0.5-R1.1'
shadow 'net.playeranalytics:Extension-EssentialsX:2.15.0-R2.0'
shadow 'net.playeranalytics:Extension-Factions:2.14.0-R1.1'
shadow 'net.playeranalytics:Extension-FactionsUUID:1.6.9.5-U0.5.25-R1.1'
shadow 'net.playeranalytics:Extension-FastLogin:R1.1'
shadow 'net.playeranalytics:Extension-Floodgate:2.0-R1.2'
shadow 'net.playeranalytics:Extension-GriefDefender:2.1.0-R1.1'
shadow 'net.playeranalytics:Extension-GriefPrevention:16.11.6-R1.2'
shadow 'net.playeranalytics:Extension-GriefPrevention-Sponge:4.0.1-R1.2'
shadow 'net.playeranalytics:Extension-Heroes:R1.2'
shadow 'net.playeranalytics:Extension-Jobs:4.16.3-R1.1'
shadow 'net.playeranalytics:Extension-KingdomsX:1.12.6.3.1-R1.4'
shadow 'net.playeranalytics:Extension-Lands:5.4.12-R1.1'
shadow 'net.playeranalytics:Extension-LibertyBans:0.8.0-R1.2'
shadow 'net.playeranalytics:Extension-Litebans:0.3.4-R1.4'
shadow 'net.playeranalytics:Extension-LogBlock:1.16.1.2-R1.9'
shadow 'net.playeranalytics:Extension-LuckPerms:5.0-R1.5'
shadow 'net.playeranalytics:Extension-MarriageMaster:2.3-R1.3'
shadow 'net.playeranalytics:Extension-McMMO:2.1.149-R2.5'
shadow 'net.playeranalytics:Extension-MinigamesLib:1.14.17-R1.2'
shadow 'net.playeranalytics:Extension-MyPet:3.10-R1.2'
// shadow 'net.playeranalytics:Extension-Nucleus:2.3.0-R1.1' // TODO Update to sponge 8
shadow 'net.playeranalytics:Extension-nuVotifier:2.3.4-R1.3'
shadow 'net.playeranalytics:Extension-PlaceholderAPI:2.10.9-R1.5'
shadow 'net.playeranalytics:Extension-PlotSquared:5.13.11-R1.2'
shadow 'net.playeranalytics:Extension-ProtectionStones:2.8.2-R1.2'
shadow 'net.playeranalytics:Extension-ProtocolSupport:1.16.4-R1.3'
shadow 'net.playeranalytics:Extension-Quests:4.0.5-R1.1'
shadow 'net.playeranalytics:Extension-React:6.651-R1.1'
// shadow 'net.playeranalytics:Extension-RedProtect:7.7.3-R1.1' // TODO Update to sponge 8
shadow 'net.playeranalytics:Extension-Sponge-Economy:8.0.0-R1.3'
shadow 'net.playeranalytics:Extension-SuperbVote:0.5.4-R1.1'
shadow 'net.playeranalytics:Extension-Tebex:R2.3'
shadow 'net.playeranalytics:Extension-Towny:0.96.7.4-R1.2'
shadow 'net.playeranalytics:Extension-Vault:1.7-R1.3'
shadow 'net.playeranalytics:Extension-ViaVersion:4.0.1-R1.3'
}
shadowJar {

View File

@ -16,11 +16,53 @@
*/
package com.djrapitops.plan.extension.implementation;
import com.djrapitops.extension.*;
import com.djrapitops.plan.extension.Caller;
import com.djrapitops.plan.extension.DataExtension;
import com.djrapitops.plan.extension.ExtensionService;
import com.djrapitops.plan.extension.NotReadyException;
import net.playeranalytics.extension.aac.AACExtensionFactory;
import net.playeranalytics.extension.advancedachievements.AdvancedAchievementsExtensionFactory;
import net.playeranalytics.extension.advancedban.AdvancedBanExtensionFactory;
import net.playeranalytics.extension.askyblock.ASkyBlockExtensionFactory;
import net.playeranalytics.extension.authme.AuthMeExtensionFactory;
import net.playeranalytics.extension.banmanager.BanManagerExtensionFactory;
import net.playeranalytics.extension.bentobox.BentoBoxExtensionFactory;
import net.playeranalytics.extension.discordsrv.DiscordSRVExtensionFactory;
import net.playeranalytics.extension.dkbans.DKBansExtensionFactory;
import net.playeranalytics.extension.dkcoins.DKCoinsExtensionFactory;
import net.playeranalytics.extension.essentials.EssentialsExtensionFactory;
import net.playeranalytics.extension.factions.FactionsExtensionFactory;
import net.playeranalytics.extension.factionsuuid.FactionsUUIDExtensionFactory;
import net.playeranalytics.extension.fastlogin.FastLoginExtensionFactory;
import net.playeranalytics.extension.floodgate.FloodgateExtensionFactory;
import net.playeranalytics.extension.griefdefender.GriefDefenderExtensionFactory;
import net.playeranalytics.extension.griefprevention.GriefPreventionExtensionFactory;
import net.playeranalytics.extension.griefprevention.sponge.GriefPreventionSpongeExtensionFactory;
import net.playeranalytics.extension.heroes.HeroesExtensionFactory;
import net.playeranalytics.extension.jobs.JobsExtensionFactory;
import net.playeranalytics.extension.kingdomsx.KingdomsXExtensionFactory;
import net.playeranalytics.extension.lands.LandsExtensionFactory;
import net.playeranalytics.extension.libertybans.LibertyBansExtensionFactory;
import net.playeranalytics.extension.litebans.LitebansExtensionFactory;
import net.playeranalytics.extension.logblock.LogBlockExtensionFactory;
import net.playeranalytics.extension.luckperms.LuckPermsExtensionFactory;
import net.playeranalytics.extension.marriagemaster.MarriageMasterExtensionFactory;
import net.playeranalytics.extension.mcmmo.McMMOExtensionFactory;
import net.playeranalytics.extension.minigameslib.MinigameLibExtensionFactory;
import net.playeranalytics.extension.mypet.MyPetExtensionFactory;
import net.playeranalytics.extension.nuvotifier.NuVotifierExtensionFactory;
import net.playeranalytics.extension.placeholderapi.PlaceholderAPIExtensionFactory;
import net.playeranalytics.extension.plotsquared.PlotSquaredExtensionFactory;
import net.playeranalytics.extension.protectionstones.ProtectionStonesExtensionFactory;
import net.playeranalytics.extension.protocolsupport.ProtocolSupportExtensionFactory;
import net.playeranalytics.extension.quests.QuestsExtensionFactory;
import net.playeranalytics.extension.react.ReactExtensionFactory;
import net.playeranalytics.extension.spongeeconomy.SpongeEconomyExtensionFactory;
import net.playeranalytics.extension.superbvote.SuperbVoteExtensionFactory;
import net.playeranalytics.extension.tebex.BuycraftExtensionFactory;
import net.playeranalytics.extension.towny.TownyExtensionFactory;
import net.playeranalytics.extension.vault.VaultExtensionFactory;
import net.playeranalytics.extension.viaversion.ViaVersionExtensionFactory;
import javax.inject.Inject;
import javax.inject.Named;
@ -75,7 +117,7 @@ public class ExtensionRegister {
register(new FloodgateExtensionFactory(), FloodgateExtensionFactory::createExtension, FloodgateExtensionFactory::registerListener);
register(new GriefDefenderExtensionFactory(), GriefDefenderExtensionFactory::createExtension);
register(new GriefPreventionExtensionFactory(), GriefPreventionExtensionFactory::createExtension);
//register(new GriefPreventionSpongeExtensionFactory(), GriefPreventionSpongeExtensionFactory::createExtension); // TODO: update for Sponge API 8
register(new GriefPreventionSpongeExtensionFactory(), GriefPreventionSpongeExtensionFactory::createExtension);
register(new HeroesExtensionFactory(), HeroesExtensionFactory::createExtension);
register(new KingdomsXExtensionFactory(), KingdomsXExtensionFactory::createExtension);
register(new JobsExtensionFactory(), JobsExtensionFactory::createExtension);
@ -96,7 +138,7 @@ public class ExtensionRegister {
register(new ProtocolSupportExtensionFactory(), ProtocolSupportExtensionFactory::createExtension);
register(new QuestsExtensionFactory(), QuestsExtensionFactory::createExtension);
register(new ReactExtensionFactory(), ReactExtensionFactory::createExtension);
register(new RedProtectExtensionFactory(), RedProtectExtensionFactory::createExtension);
// register(new RedProtectExtensionFactory(), RedProtectExtensionFactory::createExtension); // TODO: update for Sponge API 8
register(new SpongeEconomyExtensionFactory(), SpongeEconomyExtensionFactory::createExtension);
register(new SuperbVoteExtensionFactory(), SuperbVoteExtensionFactory::createExtension);
register(new TownyExtensionFactory(), TownyExtensionFactory::createExtension);