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));
}
});
}
}
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));
}
}
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."));
}
}
Aggregations