Search in sources :

Example 1 with ErrorLogger

use of com.djrapitops.plan.utilities.logging.ErrorLogger in project Plan by plan-player-analytics.

the class ConfigUpdaterTest method prepareConfigFiles.

@BeforeAll
static void prepareConfigFiles() throws URISyntaxException, IOException {
    oldConfig = tempDir.resolve("config.yml").toFile();
    File configResource = TestResources.getTestResourceFile("config/4.5.2-config.yml", ConfigUpdater.class);
    Files.copy(configResource.toPath(), oldConfig.toPath(), StandardCopyOption.REPLACE_EXISTING);
    oldBungeeConfig = tempDir.resolve("bungeeconfig.yml").toFile();
    File bungeeConfigResource = TestResources.getTestResourceFile("config/4.5.2-bungeeconfig.yml", ConfigUpdater.class);
    Files.copy(bungeeConfigResource.toPath(), oldBungeeConfig.toPath(), StandardCopyOption.REPLACE_EXISTING);
    newConfig = tempDir.resolve("newconfig.yml");
    TestResources.copyResourceIntoFile(newConfig.toFile(), "/assets/plan/config.yml");
    newBungeeConfig = tempDir.resolve("newbungeeconfig.yml");
    TestResources.copyResourceIntoFile(newBungeeConfig.toFile(), "/assets/plan/bungeeconfig.yml");
    PluginLogger testLogger = new TestPluginLogger();
    errorLogger = Mockito.mock(ErrorLogger.class);
    UNDER_TEST = new ConfigUpdater(testLogger, errorLogger);
}
Also used : TestPluginLogger(utilities.TestPluginLogger) File(java.io.File) PluginLogger(net.playeranalytics.plugin.server.PluginLogger) TestPluginLogger(utilities.TestPluginLogger) ErrorLogger(com.djrapitops.plan.utilities.logging.ErrorLogger) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with ErrorLogger

use of com.djrapitops.plan.utilities.logging.ErrorLogger in project Plan by plan-player-analytics.

the class BukkitAFKListenerTest method setUp.

@BeforeAll
static void setUp() {
    PlanConfig config = Mockito.mock(PlanConfig.class);
    when(config.get(TimeSettings.AFK_THRESHOLD)).thenReturn(TimeUnit.MINUTES.toMillis(3));
    errorLogger = Mockito.mock(ErrorLogger.class);
    underTest = new BukkitAFKListener(config, errorLogger);
    new SessionCache().cacheSession(TestConstants.PLAYER_ONE_UUID, new ActiveSession(null, null, 0, null, null));
    new SessionCache().cacheSession(TestConstants.PLAYER_TWO_UUID, new ActiveSession(null, null, 0, null, null));
}
Also used : ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) BukkitAFKListener(com.djrapitops.plan.gathering.listeners.bukkit.BukkitAFKListener) SessionCache(com.djrapitops.plan.gathering.cache.SessionCache) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) ErrorLogger(com.djrapitops.plan.utilities.logging.ErrorLogger) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with ErrorLogger

use of com.djrapitops.plan.utilities.logging.ErrorLogger in project Plan by plan-player-analytics.

the class ExportScheduler method scheduleServerPageExport.

