mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-12 16:27:34 +00:00
Add back the version checker; pings Github now.
Fix NPE on init.
This commit is contained in:
1 parent
e5e6474ff9
commit
a7076ce817
7 files changed
+108
-122
No files matched your search
@@ -435,9 +435,6 @@ public enum BeeSpecies implements IAlleleBeeSpecies, IIconProvider
|
||||
|
||||
if (BloodMagicHelper.isActive())
|
||||
{
|
||||
BloodMagicHelper.addAltarRecipeBee(MYSTICAL, BM_BLOODY, 1, 1000, 100, 100);
|
||||
|
||||
BloodMagicHelper.addBindingRecipeBee(BM_BLOODY, BM_BOUND);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -364,7 +364,7 @@ public class Config
|
||||
capsuleStackSizeMax = p.getInt();
|
||||
|
||||
p = configuration.get(section, "disableVersionNotification", false);
|
||||
p.comment = "Set to true to stop ThaumicBees from notifying you when new updates are available. (Does not supress critical updates)";
|
||||
p.comment = "Set to true to stop Magic Bees from notifying you when new updates are available. (Does not supress critical updates)";
|
||||
disableUpdateNotification = p.getBoolean(false);
|
||||
|
||||
p = configuration.get(section, "areMagicPlanksFlammable", false);
|
||||
|
||||
@@ -82,8 +82,7 @@ public class MagicBees
|
||||
CraftingManager.setupCrafting();
|
||||
CraftingManager.registerLiquidContainers();
|
||||
|
||||
// Version check file is MIA.
|
||||
//VersionInfo.doVersionCheck();
|
||||
VersionInfo.doVersionCheck();
|
||||
LogHelper.info("Postinit completed");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,59 +1,99 @@
|
||||
/*package magicbees.main.utils;
|
||||
package magicbees.main.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import magicbees.main.MagicBees;
|
||||
import magicbees.main.Config;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import cpw.mods.fml.common.IScheduledTickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import net.minecraft.event.ClickEvent;
|
||||
import net.minecraft.event.HoverEvent;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
||||
|
||||
public class TickHandlerVersion implements IScheduledTickHandler
|
||||
{
|
||||
public class TickHandlerVersion {
|
||||
|
||||
private static int TICK_POLL_INTERVAL = 250;
|
||||
|
||||
public static TickHandlerVersion instance = new TickHandlerVersion();
|
||||
private static class LazyHolder {
|
||||
private static final TickHandlerVersion instance = new TickHandlerVersion();
|
||||
}
|
||||
|
||||
private static ArrayList<VersionInfo> modVersionInfo = new ArrayList();
|
||||
private static boolean initialized;
|
||||
private static boolean sent;
|
||||
private static int modIndex = 0;
|
||||
private int ticksToPoll;
|
||||
private VersionInfo versionInfo;
|
||||
|
||||
public static boolean initialize()
|
||||
{
|
||||
if (initialized)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
initialized = true;
|
||||
return true;
|
||||
private final ChatStyle newVersion = new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(true);
|
||||
private final ChatStyle description = new ChatStyle().setColor(EnumChatFormatting.GRAY);
|
||||
private final ChatStyle alert = new ChatStyle().setColor(EnumChatFormatting.RED);
|
||||
|
||||
private TickHandlerVersion() {
|
||||
ticksToPoll = TICK_POLL_INTERVAL;
|
||||
}
|
||||
|
||||
private void setVersionInfo(VersionInfo vInfo) {
|
||||
versionInfo = vInfo;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void tickStart(PlayerTickEvent evt) {
|
||||
if (evt.phase != Phase.START) {
|
||||
return;
|
||||
}
|
||||
if (ticksToPoll > 0) {
|
||||
ticksToPoll--;
|
||||
return;
|
||||
}
|
||||
ticksToPoll = TICK_POLL_INTERVAL;
|
||||
|
||||
if (versionInfo.versionCheckComplete) {
|
||||
unsubscribeFromBus();
|
||||
|
||||
if (updateNotificationsEnabledOrCriticalUpdate()) {
|
||||
sendNotificationToPlayer(evt.player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendNotificationToPlayer(EntityPlayer player) {
|
||||
if (versionInfo.isCriticalUpdate()) {
|
||||
player.addChatMessage(new ChatComponentTranslation("magicbees.versioning.critical", versionInfo.getLatestVersion()).setChatStyle(alert));
|
||||
}
|
||||
else {
|
||||
player.addChatMessage(new ChatComponentTranslation("magicbees.versioning.newVersion", versionInfo.getLatestVersion()).setChatStyle(newVersion));
|
||||
}
|
||||
ChatStyle thisDescription = description.createShallowCopy();
|
||||
thisDescription.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, VersionInfo.DownloadURL));
|
||||
thisDescription.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(versionInfo.getVersionDescription())));
|
||||
player.addChatMessage(new ChatComponentTranslation("magicbees.versioning.clickDownload").setChatStyle(thisDescription));
|
||||
}
|
||||
|
||||
private boolean updateNotificationsEnabledOrCriticalUpdate() {
|
||||
return (!Config.disableUpdateNotification || versionInfo.isCriticalUpdate()) && versionInfo.isNewVersionAvailable();
|
||||
}
|
||||
|
||||
private void subscribeToBus() {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
|
||||
private void unsubscribeFromBus() {
|
||||
FMLCommonHandler.instance().bus().unregister(this);
|
||||
}
|
||||
|
||||
public static boolean isInitialized()
|
||||
{
|
||||
return initialized;
|
||||
}
|
||||
|
||||
public static boolean registerModVersionInfo(VersionInfo info)
|
||||
{
|
||||
if (modVersionInfo.contains(info))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
modVersionInfo.add(info);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public static void go(VersionInfo vInfo) {
|
||||
LazyHolder.instance.setVersionInfo(vInfo);
|
||||
LazyHolder.instance.subscribeToBus();
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
if (sent)
|
||||
{
|
||||
if (sent) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (modIndex < modVersionInfo.size())
|
||||
{
|
||||
if (modIndex < modVersionInfo.size()) {
|
||||
VersionInfo anInfo = modVersionInfo.get(modIndex);
|
||||
|
||||
if ((!Config.DisableUpdateNotification || anInfo.isCriticalUpdate()) && anInfo.isNewVersionAvailable())
|
||||
@@ -64,41 +104,9 @@ public class TickHandlerVersion implements IScheduledTickHandler
|
||||
}
|
||||
modIndex += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
sent = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
if (TickHandlerVersion.sent)
|
||||
{
|
||||
return EnumSet.noneOf(TickType.class);
|
||||
}
|
||||
return EnumSet.of(TickType.PLAYER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel()
|
||||
{
|
||||
return "thaumicbees.version";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextTickSpacing()
|
||||
{
|
||||
if (!sent)
|
||||
{
|
||||
return 200;
|
||||
}
|
||||
return 72000;
|
||||
}
|
||||
}*/
|
||||
*/
|
||||
}
|
||||
@@ -19,7 +19,8 @@ public class VersionInfo
|
||||
public static final String ModName = "MagicBees";
|
||||
public static final String Version = "@VERSION@";
|
||||
public static final String MCVersion = "@MCVERSION@";
|
||||
public static final String VersionURL = "http://bit.ly/magicbeesVersionInfo";
|
||||
public static final String VersionURL = "https://raw.githubusercontent.com/MagicBees/MagicBees/master/etc/version-1.7.txt";
|
||||
public static final String DownloadURL = "http://minecraft.curseforge.com/mc-mods/65764-magic-bees/files";
|
||||
public static final String GUI_FACTORY_CLASS = "magicbees.client.gui.GuiFactory";
|
||||
|
||||
public static final String Logo = "/gfx/magicbees/logo.png";
|
||||
@@ -28,11 +29,9 @@ public class VersionInfo
|
||||
|
||||
boolean criticalUpdate;
|
||||
boolean newVersion;
|
||||
boolean newMinecraftVersion;
|
||||
boolean versionCheckComplete;
|
||||
|
||||
String latestModVersion;
|
||||
String latestMCVersion = MCVersion;
|
||||
String description = "";
|
||||
|
||||
String modName;
|
||||
@@ -68,7 +67,6 @@ public class VersionInfo
|
||||
return value;
|
||||
}
|
||||
|
||||
/* VERSION COMPARISON */
|
||||
public static boolean beforeTargetVersion(String version, String target)
|
||||
{
|
||||
boolean result = false;
|
||||
@@ -129,7 +127,6 @@ public class VersionInfo
|
||||
modName = name;
|
||||
modVersion = latestModVersion = version;
|
||||
releaseURL = url;
|
||||
//modLogger = logger;
|
||||
}
|
||||
|
||||
public void checkForNewVersion()
|
||||
@@ -148,11 +145,6 @@ public class VersionInfo
|
||||
return latestModVersion;
|
||||
}
|
||||
|
||||
public String getLatestMCVersion()
|
||||
{
|
||||
return latestMCVersion;
|
||||
}
|
||||
|
||||
public String getVersionDescription()
|
||||
{
|
||||
return description;
|
||||
@@ -168,17 +160,11 @@ public class VersionInfo
|
||||
return newVersion;
|
||||
}
|
||||
|
||||
public boolean isMinecraftOutdated()
|
||||
{
|
||||
return newMinecraftVersion;
|
||||
}
|
||||
|
||||
public boolean isVersionCheckComplete()
|
||||
{
|
||||
return versionCheckComplete;
|
||||
}
|
||||
|
||||
/* VERSION CHECK THREAD CLASS */
|
||||
private class VersionCheckThread extends Thread
|
||||
{
|
||||
@Override
|
||||
@@ -204,36 +190,25 @@ public class VersionInfo
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
latestModVersion = reader.readLine();
|
||||
criticalUpdate = Boolean.parseBoolean(reader.readLine());
|
||||
latestMCVersion = reader.readLine();
|
||||
description = reader.readLine();
|
||||
while (reader.ready()) {
|
||||
description = description + reader.readLine();
|
||||
}
|
||||
reader.close();
|
||||
|
||||
if (beforeTargetVersion(modVersion, latestModVersion))
|
||||
{
|
||||
FMLLog.info("An updated version of " + modName + " is available: " + latestModVersion + ".");
|
||||
//modLogger.log(Level.INFO, "An updated version of " + modName + " is available: " +
|
||||
// latestModVersion + ".");
|
||||
FMLLog.info("An updated version of " + modName + " is available: " + latestModVersion + ". You are currently using " + Version);
|
||||
newVersion = true;
|
||||
if (criticalUpdate)
|
||||
{
|
||||
FMLLog.info("This update has been marked as CRITICAL and will ignore notification suppression" +
|
||||
".");
|
||||
//modLogger.log(Level.INFO, "This update has been marked as CRITICAL and will ignore " +
|
||||
// "notification suppression.");
|
||||
}
|
||||
if (beforeTargetVersion(MCVersion, latestMCVersion))
|
||||
{
|
||||
newMinecraftVersion = true;
|
||||
//modLogger.log(Level.INFO, "This update is for Minecraft " + latestMCVersion + ".");
|
||||
FMLLog.info("This update is for Minecraft " + latestMCVersion + ".");
|
||||
LogHelper.info("This update has been marked as CRITICAL and will ignore notification suppression.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//modLogger.log(Level.WARNING, "Version Check Failed: " + e.getMessage());
|
||||
FMLLog.warning("Version check Failed: " + e.getMessage());
|
||||
LogHelper.warn("Version check Failed: " + e.getMessage());
|
||||
}
|
||||
versionCheckComplete = true;
|
||||
}
|
||||
@@ -241,12 +216,10 @@ public class VersionInfo
|
||||
|
||||
public static void doVersionCheck()
|
||||
{
|
||||
VersionInfo main = new VersionInfo(ModName, Version, VersionURL);
|
||||
/*TickHandlerVersion.registerModVersionInfo(main);
|
||||
TickHandlerVersion.initialize();*/
|
||||
//TickRegistry.registerScheduledTickHandler(TickHandlerVersion.instance, Side.CLIENT);
|
||||
VersionInfo versionInfo = new VersionInfo(ModName, Version, VersionURL);
|
||||
TickHandlerVersion.go(versionInfo);
|
||||
|
||||
VersionCheckThread thread = main.new VersionCheckThread();
|
||||
VersionCheckThread thread = versionInfo.new VersionCheckThread();
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,9 @@ public class BloodMagicHelper
|
||||
|
||||
public static void postInit()
|
||||
{
|
||||
BloodMagicHelper.addAltarRecipeBee(BeeSpecies.MYSTICAL, BeeSpecies.BM_BLOODY, 1, 1000, 100, 100);
|
||||
|
||||
BloodMagicHelper.addBindingRecipeBee(BeeSpecies.BM_BLOODY, BeeSpecies.BM_BOUND);
|
||||
}
|
||||
|
||||
public static void getBlocks()
|
||||
|
||||
Reference in new issue
Block a user