mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2025-01-09 17:27:45 +01:00
Fixes bugs with tests. Support old Biomes addons.
This commit is contained in:
parent
6c168731d8
commit
284f18c680
@ -31,6 +31,7 @@ import world.bentobox.level.config.BlockConfig;
|
|||||||
import world.bentobox.level.config.ConfigSettings;
|
import world.bentobox.level.config.ConfigSettings;
|
||||||
import world.bentobox.level.listeners.IslandActivitiesListeners;
|
import world.bentobox.level.listeners.IslandActivitiesListeners;
|
||||||
import world.bentobox.level.listeners.JoinLeaveListener;
|
import world.bentobox.level.listeners.JoinLeaveListener;
|
||||||
|
import world.bentobox.level.objects.LevelsData;
|
||||||
import world.bentobox.level.requests.LevelRequestHandler;
|
import world.bentobox.level.requests.LevelRequestHandler;
|
||||||
import world.bentobox.level.requests.TopTenRequestHandler;
|
import world.bentobox.level.requests.TopTenRequestHandler;
|
||||||
|
|
||||||
@ -325,4 +326,20 @@ public class Level extends Addon implements Listener {
|
|||||||
if (island != null) getManager().calculateLevel(playerUUID, island);
|
if (island != null) getManager().calculateLevel(playerUUID, island);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide the levels data for the target player
|
||||||
|
* @param targetPlayer - UUID of target player
|
||||||
|
* @return LevelsData object or null if not found. Only island levels are set!
|
||||||
|
* @deprecated Do not use this anymore. Use {@link #getIslandLevel(World, UUID)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public LevelsData getLevelsData(UUID targetPlayer) {
|
||||||
|
LevelsData ld = new LevelsData(targetPlayer);
|
||||||
|
getPlugin().getAddonsManager().getGameModeAddons().stream()
|
||||||
|
.filter(gm -> !settings.getGameModes().contains(gm.getDescription().getName()))
|
||||||
|
.forEach(gm -> {
|
||||||
|
ld.setLevel(gm.getOverWorld(), this.getIslandLevel(gm.getOverWorld(), targetPlayer));
|
||||||
|
});
|
||||||
|
return ld;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,6 +158,8 @@ public class LevelsManager {
|
|||||||
addon.getPipeliner().addIsland(island).thenAccept(r -> {
|
addon.getPipeliner().addIsland(island).thenAccept(r -> {
|
||||||
// Results are irrelevant because the island is unowned or deleted, or IslandLevelCalcEvent is cancelled
|
// Results are irrelevant because the island is unowned or deleted, or IslandLevelCalcEvent is cancelled
|
||||||
if (r == null || fireIslandLevelCalcEvent(targetPlayer, island, r)) {
|
if (r == null || fireIslandLevelCalcEvent(targetPlayer, island, r)) {
|
||||||
|
System.out.println("results are null or event canceled");
|
||||||
|
|
||||||
result.complete(null);
|
result.complete(null);
|
||||||
}
|
}
|
||||||
// Save result
|
// Save result
|
||||||
@ -498,6 +500,8 @@ public class LevelsManager {
|
|||||||
// Remove the initial level
|
// Remove the initial level
|
||||||
if (addon.getSettings().isZeroNewIslandLevels()) {
|
if (addon.getSettings().isZeroNewIslandLevels()) {
|
||||||
il.setLevel(lv - il.getInitialLevel());
|
il.setLevel(lv - il.getInitialLevel());
|
||||||
|
} else {
|
||||||
|
il.setLevel(lv);
|
||||||
}
|
}
|
||||||
handler.saveObjectAsync(levelsCache.get(id));
|
handler.saveObjectAsync(levelsCache.get(id));
|
||||||
// Update TopTen
|
// Update TopTen
|
||||||
@ -520,6 +524,8 @@ public class LevelsManager {
|
|||||||
// Remove the initial level
|
// Remove the initial level
|
||||||
if (addon.getSettings().isZeroNewIslandLevels()) {
|
if (addon.getSettings().isZeroNewIslandLevels()) {
|
||||||
ld.setLevel(r.getLevel() - ld.getInitialLevel());
|
ld.setLevel(r.getLevel() - ld.getInitialLevel());
|
||||||
|
} else {
|
||||||
|
ld.setLevel(r.getLevel());
|
||||||
}
|
}
|
||||||
ld.setUwCount(Maps.asMap(r.getUwCount().elementSet(), elem -> r.getUwCount().count(elem)));
|
ld.setUwCount(Maps.asMap(r.getUwCount().elementSet(), elem -> r.getUwCount().count(elem)));
|
||||||
ld.setMdCount(Maps.asMap(r.getMdCount().elementSet(), elem -> r.getMdCount().count(elem)));
|
ld.setMdCount(Maps.asMap(r.getMdCount().elementSet(), elem -> r.getMdCount().count(elem)));
|
||||||
|
@ -256,6 +256,7 @@ public class LevelsManagerTest {
|
|||||||
results.setLevel(10000);
|
results.setLevel(10000);
|
||||||
results.setInitialLevel(3);
|
results.setInitialLevel(3);
|
||||||
lm.calculateLevel(uuid, island);
|
lm.calculateLevel(uuid, island);
|
||||||
|
// Complete the pipelined completable future
|
||||||
cf.complete(results);
|
cf.complete(results);
|
||||||
|
|
||||||
assertEquals(10000L, lm.getLevelsData(island).getLevel());
|
assertEquals(10000L, lm.getLevelsData(island).getLevel());
|
||||||
|
Loading…
Reference in New Issue
Block a user