mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-11-06 02:30:27 +01:00
Fixes bug where top ten was cleared after reloading.
https://github.com/BentoBoxWorld/Level/issues/163
This commit is contained in:
parent
66b098ec73
commit
39e294eaf6
@ -8,12 +8,15 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
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.NonNull;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.addons.Addon;
|
import world.bentobox.bentobox.api.addons.Addon;
|
||||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
import world.bentobox.bentobox.api.configuration.Config;
|
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.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
import world.bentobox.level.calculators.Pipeliner;
|
import world.bentobox.level.calculators.Pipeliner;
|
||||||
@ -35,7 +38,7 @@ import world.bentobox.level.requests.TopTenRequestHandler;
|
|||||||
* @author tastybento
|
* @author tastybento
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Level extends Addon {
|
public class Level extends Addon implements Listener {
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
private ConfigSettings settings;
|
private ConfigSettings settings;
|
||||||
@ -71,10 +74,10 @@ public class Level extends Addon {
|
|||||||
pipeliner = new Pipeliner(this);
|
pipeliner = new Pipeliner(this);
|
||||||
// Start Manager
|
// Start Manager
|
||||||
manager = new LevelsManager(this);
|
manager = new LevelsManager(this);
|
||||||
manager.loadTopTens();
|
|
||||||
// Register listeners
|
// Register listeners
|
||||||
this.registerListener(new IslandActivitiesListeners(this));
|
this.registerListener(new IslandActivitiesListeners(this));
|
||||||
this.registerListener(new JoinLeaveListener(this));
|
this.registerListener(new JoinLeaveListener(this));
|
||||||
|
this.registerListener(this);
|
||||||
// Register commands for GameModes
|
// Register commands for GameModes
|
||||||
getPlugin().getAddonsManager().getGameModeAddons().stream()
|
getPlugin().getAddonsManager().getGameModeAddons().stream()
|
||||||
.filter(gm -> !settings.getGameModes().contains(gm.getDescription().getName()))
|
.filter(gm -> !settings.getGameModes().contains(gm.getDescription().getName()))
|
||||||
@ -94,6 +97,11 @@ public class Level extends Addon {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBentoBoxReady(BentoBoxReadyEvent e) {
|
||||||
|
manager.loadTopTens();
|
||||||
|
}
|
||||||
|
|
||||||
private void registerPlaceholders(GameModeAddon gm) {
|
private void registerPlaceholders(GameModeAddon gm) {
|
||||||
if (getPlugin().getPlaceholdersManager() == null) return;
|
if (getPlugin().getPlaceholdersManager() == null) return;
|
||||||
// Island Level
|
// Island Level
|
||||||
|
@ -355,7 +355,7 @@ public class LevelsManager {
|
|||||||
World world = Bukkit.getWorld(tt.getUniqueId());
|
World world = Bukkit.getWorld(tt.getUniqueId());
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
topTenLists.put(world, tt);
|
topTenLists.put(world, tt);
|
||||||
addon.log("Loaded TopTen for " + world.getName());
|
addon.log("Loaded top ten for " + world.getName());
|
||||||
// Update based on user data
|
// Update based on user data
|
||||||
// Remove any non island owners
|
// Remove any non island owners
|
||||||
tt.getTopTen().keySet().removeIf(u -> !addon.getIslands().isOwner(world, u));
|
tt.getTopTen().keySet().removeIf(u -> !addon.getIslands().isOwner(world, u));
|
||||||
@ -434,6 +434,7 @@ public class LevelsManager {
|
|||||||
return ld.getLevel(world);
|
return ld.getLevel(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
addon.getPlugin().logDebug("Returning 0L");
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user