-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/xdnw/locutus
- Loading branch information
Showing
203 changed files
with
2,839 additions
and
2,303 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
src/main/java/link/locutus/discord/_main/FinalizedLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
package link.locutus.discord._main; | ||
|
||
import link.locutus.discord.apiv2.PoliticsAndWarV2; | ||
import link.locutus.discord.apiv3.PoliticsAndWarV3; | ||
import link.locutus.discord.commands.manager.CommandManager; | ||
import link.locutus.discord.commands.manager.v2.impl.SlashCommandManager; | ||
import link.locutus.discord.commands.stock.StockDB; | ||
import link.locutus.discord.config.Settings; | ||
import link.locutus.discord.db.*; | ||
import link.locutus.discord.util.trade.TradeManager; | ||
import net.dv8tion.jda.api.JDA; | ||
|
||
import java.sql.SQLException; | ||
import java.util.concurrent.Future; | ||
import java.util.function.Supplier; | ||
|
||
public class FinalizedLoader implements ILoader { | ||
private volatile BaseballDB baseBallDB; | ||
|
||
private final SlashCommandManager slashCommandManager; | ||
private final JDA jda; | ||
private final ForumDB forumDb; | ||
private final DiscordDB discordDB; | ||
private final NationDB nationDB; | ||
private final WarDB warDb; | ||
private final StockDB stockDB; | ||
private final BankDB bankDb; | ||
private final TradeManager tradeManager; | ||
private final CommandManager commandManager; | ||
private final PoliticsAndWarV2 apiV2; | ||
private final PoliticsAndWarV3 apiV3; | ||
|
||
public FinalizedLoader(PreLoader loader) { | ||
this.slashCommandManager = loader.getSlashCommandManager(); | ||
this.jda = loader.getJda(); | ||
this.forumDb = loader.getForumDB(); | ||
this.discordDB = loader.getDiscordDB(); | ||
this.nationDB = loader.getNationDB(); | ||
this.warDb = loader.getWarDB(); | ||
this.stockDB = loader.getStockDB(); | ||
this.bankDb = loader.getBankDB(); | ||
this.tradeManager = loader.getTradeManager(); | ||
this.commandManager = loader.getCommandManager(); | ||
this.apiV2 = loader.getApiV2(); | ||
this.apiV3 = loader.getApiV3(); | ||
} | ||
|
||
@Override | ||
public BaseballDB getBaseballDB() { | ||
if (this.baseBallDB == null) { | ||
synchronized (this) { | ||
if (this.baseBallDB == null) { | ||
try { | ||
baseBallDB = new BaseballDB(Settings.INSTANCE.DATABASE); | ||
} catch (SQLException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} | ||
} | ||
return this.baseBallDB; | ||
} | ||
|
||
@Override | ||
public SlashCommandManager getSlashCommandManager() { | ||
return slashCommandManager; | ||
} | ||
|
||
@Override | ||
public ILoader resolveFully(long timeout) { | ||
return this; | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
// Do nothing | ||
} | ||
|
||
@Override | ||
public JDA getJda() { | ||
return jda; | ||
} | ||
|
||
@Override | ||
public ForumDB getForumDB() { | ||
return forumDb; | ||
} | ||
|
||
@Override | ||
public DiscordDB getDiscordDB() { | ||
return discordDB; | ||
} | ||
|
||
@Override | ||
public NationDB getNationDB() { | ||
return nationDB; | ||
} | ||
|
||
@Override | ||
public WarDB getWarDB() { | ||
return warDb; | ||
} | ||
|
||
@Override | ||
public StockDB getStockDB() { | ||
return stockDB; | ||
} | ||
|
||
@Override | ||
public BankDB getBankDB() { | ||
return bankDb; | ||
} | ||
|
||
@Override | ||
public TradeManager getTradeManager() { | ||
return tradeManager; | ||
} | ||
|
||
@Override | ||
public CommandManager getCommandManager() { | ||
return commandManager; | ||
} | ||
|
||
@Override | ||
public PoliticsAndWarV2 getApiV2() { | ||
return apiV2; | ||
} | ||
|
||
@Override | ||
public PoliticsAndWarV3 getApiV3() { | ||
return apiV3; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package link.locutus.discord._main; | ||
|
||
import link.locutus.discord.apiv2.PoliticsAndWarV2; | ||
import link.locutus.discord.apiv3.PoliticsAndWarV3; | ||
import link.locutus.discord.commands.manager.CommandManager; | ||
import link.locutus.discord.commands.manager.v2.impl.SlashCommandManager; | ||
import link.locutus.discord.commands.stock.StockDB; | ||
import link.locutus.discord.config.Settings; | ||
import link.locutus.discord.db.*; | ||
import link.locutus.discord.util.trade.TradeManager; | ||
import net.dv8tion.jda.api.JDA; | ||
|
||
public interface ILoader { | ||
ILoader resolveFully(long timeout); | ||
void initialize(); | ||
|
||
default String getApiKey() { | ||
return Settings.INSTANCE.API_KEY_PRIMARY; | ||
} | ||
|
||
default int getNationId() { | ||
return Settings.INSTANCE.NATION_ID; | ||
} | ||
|
||
default long getAdminUserId() { | ||
return Settings.INSTANCE.ADMIN_USER_ID; | ||
} | ||
JDA getJda(); | ||
SlashCommandManager getSlashCommandManager(); | ||
CommandManager getCommandManager(); | ||
|
||
NationDB getNationDB(); | ||
DiscordDB getDiscordDB(); | ||
WarDB getWarDB(); | ||
BaseballDB getBaseballDB(); | ||
TradeManager getTradeManager(); | ||
StockDB getStockDB(); | ||
ForumDB getForumDB(); | ||
BankDB getBankDB(); | ||
|
||
PoliticsAndWarV3 getApiV3(); | ||
PoliticsAndWarV2 getApiV2(); | ||
|
||
default String printStacktrace() { | ||
return ""; | ||
} | ||
} |
Oops, something went wrong.