All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.dailystruggle.rtp.common.commands.update.UpdateCmd Maven / Gradle / Ivy

There is a newer version: 2.0.15
Show newest version
package io.github.dailystruggle.rtp.common.commands.update;

import io.github.dailystruggle.commandsapi.common.CommandsAPICommand;
import io.github.dailystruggle.rtp.common.RTP;
import io.github.dailystruggle.rtp.common.commands.BaseRTPCmdImpl;
import io.github.dailystruggle.rtp.common.configuration.ConfigParser;
import io.github.dailystruggle.rtp.common.configuration.Configs;
import io.github.dailystruggle.rtp.common.configuration.MultiConfigParser;
import io.github.dailystruggle.rtp.common.tasks.RTPRunnable;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Map;
import java.util.UUID;

public class UpdateCmd extends BaseRTPCmdImpl {
    public UpdateCmd(@Nullable CommandsAPICommand parent) {
        super(parent);

        RTP.getInstance().miscAsyncTasks.add(new RTPRunnable(this::addCommands, 5));
    }

    @Override
    public String name() {
        return "update";
    }

    @Override
    public String permission() {
        return "rtp.update";
    }

    @Override
    public String description() {
        return "update configuration files at runtime";
    }

    @Override
    public boolean onCommand(UUID callerId, Map> parameterValues, CommandsAPICommand nextCommand) {
        return true;
    }

    public void addCommands() {
        final Configs configs = RTP.configs;
        for (ConfigParser value : configs.configParserMap.values()) {
            String name = value.name.replace(".yml", "");
            if (getCommandLookup().containsKey(name)) continue;
            addSubCommand(new SubUpdateCmd(this, value.name, value));
        }

        for (Map.Entry, MultiConfigParser> e : configs.multiConfigParserMap.entrySet()) {
            MultiConfigParser> value = e.getValue();
            if (getCommandLookup().containsKey(value.name)) continue;
            addSubCommand(new SubUpdateCmd(this, value.name, value));
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy