Added update notice. Will only display once per update and not annoy the player on each startup.
This commit is contained in:
parent
9fbdd4040b
commit
c1089e5e8a
7 changed files with 155 additions and 17 deletions
|
@ -128,9 +128,14 @@
|
|||
<target name="package" depends="compile">
|
||||
|
||||
<jar destfile="${jar.dir}/buildcraft-A-${bc.version.full}.jar" basedir="${classes.dir}/client"/>
|
||||
|
||||
<copy todir="${jar.dir}/changelog">
|
||||
<fileset dir="${src.dir}/buildcraft_resources/changelog">
|
||||
<include name="*" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="main" depends="clean,package"/>
|
||||
<target name="main" depends="clean,package" />
|
||||
|
||||
</project>
|
||||
|
|
12
buildcraft_resources/changelog/3.2.1
Normal file
12
buildcraft_resources/changelog/3.2.1
Normal file
|
@ -0,0 +1,12 @@
|
|||
|
||||
#3.2.1
|
||||
|
||||
- API: Inventory triggers can now be ISided.
|
||||
- Changed: Improvements to reduce bandwith used for pipe updates and size of liquid pipe updates.
|
||||
- Changed: Localization definitions can now inherit from other definition files. (psxlover's PR.)
|
||||
- Bugfix: Fixed tooltips updating only on click in gate interface.
|
||||
- Bugfix: Fixed laser placement. (psxlover's PR.)
|
||||
- Bugfix: Combustion engine, refinery and pump should be able to handle metadata based liquids now. (gishicrafter's PR.)
|
||||
- Bugfix: Fixed incorrect handling of power providers on quarries. (tcooc's PR.)
|
||||
- Bugfix: Trees growing should not destroy pipes anymore. (tcooc's PR.)
|
||||
- Bugfix: Now using Forge autoassign for block and item ids. (AtomicStryker's PR.)
|
|
@ -1,6 +1,6 @@
|
|||
CHANGELOG
|
||||
|
||||
3.2.2
|
||||
#3.2.2
|
||||
|
||||
- Changed: Refactored quarry algorithm for efficiency to reduce CPU usage. (cpw)
|
||||
- Changed: Several improvements to the bandwith usage especially on liquid pipes. (CovertJaguar)
|
||||
- Changed: Pipes are slightly harder to break. Not quite as hard as in the 1.8.1 version though. (Nevercast)
|
||||
|
@ -12,15 +12,4 @@ CHANGELOG
|
|||
- Bugfix: Fixed a potential NPE when a mod liquid was removed but some of it still remained in pipes. (CovertJaguar)
|
||||
- Bugfix: Action state should be displayed correctly in gate gui. (Nevercast)
|
||||
- Bugfix: Fixed potential crash when addon liquid pipes do not conform to volume limits of BC pipes. (denoflions)
|
||||
- Bugfix: Resolved an issue with facade IMCs. (CovertJaguar)
|
||||
|
||||
3.2.1
|
||||
- API: Inventory triggers can now be ISided.
|
||||
- Changed: Improvements to reduce bandwith used for pipe updates and size of liquid pipe updates.
|
||||
- Changed: Localization definitions can now inherit from other definition files. (psxlover's PR.)
|
||||
- Bugfix: Fixed tooltips updating only on click in gate interface.
|
||||
- Bugfix: Fixed laser placement. (psxlover's PR.)
|
||||
- Bugfix: Combustion engine, refinery and pump should be able to handle metadata based liquids now. (gishicrafter's PR.)
|
||||
- Bugfix: Fixed incorrect handling of power providers on quarries. (tcooc's PR.)
|
||||
- Bugfix: Trees growing should not destroy pipes anymore. (tcooc's PR.)
|
||||
- Bugfix: Now using Forge autoassign for block and item ids. (AtomicStryker's PR.)
|
||||
- Bugfix: Resolved an issue with facade IMCs. (CovertJaguar)
|
|
@ -14,6 +14,7 @@ import java.util.logging.Logger;
|
|||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Side;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.PreInit;
|
||||
|
@ -26,6 +27,7 @@ import cpw.mods.fml.common.network.NetworkMod;
|
|||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import buildcraft.api.gates.Action;
|
||||
|
@ -42,6 +44,7 @@ import buildcraft.core.EntityRobot;
|
|||
import buildcraft.core.ItemBuildCraft;
|
||||
import buildcraft.core.ItemWrench;
|
||||
import buildcraft.core.RedstonePowerFramework;
|
||||
import buildcraft.core.TickHandlerCoreClient;
|
||||
import buildcraft.core.Version;
|
||||
import buildcraft.core.blueprints.BptItem;
|
||||
import buildcraft.core.network.EntityIds;
|
||||
|
@ -270,6 +273,8 @@ public class BuildCraftCore {
|
|||
}
|
||||
|
||||
BuildCraftAPI.softBlocks[Block.snow.blockID] = true;
|
||||
TickRegistry.registerTickHandler(new TickHandlerCoreClient(), Side.CLIENT);
|
||||
|
||||
}
|
||||
|
||||
@ServerStarting
|
||||
|
|
|
@ -48,7 +48,12 @@ public class CommandBuildCraft extends CommandBase {
|
|||
}
|
||||
|
||||
private void commandVersion(ICommandSender sender, String[] arguments) {
|
||||
sender.sendChatToPlayer(String.format("BuildCraft %s for Minecraft %s (Latest: %s).", Version.getVersion(), CoreProxy.proxy.getMinecraftVersion(), Version.getRecommendedVersion()));
|
||||
String colour = Version.isOutdated() ? "\u00A7c" : "\u00A7a";
|
||||
|
||||
sender.sendChatToPlayer(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.sendChatToPlayer("\u00A79" + updateLine);
|
||||
}
|
||||
|
||||
|
||||
|
|
52
common/buildcraft/core/TickHandlerCoreClient.java
Normal file
52
common/buildcraft/core/TickHandlerCoreClient.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package buildcraft.core;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
public class TickHandlerCoreClient implements ITickHandler {
|
||||
|
||||
private boolean nagged;
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
|
||||
if(nagged)
|
||||
return;
|
||||
|
||||
EntityPlayer player = (EntityPlayer)tickData[0];
|
||||
|
||||
//if(!Config.disableVersionCheck) {
|
||||
|
||||
if(Version.needsUpdateNoticeAndMarkAsSeen()) {
|
||||
player.sendChatToPlayer(String.format("\u00A7cNew version of BuildCraft available: %s for Minecraft %s", Version.getRecommendedVersion(), CoreProxy.proxy.getMinecraftVersion()));
|
||||
for(String updateLine : Version.getChangelog())
|
||||
player.sendChatToPlayer("\u00A79" + updateLine);
|
||||
player.sendChatToPlayer("\u00A7cThis message only displays once. Type '/buildcraft version' if you want to see it again.");
|
||||
}
|
||||
|
||||
//}
|
||||
|
||||
nagged = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks() {
|
||||
return EnumSet.of(TickType.PLAYER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "BuildCraft - Player update tick";
|
||||
}
|
||||
|
||||
}
|
|
@ -4,7 +4,11 @@ import java.io.BufferedReader;
|
|||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraftforge.common.Property;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
@ -16,6 +20,7 @@ public class Version {
|
|||
public static final String VERSION = "@VERSION@";
|
||||
public static final String BUILD_NUMBER = "@BUILD_NUMBER@";
|
||||
private static final String REMOTE_VERSION_FILE = "http://bit.ly/buildcraftver";
|
||||
private static final String REMOTE_CHANGELOG_ROOT = "https://dl.dropbox.com/u/44760587/buildcraft/changelog/";
|
||||
|
||||
public static EnumUpdateState currentVersion = EnumUpdateState.CURRENT;
|
||||
|
||||
|
@ -24,11 +29,32 @@ public class Version {
|
|||
public static final int FORGE_VERSION_PATCH = 0;
|
||||
|
||||
private static String recommendedVersion;
|
||||
private static String[] cachedChangelog;
|
||||
|
||||
public static String getVersion() {
|
||||
return VERSION + " (:"+ BUILD_NUMBER +")";
|
||||
}
|
||||
|
||||
public static boolean isOutdated() {
|
||||
return currentVersion == EnumUpdateState.OUTDATED;
|
||||
}
|
||||
|
||||
public static boolean needsUpdateNoticeAndMarkAsSeen() {
|
||||
if(!isOutdated())
|
||||
return false;
|
||||
|
||||
Property property = BuildCraftCore.mainConfiguration.get("vars", "version.seen", VERSION);
|
||||
property.comment = "indicates the last version the user has been informed about and will suppress further notices on it.";
|
||||
String seenVersion = property.value;
|
||||
|
||||
if(recommendedVersion.equals(seenVersion))
|
||||
return false;
|
||||
|
||||
property.value = recommendedVersion;
|
||||
BuildCraftCore.mainConfiguration.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getRecommendedVersion() {
|
||||
return recommendedVersion;
|
||||
}
|
||||
|
@ -76,4 +102,48 @@ public class Version {
|
|||
}
|
||||
}
|
||||
|
||||
public static String[] getChangelog() {
|
||||
if(cachedChangelog == null)
|
||||
cachedChangelog = grabChangelog(recommendedVersion);
|
||||
|
||||
return cachedChangelog;
|
||||
}
|
||||
|
||||
public static String[] grabChangelog(String version) {
|
||||
|
||||
try {
|
||||
|
||||
String location = REMOTE_CHANGELOG_ROOT + version;
|
||||
HttpURLConnection conn = null;
|
||||
while(location != null && !location.isEmpty()) {
|
||||
URL url = new URL(location);
|
||||
conn = (HttpURLConnection)url.openConnection();
|
||||
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)");
|
||||
conn.connect();
|
||||
location = conn.getHeaderField("Location");
|
||||
}
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
|
||||
String line = null;
|
||||
ArrayList<String> changelog = new ArrayList<String>();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if(line.startsWith("#"))
|
||||
continue;
|
||||
if(line.isEmpty())
|
||||
continue;
|
||||
|
||||
changelog.add(line);
|
||||
}
|
||||
|
||||
return changelog.toArray(new String[0]);
|
||||
|
||||
} catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
FMLLog.warning(DefaultProps.MOD + ": Unable to read changelog from remote site.");
|
||||
}
|
||||
|
||||
return new String[] { String.format("Unable to retrieve changelog for %s %s", DefaultProps.MOD, version) };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue