Skip to content

Commit

Permalink
Removing async and updating to 1.13.2 API
Browse files Browse the repository at this point in the history
The async saving is not the right thing to do here anyway, so I'm
removing it.

#45
  • Loading branch information
tastybento committed Jan 1, 2019
1 parent e279114 commit 32dbebd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 31 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void onEnable() {
@Override
public void onDisable(){
if (challengesManager != null) {
challengesManager.save(false);
challengesManager.save();
}
}

Expand Down
14 changes: 1 addition & 13 deletions src/main/java/bentobox/addon/challenges/ChallengesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public void load() {
/**
* Save configs and player data
*/
private void save() {
public void save() {
challengeMap.entrySet().forEach(en -> {
lvConfig.saveConfigObject(en.getKey());
en.getValue().forEach(chConfig::saveConfigObject);
Expand All @@ -385,18 +385,6 @@ private void savePlayer(UUID playerUUID) {
}
}

/**
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public boolean importChallenges(User user, World world, boolean overwrite) {
}
makeLevels(user);
makeChallenges(user, world, overwrite);
addon.getChallengesManager().save(false);
addon.getChallengesManager().save();
return true;
}

Expand Down
30 changes: 15 additions & 15 deletions src/main/java/bentobox/addon/challenges/listeners/SaveListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@
*/
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;
}

0 comments on commit 32dbebd

Please sign in to comment.