Guest User

VersionCheck.java

a guest
Oct 8th, 2015
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.79 KB | None | 0 0
  1. package com.chef.mod;
  2.  
  3. import net.minecraft.entity.player.EntityPlayer;
  4. import net.minecraft.event.ClickEvent;
  5. import net.minecraft.event.ClickEvent.Action;
  6. import net.minecraft.util.ChatComponentText;
  7. import net.minecraft.util.ChatStyle;
  8. import net.minecraft.util.EnumChatFormatting;
  9. import net.minecraft.util.IChatComponent;
  10.  
  11. public class VersionCheck {
  12.  
  13.     static String newVersion = "6.0";
  14.  
  15.     public static void checkVersion(EntityPlayer player) {
  16.  
  17.         String[] newVersionStringArray = newVersion.split("\\.");
  18.         String[] usingVersionStringArray = Reference.VERSION.split("\\.");
  19.  
  20.         int[] newVersionArray = new int[3];
  21.         int[] usingVersionArray = new int[3];
  22.  
  23.         for (int i = 0; i < newVersionStringArray.length; i++) {
  24.  
  25.             int a = Integer.parseInt(newVersionStringArray[i]);
  26.  
  27.             newVersionArray[i] = a;
  28.  
  29.         }
  30.  
  31.         for (int i = 0; i < usingVersionStringArray.length; i++) {
  32.  
  33.             int a = Integer.parseInt(usingVersionStringArray[i]);
  34.  
  35.             usingVersionArray[i] = a;
  36.  
  37.         }
  38.  
  39.         if (newVersionArray[0] > usingVersionArray[0] || newVersionArray[1] > usingVersionArray[1] || newVersionArray[2] > usingVersionArray[2]) {
  40.  
  41.             ClickEvent openUrl = new ClickEvent(Action.OPEN_URL, "http://minetronic.com/masterchef_downloads.php");
  42.            
  43.             player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "New version available! (V" + newVersion + ")."));
  44.             player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Please update the master chef mod."));
  45.             player.addChatMessage((IChatComponent) new ChatComponentText(EnumChatFormatting.YELLOW + "http://minetronic.com/masterchef_downloads.php").getChatStyle().setChatClickEvent(openUrl));
  46.            
  47.         }
  48.  
  49.         Debugger.log("De huidige versie is: " + Reference.VERSION);
  50.         Debugger.log("De nieuwe versie is: " + newVersion);
  51.  
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment