1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +01:00

Stop checking if plugin is disabled

This commit is contained in:
Zrips 2017-01-10 17:07:19 +02:00
parent f307a747b6
commit dd6806ac2d
5 changed files with 18 additions and 12 deletions

View File

@ -383,7 +383,7 @@ public class GeneralConfigManager {
} else {
Jobs.getPluginLogger().warning("Invalid storage method! Changing method to sqlite!");
c.getC().set("storage-method", "sqlite");
Jobs.setDAO(JobsDAOSQLite.initialize());
startSqlite();
}
c.getW().addComment("mysql-username", "Requires Mysql.");
@ -858,10 +858,10 @@ public class GeneralConfigManager {
String database = config.getString("mysql-database");
String prefix = config.getString("mysql-table-prefix");
if (plugin.isEnabled())
Jobs.setDAO(JobsDAOMySQL.initialize(hostname, database, username, password, prefix));
Jobs.setDAO(JobsDAOMySQL.initialize(plugin, hostname, database, username, password, prefix));
}
public synchronized void startSqlite() {
Jobs.setDAO(JobsDAOSQLite.initialize());
Jobs.setDAO(JobsDAOSQLite.initialize(plugin));
}
}

View File

@ -67,8 +67,10 @@ public abstract class JobsDAO {
private JobsConnectionPool pool;
private String prefix;
private HashMap<Integer, ArrayList<JobsDAOData>> map = new HashMap<Integer, ArrayList<JobsDAOData>>();
private Jobs plugin;
protected JobsDAO(String driverName, String url, String username, String password, String prefix) {
protected JobsDAO(Jobs plugin, String driverName, String url, String username, String password, String prefix) {
this.plugin = plugin;
this.prefix = prefix;
try {
pool = new JobsConnectionPool(driverName, url, username, password);
@ -845,6 +847,9 @@ public abstract class JobsDAO {
// synchronized (jPlayer.saveLock) {
jPlayer.progression.clear();
for (JobsDAOData jobdata : list) {
if (!plugin.isEnabled())
return null;
// add the job
Job job = Jobs.getJob(jobdata.getJobName());
if (job == null)

View File

@ -32,13 +32,13 @@ import com.gamingmesh.jobs.stuff.UUIDUtil;
public class JobsDAOMySQL extends JobsDAO {
private String database;
private JobsDAOMySQL(String hostname, String database, String username, String password, String prefix) {
super("com.mysql.jdbc.Driver", "jdbc:mysql://" + hostname + "/" + database, username, password, prefix);
private JobsDAOMySQL(Jobs plugin, String hostname, String database, String username, String password, String prefix) {
super(plugin, "com.mysql.jdbc.Driver", "jdbc:mysql://" + hostname + "/" + database, username, password, prefix);
this.database = database;
}
public static JobsDAOMySQL initialize(String hostname, String database, String username, String password, String prefix) {
JobsDAOMySQL dao = new JobsDAOMySQL(hostname, database, username, password, prefix);
public static JobsDAOMySQL initialize(Jobs plugin, String hostname, String database, String username, String password, String prefix) {
JobsDAOMySQL dao = new JobsDAOMySQL(plugin, hostname, database, username, password, prefix);
try {
dao.setUp();
} catch (SQLException e) {

View File

@ -29,8 +29,8 @@ import com.gamingmesh.jobs.container.PlayerInfo;
import com.gamingmesh.jobs.stuff.UUIDUtil;
public class JobsDAOSQLite extends JobsDAO {
public static JobsDAOSQLite initialize() {
JobsDAOSQLite dao = new JobsDAOSQLite();
public static JobsDAOSQLite initialize(Jobs plugin) {
JobsDAOSQLite dao = new JobsDAOSQLite(plugin);
File dir = Jobs.getFolder();
if (!dir.exists())
dir.mkdirs();
@ -42,8 +42,8 @@ public class JobsDAOSQLite extends JobsDAO {
return dao;
}
private JobsDAOSQLite() {
super("org.sqlite.JDBC", "jdbc:sqlite:" + new File(Jobs.getFolder(), "jobs.sqlite.db").getPath(), null, null, "");
private JobsDAOSQLite(Jobs plugin) {
super(plugin, "org.sqlite.JDBC", "jdbc:sqlite:" + new File(Jobs.getFolder(), "jobs.sqlite.db").getPath(), null, null, "");
}
private static void close(ResultSet res) {

View File

@ -30,6 +30,7 @@ public class Language {
public Language(Jobs plugin) {
this.plugin = plugin;
reload();
}
/**