private void scheduleServerPageExport() {
    if (config.isFalse(ExportSettings.SERVER_PAGE))
        return;
    Collection<Server> servers = dbSystem.getDatabase().query(ServerQueries.fetchPlanServerInformationCollection());
    int serverCount = servers.size();
    if (serverCount == 0)
        return;
    long period = TimeAmount.toTicks(config.get(ExportSettings.EXPORT_PERIOD), TimeUnit.MILLISECONDS);
    long offset = period / serverCount;
    Optional<Server> proxy = servers.stream().filter(Server::isProxy).findFirst();
    proxy.ifPresent(mainServer -> runnableFactory.create(new ExportTask(exporter, same -> same.exportServerPage(mainServer), errorLogger)).runTaskTimerAsynchronously(TimeAmount.toTicks(1, TimeUnit.MINUTES), period));
    // Delay first server export if on a network.
    int offsetMultiplier = proxy.isPresent() ? 1 : 0;
    for (Server server : servers) {
        runnableFactory.create(new ExportTask(exporter, same -> {
            same.exportServerPage(server);
            same.exportServerJSON(server);
        }, errorLogger)).runTaskTimerAsynchronously(offset * offsetMultiplier, period);
        offsetMultiplier++;
    }
}
Also used : PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) ServerInfo(com.djrapitops.plan.identification.ServerInfo) ExportSettings(com.djrapitops.plan.settings.config.paths.ExportSettings) Collection(java.util.Collection) TimeAmount(net.playeranalytics.plugin.scheduling.TimeAmount) Singleton(javax.inject.Singleton) Database(com.djrapitops.plan.storage.database.Database) DBSystem(com.djrapitops.plan.storage.database.DBSystem) Inject(javax.inject.Inject) TimeUnit(java.util.concurrent.TimeUnit) Server(com.djrapitops.plan.identification.Server) ErrorLogger(com.djrapitops.plan.utilities.logging.ErrorLogger) RunnableFactory(net.playeranalytics.plugin.scheduling.RunnableFactory) Optional(java.util.Optional) PluginRunnable(net.playeranalytics.plugin.scheduling.PluginRunnable) ServerQueries(com.djrapitops.plan.storage.database.queries.objects.ServerQueries) Server(com.djrapitops.plan.identification.Server)

Example 4 with ErrorLogger

use of com.djrapitops.plan.utilities.logging.ErrorLogger in project Plan by plan-player-analytics.

the class NukkitAFKListenerTest method setUp.

@BeforeAll
static void setUp() {
    PlanConfig config = Mockito.mock(PlanConfig.class);
    when(config.get(TimeSettings.AFK_THRESHOLD)).thenReturn(TimeUnit.MINUTES.toMillis(3));
    errorLogger = Mockito.mock(ErrorLogger.class);
    underTest = new NukkitAFKListener(config, errorLogger);
    new SessionCache().cacheSession(TestConstants.PLAYER_ONE_UUID, new ActiveSession(null, null, 0, null, null));
    new SessionCache().cacheSession(TestConstants.PLAYER_TWO_UUID, new ActiveSession(null, null, 0, null, null));
}
Also used : ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) NukkitAFKListener(com.djrapitops.plan.gathering.listeners.nukkit.NukkitAFKListener) SessionCache(com.djrapitops.plan.gathering.cache.SessionCache) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) ErrorLogger(com.djrapitops.plan.utilities.logging.ErrorLogger) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

ErrorLogger (com.djrapitops.plan.utilities.logging.ErrorLogger)4 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)3 BeforeAll (org.junit.jupiter.api.BeforeAll)3 SessionCache (com.djrapitops.plan.gathering.cache.SessionCache)2 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)2 BukkitAFKListener (com.djrapitops.plan.gathering.listeners.bukkit.BukkitAFKListener)1 NukkitAFKListener (com.djrapitops.plan.gathering.listeners.nukkit.NukkitAFKListener)1 Server (com.djrapitops.plan.identification.Server)1 ServerInfo (com.djrapitops.plan.identification.ServerInfo)1 ExportSettings (com.djrapitops.plan.settings.config.paths.ExportSettings)1 DBSystem (com.djrapitops.plan.storage.database.DBSystem)1 Database (com.djrapitops.plan.storage.database.Database)1 ServerQueries (com.djrapitops.plan.storage.database.queries.objects.ServerQueries)1 File (java.io.File)1 Collection (java.util.Collection)1 Optional (java.util.Optional)1 TimeUnit (java.util.concurrent.TimeUnit)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 PluginRunnable (net.playeranalytics.plugin.scheduling.PluginRunnable)1