Update to new API

This commit is contained in:
tastybento 2018-07-29 17:22:23 -07:00
parent e559c67dd3
commit 1b38a2c38a
3 changed files with 15 additions and 15 deletions

View File

@ -92,7 +92,7 @@ public class Level extends Addon {
@Override @Override
public void onEnable() { public void onEnable() {
// Check if it is enabled - it might be loaded, but not enabled. // 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."); getLogger().severe("BSkyBlock does not exist or is not enabled. Stopping.");
this.setEnabled(false); this.setEnabled(false);
return; return;
@ -106,30 +106,30 @@ public class Level extends Addon {
// Initialize the cache // Initialize the cache
levelsCache = new HashMap<>(); levelsCache = new HashMap<>();
// Load the calculator // Load the calculator
levelCalc = new LevelPresenter(this, this.getBSkyBlock()); levelCalc = new LevelPresenter(this, this.getPlugin());
// Start the top ten and register it for clicks // Start the top ten and register it for clicks
topTen = new TopTen(this); topTen = new TopTen(this);
registerListener(topTen); registerListener(topTen);
// Register commands - run one tick later to allow all addons to load // Register commands - run one tick later to allow all addons to load
// AcidIsland hook in // AcidIsland hook in
getServer().getScheduler().runTask(getBSkyBlock(), () -> { getServer().getScheduler().runTask(getPlugin(), () -> {
this.getBSkyBlock().getAddonsManager().getAddonByName("AcidIsland").ifPresent(a -> { this.getPlugin().getAddonsManager().getAddonByName("AcidIsland").ifPresent(a -> {
CompositeCommand acidIslandCmd = getBSkyBlock().getCommandsManager().getCommand("ai"); CompositeCommand acidIslandCmd = getPlugin().getCommandsManager().getCommand("ai");
if (acidIslandCmd != null) { if (acidIslandCmd != null) {
new IslandLevel(this, acidIslandCmd); new IslandLevel(this, acidIslandCmd);
new IslandTop(this, acidIslandCmd); new IslandTop(this, acidIslandCmd);
CompositeCommand acidCmd = getBSkyBlock().getCommandsManager().getCommand("acid"); CompositeCommand acidCmd = getPlugin().getCommandsManager().getCommand("acid");
new AdminLevel(this, acidCmd); new AdminLevel(this, acidCmd);
new AdminTop(this, acidCmd); new AdminTop(this, acidCmd);
} }
}); });
// BSkyBlock hook in // BSkyBlock hook in
this.getBSkyBlock().getAddonsManager().getAddonByName("BSkyBlock").ifPresent(a -> { this.getPlugin().getAddonsManager().getAddonByName("BSkyBlock").ifPresent(a -> {
CompositeCommand bsbIslandCmd = getBSkyBlock().getCommandsManager().getCommand("island"); CompositeCommand bsbIslandCmd = getPlugin().getCommandsManager().getCommand("island");
if (bsbIslandCmd != null) { if (bsbIslandCmd != null) {
new IslandLevel(this, bsbIslandCmd); new IslandLevel(this, bsbIslandCmd);
new IslandTop(this, bsbIslandCmd); new IslandTop(this, bsbIslandCmd);
CompositeCommand bsbAdminCmd = getBSkyBlock().getCommandsManager().getCommand("bsbadmin"); CompositeCommand bsbAdminCmd = getPlugin().getCommandsManager().getCommand("bsbadmin");
new AdminLevel(this, bsbAdminCmd); new AdminLevel(this, bsbAdminCmd);
new AdminTop(this, bsbAdminCmd); new AdminTop(this, bsbAdminCmd);
} }
@ -149,7 +149,7 @@ public class Level extends Addon {
public void save(boolean async){ public void save(boolean async){
Runnable save = () -> levelsCache.values().forEach(handler::saveObject); Runnable save = () -> levelsCache.values().forEach(handler::saveObject);
if(async){ if(async){
getServer().getScheduler().runTaskAsynchronously(getBSkyBlock(), save); getServer().getScheduler().runTaskAsynchronously(getPlugin(), save);
} else { } else {
save.run(); save.run();
} }

View File

@ -63,7 +63,7 @@ public class TopTen implements Listener {
Player player = addon.getServer().getPlayer(ownerUUID); Player player = addon.getServer().getPlayer(ownerUUID);
if (player != null) { if (player != null) {
// Online // Online
if (!player.hasPermission(addon.getBSkyBlock().getIWM().getPermissionPrefix(world) + ".intopten")) { if (!player.hasPermission(addon.getPlugin().getIWM().getPermissionPrefix(world) + ".intopten")) {
topTenList.get(world).remove(ownerUUID); topTenList.get(world).remove(ownerUUID);
return; return;
} }

View File

@ -68,7 +68,7 @@ public class CalcIslandLevel {
checking = true; checking = true;
// Start a recurring task until done or cancelled // 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<>(); Set<ChunkSnapshot> chunkSnapshot = new HashSet<>();
if (checking) { if (checking) {
Iterator<Pair<Integer, Integer>> it = chunksToScan.iterator(); Iterator<Pair<Integer, Integer>> it = chunksToScan.iterator();
@ -98,7 +98,7 @@ public class CalcIslandLevel {
private void checkChunksAsync(final Set<ChunkSnapshot> chunkSnapshot) { private void checkChunksAsync(final Set<ChunkSnapshot> chunkSnapshot) {
// Run async task to scan chunks // Run async task to scan chunks
addon.getServer().getScheduler().runTaskAsynchronously(addon.getBSkyBlock(), () -> { addon.getServer().getScheduler().runTaskAsynchronously(addon.getPlugin(), () -> {
for (ChunkSnapshot chunk: chunkSnapshot) { for (ChunkSnapshot chunk: chunkSnapshot) {
scanChunk(chunk); scanChunk(chunk);
} }
@ -212,7 +212,7 @@ public class CalcIslandLevel {
result.report = getReport(); result.report = getReport();
// All done. // All done.
if (onExit != null) { 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() { private List<String> getReport() {
List<String> reportLines = new ArrayList<>(); List<String> reportLines = new ArrayList<>();
// provide counts // 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("Island owner UUID = " + island.getOwner());
reportLines.add("Total block value count = " + String.format("%,d",result.rawBlockCount)); reportLines.add("Total block value count = " + String.format("%,d",result.rawBlockCount));
reportLines.add("Level cost = " + addon.getSettings().getLevelCost()); reportLines.add("Level cost = " + addon.getSettings().getLevelCost());