Skip to content
This repository was archived by the owner on May 27, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ private static void checkTable() throws SQLException {

try {
if (!(rs = md.getColumns(null, null, "corporations", "custom_model_data")).next())
db.createStatement().execute("ALTER TABLE corporations ADD COLUMN custom_model_dat INT NOT NULL");
db.createStatement().execute("ALTER TABLE corporations ADD COLUMN custom_model_data INT NOT NULL");
} finally {
if (rs != null) rs.close();
}
Expand Down
33 changes: 20 additions & 13 deletions plugin/src/main/java/us/teaminceptus/novaconomy/Novaconomy.java
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@ private void loadFiles() {
getLogger().info("Database found! Connecting...");

connectDB(true);
PING_DB_RUNNABLE.runTaskTimerAsynchronously(this, 60 * 20, 60 * 20);

getLogger().info("Connection Successful!");
convertToDatabase();
Expand Down Expand Up @@ -941,6 +940,9 @@ private static Map<String, Object> toMap(Map<String, Object> serial) {
@Override
public void onLoad() {
config = getConfig();
loadFiles();

getLogger().info("Loaded Files...");

if (hasVault()) {
getLogger().info("Vault Found! Hooking...");
Expand All @@ -960,9 +962,7 @@ public void onEnable() {
interest = config.getConfigurationSection("Interest");
ncauses = config.getConfigurationSection("NaturalCauses");

loadFiles();

getLogger().info("Loaded Files...");
loadTasks();

SERIALIZABLE.forEach(ConfigurationSerialization::registerClass);
getLogger().info("Initialized Serializables...");
Expand Down Expand Up @@ -1038,6 +1038,22 @@ public void onEnable() {
getLogger().info("Successfully loaded Novaconomy");
}

// Some tasks that were loaded by loadFiles or Vault are needed to be ran in onEnable
private void loadTasks() {
if (isDatabaseEnabled()) {
PING_DB_RUNNABLE.runTaskTimerAsynchronously(this, 60 * 20, 60 * 20);
}

boolean scheduled = false;
try {
RESTOCK_RUNNABLE.getTaskId();
scheduled = true;
} catch (IllegalStateException ignored) {}

if (isMarketEnabled() && isMarketRestockEnabled() && !scheduled)
RESTOCK_RUNNABLE.runTaskTimerAsynchronously(this, getMarketRestockInterval(), getMarketRestockInterval());
}

@Override
public void onDisable() {
writeMarket();
Expand Down Expand Up @@ -1996,15 +2012,6 @@ private void loadMarket() {
.map(Material::matchMaterial)
.filter(w::isItem)
.forEach(m -> stock.putIfAbsent(m, getMarketRestockAmount()));

boolean scheduled = false;
try {
RESTOCK_RUNNABLE.getTaskId();
scheduled = true;
} catch (IllegalStateException ignored) {}

if (isMarketEnabled() && isMarketRestockEnabled() && !scheduled)
RESTOCK_RUNNABLE.runTaskTimerAsynchronously(this, getMarketRestockInterval(), getMarketRestockInterval());
}

private void writeMarket() {
Expand Down