1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 23:13:48 +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 { } else {
Jobs.getPluginLogger().warning("Invalid storage method! Changing method to sqlite!"); Jobs.getPluginLogger().warning("Invalid storage method! Changing method to sqlite!");
c.getC().set("storage-method", "sqlite"); c.getC().set("storage-method", "sqlite");
Jobs.setDAO(JobsDAOSQLite.initialize()); startSqlite();
} }
c.getW().addComment("mysql-username", "Requires Mysql."); c.getW().addComment("mysql-username", "Requires Mysql.");
@ -858,10 +858,10 @@ public class GeneralConfigManager {
String database = config.getString("mysql-database"); String database = config.getString("mysql-database");
String prefix = config.getString("mysql-table-prefix"); String prefix = config.getString("mysql-table-prefix");
if (plugin.isEnabled()) 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() { 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 JobsConnectionPool pool;
private String prefix; private String prefix;
private HashMap<Integer, ArrayList<JobsDAOData>> map = new HashMap<Integer, ArrayList<JobsDAOData>>(); 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; this.prefix = prefix;
try { try {
pool = new JobsConnectionPool(driverName, url, username, password); pool = new JobsConnectionPool(driverName, url, username, password);
@ -845,6 +847,9 @@ public abstract class JobsDAO {
// synchronized (jPlayer.saveLock) { // synchronized (jPlayer.saveLock) {
jPlayer.progression.clear(); jPlayer.progression.clear();
for (JobsDAOData jobdata : list) { for (JobsDAOData jobdata : list) {
if (!plugin.isEnabled())
return null;
// add the job // add the job
Job job = Jobs.getJob(jobdata.getJobName()); Job job = Jobs.getJob(jobdata.getJobName());
if (job == null) if (job == null)

View File

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

View File

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

View File

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