Search in sources :

Example 1 with ItemManager

use of me.time6628.clag.sponge.handlers.ItemManager 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<>();
    if (cclConfig.liveTime.enabled) {
        this.itemManager = new ItemManager();
        getGame().getEventManager().registerListeners(this, itemManager);
        getCclService().addCheck(Type.ITEM, entity -> !itemManager.getItems().contains(entity));
    }
    Scheduler scheduler = getGame().getScheduler();
    if (getCclConfig().interval != -1) {
        tasks.add(scheduler.createTaskBuilder().execute(new ItemClearer()).delay(cclConfig.interval, TimeUnit.MINUTES).interval(cclConfig.interval, TimeUnit.MINUTES).name("CatClearLag Item Remover").submit(this));
        cclConfig.warnings.forEach((d) -> tasks.add(scheduler.createTaskBuilder().execute(new ItemClearingWarning(((cclConfig.interval * 60) - d))).delay(d, TimeUnit.SECONDS).interval(cclConfig.interval, TimeUnit.MINUTES).name("CatClearLag Removal Warnings").submit(this)));
    }
    tasks.add(scheduler.createTaskBuilder().execute(new EntityChecker()).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) ItemManager(me.time6628.clag.sponge.handlers.ItemManager) Scheduler(org.spongepowered.api.scheduler.Scheduler) EntityChecker(me.time6628.clag.sponge.runnables.EntityChecker) ItemClearer(me.time6628.clag.sponge.runnables.ItemClearer) Listener(org.spongepowered.api.event.Listener)

Aggregations

ItemManager (me.time6628.clag.sponge.handlers.ItemManager)1 EntityChecker (me.time6628.clag.sponge.runnables.EntityChecker)1 ItemClearer (me.time6628.clag.sponge.runnables.ItemClearer)1 ItemClearingWarning (me.time6628.clag.sponge.runnables.ItemClearingWarning)1 Listener (org.spongepowered.api.event.Listener)1 Scheduler (org.spongepowered.api.scheduler.Scheduler)1