use of dev.frankheijden.insights.api.concurrent.storage.WorldStorage in project Insights by InsightsPlugin.
the class Insights method onEnable.
@Override
public void onEnable() {
super.onEnable();
this.audiences = BukkitAudiences.create(this);
this.listenerManager = new ListenerManager(this);
reloadConfigs();
addonManager = new AddonManager(this, getDataFolder().toPath().resolve("addons"));
try {
addonManager.createAddonsFolder();
} catch (IOException ex) {
ex.printStackTrace();
}
getServer().getScheduler().runTaskLater(this, () -> {
try {
addonManager.loadAddons();
} catch (IOException ex) {
ex.printStackTrace();
}
}, 1);
playerList = new PlayerList(Bukkit.getOnlinePlayers());
worldStorage = new WorldStorage();
addonStorage = new AddonStorage();
worldChunkScanTracker = new WorldChunkScanTracker();
addonScanTracker = new AddonScanTracker();
executor = ContainerExecutorService.newExecutor(settings.SCANS_CONCURRENT_THREADS);
chunkContainerExecutor = new ChunkContainerExecutor(executor, worldStorage, worldChunkScanTracker);
metricsManager = new MetricsManager(this);
scanHistory = new ScanHistory();
redstoneUpdateCount = new RedstoneUpdateCount(this);
redstoneUpdateCount.start();
chunkTeleport = new ChunkTeleport(this);
loadCommands();
if (!PaperLib.isPaper()) {
entityTrackerTask = new EntityTrackerTask(this);
var interval = settings.SPIGOT_ENTITY_TRACKER_INTERVAL_TICKS;
Bukkit.getScheduler().runTaskTimer(this, entityTrackerTask, 0, interval);
}
reload();
}
use of dev.frankheijden.insights.api.concurrent.storage.WorldStorage in project Insights by InsightsPlugin.
the class InsightsListener method handleChunkAddition.
private Optional<Storage> handleChunkAddition(Player player, Chunk chunk, Consumer<Storage> storageConsumer) {
UUID worldUid = chunk.getWorld().getUID();
long chunkKey = ChunkUtils.getKey(chunk);
WorldStorage worldStorage = plugin.getWorldStorage();
ChunkStorage chunkStorage = worldStorage.getWorld(worldUid);
Optional<Storage> storageOptional = chunkStorage.get(chunkKey);
// If the chunk is not known
if (storageOptional.isEmpty()) {
// Notify the user scan started
if (plugin.getSettings().canReceiveAreaScanNotifications(player)) {
plugin.getMessages().getMessage(Messages.Key.AREA_SCAN_STARTED).addTemplates(Messages.tagOf("area", "chunk")).sendTo(player);
}
// Submit the chunk for scanning
plugin.getChunkContainerExecutor().submit(chunk).thenAccept(storageConsumer).exceptionally(th -> {
plugin.getLogger().log(Level.SEVERE, th, th::getMessage);
return null;
});
}
return storageOptional;
}
Aggregations