mirror of
https://github.com/songoda/EpicFarming.git
synced 2025-02-20 14:32:07 +01:00
Update DataHelper
This commit is contained in:
parent
f2b3c6980e
commit
c4af287f5b
@ -128,6 +128,7 @@ public class EpicFarming extends SongodaPlugin {
|
||||
|
||||
// Database stuff.
|
||||
initDatabase(Collections.singletonList(new _1_InitialMigration()));
|
||||
DataHelper.init(this);
|
||||
|
||||
this.loadLevelManager();
|
||||
|
||||
@ -390,10 +391,6 @@ public class EpicFarming extends SongodaPlugin {
|
||||
return this.entityUtils;
|
||||
}
|
||||
|
||||
public DatabaseConnector getDatabaseConnector() {
|
||||
return this.dataManager.getDatabaseConnector();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link EpicFarming#getPlugin(Class)} instead.
|
||||
*/
|
||||
|
@ -11,11 +11,15 @@ import java.util.List;
|
||||
|
||||
public class DataHelper {
|
||||
|
||||
private static final EpicFarming plugin = EpicFarming.getPlugin(EpicFarming.class);
|
||||
private static EpicFarming plugin;
|
||||
|
||||
public static void init(EpicFarming plugin) {
|
||||
DataHelper.plugin = plugin;
|
||||
}
|
||||
|
||||
public static void createFarms(List<Farm> farms) {
|
||||
|
||||
plugin.getDatabaseConnector().connectDSL(dslContext -> {
|
||||
plugin.getDataManager().getDatabaseConnector().connectDSL(dslContext -> {
|
||||
List<Query> queries = new ArrayList<>();
|
||||
for (Farm farm : farms) {
|
||||
queries.add(dslContext.insertInto(DSL.table(plugin.getDataManager().getTablePrefix() + "active_farms"))
|
||||
@ -45,7 +49,7 @@ public class DataHelper {
|
||||
public static void updateItems(Farm farm) {
|
||||
String tablePrefix = plugin.getDataManager().getTablePrefix();
|
||||
|
||||
plugin.getDatabaseConnector().connectDSL(dslContext -> {
|
||||
plugin.getDataManager().getDatabaseConnector().connectDSL(dslContext -> {
|
||||
dslContext.deleteFrom(DSL.table(tablePrefix + "items"))
|
||||
.where(DSL.field("farm_id").eq(farm.getId()))
|
||||
.execute();
|
||||
|
Loading…
Reference in New Issue
Block a user