ModUpdater/src/main/java/com/thebrokenrail/modupdater/ModUpdater.java

47 lines
1.3 KiB
Java
Raw Normal View History

2020-06-24 02:04:22 +00:00
package com.thebrokenrail.modupdater;
2020-06-27 23:22:04 +00:00
import com.thebrokenrail.modupdater.command.ModUpdaterCommand;
2020-06-25 20:56:09 +00:00
import com.thebrokenrail.modupdater.data.ModUpdate;
2020-06-28 17:43:17 +00:00
import com.thebrokenrail.modupdater.strategy.util.UpdateStrategyRunner;
2020-06-24 02:04:22 +00:00
import net.fabricmc.api.ModInitializer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
2020-06-27 17:56:22 +00:00
import javax.annotation.Nullable;
2020-06-24 18:03:02 +00:00
2020-06-24 02:04:22 +00:00
public class ModUpdater implements ModInitializer {
public static final String NAMESPACE = "modupdater";
private static final String LOGGER_NAME = "ModUpdater";
2020-06-25 20:56:09 +00:00
private static Logger getLogger() {
2020-06-24 02:04:22 +00:00
return LogManager.getLogger(LOGGER_NAME);
}
2020-06-27 17:56:22 +00:00
public static void logWarn(String name, String msg) {
2020-06-25 20:56:09 +00:00
getLogger().warn(String.format("%s: %s", name, msg));
2020-06-24 02:04:22 +00:00
}
2020-06-27 17:56:22 +00:00
public static void logInfo(String info) {
getLogger().info(info);
}
2020-06-27 23:22:04 +00:00
private static volatile ModUpdate[] updates = null;
2020-06-24 02:04:22 +00:00
2020-06-27 17:56:22 +00:00
public static void findUpdates() {
2020-06-27 23:22:04 +00:00
updates = null;
new Thread(() -> updates = UpdateStrategyRunner.checkAllModsForUpdates()).start();
2020-06-27 17:56:22 +00:00
}
2020-06-24 18:03:02 +00:00
2020-06-27 17:56:22 +00:00
@Nullable
2020-06-24 02:04:22 +00:00
public static ModUpdate[] getUpdates() {
return updates;
}
@Override
public void onInitialize() {
2020-06-27 23:22:04 +00:00
findUpdates();
ModUpdaterCommand.register();
2020-06-24 02:04:22 +00:00
}
}