Skip to content

Commit

Permalink
Fixes bug where top ten was cleared after reloading.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jul 4, 2020
1 parent 66b098e commit 39e294e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/main/java/world/bentobox/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
import org.bukkit.World;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.configuration.Config;
import world.bentobox.bentobox.api.events.BentoBoxReadyEvent;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.level.calculators.Pipeliner;
Expand All @@ -35,7 +38,7 @@
* @author tastybento
*
*/
public class Level extends Addon {
public class Level extends Addon implements Listener {

// Settings
private ConfigSettings settings;
Expand Down Expand Up @@ -71,10 +74,10 @@ public void onEnable() {
pipeliner = new Pipeliner(this);
// Start Manager
manager = new LevelsManager(this);
manager.loadTopTens();
// Register listeners
this.registerListener(new IslandActivitiesListeners(this));
this.registerListener(new JoinLeaveListener(this));
this.registerListener(this);
// Register commands for GameModes
getPlugin().getAddonsManager().getGameModeAddons().stream()
.filter(gm -> !settings.getGameModes().contains(gm.getDescription().getName()))
Expand All @@ -94,6 +97,11 @@ public void onEnable() {

}

@EventHandler
public void onBentoBoxReady(BentoBoxReadyEvent e) {
manager.loadTopTens();
}

private void registerPlaceholders(GameModeAddon gm) {
if (getPlugin().getPlaceholdersManager() == null) return;
// Island Level
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/world/bentobox/level/LevelsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void loadTopTens() {
World world = Bukkit.getWorld(tt.getUniqueId());
if (world != null) {
topTenLists.put(world, tt);
addon.log("Loaded TopTen for " + world.getName());
addon.log("Loaded top ten for " + world.getName());
// Update based on user data
// Remove any non island owners
tt.getTopTen().keySet().removeIf(u -> !addon.getIslands().isOwner(world, u));
Expand Down Expand Up @@ -434,6 +434,7 @@ private Long updateLevel(UUID uuid, World world) {
return ld.getLevel(world);
}
}
addon.getPlugin().logDebug("Returning 0L");
return 0L;
}

Expand Down

0 comments on commit 39e294e

Please sign in to comment.