Search in sources :

Example 1 with WorldStorage

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();
}
Also used : AddonScanTracker(dev.frankheijden.insights.api.concurrent.tracker.AddonScanTracker) ScanHistory(dev.frankheijden.insights.api.concurrent.storage.ScanHistory) CommandScanHistory(dev.frankheijden.insights.commands.CommandScanHistory) PlayerList(dev.frankheijden.insights.api.concurrent.PlayerList) EntityTrackerTask(dev.frankheijden.insights.tasks.EntityTrackerTask) IOException(java.io.IOException) AddonStorage(dev.frankheijden.insights.api.concurrent.storage.AddonStorage) WorldStorage(dev.frankheijden.insights.api.concurrent.storage.WorldStorage) ChunkTeleport(dev.frankheijden.insights.api.concurrent.ChunkTeleport) MetricsManager(dev.frankheijden.insights.api.metrics.MetricsManager) ChunkContainerExecutor(dev.frankheijden.insights.api.concurrent.ChunkContainerExecutor) RedstoneUpdateCount(dev.frankheijden.insights.api.concurrent.count.RedstoneUpdateCount) WorldChunkScanTracker(dev.frankheijden.insights.api.concurrent.tracker.WorldChunkScanTracker) AddonManager(dev.frankheijden.insights.api.addons.AddonManager) ListenerManager(dev.frankheijden.insights.listeners.manager.ListenerManager)

Example 2 with WorldStorage

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;
}
Also used : WorldStorage(dev.frankheijden.insights.api.concurrent.storage.WorldStorage) Storage(dev.frankheijden.insights.api.concurrent.storage.Storage) ChunkStorage(dev.frankheijden.insights.api.concurrent.storage.ChunkStorage) WorldStorage(dev.frankheijden.insights.api.concurrent.storage.WorldStorage) AddonStorage(dev.frankheijden.insights.api.concurrent.storage.AddonStorage) DistributionStorage(dev.frankheijden.insights.api.concurrent.storage.DistributionStorage) ChunkStorage(dev.frankheijden.insights.api.concurrent.storage.ChunkStorage) UUID(java.util.UUID)

Aggregations

AddonStorage (dev.frankheijden.insights.api.concurrent.storage.AddonStorage)2 WorldStorage (dev.frankheijden.insights.api.concurrent.storage.WorldStorage)2 AddonManager (dev.frankheijden.insights.api.addons.AddonManager)1 ChunkContainerExecutor (dev.frankheijden.insights.api.concurrent.ChunkContainerExecutor)1 ChunkTeleport (dev.frankheijden.insights.api.concurrent.ChunkTeleport)1 PlayerList (dev.frankheijden.insights.api.concurrent.PlayerList)1 RedstoneUpdateCount (dev.frankheijden.insights.api.concurrent.count.RedstoneUpdateCount)1 ChunkStorage (dev.frankheijden.insights.api.concurrent.storage.ChunkStorage)1 DistributionStorage (dev.frankheijden.insights.api.concurrent.storage.DistributionStorage)1 ScanHistory (dev.frankheijden.insights.api.concurrent.storage.ScanHistory)1 Storage (dev.frankheijden.insights.api.concurrent.storage.Storage)1 AddonScanTracker (dev.frankheijden.insights.api.concurrent.tracker.AddonScanTracker)1 WorldChunkScanTracker (dev.frankheijden.insights.api.concurrent.tracker.WorldChunkScanTracker)1 MetricsManager (dev.frankheijden.insights.api.metrics.MetricsManager)1 CommandScanHistory (dev.frankheijden.insights.commands.CommandScanHistory)1 ListenerManager (dev.frankheijden.insights.listeners.manager.ListenerManager)1 EntityTrackerTask (dev.frankheijden.insights.tasks.EntityTrackerTask)1 IOException (java.io.IOException)1 UUID (java.util.UUID)1