diff options
Diffstat (limited to 'libraries')
30 files changed, 150 insertions, 1069 deletions
diff --git a/libraries/classparser/CMakeLists.txt b/libraries/classparser/CMakeLists.txt index a6c3fa14..db266f53 100644 --- a/libraries/classparser/CMakeLists.txt +++ b/libraries/classparser/CMakeLists.txt @@ -18,7 +18,7 @@ include_directories(${Qt5Base_INCLUDE_DIRS}) set(CLASSPARSER_HEADERS # Public headers include/classparser_config.h -include/javautils.h +include/classparser.h # Private headers src/annotations.h @@ -30,12 +30,13 @@ src/membuffer.h ) set(CLASSPARSER_SOURCES -src/javautils.cpp +src/classparser.cpp src/annotations.cpp ) add_definitions(-DCLASSPARSER_LIBRARY) -add_library(classparser SHARED ${CLASSPARSER_SOURCES} ${CLASSPARSER_HEADERS}) -target_include_directories(classparser PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") -qt5_use_modules(classparser Core) +add_library(MultiMC_classparser STATIC ${CLASSPARSER_SOURCES} ${CLASSPARSER_HEADERS}) +target_include_directories(MultiMC_classparser PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") +target_link_libraries(MultiMC_classparser MultiMC_quazip) +qt5_use_modules(MultiMC_classparser Core) diff --git a/libraries/classparser/include/javautils.h b/libraries/classparser/include/classparser.h index aad7b504..23a65589 100644 --- a/libraries/classparser/include/javautils.h +++ b/libraries/classparser/include/classparser.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Authors: Orochimarufan <orochimarufan.x3@gmail.com> * @@ -18,9 +18,7 @@ #include <QString> #include "classparser_config.h" -#define MCVer_Unknown "Unknown" - -namespace javautils +namespace classparser { /** * @brief Get the version from a minecraft.jar by parsing its class files. Expensive! diff --git a/libraries/classparser/include/classparser_config.h b/libraries/classparser/include/classparser_config.h index cc903210..db8f40a3 100644 --- a/libraries/classparser/include/classparser_config.h +++ b/libraries/classparser/include/classparser_config.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/libraries/classparser/src/annotations.h b/libraries/classparser/src/annotations.h index aa25d241..dd603af3 100644 --- a/libraries/classparser/src/annotations.h +++ b/libraries/classparser/src/annotations.h @@ -42,6 +42,7 @@ protected: public: element_value(element_value_type type, constant_pool &pool) : type(type), pool(pool) {}; + virtual ~element_value() {} element_value_type getElementValueType() { diff --git a/libraries/classparser/src/javautils.cpp b/libraries/classparser/src/classparser.cpp index 719032af..8837781f 100644 --- a/libraries/classparser/src/javautils.cpp +++ b/libraries/classparser/src/classparser.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Authors: Orochimarufan <orochimarufan.x3@gmail.com> * @@ -15,17 +15,18 @@ * limitations under the License. */ #include "classfile.h" -#include "javautils.h" +#include "classparser.h" #include <QFile> #include <quazipfile.h> +#include <QDebug> -namespace javautils +namespace classparser { QString GetMinecraftJarVersion(QString jarName) { - QString version = MCVer_Unknown; + QString version; // check if minecraft.jar exists QFile jar(jarName); @@ -61,6 +62,7 @@ QString GetMinecraftJarVersion(QString jarName) if (constant.type != java::constant::j_string_data) continue; const std::string &str = constant.str_data; + qDebug() << QString::fromStdString(str); if (str.compare(0, 20, "Minecraft Minecraft ") == 0) { version = str.substr(20).data(); diff --git a/libraries/classparser/src/constants.h b/libraries/classparser/src/constants.h index 242b943e..9c74ab20 100644 --- a/libraries/classparser/src/constants.h +++ b/libraries/classparser/src/constants.h @@ -21,14 +21,12 @@ public: j_methodref = 10, j_interface_methodref = 11, j_nameandtype = 12 + // FIXME: missing some constant types, see https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4 } type; constant(util::membuffer &buf) { buf.read(type); - // invalid constant type! - if (type > j_nameandtype || type == (type_t)0 || type == (type_t)2) - throw new classfile_exception(); // load data depending on type switch (type) @@ -65,10 +63,13 @@ public: buf.read_be(name_and_type.name_index); buf.read_be(name_and_type.descriptor_index); break; + default: + // invalid constant type! + throw new classfile_exception(); } } - constant(int fake) + constant(int) { type = j_hole; } @@ -115,6 +116,9 @@ public: ss << "NameAndType: " << name_and_type.name_index << " " << name_and_type.descriptor_index; break; + default: + ss << "Invalid entry (" << int(type) << ")"; + break; } return ss.str(); } @@ -166,10 +170,10 @@ public: */ void load(util::membuffer &buf) { + // FIXME: @SANITY this should check for the end of buffer. uint16_t length = 0; buf.read_be(length); length--; - uint16_t index = 1; const constant *last_constant = nullptr; while (length) { @@ -182,12 +186,10 @@ public: // push in a fake constant to preserve indexing constants.push_back(constant(0)); length -= 2; - index += 2; } else { length--; - index++; } } } diff --git a/libraries/iconfix/CMakeLists.txt b/libraries/iconfix/CMakeLists.txt index 6a99effe..93bfdd06 100644 --- a/libraries/iconfix/CMakeLists.txt +++ b/libraries/iconfix/CMakeLists.txt @@ -19,3 +19,10 @@ qt5_use_modules(MultiMC_iconfix Core Widgets) set_target_properties(MultiMC_iconfix PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN 1) generate_export_header(MultiMC_iconfix) + +# Install it +install( + TARGETS MultiMC_iconfix + RUNTIME DESTINATION ${LIBRARY_DEST_DIR} + LIBRARY DESTINATION ${LIBRARY_DEST_DIR} +)
\ No newline at end of file diff --git a/libraries/javacheck/CMakeLists.txt b/libraries/javacheck/CMakeLists.txt index 9768650e..381efe08 100644 --- a/libraries/javacheck/CMakeLists.txt +++ b/libraries/javacheck/CMakeLists.txt @@ -11,3 +11,4 @@ set(SRC ) add_jar(JavaCheck ${SRC}) +install_jar(JavaCheck "${JARS_DEST_DIR}") diff --git a/libraries/launcher/CMakeLists.txt b/libraries/launcher/CMakeLists.txt index 9c0e128b..a4f52edb 100644 --- a/libraries/launcher/CMakeLists.txt +++ b/libraries/launcher/CMakeLists.txt @@ -7,27 +7,15 @@ set(CMAKE_JAVA_JAR_ENTRY_POINT org.multimc.EntryPoint) set(CMAKE_JAVA_COMPILE_FLAGS -target 1.6 -source 1.6 -Xlint:deprecation -Xlint:unchecked) set(SRC - # OSX things - org/simplericity/macify/eawt/Application.java - org/simplericity/macify/eawt/ApplicationAdapter.java - org/simplericity/macify/eawt/ApplicationEvent.java - org/simplericity/macify/eawt/ApplicationListener.java - org/simplericity/macify/eawt/DefaultApplication.java - - # legacy applet wrapper thing. - # The launcher has to be there for silly FML/Forge relauncher. - net/minecraft/Launcher.java - org/multimc/LegacyFrame.java - - # onesix launcher - org/multimc/onesix/OneSixLauncher.java - - # generic launcher org/multimc/EntryPoint.java org/multimc/Launcher.java + org/multimc/LegacyFrame.java + org/multimc/NotFoundException.java + org/multimc/ParamBucket.java org/multimc/ParseException.java org/multimc/Utils.java - org/multimc/IconLoader.java + org/multimc/onesix/OneSixLauncher.java + net/minecraft/Launcher.java ) add_jar(NewLaunch ${SRC}) - +install_jar(NewLaunch "${JARS_DEST_DIR}") diff --git a/libraries/launcher/net/minecraft/Launcher.java b/libraries/launcher/net/minecraft/Launcher.java index 5aec2654..0c991cf5 100644 --- a/libraries/launcher/net/minecraft/Launcher.java +++ b/libraries/launcher/net/minecraft/Launcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 MultiMC Contributors + * Copyright 2012-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/libraries/launcher/org/multimc/EntryPoint.java b/libraries/launcher/org/multimc/EntryPoint.java index e4d335b7..8c9b8074 100644 --- a/libraries/launcher/org/multimc/EntryPoint.java +++ b/libraries/launcher/org/multimc/EntryPoint.java @@ -1,5 +1,5 @@ package org.multimc;/* - * Copyright 2012-2017 MultiMC Contributors + * Copyright 2012-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,11 +15,7 @@ package org.multimc;/* */ import org.multimc.onesix.OneSixLauncher; -import org.simplericity.macify.eawt.Application; -import org.simplericity.macify.eawt.DefaultApplication; -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; import java.io.*; import java.nio.charset.Charset; @@ -34,21 +30,6 @@ public class EntryPoint public static void main(String[] args) { - // Set the OSX application icon first, if we are on OSX. - Application application = new DefaultApplication(); - if(application.isMac()) - { - try - { - BufferedImage image = ImageIO.read(new File("icon.png")); - application.setApplicationIconImage(image); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - EntryPoint listener = new EntryPoint(); int retCode = listener.listen(); if (retCode != 0) diff --git a/libraries/launcher/org/multimc/IconLoader.java b/libraries/launcher/org/multimc/IconLoader.java deleted file mode 100644 index f1638f3a..00000000 --- a/libraries/launcher/org/multimc/IconLoader.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.multimc; - -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.nio.ByteBuffer; - -/***************************************************************************** - * A convenience class for loading icons from images. - * - * Icons loaded from this class are formatted to fit within the required - * dimension (16x16, 32x32, or 128x128). If the source image is larger than the - * target dimension, it is shrunk down to the minimum size that will fit. If it - * is smaller, then it is only scaled up if the new scale can be a per-pixel - * linear scale (i.e., x2, x3, x4, etc). In both cases, the image's width/height - * ratio is kept the same as the source image. - * - * @author Chris Molini - *****************************************************************************/ -public class IconLoader -{ - /************************************************************************* - * Loads an icon in ByteBuffer form. - * - * @param filepath - * The location of the Image to use as an icon. - * - * @return An array of ByteBuffers containing the pixel data for the icon in - * various sizes (as recommended by the OS). - *************************************************************************/ - public static ByteBuffer[] load(String filepath) - { - BufferedImage image; - try { - image = ImageIO.read ( new File( filepath ) ); - } catch ( IOException e ) { - e.printStackTrace(); - return new ByteBuffer[0]; - } - ByteBuffer[] buffers; - buffers = new ByteBuffer[1]; - buffers[0] = loadInstance(image, 128); - return buffers; - } - - /************************************************************************* - * Copies the supplied image into a square icon at the indicated size. - * - * @param image - * The image to place onto the icon. - * @param dimension - * The desired size of the icon. - * - * @return A ByteBuffer of pixel data at the indicated size. - *************************************************************************/ - private static ByteBuffer loadInstance(BufferedImage image, int dimension) - { - BufferedImage scaledIcon = new BufferedImage(dimension, dimension, - BufferedImage.TYPE_INT_ARGB_PRE); - Graphics2D g = scaledIcon.createGraphics(); - double ratio = getIconRatio(image, scaledIcon); - double width = image.getWidth() * ratio; - double height = image.getHeight() * ratio; - g.drawImage(image, (int) ((scaledIcon.getWidth() - width) / 2), - (int) ((scaledIcon.getHeight() - height) / 2), (int) (width), - (int) (height), null); - g.dispose(); - - return convertToByteBuffer(scaledIcon); - } - - /************************************************************************* - * Gets the width/height ratio of the icon. This is meant to simplify - * scaling the icon to a new dimension. - * - * @param src - * The base image that will be placed onto the icon. - * @param icon - * The icon that will have the image placed on it. - * - * @return The amount to scale the source image to fit it onto the icon - * appropriately. - *************************************************************************/ - private static double getIconRatio(BufferedImage src, BufferedImage icon) - { - double ratio = 1; - if (src.getWidth() > icon.getWidth()) - ratio = (double) (icon.getWidth()) / src.getWidth(); - else - ratio = (int) (icon.getWidth() / src.getWidth()); - if (src.getHeight() > icon.getHeight()) - { - double r2 = (double) (icon.getHeight()) / src.getHeight(); - if (r2 < ratio) - ratio = r2; - } - else - { - double r2 = (int) (icon.getHeight() / src.getHeight()); - if (r2 < ratio) - ratio = r2; - } - return ratio; - } - - /************************************************************************* - * Converts a BufferedImage into a ByteBuffer of pixel data. - * - * @param image - * The image to convert. - * - * @return A ByteBuffer that contains the pixel data of the supplied image. - *************************************************************************/ - public static ByteBuffer convertToByteBuffer(BufferedImage image) - { - byte[] buffer = new byte[image.getWidth() * image.getHeight() * 4]; - int counter = 0; - for (int i = 0; i < image.getHeight(); i++) - for (int j = 0; j < image.getWidth(); j++) - { - int colorSpace = image.getRGB(j, i); - buffer[counter + 0] = (byte) ((colorSpace << 8) >> 24); - buffer[counter + 1] = (byte) ((colorSpace << 16) >> 24); - buffer[counter + 2] = (byte) ((colorSpace << 24) >> 24); - buffer[counter + 3] = (byte) (colorSpace >> 24); - counter += 4; - } - return ByteBuffer.wrap(buffer); - } -}
\ No newline at end of file diff --git a/libraries/launcher/org/multimc/Launcher.java b/libraries/launcher/org/multimc/Launcher.java index fd7af8b8..2e851d18 100644 --- a/libraries/launcher/org/multimc/Launcher.java +++ b/libraries/launcher/org/multimc/Launcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 MultiMC Contributors + * Copyright 2012-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/libraries/launcher/org/multimc/LegacyFrame.java b/libraries/launcher/org/multimc/LegacyFrame.java index 8f7a364c..9842eb0e 100644 --- a/libraries/launcher/org/multimc/LegacyFrame.java +++ b/libraries/launcher/org/multimc/LegacyFrame.java @@ -1,5 +1,5 @@ package org.multimc;/* - * Copyright 2012-2017 MultiMC Contributors + * Copyright 2012-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,12 @@ import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.awt.image.BufferedImage; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; +import java.util.Scanner; public class LegacyFrame extends Frame implements WindowListener { @@ -43,19 +46,64 @@ public class LegacyFrame extends Frame implements WindowListener this.addWindowListener ( this ); } - public void start ( Applet mcApplet, String user, String session, Dimension winSize, boolean maximize ) + public void start ( Applet mcApplet, String user, String session, int winSizeW, int winSizeH, boolean maximize ) { try { appletWrap = new Launcher( mcApplet, new URL ( "http://www.minecraft.net/game" ) ); } catch ( MalformedURLException ignored ) {} + + // Implements support for launching in to multiplayer on classic servers using a mpticket + // file generated by an external program and stored in the instance's root folder. + File mpticketFile = null; + Scanner fileReader = null; + try { + mpticketFile = new File(System.getProperty("user.dir") + "/../mpticket").getCanonicalFile(); + fileReader = new Scanner(new FileInputStream(mpticketFile), "ascii"); + String[] mpticketParams = new String[3]; + + for(int i=0;i<3;i++) { + if(fileReader.hasNextLine()) { + mpticketParams[i] = fileReader.nextLine(); + } else { + throw new IllegalArgumentException(); + } + } + + // Assumes parameters are valid and in the correct order + appletWrap.setParameter("server", mpticketParams[0]); + appletWrap.setParameter("port", mpticketParams[1]); + appletWrap.setParameter("mppass", mpticketParams[2]); + + fileReader.close(); + mpticketFile.delete(); + } + catch (FileNotFoundException e) {} + catch (IllegalArgumentException e) { + + fileReader.close(); + File mpticketFileCorrupt = new File(System.getProperty("user.dir") + "/../mpticket.corrupt"); + if(mpticketFileCorrupt.exists()) { + mpticketFileCorrupt.delete(); + } + mpticketFile.renameTo(mpticketFileCorrupt); + + System.err.println("Malformed mpticket file, missing argument."); + e.printStackTrace(System.err); + System.exit(-1); + } + catch (Exception e) { + e.printStackTrace(System.err); + System.exit(-1); + } appletWrap.setParameter ( "username", user ); appletWrap.setParameter ( "sessionid", session ); appletWrap.setParameter ( "stand-alone", "true" ); // Show the quit button. - appletWrap.setParameter ( "demo", "false" ); - appletWrap.setParameter("fullscreen", "false"); + appletWrap.setParameter ( "haspaid", "true" ); // Some old versions need this for world saves to work. + appletWrap.setParameter ( "demo", "false" ); + appletWrap.setParameter ( "fullscreen", "false" ); mcApplet.setStub(appletWrap); this.add ( appletWrap ); - appletWrap.setPreferredSize ( winSize ); + appletWrap.setPreferredSize ( new Dimension (winSizeW, winSizeH) ); this.pack(); this.setLocationRelativeTo ( null ); this.setResizable ( true ); diff --git a/libraries/launcher/org/multimc/NotFoundException.java b/libraries/launcher/org/multimc/NotFoundException.java index aa27c173..2c5da6de 100644 --- a/libraries/launcher/org/multimc/NotFoundException.java +++ b/libraries/launcher/org/multimc/NotFoundException.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 MultiMC Contributors + * Copyright 2012-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/libraries/launcher/org/multimc/ParamBucket.java b/libraries/launcher/org/multimc/ParamBucket.java index d3880dd7..5e9c3ff6 100644 --- a/libraries/launcher/org/multimc/ParamBucket.java +++ b/libraries/launcher/org/multimc/ParamBucket.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 MultiMC Contributors + * Copyright 2012-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/libraries/launcher/org/multimc/ParseException.java b/libraries/launcher/org/multimc/ParseException.java index b2e5ff65..9a8fe521 100644 --- a/libraries/launcher/org/multimc/ParseException.java +++ b/libraries/launcher/org/multimc/ParseException.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 MultiMC Contributors + * Copyright 2012-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/libraries/launcher/org/multimc/Utils.java b/libraries/launcher/org/multimc/Utils.java index 860c0864..c5292eaf 100644 --- a/libraries/launcher/org/multimc/Utils.java +++ b/libraries/launcher/org/multimc/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 MultiMC Contributors + * Copyright 2012-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,77 +68,6 @@ public class Utils } /** - * Adds the specified library to the classpath - * - * @param s the path to add - * @throws Exception - */ - public static void addToClassPath(String s) throws Exception - { - File f = new File(s); - URL u = f.toURI().toURL(); - URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); - Class urlClass = URLClassLoader.class; - Method method = urlClass.getDeclaredMethod("addURL", new Class[]{URL.class}); - method.setAccessible(true); - method.invoke(urlClassLoader, new Object[]{u}); - } - - /** - * Adds many libraries to the classpath - * - * @param jars the paths to add - */ - public static boolean addToClassPath(List<String> jars) - { - boolean pure = true; - // initialize the class path - for (String jar : jars) - { - try - { - Utils.addToClassPath(jar); - } catch (Exception e) - { - System.err.println("Unable to load: " + jar); - e.printStackTrace(System.err); - pure = false; - } - } - return pure; - } - - /** - * Adds the specified path to the java library path - * - * @param pathToAdd the path to add - * @throws Exception - */ - @Deprecated - public static void addLibraryPath(String pathToAdd) throws Exception - { - final Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths"); - usrPathsField.setAccessible(true); - - //get array of paths - final String[] paths = (String[]) usrPathsField.get(null); - - //check if the path to add is already present - for (String path : paths) - { - if (path.equals(pathToAdd)) - { - return; - } - } - - //add the new path - final String[] newPaths = Arrays.copyOf(paths, paths.length + 1); - newPaths[newPaths.length - 1] = pathToAdd; - usrPathsField.set(null, newPaths); - } - - /** * Finds a field that looks like a Minecraft base folder in a supplied class * * @param mc the class to scan diff --git a/libraries/launcher/org/multimc/onesix/OneSixLauncher.java b/libraries/launcher/org/multimc/onesix/OneSixLauncher.java index 61a30ede..9667297d 100644 --- a/libraries/launcher/org/multimc/onesix/OneSixLauncher.java +++ b/libraries/launcher/org/multimc/onesix/OneSixLauncher.java @@ -1,4 +1,4 @@ -/* Copyright 2012-2017 MultiMC Contributors +/* Copyright 2012-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ import org.multimc.*; import java.applet.Applet; import java.io.File; -import java.awt.*; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -43,7 +42,8 @@ public class OneSixLauncher implements Launcher private String windowParams; // secondary parameters - private Dimension winSize; + private int winSizeW; + private int winSizeH; private boolean maximize; private String cwd; @@ -65,7 +65,9 @@ public class OneSixLauncher implements Launcher windowParams = params.firstSafe("windowParams", "854x480"); cwd = System.getProperty("user.dir"); - winSize = new Dimension(854, 480); + + winSizeW = 854; + winSizeH = 480; maximize = false; String[] dimStrings = windowParams.split("x"); @@ -78,7 +80,8 @@ public class OneSixLauncher implements Launcher { try { - winSize = new Dimension(Integer.parseInt(dimStrings[0]), Integer.parseInt(dimStrings[1])); + winSizeW = Integer.parseInt(dimStrings[0]); + winSizeH = Integer.parseInt(dimStrings[1]); } catch (NumberFormatException ignored) {} } } @@ -111,34 +114,37 @@ public class OneSixLauncher implements Launcher System.setProperty("minecraft.applet.TargetDirectory", cwd); - String[] mcArgs = new String[2]; - mcArgs[0] = userName; - mcArgs[1] = sessionId; + if(!traits.contains("noapplet")) + { + Utils.log("Launching with applet wrapper..."); + try + { + Class<?> MCAppletClass = cl.loadClass(appletClass); + Applet mcappl = (Applet) MCAppletClass.newInstance(); + LegacyFrame mcWindow = new LegacyFrame(windowTitle); + mcWindow.start(mcappl, userName, sessionId, winSizeW, winSizeH, maximize); + return 0; + } catch (Exception e) + { + Utils.log("Applet wrapper failed:", "Error"); + e.printStackTrace(System.err); + Utils.log(); + Utils.log("Falling back to using main class."); + } + } - Utils.log("Launching with applet wrapper..."); + // init params for the main method to chomp on. + String[] paramsArray = mcparams.toArray(new String[mcparams.size()]); try { - Class<?> MCAppletClass = cl.loadClass(appletClass); - Applet mcappl = (Applet) MCAppletClass.newInstance(); - LegacyFrame mcWindow = new LegacyFrame(windowTitle); - mcWindow.start(mcappl, userName, sessionId, winSize, maximize); + mc.getMethod("main", String[].class).invoke(null, (Object) paramsArray); + return 0; } catch (Exception e) { - Utils.log("Applet wrapper failed:", "Error"); + Utils.log("Failed to invoke the Minecraft main class:", "Fatal"); e.printStackTrace(System.err); - Utils.log(); - Utils.log("Falling back to compatibility mode."); - try - { - mc.getMethod("main", String[].class).invoke(null, (Object) mcArgs); - } catch (Exception e1) - { - Utils.log("Failed to invoke the Minecraft main class:", "Fatal"); - e1.printStackTrace(System.err); - return -1; - } + return -1; } - return 0; } int launchWithMainClass() @@ -153,9 +159,9 @@ public class OneSixLauncher implements Launcher else { mcparams.add("--width"); - mcparams.add(Integer.toString(winSize.width)); + mcparams.add(Integer.toString(winSizeW)); mcparams.add("--height"); - mcparams.add(Integer.toString(winSize.height)); + mcparams.add(Integer.toString(winSizeH)); } // Get the Minecraft Class. @@ -181,53 +187,7 @@ public class OneSixLauncher implements Launcher e.printStackTrace(System.err); return -1; } - /* - final java.nio.ByteBuffer[] icons = IconLoader.load("icon.png"); - new Thread() { - public void run() { - ClassLoader cl = ClassLoader.getSystemClassLoader(); - try - { - Class<?> Display; - Method isCreated; - Method setTitle; - Method setIcon; - Field fieldWindowCreated; - Boolean created = false; - Display = cl.loadClass("org.lwjgl.opengl.Display"); - fieldWindowCreated = Display.getDeclaredField("window_created"); - fieldWindowCreated.setAccessible( true ); - setTitle = Display.getMethod("setTitle", String.class); - setIcon = Display.getMethod("setIcon", java.nio.ByteBuffer[].class); - created = (Boolean) fieldWindowCreated.get( null ); - // set the window title? Maybe? - while(!created) - { - try - { - Thread.sleep(150); - created = (Boolean) fieldWindowCreated.get( null ); - } catch (InterruptedException ignored) {} - } - // Give it a bit more time ;) - Thread.sleep(150); - // set the title - setTitle.invoke(null,windowTitle); - // only set icon when there's actually something to set... - if(icons.length > 0) - { - setIcon.invoke(null,(Object)icons); - } - } - catch (Exception e) - { - System.err.println("Couldn't set window icon or title."); - e.printStackTrace(System.err); - } - } - } - .start(); - */ + // init params for the main method to chomp on. String[] paramsArray = mcparams.toArray(new String[mcparams.size()]); try @@ -257,32 +217,6 @@ public class OneSixLauncher implements Launcher return -1; } - // add libraries to classpath - if(!Utils.addToClassPath(libraries)) - { - System.err.println("Halting launch due to previous errors."); - return -1; - } - - // set the native libs path... the brute force way - try - { - System.setProperty("java.library.path", nativePath); - System.setProperty("org.lwjgl.librarypath", nativePath); - System.setProperty("net.java.games.input.librarypath", nativePath); - // by the power of reflection, initialize native libs again. DIRTY! - // this is SO BAD. imagine doing that to ld - Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths"); - fieldSysPath.setAccessible( true ); - fieldSysPath.set( null, null ); - } - catch (Exception e) - { - System.err.println("Failed to set the native library path:"); - e.printStackTrace(System.err); - System.err.println("Minecraft might fail to launch..."); - } - // grab the system classloader and ... cl = ClassLoader.getSystemClassLoader(); diff --git a/libraries/launcher/org/simplericity/macify/eawt/Application.java b/libraries/launcher/org/simplericity/macify/eawt/Application.java deleted file mode 100644 index 153bb9ee..00000000 --- a/libraries/launcher/org/simplericity/macify/eawt/Application.java +++ /dev/null @@ -1,176 +0,0 @@ -package org.simplericity.macify.eawt; - -/* - * Copyright 2007 Eirik Bjorsnos. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.awt.*; -import java.awt.image.BufferedImage; - -/** - * The Macify Library API interface provides integration with the OS X platform for Java Applications. - * The API includes a facade to the - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/index.html"> - * Apple Java Extensions API - * </a>. - * Additionally, it provides access to several useful methods in the Cocoa NSApplication API. - * - * The default implementation of this interface is {@link org.simplericity.macify.eawt.DefaultApplication}. - */ -public interface Application { - - static int REQUEST_USER_ATTENTION_TYPE_CRITICAL = 1 ; - static int REQUEST_USER_ATTENTION_TYPE_INFORMATIONAL = 2 ; - - /** - * See - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/Application.html#addAboutMenuItem()"> - * Apple's API - * </a>. - */ - void addAboutMenuItem(); - - /** - * See - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/Application.html#addApplicationListener(com.apple.eawt.ApplicationListener)"> - * Apple's API - * </a>. - */ - void addApplicationListener(ApplicationListener applicationListener); - - /** - * See - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/Application.html#addPreferencesMenuItem()"> - * Apple's API - * </a>. - */ - void addPreferencesMenuItem(); - - /** - * See - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/Application.html#getEnabledAboutMenu()"> - * Apple's API - * </a>. - */ - boolean getEnabledAboutMenu(); - - /** - * See - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/Application.html#getEnabledPreferencesMenu()"> - * Apple's API - * </a>. - */ - boolean getEnabledPreferencesMenu(); - - /** - * See - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/Application.html#isAboutMenuItemPresent()"> - * Apple's API - * </a>. - */ - boolean isAboutMenuItemPresent(); - - /** - * See - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/Application.html#isPreferencesMenuItemPresent()"> - * Apple's API - * </a>. - */ - boolean isPreferencesMenuItemPresent(); - - /** - * See - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/Application.html#removeAboutMenuItem()"> - * Apple's API - * </a>. - */ - void removeAboutMenuItem(); - - /** - * See - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/Application.html#removeApplicationListener(com.apple.eawt.ApplicationListener)"> - * Apple's API - * </a>. - */ - void removeApplicationListener(ApplicationListener applicationListener); - - /** - * See - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/Application.html#removePreferencesMenuItem()"> - * Apple's API - * </a>. - */ - void removePreferencesMenuItem(); - - /** - * See - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/Application.html#getEnabledAboutMenu()"> - * Apple's API - * </a>. - */ - void setEnabledAboutMenu(boolean enabled); - - /** - * See - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/Application.html#getEnabledPreferencesMenu()"> - * Apple's API - * </a>. - */ - void setEnabledPreferencesMenu(boolean enabled); - - /** - * See - * <a href="http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/Application.html#getMouseLocationOnScreen()"> - * Apple's API - * </a>. - */ - Point getMouseLocationOnScreen(); - - /** - * See - * <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/index.html#//apple_ref/doc/uid/TP40004004"> - * Apple's NSApplication Class Reference - * </a>. - * @param type on of {@link #REQUEST_USER_ATTENTION_TYPE_CRITICAL} or {@link #REQUEST_USER_ATTENTION_TYPE_INFORMATIONAL}. - */ - int requestUserAttention(int type); - - /** - * See - * <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/index.html#//apple_ref/doc/uid/TP40004004"> - * Apple's NSApplication Class Reference - * </a> - */ - void cancelUserAttentionRequest(int request); - - /** - * Update the application's icon image - * @param image - */ - void setApplicationIconImage(BufferedImage image); - - /** - * Get the application's icon image. - */ - BufferedImage getApplicationIconImage(); - - /** - * Determines whether the application is running on a Mac AND the Apple Extensions API classes are available. - * @return - */ - boolean isMac(); - - -} diff --git a/libraries/launcher/org/simplericity/macify/eawt/ApplicationAdapter.java b/libraries/launcher/org/simplericity/macify/eawt/ApplicationAdapter.java deleted file mode 100644 index e9c3db7d..00000000 --- a/libraries/launcher/org/simplericity/macify/eawt/ApplicationAdapter.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.simplericity.macify.eawt; - -/* - * Copyright 2007 Eirik Bjorsnos. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -public class ApplicationAdapter implements ApplicationListener { - - public void handleQuit(ApplicationEvent event) { - - } - - public void handleAbout(ApplicationEvent event) { - - } - - public void handleOpenApplication(ApplicationEvent event) { - - } - - public void handleOpenFile(ApplicationEvent event) { - - } - - public void handlePreferences(ApplicationEvent event) { - - } - - public void handlePrintFile(ApplicationEvent event) { - - } - - public void handleReOpenApplication(ApplicationEvent event) { - - } -} diff --git a/libraries/launcher/org/simplericity/macify/eawt/ApplicationEvent.java b/libraries/launcher/org/simplericity/macify/eawt/ApplicationEvent.java deleted file mode 100644 index 78420355..00000000 --- a/libraries/launcher/org/simplericity/macify/eawt/ApplicationEvent.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.simplericity.macify.eawt; - -/* - * Copyright 2007 Eirik Bjorsnos. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -public interface ApplicationEvent { - String getFilename(); - boolean isHandled(); - void setHandled(boolean handled); - Object getSource(); - String toString(); -} diff --git a/libraries/launcher/org/simplericity/macify/eawt/ApplicationListener.java b/libraries/launcher/org/simplericity/macify/eawt/ApplicationListener.java deleted file mode 100644 index a291bee4..00000000 --- a/libraries/launcher/org/simplericity/macify/eawt/ApplicationListener.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.simplericity.macify.eawt; - -/* - * Copyright 2007 Eirik Bjorsnos. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -public interface ApplicationListener { - void handleAbout(ApplicationEvent event); - void handleOpenApplication(ApplicationEvent event); - void handleOpenFile(ApplicationEvent event); - void handlePreferences(ApplicationEvent event); - void handlePrintFile(ApplicationEvent event); - void handleQuit(ApplicationEvent event); - void handleReOpenApplication(ApplicationEvent event); -} diff --git a/libraries/launcher/org/simplericity/macify/eawt/DefaultApplication.java b/libraries/launcher/org/simplericity/macify/eawt/DefaultApplication.java deleted file mode 100644 index 5752a350..00000000 --- a/libraries/launcher/org/simplericity/macify/eawt/DefaultApplication.java +++ /dev/null @@ -1,418 +0,0 @@ -package org.simplericity.macify.eawt; - -/* - * Copyright 2007 Eirik Bjorsnos. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.*; -import java.lang.reflect.*; -import java.net.URL; -import java.net.URLClassLoader; -import java.net.MalformedURLException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - - -/** - * Implements Application by calling the Mac OS X API through reflection. - * If this class is used on a non-OS X platform the operations will have no effect or they will simulate - * what the Apple API would do for those who manipulate state. ({@link #setEnabledAboutMenu(boolean)} etc.) - */ -@SuppressWarnings("unchecked") -public class DefaultApplication implements Application { - - private Object application; - private Class applicationListenerClass; - - Map listenerMap = Collections.synchronizedMap(new HashMap<Object, Object>()); - private boolean enabledAboutMenu = true; - private boolean enabledPreferencesMenu; - private boolean aboutMenuItemPresent = true; - private boolean preferencesMenuItemPresent; - private ClassLoader classLoader; - - public DefaultApplication() { - try { - final File file = new File("/System/Library/Java"); - if (file.exists()) { - ClassLoader scl = ClassLoader.getSystemClassLoader(); - Class clc = scl.getClass(); - if (URLClassLoader.class.isAssignableFrom(clc)) { - Method addUrl = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class}); - addUrl.setAccessible(true); - addUrl.invoke(scl, new Object[]{file.toURI().toURL()}); - } - } - - Class appClass = Class.forName("com.apple.eawt.Application"); - application = appClass.getMethod("getApplication", new Class[0]).invoke(null, new Object[0]); - applicationListenerClass = Class.forName("com.apple.eawt.ApplicationListener"); - } catch (ClassNotFoundException e) { - application = null; - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - - } - - public boolean isMac() { - return application != null; - } - - public void addAboutMenuItem() { - if (isMac()) { - callMethod(application, "addAboutMenuItem"); - } else { - this.aboutMenuItemPresent = true; - } - } - - public void addApplicationListener(ApplicationListener applicationListener) { - - if (!Modifier.isPublic(applicationListener.getClass().getModifiers())) { - throw new IllegalArgumentException("ApplicationListener must be a public class"); - } - if (isMac()) { - Object listener = Proxy.newProxyInstance(getClass().getClassLoader(), - new Class[]{applicationListenerClass}, - new ApplicationListenerInvocationHandler(applicationListener)); - - callMethod(application, "addApplicationListener", new Class[]{applicationListenerClass}, new Object[]{listener}); - listenerMap.put(applicationListener, listener); - } else { - listenerMap.put(applicationListener, applicationListener); - } - } - - public void addPreferencesMenuItem() { - if (isMac()) { - callMethod("addPreferencesMenuItem"); - } else { - this.preferencesMenuItemPresent = true; - } - } - - public boolean getEnabledAboutMenu() { - if (isMac()) { - return callMethod("getEnabledAboutMenu").equals(Boolean.TRUE); - } else { - return enabledAboutMenu; - } - } - - public boolean getEnabledPreferencesMenu() { - if (isMac()) { - Object result = callMethod("getEnabledPreferencesMenu"); - return result.equals(Boolean.TRUE); - } else { - return enabledPreferencesMenu; - } - } - - public Point getMouseLocationOnScreen() { - if (isMac()) { - try { - Method method = application.getClass().getMethod("getMouseLocationOnScreen", new Class[0]); - return (Point) method.invoke(null, new Object[0]); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } - } else { - return new Point(0, 0); - } - } - - public boolean isAboutMenuItemPresent() { - if (isMac()) { - return callMethod("isAboutMenuItemPresent").equals(Boolean.TRUE); - } else { - return aboutMenuItemPresent; - } - } - - public boolean isPreferencesMenuItemPresent() { - if (isMac()) { - return callMethod("isPreferencesMenuItemPresent").equals(Boolean.TRUE); - } else { - return this.preferencesMenuItemPresent; - } - } - - public void removeAboutMenuItem() { - if (isMac()) { - callMethod("removeAboutMenuItem"); - } else { - this.aboutMenuItemPresent = false; - } - } - - public synchronized void removeApplicationListener(ApplicationListener applicationListener) { - if (isMac()) { - Object listener = listenerMap.get(applicationListener); - callMethod(application, "removeApplicationListener", new Class[]{applicationListenerClass}, new Object[]{listener}); - - } - listenerMap.remove(applicationListener); - } - - public void removePreferencesMenuItem() { - if (isMac()) { - callMethod("removeAboutMenuItem"); - } else { - this.preferencesMenuItemPresent = false; - } - } - - public void setEnabledAboutMenu(boolean enabled) { - if (isMac()) { - callMethod(application, "setEnabledAboutMenu", new Class[]{Boolean.TYPE}, new Object[]{Boolean.valueOf(enabled)}); - } else { - this.enabledAboutMenu = enabled; - } - } - - public void setEnabledPreferencesMenu(boolean enabled) { - if (isMac()) { - callMethod(application, "setEnabledPreferencesMenu", new Class[]{Boolean.TYPE}, new Object[]{Boolean.valueOf(enabled)}); - } else { - this.enabledPreferencesMenu = enabled; - } - - } - - public int requestUserAttention(int type) { - if (type != REQUEST_USER_ATTENTION_TYPE_CRITICAL && type != REQUEST_USER_ATTENTION_TYPE_INFORMATIONAL) { - throw new IllegalArgumentException("Requested user attention type is not allowed: " + type); - } - try { - Object application = getNSApplication(); - Field critical = application.getClass().getField("UserAttentionRequestCritical"); - Field informational = application.getClass().getField("UserAttentionRequestInformational"); - Field actual = type == REQUEST_USER_ATTENTION_TYPE_CRITICAL ? critical : informational; - - return ((Integer) application.getClass().getMethod("requestUserAttention", new Class[]{Integer.TYPE}).invoke(application, new Object[]{actual.get(null)})).intValue(); - - } catch (ClassNotFoundException e) { - return -1; - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } catch (NoSuchFieldException e) { - throw new RuntimeException(e); - } - } - - public void cancelUserAttentionRequest(int request) { - try { - Object application = getNSApplication(); - application.getClass().getMethod("cancelUserAttentionRequest", new Class[]{Integer.TYPE}).invoke(application, new Object[]{new Integer(request)}); - } catch (ClassNotFoundException e) { - // Nada - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } - } - - private Object getNSApplication() throws ClassNotFoundException { - try { - Class applicationClass = Class.forName("com.apple.cocoa.application.NSApplication"); - return applicationClass.getMethod("sharedApplication", new Class[0]).invoke(null, new Object[0]); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - } - - public void setApplicationIconImage(BufferedImage image) { - if (isMac()) { - try { - Method setDockIconImage = application.getClass().getMethod("setDockIconImage", Image.class); - - try { - setDockIconImage.invoke(application, image); - } catch (IllegalAccessException e) { - - } catch (InvocationTargetException e) { - - } - } catch (NoSuchMethodException mnfe) { - - - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - try { - ImageIO.write(image, "png", stream); - } catch (IOException e) { - throw new RuntimeException(e); - } - - try { - Class nsDataClass = Class.forName("com.apple.cocoa.foundation.NSData"); - Constructor constructor = nsDataClass.getConstructor(new Class[]{new byte[0].getClass()}); - - Object nsData = constructor.newInstance(new Object[]{stream.toByteArray()}); - - Class nsImageClass = Class.forName("com.apple.cocoa.application.NSImage"); - Object nsImage = nsImageClass.getConstructor(new Class[]{nsDataClass}).newInstance(new Object[]{nsData}); - - Object application = getNSApplication(); - - application.getClass().getMethod("setApplicationIconImage", new Class[]{nsImageClass}).invoke(application, new Object[]{nsImage}); - - } catch (ClassNotFoundException e) { - - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } - - } - - } - } - - public BufferedImage getApplicationIconImage() { - if (isMac()) { - - try { - Method getDockIconImage = application.getClass().getMethod("getDockIconImage"); - try { - return (BufferedImage) getDockIconImage.invoke(application); - } catch (IllegalAccessException e) { - - } catch (InvocationTargetException e) { - - } - } catch (NoSuchMethodException nsme) { - - try { - Class nsDataClass = Class.forName("com.apple.cocoa.foundation.NSData"); - Class nsImageClass = Class.forName("com.apple.cocoa.application.NSImage"); - Object application = getNSApplication(); - Object nsImage = application.getClass().getMethod("applicationIconImage", new Class[0]).invoke(application, new Object[0]); - - Object nsData = nsImageClass.getMethod("TIFFRepresentation", new Class[0]).invoke(nsImage, new Object[0]); - - Integer length = (Integer) nsDataClass.getMethod("length", new Class[0]).invoke(nsData, new Object[0]); - byte[] bytes = (byte[]) nsDataClass.getMethod("bytes", new Class[]{Integer.TYPE, Integer.TYPE}).invoke(nsData, new Object[]{Integer.valueOf(0), length}); - - BufferedImage image = ImageIO.read(new ByteArrayInputStream(bytes)); - return image; - - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - } - - return null; - } - - private Object callMethod(String methodname) { - return callMethod(application, methodname, new Class[0], new Object[0]); - } - - private Object callMethod(Object object, String methodname) { - return callMethod(object, methodname, new Class[0], new Object[0]); - } - - private Object callMethod(Object object, String methodname, Class[] classes, Object[] arguments) { - try { - if (classes == null) { - classes = new Class[arguments.length]; - for (int i = 0; i < classes.length; i++) { - classes[i] = arguments[i].getClass(); - - } - } - Method addListnerMethod = object.getClass().getMethod(methodname, classes); - return addListnerMethod.invoke(object, arguments); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } - } - - class ApplicationListenerInvocationHandler implements InvocationHandler { - private ApplicationListener applicationListener; - - ApplicationListenerInvocationHandler(ApplicationListener applicationListener) { - this.applicationListener = applicationListener; - } - - public Object invoke(Object object, Method appleMethod, Object[] objects) throws Throwable { - - ApplicationEvent event = createApplicationEvent(objects[0]); - try { - Method method = applicationListener.getClass().getMethod(appleMethod.getName(), new Class[]{ApplicationEvent.class}); - return method.invoke(applicationListener, new Object[]{event}); - } catch (NoSuchMethodException e) { - if (appleMethod.getName().equals("equals") && objects.length == 1) { - return Boolean.valueOf(object == objects[0]); - } - return null; - } - } - } - - private ApplicationEvent createApplicationEvent(final Object appleApplicationEvent) { - return (ApplicationEvent) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{ApplicationEvent.class}, new InvocationHandler() { - public Object invoke(Object o, Method method, Object[] objects) throws Throwable { - return appleApplicationEvent.getClass().getMethod(method.getName(), method.getParameterTypes()).invoke(appleApplicationEvent, objects); - } - }); - } -} diff --git a/libraries/libnbtplusplus b/libraries/libnbtplusplus -Subproject 4b305bbd2ac0e7a26987baf7949a484a87b474d +Subproject 92f8d57227feb94643378ecf595626c60c0f59b diff --git a/libraries/pack200/CMakeLists.txt b/libraries/pack200/CMakeLists.txt index 359445d2..b568e506 100644 --- a/libraries/pack200/CMakeLists.txt +++ b/libraries/pack200/CMakeLists.txt @@ -37,6 +37,13 @@ target_link_libraries(MultiMC_unpack200 ${ZLIB_LIBRARIES}) set_target_properties(MultiMC_unpack200 PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN 1) generate_export_header(MultiMC_unpack200) +# Install it +install( + TARGETS MultiMC_unpack200 + RUNTIME DESTINATION ${LIBRARY_DEST_DIR} + LIBRARY DESTINATION ${LIBRARY_DEST_DIR} +) + if(PACK200_BUILD_BINARY) add_executable(anti200 anti200.cpp) target_link_libraries(anti200 MultiMC_unpack200) diff --git a/libraries/quazip b/libraries/quazip -Subproject 164acc35fd5f77d353161dcf1c4e121bc2ce756 +Subproject 683e2ec8ada758d6e48d31ec606840802e6941b diff --git a/libraries/rainbow/CMakeLists.txt b/libraries/rainbow/CMakeLists.txt index 15019a71..bc561800 100644 --- a/libraries/rainbow/CMakeLists.txt +++ b/libraries/rainbow/CMakeLists.txt @@ -13,3 +13,10 @@ add_library(MultiMC_rainbow SHARED ${RAINBOW_SOURCES}) target_include_directories(MultiMC_rainbow PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") qt5_use_modules(MultiMC_rainbow Core Gui) + +# Install it +install( + TARGETS MultiMC_rainbow + RUNTIME DESTINATION ${LIBRARY_DEST_DIR} + LIBRARY DESTINATION ${LIBRARY_DEST_DIR} +) diff --git a/libraries/rainbow/include/rainbow_config.h b/libraries/rainbow/include/rainbow_config.h index cac53837..9290dc8a 100644 --- a/libraries/rainbow/include/rainbow_config.h +++ b/libraries/rainbow/include/rainbow_config.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/libraries/systeminfo/include/sys.h b/libraries/systeminfo/include/sys.h index 36f7d9cd..e40d9a92 100644 --- a/libraries/systeminfo/include/sys.h +++ b/libraries/systeminfo/include/sys.h @@ -3,6 +3,7 @@ namespace Sys { +const uint64_t megabyte = 1024ull * 1024ull; struct KernelInfo { QString kernelName; |