Re-activated version check and changelog extracting, now based on github files.
Close #1709
This commit is contained in:
parent
a66ba2f637
commit
21fd683e58
5 changed files with 61 additions and 23 deletions
13
buildcraft_resources/changelog/6.0.9
Executable file
13
buildcraft_resources/changelog/6.0.9
Executable file
|
@ -0,0 +1,13 @@
|
|||
#1700 make blocking gate triggers by plugs enhancement [Prototik]
|
||||
#1699 make all blank blueprints and templates stack to 16 enhancement [tambry]
|
||||
#1698 fix rendering of blueprints and templates in player hands [tambry]
|
||||
#1697 fixed laser dot created when placing a laser [tambry]
|
||||
#1695 improved code style checker [jk-5]
|
||||
#1691 fix for the blueprint deployer [AEnterprise]
|
||||
#1690 improved auto style checks with travis [jk-5]
|
||||
#1688 implemented convertors between the old and new energy APIs [Prototik]
|
||||
#1687 fixed pumps [Prototik]
|
||||
#1686 itegrated auto style checks with travis [Prototik]
|
||||
#1685 enable style check in gradle [Prototik]
|
||||
#1684 improved gradle build when no localisation installed [anti344]
|
||||
#1682 architect options are now localized [SpaceToad]
|
2
buildcraft_resources/versions.txt
Executable file
2
buildcraft_resources/versions.txt
Executable file
|
@ -0,0 +1,2 @@
|
|||
1.6.4:BuildCraft:4.2.2
|
||||
1.7.2:BuildCraft:6.0.9
|
|
@ -71,11 +71,11 @@ public class CommandBuildCraft extends CommandBase {
|
|||
|
||||
sender.addChatMessage(new ChatComponentText(String.format(colour + "BuildCraft %s for Minecraft %s (Latest: %s).", Version.getVersion(),
|
||||
CoreProxy.proxy.getMinecraftVersion(), Version.getRecommendedVersion())));
|
||||
if (Version.isOutdated()) {
|
||||
for (String updateLine : Version.getChangelog()) {
|
||||
sender.addChatMessage(new ChatComponentText("\u00A79" + updateLine));
|
||||
}
|
||||
}
|
||||
|
||||
// TODD This takes too much realstate. See how to improve
|
||||
// if (Version.isOutdated()) {
|
||||
// Version.displayChangelog(sender);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,11 +40,17 @@ public class TickHandlerCoreClient {
|
|||
"\u00A7cNew version of BuildCraft available: %s for Minecraft %s",
|
||||
Version.getRecommendedVersion(),
|
||||
CoreProxy.proxy.getMinecraftVersion())));
|
||||
for (String updateLine : Version.getChangelog()) {
|
||||
player.addChatMessage(new ChatComponentText("\u00A79" + updateLine));
|
||||
}
|
||||
player.addChatMessage(new ChatComponentText(
|
||||
"\u00A7cThis message only displays once. Type '/buildcraft version' if you want to see it again."));
|
||||
String.format(
|
||||
"\u00A7cDownload from http://www.mod-buildcraft.com/download",
|
||||
Version.getRecommendedVersion(),
|
||||
CoreProxy.proxy.getMinecraftVersion())));
|
||||
|
||||
// TODD This takes too much realstate. See how to improve
|
||||
// Version.displayChangelog(player);
|
||||
|
||||
player.addChatMessage(new ChatComponentText("This message only displays once."));
|
||||
player.addChatMessage(new ChatComponentText("Type '/buildcraft version' if you want to see it again."));
|
||||
}
|
||||
|
||||
// }
|
||||
|
|
|
@ -14,6 +14,9 @@ import java.net.HttpURLConnection;
|
|||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
|
@ -26,21 +29,24 @@ public class Version implements Runnable {
|
|||
}
|
||||
|
||||
public static final String VERSION = "@VERSION@";
|
||||
public static final String BUILD_NUMBER = "@BUILD_NUMBER@";
|
||||
public static EnumUpdateState currentVersion = EnumUpdateState.CURRENT;
|
||||
public static final int FORGE_VERSION_MAJOR = 4;
|
||||
public static final int FORGE_VERSION_MINOR = 0;
|
||||
public static final int FORGE_VERSION_PATCH = 0;
|
||||
|
||||
private static final String REMOTE_VERSION_FILE = "http://www.mod-buildcraft.com/releases/versions.txt";
|
||||
private static final String REMOTE_CHANGELOG_ROOT = "https://dl.dropboxusercontent.com/u/38558957/Minecraft/Buildcraft/changelogs/";
|
||||
private static final String REMOTE_VERSION_FILE =
|
||||
"https://raw.githubusercontent.com/BuildCraft/BuildCraft/master/buildcraft_resources/versions.txt";
|
||||
|
||||
private static final String REMOTE_CHANGELOG_ROOT =
|
||||
"https://raw.githubusercontent.com/BuildCraft/BuildCraft/master/buildcraft_resources/changelog/";
|
||||
|
||||
private static String recommendedVersion;
|
||||
private static String[] cachedChangelog;
|
||||
|
||||
private static Version instance = new Version();
|
||||
|
||||
public static String getVersion() {
|
||||
return VERSION + " (:" + BUILD_NUMBER + ")";
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
public static boolean isOutdated() {
|
||||
|
@ -104,8 +110,9 @@ public class Version implements Runnable {
|
|||
String[] tokens = line.split(":");
|
||||
if (mcVersion.matches(tokens[0])) {
|
||||
if (DefaultProps.MOD.matches(tokens[1])) {
|
||||
recommendedVersion = tokens[2];
|
||||
|
||||
if (VERSION.matches(tokens[2])) {
|
||||
recommendedVersion = tokens[2];
|
||||
BCLog.logger.finer("Using the latest version [" + getVersion() + "] for Minecraft " + mcVersion);
|
||||
currentVersion = EnumUpdateState.CURRENT;
|
||||
return;
|
||||
|
@ -114,8 +121,8 @@ public class Version implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
BCLog.logger.warning("Using outdated version [" + VERSION + " (build:" + BUILD_NUMBER + ")] for Minecraft " + mcVersion
|
||||
+ ". Consider updating.");
|
||||
BCLog.logger.warning("Using outdated version [" + VERSION + "] for Minecraft " + mcVersion
|
||||
+ ". Consider updating to " + recommendedVersion + ".");
|
||||
currentVersion = EnumUpdateState.OUTDATED;
|
||||
|
||||
conn.disconnect();
|
||||
|
@ -138,8 +145,7 @@ public class Version implements Runnable {
|
|||
public static String[] grabChangelog(String version) {
|
||||
|
||||
try {
|
||||
|
||||
String location = REMOTE_CHANGELOG_ROOT + version;
|
||||
String location = REMOTE_CHANGELOG_ROOT + "/" + version;
|
||||
HttpURLConnection conn = null;
|
||||
while (location != null && !location.isEmpty()) {
|
||||
URL url = new URL(location);
|
||||
|
@ -160,14 +166,10 @@ public class Version implements Runnable {
|
|||
}
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
conn.disconnect();
|
||||
|
||||
String line;
|
||||
ArrayList<String> changelog = new ArrayList<String>();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
if (line.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -175,6 +177,8 @@ public class Version implements Runnable {
|
|||
changelog.add(line);
|
||||
}
|
||||
|
||||
conn.disconnect();
|
||||
|
||||
return changelog.toArray(new String[0]);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
@ -213,8 +217,21 @@ public class Version implements Runnable {
|
|||
|
||||
}
|
||||
|
||||
public static void check() {
|
||||
public static void displayChangelog(ICommandSender sender) {
|
||||
int nb = 0;
|
||||
for (String updateLine : Version.getChangelog()) {
|
||||
sender.addChatMessage(new ChatComponentText("\u00A79" + updateLine));
|
||||
|
||||
nb++;
|
||||
|
||||
if (nb > 3) {
|
||||
sender.addChatMessage(new ChatComponentText("\u00A79[...]"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void check() {
|
||||
new Thread(instance).start();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue