mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-11-13 06:07:26 +01:00
Update to new API
This commit is contained in:
parent
e559c67dd3
commit
1b38a2c38a
@ -92,7 +92,7 @@ public class Level extends Addon {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Check if it is enabled - it might be loaded, but not enabled.
|
||||
if (getBSkyBlock() == null || !getBSkyBlock().isEnabled()) {
|
||||
if (getPlugin() == null || !getPlugin().isEnabled()) {
|
||||
getLogger().severe("BSkyBlock does not exist or is not enabled. Stopping.");
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
@ -106,30 +106,30 @@ public class Level extends Addon {
|
||||
// Initialize the cache
|
||||
levelsCache = new HashMap<>();
|
||||
// Load the calculator
|
||||
levelCalc = new LevelPresenter(this, this.getBSkyBlock());
|
||||
levelCalc = new LevelPresenter(this, this.getPlugin());
|
||||
// Start the top ten and register it for clicks
|
||||
topTen = new TopTen(this);
|
||||
registerListener(topTen);
|
||||
// Register commands - run one tick later to allow all addons to load
|
||||
// AcidIsland hook in
|
||||
getServer().getScheduler().runTask(getBSkyBlock(), () -> {
|
||||
this.getBSkyBlock().getAddonsManager().getAddonByName("AcidIsland").ifPresent(a -> {
|
||||
CompositeCommand acidIslandCmd = getBSkyBlock().getCommandsManager().getCommand("ai");
|
||||
getServer().getScheduler().runTask(getPlugin(), () -> {
|
||||
this.getPlugin().getAddonsManager().getAddonByName("AcidIsland").ifPresent(a -> {
|
||||
CompositeCommand acidIslandCmd = getPlugin().getCommandsManager().getCommand("ai");
|
||||
if (acidIslandCmd != null) {
|
||||
new IslandLevel(this, acidIslandCmd);
|
||||
new IslandTop(this, acidIslandCmd);
|
||||
CompositeCommand acidCmd = getBSkyBlock().getCommandsManager().getCommand("acid");
|
||||
CompositeCommand acidCmd = getPlugin().getCommandsManager().getCommand("acid");
|
||||
new AdminLevel(this, acidCmd);
|
||||
new AdminTop(this, acidCmd);
|
||||
}
|
||||
});
|
||||
// BSkyBlock hook in
|
||||
this.getBSkyBlock().getAddonsManager().getAddonByName("BSkyBlock").ifPresent(a -> {
|
||||
CompositeCommand bsbIslandCmd = getBSkyBlock().getCommandsManager().getCommand("island");
|
||||
this.getPlugin().getAddonsManager().getAddonByName("BSkyBlock").ifPresent(a -> {
|
||||
CompositeCommand bsbIslandCmd = getPlugin().getCommandsManager().getCommand("island");
|
||||
if (bsbIslandCmd != null) {
|
||||
new IslandLevel(this, bsbIslandCmd);
|
||||
new IslandTop(this, bsbIslandCmd);
|
||||
CompositeCommand bsbAdminCmd = getBSkyBlock().getCommandsManager().getCommand("bsbadmin");
|
||||
CompositeCommand bsbAdminCmd = getPlugin().getCommandsManager().getCommand("bsbadmin");
|
||||
new AdminLevel(this, bsbAdminCmd);
|
||||
new AdminTop(this, bsbAdminCmd);
|
||||
}
|
||||
@ -149,7 +149,7 @@ public class Level extends Addon {
|
||||
public void save(boolean async){
|
||||
Runnable save = () -> levelsCache.values().forEach(handler::saveObject);
|
||||
if(async){
|
||||
getServer().getScheduler().runTaskAsynchronously(getBSkyBlock(), save);
|
||||
getServer().getScheduler().runTaskAsynchronously(getPlugin(), save);
|
||||
} else {
|
||||
save.run();
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class TopTen implements Listener {
|
||||
Player player = addon.getServer().getPlayer(ownerUUID);
|
||||
if (player != null) {
|
||||
// Online
|
||||
if (!player.hasPermission(addon.getBSkyBlock().getIWM().getPermissionPrefix(world) + ".intopten")) {
|
||||
if (!player.hasPermission(addon.getPlugin().getIWM().getPermissionPrefix(world) + ".intopten")) {
|
||||
topTenList.get(world).remove(ownerUUID);
|
||||
return;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class CalcIslandLevel {
|
||||
checking = true;
|
||||
|
||||
// Start a recurring task until done or cancelled
|
||||
task = addon.getServer().getScheduler().runTaskTimer(addon.getBSkyBlock(), () -> {
|
||||
task = addon.getServer().getScheduler().runTaskTimer(addon.getPlugin(), () -> {
|
||||
Set<ChunkSnapshot> chunkSnapshot = new HashSet<>();
|
||||
if (checking) {
|
||||
Iterator<Pair<Integer, Integer>> it = chunksToScan.iterator();
|
||||
@ -98,7 +98,7 @@ public class CalcIslandLevel {
|
||||
|
||||
private void checkChunksAsync(final Set<ChunkSnapshot> chunkSnapshot) {
|
||||
// Run async task to scan chunks
|
||||
addon.getServer().getScheduler().runTaskAsynchronously(addon.getBSkyBlock(), () -> {
|
||||
addon.getServer().getScheduler().runTaskAsynchronously(addon.getPlugin(), () -> {
|
||||
for (ChunkSnapshot chunk: chunkSnapshot) {
|
||||
scanChunk(chunk);
|
||||
}
|
||||
@ -212,7 +212,7 @@ public class CalcIslandLevel {
|
||||
result.report = getReport();
|
||||
// All done.
|
||||
if (onExit != null) {
|
||||
Bukkit.getScheduler().runTask(addon.getBSkyBlock(), onExit);
|
||||
Bukkit.getScheduler().runTask(addon.getPlugin(), onExit);
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,7 +220,7 @@ public class CalcIslandLevel {
|
||||
private List<String> getReport() {
|
||||
List<String> reportLines = new ArrayList<>();
|
||||
// provide counts
|
||||
reportLines.add("Level Log for island in " + addon.getBSkyBlock().getIWM().getFriendlyName(island.getWorld()) + " at " + Util.xyz(island.getCenter().toVector()));
|
||||
reportLines.add("Level Log for island in " + addon.getPlugin().getIWM().getFriendlyName(island.getWorld()) + " at " + Util.xyz(island.getCenter().toVector()));
|
||||
reportLines.add("Island owner UUID = " + island.getOwner());
|
||||
reportLines.add("Total block value count = " + String.format("%,d",result.rawBlockCount));
|
||||
reportLines.add("Level cost = " + addon.getSettings().getLevelCost());
|
||||
|
Loading…
Reference in New Issue
Block a user