mrkirby153

VersionCheckTickHandler

Apr 14th, 2013
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.13 KB | None | 0 0
  1. package mrkirby153.MscHouses.core.handlers;
  2.  
  3. import java.util.EnumSet;
  4.  
  5. import mrkirby153.MscHouses.configuration.ConfigurationHandler;
  6. import mrkirby153.MscHouses.configuration.ConfigurationSettings;
  7. import mrkirby153.MscHouses.core.helpers.VersionHelper;
  8. import mrkirby153.MscHouses.core.lang.Strings;
  9. import mrkirby153.MscHouses.lib.Reference;
  10. import net.minecraftforge.common.Configuration;
  11. import cpw.mods.fml.client.FMLClientHandler;
  12. import cpw.mods.fml.common.ITickHandler;
  13. import cpw.mods.fml.common.TickType;
  14.  
  15. public class VersionCheckTickHandler implements ITickHandler {
  16.  
  17.     private static boolean initialized = false;
  18.  
  19.     @Override
  20.     public void tickStart(EnumSet<TickType> type, Object... tickData) {
  21.  
  22.     }
  23.  
  24.     @Override
  25.     public void tickEnd(EnumSet<TickType> type, Object... tickData) {
  26.  
  27.         if (ConfigurationSettings.DISPLAY_VERSION_RESULT) {
  28.             if (!initialized) {
  29.                 for (TickType tickType : type) {
  30.                     if (tickType == TickType.CLIENT) {
  31.                         if (FMLClientHandler.instance().getClient().currentScreen == null) {
  32.                             if (VersionHelper.getResult() != VersionHelper.UNINITIALIZED || VersionHelper.getResult() != VersionHelper.FINAL_ERROR) {
  33.  
  34.                                 initialized = true;
  35.  
  36.                                 if (VersionHelper.getResult() == VersionHelper.OUTDATED) {
  37.                                     FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(VersionHelper.getResultMessageForClient());
  38.                                     ConfigurationHandler.set(Configuration.CATEGORY_GENERAL, ConfigurationSettings.DISPLAY_VERSION_RESULT_CONFIGNAME, Strings.FALSE);
  39.                                 }
  40.                             }
  41.                         }
  42.                     }
  43.                 }
  44.             }
  45.         }
  46.     }
  47.  
  48.     @Override
  49.     public EnumSet<TickType> ticks() {
  50.  
  51.         return EnumSet.of(TickType.CLIENT);
  52.     }
  53.  
  54.     @Override
  55.     public String getLabel() {
  56.  
  57.         return Reference.MOD_NAME + ": " + this.getClass().getSimpleName();
  58.     }
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment