Advertisement
Olivki

totally legit

Mar 29th, 2013
658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.10 KB | None | 0 0
  1. package se.proxus;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.File;
  5. import java.io.InputStreamReader;
  6. import java.net.URL;
  7. import java.text.DateFormat;
  8. import java.text.SimpleDateFormat;
  9. import java.util.Calendar;
  10. import java.util.logging.Level;
  11. import java.util.logging.Logger;
  12.  
  13. import net.minecraft.client.Minecraft;
  14. import net.minecraft.src.Packet;
  15. import net.minecraft.src.ScaledResolution;
  16. import net.minecraft.src.Session;
  17. import se.proxus.betterfonts.StringCache;
  18. import se.proxus.commands.CommandManager;
  19. import se.proxus.events.EventManager;
  20. import se.proxus.hooks.Player;
  21. import se.proxus.hooks.PlayerImpl;
  22. import se.proxus.mods.ModHandler;
  23. import se.proxus.tools.FileUtils;
  24. import se.proxus.tools.FontFactory;
  25. import se.proxus.tools.Location;
  26.  
  27. public class Gallium {
  28.  
  29.     private File directory;
  30.     private PlayerImpl player;
  31.     private final EventManager events = new EventManager(this);
  32.     private final ModHandler mods = new ModHandler(this);
  33.     private final FileUtils fileUtils = new FileUtils();
  34.     private final CommandManager commands = new CommandManager(this);
  35.     private final FontFactory fontFactory = new FontFactory(this);
  36.     private StringCache font;
  37.     private StringCache fontPanel;
  38.     private StringCache fontChat;
  39.  
  40.     /**
  41.      * @author Oliver
  42.      * @param type
  43.      *            Where the method gets ran from. <i>(Example; 0 (First
  44.      *            Minecraft startup.), 1 (Each time the Main menu gets
  45.      *            opened.))</i>
  46.      */
  47.     public void init(final int type) {
  48.     try {
  49.         switch (type) {
  50.         case 0:
  51.         getLogger().log(Level.INFO, toString() + " " + getDate());
  52.         player = new PlayerImpl(this);
  53.         directory = new File(getMinecraft().getMinecraftDir(),
  54.             getName().toLowerCase());
  55.         getDirectory().mkdirs();
  56.         getMods().init();
  57.         getCommands().init();
  58.         break;
  59.         case 1:
  60.         if (getFont() == null) {
  61.             setFont(new StringCache(
  62.                 getMinecraft().fontRenderer.getColorCode()));
  63.             getFont().setDefaultFont("Lucida Console", 18, true);
  64.         }
  65.         if (getFontPanel() == null) {
  66.             setFontPanel(new StringCache(
  67.                 getMinecraft().fontRenderer.getColorCode()));
  68.             getFontPanel().setDefaultFont("Verdana", 18, true);
  69.         }
  70.         if (getFontChat() == null) {
  71.             setFontChat(new StringCache(
  72.                 getMinecraft().fontRenderer.getColorCode()));
  73.             getFontChat().setDefaultFont("Verdana Bold", 17, true);
  74.         }
  75.         break;
  76.         }
  77.     } catch (Exception exception) {
  78.         exception.printStackTrace();
  79.     }
  80.     }
  81.  
  82.     /**
  83.      * @return The clients name. <i>(Example: "Gallium")</i>
  84.      */
  85.     public String getName() {
  86.     return "Gallium";
  87.     }
  88.  
  89.     /**
  90.      * @return The clients current version. <i>(Example: 1.53D)</i>
  91.      */
  92.     public double getVersion() {
  93.     return 1.0D;
  94.     }
  95.  
  96.     /**
  97.      * @author Oliver
  98.      * @return Minecrafts current version
  99.      */
  100.     public String getMinecraftVersion() {
  101.     return "1.5.1";
  102.     }
  103.  
  104.     /**
  105.      * @return The clients Logger. <i>(Example: Logger.getLogger("Gallium"))</i>
  106.      */
  107.     public Logger getLogger() {
  108.     return Logger.getLogger(toString());
  109.     }
  110.  
  111.     /**
  112.      * @author Oliver
  113.      * @return Returns the clients current file. <i>(Example:
  114.      *         Client.getMinecraft().getMinecraftDir() + "/gallium/")</i>
  115.      */
  116.     public File getDirectory() {
  117.     return directory;
  118.     }
  119.  
  120.     /**
  121.      * @return Returns the hooked player class.
  122.      */
  123.     public Player getPlayer() {
  124.     return player;
  125.     }
  126.  
  127.     /**
  128.      * @return Returns a instance of Minecraft.java
  129.      */
  130.     public Minecraft getMinecraft() {
  131.     return Minecraft.getMinecraft();
  132.     }
  133.  
  134.     /**
  135.      * @return Returns the clients mod handler.
  136.      */
  137.     public ModHandler getMods() {
  138.     return mods;
  139.     }
  140.  
  141.     /**
  142.      * @author Ramisme
  143.      * @return Returns the clients event manager.
  144.      */
  145.     public EventManager getEvents() {
  146.     return events;
  147.     }
  148.  
  149.     /**
  150.      * @return Returns the clients file utils.
  151.      */
  152.     public FileUtils getFileUtils() {
  153.     return fileUtils;
  154.     }
  155.  
  156.     /**
  157.      * @author Oliver
  158.      * @return Returns the clients command manager.
  159.      */
  160.     public CommandManager getCommands() {
  161.     return commands;
  162.     }
  163.  
  164.     /**
  165.      * @return Returns the clients font factory.
  166.      */
  167.     public FontFactory getFontFactory() {
  168.     return fontFactory;
  169.     }
  170.  
  171.     public ScaledResolution getResolution() {
  172.     return new ScaledResolution(getMinecraft().gameSettings,
  173.         getMinecraft().displayWidth, getMinecraft().displayHeight);
  174.     }
  175.  
  176.     /**
  177.      * @param packet
  178.      *            The Packet to be sent to the server.
  179.      */
  180.     public void sendPacket(final Packet packet) {
  181.     getMinecraft().thePlayer.sendQueue.addToSendQueue(packet);
  182.     }
  183.  
  184.     /**
  185.      * A method for getting the distance between 2 locations.
  186.      *
  187.      * @param location1
  188.      *            Location one.
  189.      * @param location2
  190.      *            Location two.
  191.      * @return The distance between to locations in doubles.
  192.      */
  193.     public double distanceTo(final Location location1, final Location location2) {
  194.     return location1.distanceTo(location2.getX(), location2.getY(),
  195.         location2.getZ());
  196.     }
  197.  
  198.     /**
  199.      * Attempts to log you into the specified account.
  200.      *
  201.      * @author JordinJM
  202.      * @param username
  203.      *            The Minecraft username/email.
  204.      * @param password
  205.      *            The password.
  206.      * @return If the login was successful or not.
  207.      */
  208.     public boolean loginToAccount(final String username, final String password) {
  209.     try {
  210.         URL url = new URL(
  211.             String.format(
  212.                 "http://login.minecraft.net/?user=%s&password=%s&version=69",
  213.                 username, password));
  214.         BufferedReader in = new BufferedReader(new InputStreamReader(url
  215.             .openConnection().getInputStream()));
  216.         String as[] = in.readLine().split(":");
  217.         getMinecraft().session = new Session(as[2], as[3]);
  218.         return true;
  219.     } catch (Exception e) {
  220.         return false;
  221.     }
  222.     }
  223.  
  224.     /**
  225.      * The default font for the Client. <i>(Might be used in global TTF later
  226.      * on.)</i>
  227.      *
  228.      * @return The clients default font.
  229.      */
  230.     public StringCache getFont() {
  231.     return font;
  232.     }
  233.  
  234.     /**
  235.      * Sets the clients default font.
  236.      *
  237.      * @param font
  238.      *            The font to be set.
  239.      */
  240.     public void setFont(final StringCache font) {
  241.     this.font = font;
  242.     }
  243.  
  244.     /**
  245.      * The font for the 'panels' in the client.
  246.      *
  247.      * @return The font for the 'panels' in the client.
  248.      */
  249.     public StringCache getFontPanel() {
  250.     return fontPanel;
  251.     }
  252.  
  253.     /**
  254.      * Sets the clients panel font.
  255.      *
  256.      * @param font
  257.      *            The font to be set.
  258.      */
  259.     public void setFontPanel(final StringCache fontPanel) {
  260.     this.fontPanel = fontPanel;
  261.     }
  262.  
  263.     /**
  264.      * The font for the chat in the client.
  265.      *
  266.      * @return The font for the chat in the client.
  267.      */
  268.     public StringCache getFontChat() {
  269.     return fontChat;
  270.     }
  271.  
  272.     /**
  273.      * Sets the clients chat font.
  274.      *
  275.      * @param font
  276.      *            The font to be set.
  277.      */
  278.     public void setFontChat(final StringCache fontChat) {
  279.     this.fontChat = fontChat;
  280.     }
  281.  
  282.     /**
  283.      * A method for getting the computers current date, without a default
  284.      * format.
  285.      *
  286.      * @param format
  287.      *            The format for the SimpleDateFormat. <i>(Example:
  288.      *            yyyy/mm/dd/hh:mm)</i>
  289.      * @see Gallium#getDate()
  290.      * @return Returns computers current date.
  291.      */
  292.     public String getDate(final String format) {
  293.     DateFormat date = new SimpleDateFormat(format);
  294.     Calendar calendar = Calendar.getInstance();
  295.     return date.format(calendar.getTime());
  296.     }
  297.  
  298.     /**
  299.      * A method for getting the computers current date, with a default format.
  300.      *
  301.      * @see Gallium#getDate(String)
  302.      * @return Returns computers current date.
  303.      */
  304.     public String getDate() {
  305.     return getDate("yyyy/mm/dd/hh:mm");
  306.     }
  307.  
  308.     @Override
  309.     public String toString() {
  310.     return getName() + " " + getVersion() + " (" + getMinecraftVersion()
  311.         + ")";
  312.     }
  313. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement