use of net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdateRequest in project FunnyGuilds by FunnyGuilds.
the class DatabaseBasic method load.
public void load() {
Database db = Database.getInstance();
PluginConfig config = Settings.getConfig();
usersTable(db);
regionsTable(db);
guildsTable(db);
Database.getInstance().executeQuery("SELECT * FROM `" + config.mysql.usersTableName + "`", usersResult -> {
try {
while (usersResult.next()) {
User user = DatabaseUser.deserialize(usersResult);
if (user != null) {
user.changed();
}
}
FunnyLogger.info("Loaded users: " + UserUtils.getUsers().size());
} catch (Exception e) {
if (FunnyLogger.exception(e.getCause())) {
e.printStackTrace();
}
}
});
if (Settings.getConfig().regionsEnabled) {
Database.getInstance().executeQuery("SELECT * FROM `" + config.mysql.regionsTableName + "`", regionsResult -> {
try {
while (regionsResult.next()) {
Region region = DatabaseRegion.deserialize(regionsResult);
if (region != null) {
region.changed();
}
}
FunnyLogger.info("Loaded regions: " + RegionUtils.getRegions().size());
} catch (Exception e) {
if (FunnyLogger.exception(e.getCause())) {
e.printStackTrace();
}
}
});
} else {
FunnyLogger.info("Regions are disabled and thus - not loaded");
}
Database.getInstance().executeQuery("SELECT * FROM `" + config.mysql.guildsTableName + "`", guildsResult -> {
try {
while (guildsResult.next()) {
Guild guild = DatabaseGuild.deserialize(guildsResult);
if (guild != null) {
guild.changed();
}
}
FunnyLogger.info("Loaded guilds: " + GuildUtils.getGuilds().size());
} catch (Exception e) {
if (FunnyLogger.exception(e.getCause())) {
e.printStackTrace();
}
}
});
// TODO
for (Guild guild : GuildUtils.getGuilds()) {
if (guild.getOwner() != null) {
continue;
}
GuildUtils.deleteGuild(guild);
}
// IndependentThread.action(ActionType.PREFIX_GLOBAL_UPDATE);
ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
concurrencyManager.postRequests(new PrefixGlobalUpdateRequest());
}
use of net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdateRequest in project FunnyGuilds by FunnyGuilds.
the class Flat method loadGuilds.
private void loadGuilds() {
GuildUtils.getGuilds().clear();
File[] path = GUILDS.listFiles();
if (path != null) {
for (File file : path) {
Guild guild = FlatGuild.deserialize(file);
if (guild == null) {
file.delete();
} else {
guild.changed();
}
}
}
// TODO
for (Guild guild : GuildUtils.getGuilds()) {
if (guild.getOwner() != null) {
continue;
}
GuildUtils.deleteGuild(guild);
}
// IndependentThread.action(ActionType.PREFIX_GLOBAL_UPDATE);
ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
concurrencyManager.postRequests(new PrefixGlobalUpdateRequest());
FunnyLogger.info("Loaded guilds: " + GuildUtils.getGuilds().size());
}
Aggregations