Search in sources :

Example 1 with EntityChecker

use of me.time6628.clag.sponge.runnables.EntityChecker in project CatClearLag by Time6628.

the class CatClearLag method onInit.

@Listener
public void onInit(GameInitializationEvent event) {
    getLogger().info("Starting plugin...");
    registerCommands();
    registerEvents();
    tasks = new ArrayList<>();
    Task.Builder builder = getGame().getScheduler().createTaskBuilder();
    tasks.add(builder.execute(new ItemClearer()).async().delay(cclConfig.interval, TimeUnit.MINUTES).interval(cclConfig.interval, TimeUnit.MINUTES).name("CatClearLag Item Remover").submit(this));
    cclConfig.warnings.forEach((d) -> tasks.add(builder.execute(new ItemClearingWarning(((cclConfig.interval * 60) - d))).async().delay(d, TimeUnit.SECONDS).interval(cclConfig.interval, TimeUnit.MINUTES).name("CatClearLag Removal Warnings").submit(this)));
    tasks.add(builder.execute(new EntityChecker()).async().delay(cclConfig.limits.entityCheckInterval, TimeUnit.MINUTES).interval(cclConfig.limits.entityCheckInterval, TimeUnit.MINUTES).name("CatClearLag hostile checker").submit(this));
}
Also used : ItemClearingWarning(me.time6628.clag.sponge.runnables.ItemClearingWarning) Task(org.spongepowered.api.scheduler.Task) EntityChecker(me.time6628.clag.sponge.runnables.EntityChecker) ItemClearer(me.time6628.clag.sponge.runnables.ItemClearer) Listener(org.spongepowered.api.event.Listener)

Example 2 with EntityChecker

use of me.time6628.clag.sponge.runnables.EntityChecker in project CatClearLag by Time6628.

the class CatClearLag method onReload.

@Listener
public void onReload(GameReloadEvent event) {
    cfgLoader = new ConfigLoader(this);
    if (cfgLoader.loadConfig())
        cclConfig = cfgLoader.getCclConfig();
    if (cfgLoader.loadMessages())
        messages = cfgLoader.getMessagesConfig();
    for (Task task : tasks) {
        task.cancel();
    }
    tasks = new ArrayList<>();
    Task.Builder builder = getGame().getScheduler().createTaskBuilder();
    tasks.add(builder.execute(new ItemClearer()).async().delay(cclConfig.interval, TimeUnit.MINUTES).interval(cclConfig.interval, TimeUnit.MINUTES).name("CatClearLag Item Remover").submit(this));
    cclConfig.warnings.forEach((d) -> tasks.add(builder.execute(new ItemClearingWarning(((cclConfig.interval * 60) - d))).async().delay(d, TimeUnit.SECONDS).interval(cclConfig.interval, TimeUnit.MINUTES).name("CatClearLag Removal Warnings").submit(this)));
    tasks.add(builder.execute(new EntityChecker()).async().delay(cclConfig.limits.entityCheckInterval, TimeUnit.MINUTES).interval(cclConfig.limits.entityCheckInterval, TimeUnit.MINUTES).name("CatClearLag hostile checker").submit(this));
}
Also used : ItemClearingWarning(me.time6628.clag.sponge.runnables.ItemClearingWarning) Task(org.spongepowered.api.scheduler.Task) ConfigLoader(me.time6628.clag.sponge.config.ConfigLoader) EntityChecker(me.time6628.clag.sponge.runnables.EntityChecker) ItemClearer(me.time6628.clag.sponge.runnables.ItemClearer) Listener(org.spongepowered.api.event.Listener)

Aggregations

EntityChecker (me.time6628.clag.sponge.runnables.EntityChecker)2 ItemClearer (me.time6628.clag.sponge.runnables.ItemClearer)2 ItemClearingWarning (me.time6628.clag.sponge.runnables.ItemClearingWarning)2 Listener (org.spongepowered.api.event.Listener)2 Task (org.spongepowered.api.scheduler.Task)2 ConfigLoader (me.time6628.clag.sponge.config.ConfigLoader)1