Removing async and updating to 1.13.2 API

The async saving is not the right thing to do here anyway, so I'm
removing it.

https://github.com/BentoBoxWorld/Challenges/issues/45
This commit is contained in:
tastybento 2018-12-31 18:43:32 -08:00
parent e279114a90
commit 32dbebd607
5 changed files with 19 additions and 31 deletions

View File

@ -66,7 +66,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.1-R0.1-SNAPSHOT</version>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -82,7 +82,7 @@ public class ChallengesAddon extends Addon {
@Override
public void onDisable(){
if (challengesManager != null) {
challengesManager.save(false);
challengesManager.save();
}
}

View File

@ -367,7 +367,7 @@ public class ChallengesManager {
/**
* Save configs and player data
*/
private void save() {
public void save() {
challengeMap.entrySet().forEach(en -> {
lvConfig.saveConfigObject(en.getKey());
en.getValue().forEach(chConfig::saveConfigObject);
@ -385,18 +385,6 @@ public class ChallengesManager {
}
}
/**
* Save to the database
* @param async - if true, saving will be done async
*/
public void save(boolean async) {
if (async) {
addon.getServer().getScheduler().runTaskAsynchronously(addon.getPlugin(), this::save);
} else {
save();
}
}
/**
* Sets the challenge as complete and increments the number of times it has been completed
* @param user - user

View File

@ -65,7 +65,7 @@ public class FreshSqueezedChallenges {
}
makeLevels(user);
makeChallenges(user, world, overwrite);
addon.getChallengesManager().save(false);
addon.getChallengesManager().save();
return true;
}

View File

@ -15,25 +15,25 @@ import bentobox.addon.challenges.ChallengesAddon;
*/
public class SaveListener implements Listener
{
public SaveListener(ChallengesAddon addon) {
this.addon = addon;
}
public SaveListener(ChallengesAddon addon) {
this.addon = addon;
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onWorldSave(WorldSaveEvent e)
{
if (!this.addon.getChallengesManager().getAllChallengesList(e.getWorld()).isEmpty())
{
this.addon.getChallengesManager().save(e.isAsynchronous());
}
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onWorldSave(WorldSaveEvent e)
{
if (!this.addon.getChallengesManager().getAllChallengesList(e.getWorld()).isEmpty())
{
this.addon.getChallengesManager().save();
}
}
// ---------------------------------------------------------------------
// Section: Variables
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Section: Variables
// ---------------------------------------------------------------------
private ChallengesAddon addon;
private ChallengesAddon addon;
}