forge installer
This commit is contained in:
parent
9d920a5510
commit
2d295effee
@ -5,6 +5,10 @@ public class FaweVersion {
|
||||
|
||||
public FaweVersion(String version) {
|
||||
String[] split = version.substring(version.indexOf('=') + 1).split("-");
|
||||
if (split[0].equals("unknown")) {
|
||||
this.year = month = day = hash = build = major = minor = patch = 0;
|
||||
return;
|
||||
}
|
||||
String[] date = split[0].split("\\.");
|
||||
this.year = Integer.parseInt(date[0]);
|
||||
this.month = Integer.parseInt(date[1]);
|
||||
|
@ -0,0 +1,24 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
public abstract class BrowseButton extends InteractiveButton {
|
||||
public BrowseButton() {
|
||||
super("Browse");
|
||||
}
|
||||
|
||||
public abstract void onSelect(File folder);
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
int returnValue = chooser.showOpenDialog(null);
|
||||
if (returnValue == JFileChooser.APPROVE_OPTION) {
|
||||
File selectedFile = chooser.getSelectedFile();
|
||||
onSelect(selectedFile);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class CloseButton extends InteractiveButton {
|
||||
public CloseButton() {
|
||||
super("X");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
346
core/src/main/java/com/boydti/fawe/installer/InstallerFrame.java
Normal file
346
core/src/main/java/com/boydti/fawe/installer/InstallerFrame.java
Normal file
@ -0,0 +1,346 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import com.boydti.fawe.FaweVersion;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
public class InstallerFrame extends JFrame {
|
||||
private final InvisiblePanel loggerPanel;
|
||||
private Color LIGHT_GRAY = new Color(0x66, 0x66, 0x66);
|
||||
private Color GRAY = new Color(0x44, 0x44, 0x46);
|
||||
private Color DARK_GRAY = new Color(0x33, 0x33, 0x36);
|
||||
private Color DARKER_GRAY = new Color(0x26, 0x26, 0x28);
|
||||
private Color INVISIBLE = new Color(0, 0, 0, 0);
|
||||
private Color OFF_WHITE = new Color(200, 200, 200);
|
||||
|
||||
private JTextArea loggerTextArea;
|
||||
private BrowseButton browse;
|
||||
|
||||
public InstallerFrame() throws Exception {
|
||||
final MovablePanel movable = new MovablePanel(this);
|
||||
|
||||
Container content = this.getContentPane();
|
||||
content.add(movable);
|
||||
this.setSize(480, 320);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setUndecorated(true);
|
||||
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
int x = (int) ((dimension.getWidth() - this.getWidth()) / 2);
|
||||
int y = (int) ((dimension.getHeight() - this.getHeight()) / 2);
|
||||
this.setLocation(x, y);
|
||||
this.setVisible(true);
|
||||
this.setOpacity(0);
|
||||
movable.setBackground(DARK_GRAY);
|
||||
movable.setLayout(new BorderLayout());
|
||||
|
||||
fadeIn();
|
||||
|
||||
JPanel topBar = new InvisiblePanel(new BorderLayout());
|
||||
{
|
||||
JPanel topBarLeft = new InvisiblePanel();
|
||||
JPanel topBarRight = new InvisiblePanel();
|
||||
|
||||
JLabel title = new JLabel("FastAsyncWorldEdit Installer");
|
||||
title.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
title.setAlignmentX(Component.RIGHT_ALIGNMENT);
|
||||
title.setForeground(LIGHT_GRAY);
|
||||
|
||||
|
||||
MinimizeButton minimize = new MinimizeButton(this);
|
||||
CloseButton exit = new CloseButton();
|
||||
|
||||
topBarLeft.add(title);
|
||||
topBarRight.add(minimize);
|
||||
topBarRight.add(exit);
|
||||
|
||||
topBar.add(topBarLeft, BorderLayout.CENTER);
|
||||
topBar.add(topBarRight, BorderLayout.EAST);
|
||||
}
|
||||
final JPanel mainContent = new InvisiblePanel(new BorderLayout());
|
||||
{
|
||||
final JPanel browseContent = new InvisiblePanel(new BorderLayout());
|
||||
File dir = MainUtil.getWorkingDirectory("minecraft");
|
||||
JLabel folder = new JLabel("Folder: ");
|
||||
folder.setForeground(OFF_WHITE);
|
||||
final InteractiveButton text = new InteractiveButton(dir.getPath(), DARKER_GRAY) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
browse.actionPerformed(e);
|
||||
}
|
||||
};
|
||||
text.setForeground(OFF_WHITE);
|
||||
text.setBackground(DARKER_GRAY);
|
||||
text.setOpaque(true);
|
||||
text.setBorder(new EmptyBorder(4, 4, 4, 4));
|
||||
browse = new BrowseButton() {
|
||||
@Override
|
||||
public void onSelect(File folder) {
|
||||
text.setText(folder.getPath());
|
||||
movable.repaint();
|
||||
}
|
||||
};
|
||||
InteractiveButton install = new InteractiveButton(">> Create Profile <<", DARKER_GRAY) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
install(text.getText());
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
browseContent.add(folder, BorderLayout.WEST);
|
||||
browseContent.add(text, BorderLayout.CENTER);
|
||||
browseContent.add(browse, BorderLayout.EAST);
|
||||
final JPanel installContent = new InvisiblePanel(new FlowLayout());
|
||||
install.setPreferredSize(new Dimension(416, 32));
|
||||
installContent.add(install);
|
||||
installContent.setBorder(new EmptyBorder(10, 0, 10, 0));
|
||||
this.loggerPanel = new InvisiblePanel(new BorderLayout());
|
||||
this.loggerPanel.setBackground(Color.GREEN);
|
||||
loggerPanel.setPreferredSize(new Dimension(416, 160));
|
||||
loggerTextArea = new JTextArea(12, 52);
|
||||
loggerTextArea.setBackground(GRAY);
|
||||
loggerTextArea.setForeground(DARKER_GRAY);
|
||||
loggerTextArea.setFont(new Font(loggerTextArea.getFont().getName(), Font.PLAIN, 9));
|
||||
JScrollPane scroll = new JScrollPane(loggerTextArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scroll.setBackground(DARK_GRAY);
|
||||
scroll.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
loggerPanel.add(scroll);
|
||||
loggerPanel.setVisible(false);
|
||||
|
||||
mainContent.setBorder(new EmptyBorder(6, 32, 6, 32));
|
||||
mainContent.add(browseContent, BorderLayout.NORTH);
|
||||
mainContent.add(installContent, BorderLayout.CENTER);
|
||||
mainContent.add(loggerPanel, BorderLayout.SOUTH);
|
||||
}
|
||||
JPanel bottomBar = new InvisiblePanel();
|
||||
{
|
||||
try {
|
||||
InputStream stream = getClass().getResourceAsStream("/fawe.properties");
|
||||
java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A");
|
||||
String versionString = scanner.next().trim();
|
||||
scanner.close();
|
||||
FaweVersion version = new FaweVersion(versionString);
|
||||
String date = new Date(100 + version.year, version.month, version.day).toGMTString();
|
||||
String build = "https://ci.athion.net/job/FastAsyncWorldEdit/" + version.build;
|
||||
String commit = "https://github.com/boy0001/FastAsyncWorldedit/commit/" + Integer.toHexString(version.hash);
|
||||
String footerMessage = "FAWE v" + version.major + "." + version.minor + "." + version.patch + " by Empire92 (c) 2016 (GPL v3.0)";
|
||||
URL licenseUrl = new URL("https://github.com/boy0001/FastAsyncWorldedit/blob/master/LICENSE");
|
||||
URLButton licenseButton = new URLButton(licenseUrl, footerMessage);
|
||||
bottomBar.add(licenseButton);
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
URL chat = new URL("http://webchat.esper.net/?nick=&channels=IntellectualCrafters&fg_color=000&fg_sec_color=000&bg_color=FFF");
|
||||
URLButton chatButton = new URLButton(chat, "Chat");
|
||||
bottomBar.add(chatButton);
|
||||
URL wiki = new URL("https://github.com/boy0001/FastAsyncWorldedit/wiki");
|
||||
URLButton wikiButton = new URLButton(wiki, "Wiki");
|
||||
bottomBar.add(wikiButton);
|
||||
URL issue = new URL("https://github.com/boy0001/FastAsyncWorldedit/issues/new");
|
||||
URLButton issueButton = new URLButton(issue, "Report Issue");
|
||||
bottomBar.add(issueButton);
|
||||
}
|
||||
|
||||
// We want to add these a bit later
|
||||
movable.add(topBar, BorderLayout.NORTH);
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
movable.add(mainContent, BorderLayout.CENTER);
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
movable.add(bottomBar, BorderLayout.SOUTH);
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private boolean newLine = false;
|
||||
|
||||
public void prompt(String message) {
|
||||
JOptionPane.showMessageDialog(null, message);
|
||||
}
|
||||
|
||||
public void debug(String m) {
|
||||
System.out.println(m);
|
||||
}
|
||||
|
||||
public void install(String name) throws Exception {
|
||||
if (!loggerPanel.isVisible()) {
|
||||
loggerPanel.setVisible(true);
|
||||
this.repaint();
|
||||
System.setOut(new TextAreaOutputStream(loggerTextArea));
|
||||
}
|
||||
if (name == null || name.isEmpty()) {
|
||||
prompt("No folder selection");
|
||||
return;
|
||||
}
|
||||
final File dirMc = new File(name);
|
||||
if (!dirMc.exists()) {
|
||||
prompt("Folder does not exist");
|
||||
return;
|
||||
}
|
||||
if (!dirMc.isDirectory()) {
|
||||
prompt("You must select a folder, not a file");
|
||||
return;
|
||||
}
|
||||
Thread installThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<String> supported = Arrays.asList("v1710", "v189", "v194", "v110", "v111");
|
||||
String supportedString = null;
|
||||
for (String version : supported) {
|
||||
try {
|
||||
Class.forName("com.boydti.fawe.forge." + version + ".ForgeChunk_All");
|
||||
supportedString = version;
|
||||
break;
|
||||
} catch (ClassNotFoundException ignore){}
|
||||
}
|
||||
if (supportedString == null) {
|
||||
prompt("This version of FAWE cannot be installed this way.");
|
||||
return;
|
||||
}
|
||||
debug("Selected version " + supportedString);
|
||||
URL forgeUrl;
|
||||
URL worldEditUrl;
|
||||
try {
|
||||
switch (supportedString) {
|
||||
case "v111":
|
||||
forgeUrl = new URL("https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.11.2-13.20.0.2201/forge-1.11.2-13.20.0.2201-installer.jar");
|
||||
worldEditUrl = new URL("http://builds.enginehub.org/job/worldedit/9593/download/worldedit-forge-mc1.11-6.1.6-SNAPSHOT-dist.jar");
|
||||
break;
|
||||
case "v110":
|
||||
forgeUrl = new URL("http://files.minecraftforge.net/maven/net/minecraftforge/forge/1.10.2-12.18.3.2185/forge-1.10.2-12.18.3.2185-installer.jar");
|
||||
worldEditUrl = new URL("http://builds.enginehub.org/job/worldedit/9395/download/worldedit-forge-mc1.10.2-6.1.4-SNAPSHOT-dist.jar");
|
||||
break;
|
||||
case "v194":
|
||||
forgeUrl = new URL("https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.9.4-12.17.0.2051/forge-1.9.4-12.17.0.2051-installer.jar");
|
||||
worldEditUrl = new URL("http://builds.enginehub.org/job/worldedit/9171/download/worldedit-forge-mc1.9.4-6.1.3-SNAPSHOT-dist.jar");
|
||||
break;
|
||||
case "v189":
|
||||
forgeUrl = new URL("https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.8.9-11.15.1.1902-1.8.9/forge-1.8.9-11.15.1.1902-1.8.9-installer.jar");
|
||||
worldEditUrl = new URL("http://builds.enginehub.org/job/worldedit/8755/download/worldedit-forge-mc1.8.9-6.1.1-dist.jar");
|
||||
break;
|
||||
case "v1710":
|
||||
forgeUrl = new URL("https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.7.10-10.13.4.1614-1.7.10/forge-1.7.10-10.13.4.1614-1.7.10-installer.jar");
|
||||
worldEditUrl = new URL("http://builds.enginehub.org/job/worldedit/9194/download/worldedit-forge-mc1.7.10-6.1.2-SNAPSHOT-dist.jar");
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
try { // install forge
|
||||
debug("Downloading forge installer from:\n - https://files.minecraftforge.net/");
|
||||
URLClassLoader loader = new URLClassLoader(new URL[]{forgeUrl});
|
||||
debug("Connected");
|
||||
Class<?> forgeInstallClass = loader.loadClass("net.minecraftforge.installer.ClientInstall");
|
||||
debug("Found ClientInstall class");
|
||||
Object forgeInstallInstance = forgeInstallClass.newInstance();
|
||||
debug(forgeInstallInstance + " | " + forgeInstallClass + " | " + StringMan.getString(forgeInstallClass.getMethods()));
|
||||
debug("Created instance " + forgeInstallInstance);
|
||||
Method methodRun = forgeInstallClass.getDeclaredMethods()[0];//("run", File.class, Predicate.class);
|
||||
Object alwaysTrue = loader.loadClass("com.google.common.base.Predicates").getDeclaredMethod("alwaysTrue").invoke(null);
|
||||
methodRun.invoke(forgeInstallInstance, dirMc, alwaysTrue);
|
||||
debug("Forge profile created, now installing WorldEdit");
|
||||
} catch (Throwable e) {
|
||||
prompt("[ERROR] Forge install failed, download from:\nhttps://files.minecraftforge.net/");
|
||||
}
|
||||
File mods = new File(dirMc, "mods");
|
||||
if (!mods.exists()) {
|
||||
debug("Creating mods directory");
|
||||
mods.mkdirs();
|
||||
} else {
|
||||
for (File file : mods.listFiles()) {
|
||||
String name = file.getName().toLowerCase();
|
||||
if ((name.contains("worldedit") || name.contains("fawe")) && !name.contains("cui")) {
|
||||
debug("Delete existing: " + file.getName());
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
try { // install worldedit
|
||||
debug("Downloading worldedit from:\n - http://builds.enginehub.org/job/worldedit");
|
||||
try (ReadableByteChannel rbc = Channels.newChannel(worldEditUrl.openStream())) {
|
||||
try (FileOutputStream fos = new FileOutputStream(new File(mods, "worldedit-forge-mc1.10.2-6.1.4-SNAPSHOT-dist.jar"))) {
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
debug("Successfully downloaded WorldEdit");
|
||||
} catch (Throwable e) {
|
||||
prompt("[ERROR] WorldEdit install failed, download from:\nhttp://builds.enginehub.org/job/worldedit");
|
||||
}
|
||||
try { // install FAWE
|
||||
debug("Copying FastAsyncWorldEdit to mods directory");
|
||||
File file = new File(InstallerFrame.class.getProtectionDomain().getCodeSource().getLocation().getPath());
|
||||
debug(" - " + file.getPath());
|
||||
MainUtil.copyFile(file, new File(mods, "FastAsyncWorldEdit.jar"));
|
||||
debug("Installation complete!");
|
||||
} catch (Throwable e) {
|
||||
prompt("[ERROR] Copy installer failed, please copy this installer jar manually");
|
||||
}
|
||||
prompt("Installation comlete!\nLaunch the game using the forge profile.");
|
||||
}
|
||||
});
|
||||
installThread.start();
|
||||
}
|
||||
|
||||
public void fadeIn() {
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (float i = 0; i <= 1; i += 0.001) {
|
||||
InstallerFrame.this.setOpacity(i);
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception{
|
||||
InstallerFrame window = new InstallerFrame();
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import javax.swing.JButton;
|
||||
|
||||
public class InteractiveButton extends JButton implements ActionListener, MouseListener {
|
||||
private final Color background;
|
||||
|
||||
public InteractiveButton(String text) {
|
||||
this(text, new Color(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
public InteractiveButton(String text, Color background) {
|
||||
setText(text);
|
||||
setBorderPainted(false);
|
||||
setBackground(background);
|
||||
setFocusable(false);
|
||||
setVisible(true);
|
||||
setForeground(new Color(200, 200, 200));
|
||||
addActionListener(this);
|
||||
addMouseListener(this);
|
||||
setFocusable(false);
|
||||
if (background.getAlpha() != 0) {
|
||||
this.background = background;
|
||||
} else {
|
||||
this.background = new Color(0x33, 0x33, 0x36);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
setBackground(new Color(0x44, 0x44, 0x44));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
setBackground(this.background);
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
setBackground(new Color(0x77, 0x77, 0x77));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
setBackground(new Color(0x33, 0x33, 0x36));
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.LayoutManager;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class InvisiblePanel extends JPanel {
|
||||
public InvisiblePanel(LayoutManager layout) {
|
||||
super(layout);
|
||||
setBackground(new Color(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
public InvisiblePanel() {
|
||||
this(new FlowLayout());
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
public class MinimizeButton extends InteractiveButton {
|
||||
private final JFrame window;
|
||||
|
||||
public MinimizeButton(JFrame window) {
|
||||
super("-");
|
||||
this.window = window;
|
||||
}
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
window.setState(Frame.ICONIFIED);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class MovablePanel extends JPanel {
|
||||
private Point initialClick;
|
||||
private Component parent;
|
||||
|
||||
public MovablePanel(final Component parent) {
|
||||
this.parent = parent;
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
initialClick = e.getPoint();
|
||||
getComponentAt(initialClick);
|
||||
}
|
||||
});
|
||||
|
||||
addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
|
||||
// get location of Window
|
||||
int thisX = parent.getLocation().x;
|
||||
int thisY = parent.getLocation().y;
|
||||
|
||||
// Determine how much the mouse moved since the initial click
|
||||
int xMoved = (thisX + e.getX()) - (thisX + initialClick.x);
|
||||
int yMoved = (thisY + e.getY()) - (thisY + initialClick.y);
|
||||
|
||||
// Move window to this position
|
||||
int X = thisX + xMoved;
|
||||
int Y = thisY + yMoved;
|
||||
parent.setLocation(X, Y);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
public class TextAreaOutputStream extends PrintStream {
|
||||
|
||||
public TextAreaOutputStream(final JTextArea textArea) {
|
||||
super(new OutputStream() {
|
||||
private StringBuffer buffer = new StringBuffer();
|
||||
private String newLine = "";
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
if (b != '\n') {
|
||||
buffer.append((char) b);
|
||||
} else {
|
||||
textArea.setText(buffer + newLine + textArea.getText());
|
||||
newLine = "\n";
|
||||
buffer.delete(0, buffer.length());
|
||||
textArea.setVisible(true);
|
||||
textArea.repaint();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
40
core/src/main/java/com/boydti/fawe/installer/URLButton.java
Normal file
40
core/src/main/java/com/boydti/fawe/installer/URLButton.java
Normal file
@ -0,0 +1,40 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Font;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
public class URLButton extends InteractiveButton {
|
||||
private final URL url;
|
||||
|
||||
public URLButton(URL url, String text) {
|
||||
super("<HTML>" + text + "</HTML>");
|
||||
this.url = url;
|
||||
setFont(new Font(getFont().getName(), Font.PLAIN, 9));
|
||||
setForeground(new Color(0x77, 0x77, 0x77));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(url.toURI());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
|
||||
Clipboard systemClipboard = defaultToolkit.getSystemClipboard();
|
||||
systemClipboard.setContents(new StringSelection(url.toString()), null);
|
||||
}
|
||||
}
|
@ -836,4 +836,61 @@ public class MainUtil {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public enum OS
|
||||
{
|
||||
LINUX, SOLARIS, WINDOWS, MACOS, UNKNOWN;
|
||||
}
|
||||
|
||||
public static File getWorkingDirectory(String applicationName) {
|
||||
String userHome = System.getProperty("user.home", ".");
|
||||
File workingDirectory = null;
|
||||
switch (getPlatform())
|
||||
{
|
||||
case LINUX:
|
||||
case SOLARIS:
|
||||
workingDirectory = new File(userHome, '.' + applicationName + '/');
|
||||
break;
|
||||
case WINDOWS:
|
||||
String applicationData = System.getenv("APPDATA");
|
||||
if (applicationData != null) {
|
||||
workingDirectory = new File(applicationData, "." + applicationName + '/');
|
||||
} else {
|
||||
workingDirectory = new File(userHome, '.' + applicationName + '/');
|
||||
}
|
||||
break;
|
||||
case MACOS:
|
||||
workingDirectory = new File(userHome, "Library/Application Support/" + applicationName);
|
||||
break;
|
||||
default:
|
||||
workingDirectory = new File(userHome, applicationName + '/');
|
||||
}
|
||||
if ((!workingDirectory.exists()) && (!workingDirectory.mkdirs())) {
|
||||
throw new RuntimeException("The working directory could not be created: " + workingDirectory);
|
||||
}
|
||||
return workingDirectory;
|
||||
}
|
||||
|
||||
public static OS getPlatform() {
|
||||
String osName = System.getProperty("os.name").toLowerCase();
|
||||
if (osName.contains("win")) {
|
||||
return OS.WINDOWS;
|
||||
}
|
||||
if (osName.contains("mac")) {
|
||||
return OS.MACOS;
|
||||
}
|
||||
if (osName.contains("solaris")) {
|
||||
return OS.SOLARIS;
|
||||
}
|
||||
if (osName.contains("sunos")) {
|
||||
return OS.SOLARIS;
|
||||
}
|
||||
if (osName.contains("linux")) {
|
||||
return OS.LINUX;
|
||||
}
|
||||
if (osName.contains("unix")) {
|
||||
return OS.LINUX;
|
||||
}
|
||||
return OS.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +1 @@
|
||||
version=${version}
|
||||
|
||||
|
@ -63,6 +63,9 @@ shadowJar {
|
||||
}
|
||||
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
|
||||
destinationDir = file '../target'
|
||||
manifest {
|
||||
attributes("Main-Class": "com.boydti.fawe.installer.InstallerFrame")
|
||||
}
|
||||
}
|
||||
shadowJar.doLast {
|
||||
task ->
|
||||
|
@ -3,7 +3,7 @@ package com.boydti.fawe.forge;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.IFawe;
|
||||
import com.boydti.fawe.forge.v0.ForgeQueue_All;
|
||||
import com.boydti.fawe.forge.v110.ForgeQueue_All;
|
||||
import com.boydti.fawe.object.FaweCommand;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.forge.v0;
|
||||
package com.boydti.fawe.forge.v110;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.forge.v0;
|
||||
package com.boydti.fawe.forge.v110;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
@ -63,6 +63,9 @@ shadowJar {
|
||||
}
|
||||
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
|
||||
destinationDir = file '../target'
|
||||
manifest {
|
||||
attributes("Main-Class": "com.boydti.fawe.installer.InstallerFrame")
|
||||
}
|
||||
}
|
||||
shadowJar.doLast {
|
||||
task ->
|
||||
|
@ -3,7 +3,7 @@ package com.boydti.fawe.forge;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.IFawe;
|
||||
import com.boydti.fawe.forge.v0.ForgeQueue_All;
|
||||
import com.boydti.fawe.forge.v111.ForgeQueue_All;
|
||||
import com.boydti.fawe.object.FaweCommand;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.forge.v0;
|
||||
package com.boydti.fawe.forge.v111;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.forge.v0;
|
||||
package com.boydti.fawe.forge.v111;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
@ -54,6 +54,9 @@ shadowJar {
|
||||
}
|
||||
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
|
||||
destinationDir = file '../target'
|
||||
manifest {
|
||||
attributes("Main-Class": "com.boydti.fawe.installer.InstallerFrame")
|
||||
}
|
||||
}
|
||||
shadowJar.doLast {
|
||||
task ->
|
||||
|
@ -3,7 +3,7 @@ package com.boydti.fawe.forge;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.IFawe;
|
||||
import com.boydti.fawe.forge.v0.ForgeQueue_All;
|
||||
import com.boydti.fawe.forge.v1710.ForgeQueue_All;
|
||||
import com.boydti.fawe.object.FaweCommand;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.forge.v0;
|
||||
package com.boydti.fawe.forge.v1710;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.forge.v0;
|
||||
package com.boydti.fawe.forge.v1710;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
@ -63,6 +63,9 @@ shadowJar {
|
||||
}
|
||||
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
|
||||
destinationDir = file '../target'
|
||||
manifest {
|
||||
attributes("Main-Class": "com.boydti.fawe.installer.InstallerFrame")
|
||||
}
|
||||
}
|
||||
shadowJar.doLast {
|
||||
task ->
|
||||
|
@ -3,7 +3,7 @@ package com.boydti.fawe.forge;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.IFawe;
|
||||
import com.boydti.fawe.forge.v0.ForgeQueue_All;
|
||||
import com.boydti.fawe.forge.v189.ForgeQueue_All;
|
||||
import com.boydti.fawe.object.FaweCommand;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.forge.v0;
|
||||
package com.boydti.fawe.forge.v189;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.forge.v0;
|
||||
package com.boydti.fawe.forge.v189;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
@ -62,6 +62,9 @@ shadowJar {
|
||||
}
|
||||
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
|
||||
destinationDir = file '../target'
|
||||
manifest {
|
||||
attributes("Main-Class": "com.boydti.fawe.installer.InstallerFrame")
|
||||
}
|
||||
}
|
||||
shadowJar.doLast {
|
||||
task ->
|
||||
|
@ -3,7 +3,7 @@ package com.boydti.fawe.forge;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.IFawe;
|
||||
import com.boydti.fawe.forge.v0.ForgeQueue_All;
|
||||
import com.boydti.fawe.forge.v194.ForgeQueue_All;
|
||||
import com.boydti.fawe.object.FaweCommand;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.forge.v0;
|
||||
package com.boydti.fawe.forge.v194;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.forge.v0;
|
||||
package com.boydti.fawe.forge.v194;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.CharFaweChunk;
|
Loading…
Reference in New Issue
Block a user