mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-12-30 21:07:47 +01:00
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:
parent
e279114a90
commit
32dbebd607
2
pom.xml
2
pom.xml
@ -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>
|
||||
|
@ -82,7 +82,7 @@ public class ChallengesAddon extends Addon {
|
||||
@Override
|
||||
public void onDisable(){
|
||||
if (challengesManager != null) {
|
||||
challengesManager.save(false);
|
||||
challengesManager.save();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -65,7 +65,7 @@ public class FreshSqueezedChallenges {
|
||||
}
|
||||
makeLevels(user);
|
||||
makeChallenges(user, world, overwrite);
|
||||
addon.getChallengesManager().save(false);
|
||||
addon.getChallengesManager().save();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user