mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-12 11:21:16 +01:00
[#901] Replaced hardcoded Litebans table prefix
This commit is contained in:
parent
5ab48991f2
commit
1c50723ccc
@ -95,7 +95,7 @@
|
||||
<dependency>
|
||||
<groupId>com.djrapitops</groupId>
|
||||
<artifactId>Plan-plugin</artifactId>
|
||||
<version>4.5.0-SNAPSHOT</version>
|
||||
<version>4.6.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -25,8 +25,6 @@ import litebans.api.Database;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static github.scarsz.discordsrv.util.PluginUtil.getPlugin;
|
||||
|
||||
/**
|
||||
* A Class responsible for hooking to LiteBans and registering data
|
||||
* sources.
|
||||
@ -54,8 +52,7 @@ public class LiteBansBukkitHook extends Hook {
|
||||
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
String tablePrefix = getPlugin("LiteBans").getConfig().getString("sql.table_prefix");
|
||||
LiteBansDatabaseQueries db = new LiteBansDatabaseQueries(tablePrefix);
|
||||
LiteBansDatabaseQueries db = new LiteBansDatabaseQueries();
|
||||
handler.addPluginDataSource(new LiteBansData(db, timestampFormatter));
|
||||
}
|
||||
}
|
||||
|
@ -21,17 +21,9 @@ import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
import litebans.api.Database;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* A Class responsible for hooking to LiteBans and registering data
|
||||
@ -60,22 +52,8 @@ public class LiteBansBungeeHook extends Hook {
|
||||
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
LiteBansDatabaseQueries db = new LiteBansDatabaseQueries(getTablePrefix());
|
||||
LiteBansDatabaseQueries db = new LiteBansDatabaseQueries();
|
||||
handler.addPluginDataSource(new LiteBansData(db, timestampFormatter));
|
||||
}
|
||||
}
|
||||
|
||||
private String getTablePrefix() {
|
||||
String tablePrefix = "libeans_";
|
||||
try {
|
||||
File litebansDataFolder = ProxyServer.getInstance().getPluginManager().getPlugin("LiteBans").getDataFolder();
|
||||
File configFile = new File(litebansDataFolder, "config.yml");
|
||||
|
||||
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||
tablePrefix = configuration.getString("sql.table_prefix");
|
||||
} catch (NullPointerException | IOException e) {
|
||||
Logger.getLogger("Plan").log(Level.WARNING, "Could not get Litebans table prefix, using default (litebans_). " + e.toString());
|
||||
}
|
||||
return tablePrefix;
|
||||
}
|
||||
}
|
||||
|
@ -45,13 +45,13 @@ public class LiteBansDatabaseQueries extends Table {
|
||||
|
||||
private final String selectSQL;
|
||||
|
||||
public LiteBansDatabaseQueries(String tablePrefix) {
|
||||
public LiteBansDatabaseQueries() {
|
||||
super("litebans", null);
|
||||
database = Database.get();
|
||||
banTable = tablePrefix + "bans";
|
||||
mutesTable = tablePrefix + "mutes";
|
||||
warningsTable = tablePrefix + "warnings";
|
||||
kicksTable = tablePrefix + "kicks";
|
||||
banTable = "{bans}";
|
||||
mutesTable = "{mutes}";
|
||||
warningsTable = "{warnings}";
|
||||
kicksTable = "{kicks}";
|
||||
selectSQL = "SELECT uuid, reason, banned_by_name, until, active, time FROM ";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user