Search in sources :

Example 1 with VersionChecker

use of logisticspipes.ticks.VersionChecker in project LogisticsPipes by RS485.

the class LogisticsEventListener method clientLoggedIn.

@SubscribeEvent
public void clientLoggedIn(ClientConnectedToServerEvent event) {
    SimpleServiceLocator.clientBufferHandler.clear();
    if (Configs.CHECK_FOR_UPDATES) {
        LogisticsPipes.singleThreadExecutor.execute(() -> {
            // try to get player entity ten times, once a second
            int times = 0;
            EntityClientPlayerMP playerEntity;
            do {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    return;
                }
                playerEntity = FMLClientHandler.instance().getClientPlayerEntity();
                ++times;
            } while (playerEntity == null && times <= 10);
            if (times > 10) {
                return;
            }
            assert playerEntity != null;
            VersionChecker checker = LogisticsPipes.versionChecker;
            // send player message
            String versionMessage = checker.getVersionCheckerStatus();
            if (checker.isVersionCheckDone() && checker.getVersionInfo().isNewVersionAvailable() && !checker.getVersionInfo().isImcMessageSent()) {
                playerEntity.addChatComponentMessage(new ChatComponentText(versionMessage));
                playerEntity.addChatComponentMessage(new ChatComponentText("Use \"/logisticspipes changelog\" to see a changelog."));
            } else if (!checker.isVersionCheckDone()) {
                playerEntity.addChatComponentMessage(new ChatComponentText(versionMessage));
            }
        });
    }
}
Also used : VersionChecker(logisticspipes.ticks.VersionChecker) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) ChatComponentText(net.minecraft.util.ChatComponentText) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 2 with VersionChecker

use of logisticspipes.ticks.VersionChecker in project LogisticsPipes by RS485.

the class ChangelogCommand method executeCommand.

@Override
public void executeCommand(ICommandSender sender, String[] args) {
    VersionChecker versionChecker = LogisticsPipes.versionChecker;
    String statusMessage = versionChecker.getVersionCheckerStatus();
    if (versionChecker.isVersionCheckDone() && versionChecker.getVersionInfo().isNewVersionAvailable()) {
        VersionChecker.VersionInfo versionInfo = versionChecker.getVersionInfo();
        MorePageDisplay display = new MorePageDisplay(new String[] { "(The newest version is #" + versionInfo.getNewestBuild() + ")", "< Changelog Page %/$ >" }, sender);
        if (versionInfo.getChangelog().isEmpty()) {
            display.append("No commits since your version.");
        } else {
            versionInfo.getChangelog().forEach(display::append);
        }
        display.display(sender);
    } else {
        sender.addChatMessage(new ChatComponentText(statusMessage));
    }
}
Also used : VersionChecker(logisticspipes.ticks.VersionChecker) ChatComponentText(net.minecraft.util.ChatComponentText) MorePageDisplay(logisticspipes.commands.chathelper.MorePageDisplay)

Example 3 with VersionChecker

use of logisticspipes.ticks.VersionChecker in project LogisticsPipes by RS485.

the class VersionCommand method executeCommand.

@Override
public void executeCommand(ICommandSender sender, String[] args) {
    sender.addChatMessage(new ChatComponentText(String.format("LogisticsPipes %s for Minecraft %s.", LogisticsPipes.class.getAnnotation(Mod.class).version(), LPConstants.MCVersion)));
    VersionChecker versionChecker = LogisticsPipes.versionChecker;
    sender.addChatMessage(new ChatComponentText(versionChecker.getVersionCheckerStatus()));
    if (versionChecker.isVersionCheckDone() && versionChecker.getVersionInfo().isNewVersionAvailable()) {
        sender.addChatMessage(new ChatComponentText("Use \"/logisticspipes changelog\" to see a changelog."));
    }
}
Also used : VersionChecker(logisticspipes.ticks.VersionChecker) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

VersionChecker (logisticspipes.ticks.VersionChecker)3 ChatComponentText (net.minecraft.util.ChatComponentText)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 MorePageDisplay (logisticspipes.commands.chathelper.MorePageDisplay)1 EntityClientPlayerMP (net.minecraft.client.entity.EntityClientPlayerMP)1